|
@@ -1560,10 +1560,83 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 查询三坐标检测空闲位置
|
|
|
+ /// </summary>
|
|
|
+ public async Task<ResponseECSData> QueryThreeCoordinatesFreePos(RequestToolData req)
|
|
|
+ {
|
|
|
+ ResponseECSData responseData = new ResponseECSData("", "");
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ List<Device> devices = _deviceService.GetDeviceList();
|
|
|
+
|
|
|
+ Device device = devices.Where(x => x.Ip.Equals(req.url) && x.Port.Equals(req.port)).FirstOrDefault();
|
|
|
+
|
|
|
+ if (device == null)
|
|
|
+ {
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.QueryThreeCoordinatesFreePos + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.QueryThreeCoordinatesFreePos));
|
|
|
+ responseData.result = "false";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ CcsAction actionQuery = new CcsAction();
|
|
|
+ actionQuery.OperateType = ActionTypeEnum.QueryThreeCoordinatesFreePos.ToString();
|
|
|
+ actionQuery.Ip = req.url;
|
|
|
+ CcsAction actionInfo = _ccsActionService.GetList(actionQuery).FirstOrDefault();
|
|
|
+
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ HslCommunication.OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.QueryThreeCoordinatesFreePos + "查询三坐标检测空闲位置===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.QueryThreeCoordinatesFreePos));
|
|
|
+ responseData.result = "false";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ CcsActionAddress actionAddressQuery = new CcsActionAddress();
|
|
|
+ actionAddressQuery.ActionId = actionInfo.Id;
|
|
|
+ List<CcsActionAddress> CcsActionAddresses = _ccsActionAddressService.GetList(actionAddressQuery);
|
|
|
+ //初始化为false,否则返回点位
|
|
|
+ responseData.result = "false";
|
|
|
+ //查询条件
|
|
|
+ List<CcsActionAddress> CcsActionAddressChecks = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.CHECK.ToString()).ToList();
|
|
|
+ foreach (CcsActionAddress actionAddress in CcsActionAddressChecks)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(actionAddress.Address) && !string.IsNullOrEmpty(actionAddress.Value))
|
|
|
+ {
|
|
|
+ var operateResult = s7.ReadInt16(actionAddress.Address);
|
|
|
+ if (operateResult.ToString() == actionAddress.Value)
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.QueryThreeCoordinatesFreePos + "三坐标检测空闲位置===>>"+ actionAddress.Address + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.QueryThreeCoordinatesFreePos));
|
|
|
+ responseData.result = actionAddress.Address;
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ s7.ConnectClose();
|
|
|
+
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.QueryThreeCoordinatesFreePos + "查询三坐标检测空闲位置===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.QueryThreeCoordinatesFreePos));
|
|
|
+ responseData.result = "false";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 启动三坐标
|
|
|
/// </summary>
|
|
|
- public async Task<ResponseECSData> StartCoordinateMeasuringMachine(RequestData<WorkData> req)
|
|
|
+ public async Task<ResponseECSData> StartThreeCoordinates(RequestData<WorkData> req)
|
|
|
{
|
|
|
ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId);
|
|
|
try
|
|
@@ -1574,14 +1647,14 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
if (device == null)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
|
|
|
|
CcsAction actionQuery = new CcsAction();
|
|
|
- actionQuery.OperateType = ActionTypeEnum.StartCoordinateMeasuringMachine.ToString();
|
|
|
+ actionQuery.OperateType = ActionTypeEnum.StartThreeCoordinates.ToString();
|
|
|
actionQuery.Ip = req.url;
|
|
|
CcsAction actionInfo = _ccsActionService.GetList(actionQuery).FirstOrDefault();
|
|
|
|
|
@@ -1590,8 +1663,8 @@ namespace IMCS.CCS.Services
|
|
|
if (!ConnectionResult.IsSuccess)
|
|
|
{
|
|
|
s7.ConnectClose();
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "启动三坐标异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
@@ -1600,68 +1673,67 @@ namespace IMCS.CCS.Services
|
|
|
actionAddressQuery.ActionId = actionInfo.Id;
|
|
|
List<CcsActionAddress> CcsActionAddresses = _ccsActionAddressService.GetList(actionAddressQuery);
|
|
|
|
|
|
- //查询条件
|
|
|
+ CcsActionAddress freeActionAdress = new CcsActionAddress();
|
|
|
+ //查询空闲位置
|
|
|
List<CcsActionAddress> CcsActionAddressChecks = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.CHECK.ToString()).ToList();
|
|
|
foreach (CcsActionAddress actionAddress in CcsActionAddressChecks)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address) && !string.IsNullOrEmpty(actionAddress.Value))
|
|
|
{
|
|
|
var operateResult = s7.ReadInt16(actionAddress.Address);
|
|
|
- if (actionAddress.CheckType ? operateResult.ToString().Equals(actionAddress.Value) : operateResult.ToString() != actionAddress.Value)
|
|
|
+ if (operateResult.ToString() == actionAddress.Value)
|
|
|
{
|
|
|
- s7.ConnectClose();
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "启动异常===>>" + "条件不满足" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
- responseData.result = "false";
|
|
|
- return responseData;
|
|
|
+ freeActionAdress = actionAddress;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //判断是否存在空闲滑台
|
|
|
+ if(freeActionAdress == null)
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标异常===>>" + "当前没有空闲位置" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
+ responseData.result = "false";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
|
|
|
- //查询写入地址列表
|
|
|
- List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString()).ToList();
|
|
|
+ //根据sort顺序,查询左中右空闲位置,写入地址列表
|
|
|
+ List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString() && o.Sort == freeActionAdress.Sort).ToList();
|
|
|
foreach (CcsActionAddress actionAddress in CcsActionAddressWrites)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
|
{
|
|
|
- //string Address = ToolUtils.AddressConvertDBW(actionAddress.Address);
|
|
|
- if (actionAddress.Sort == 1)
|
|
|
+ if(actionAddress.Value == "workProgramName")
|
|
|
+ {
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(req.data.workProgramName, 20));
|
|
|
+ }else if (actionAddress.Value == "workId")
|
|
|
{
|
|
|
s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(req.data.workId, 40));
|
|
|
- Thread.Sleep(SLEEP_TIME);
|
|
|
- } else if (actionAddress.Sort == 2) {
|
|
|
- s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(req.data.workType, 20));
|
|
|
- Thread.Sleep(SLEEP_TIME);
|
|
|
}
|
|
|
- else if (actionAddress.Sort == 3)
|
|
|
+ else if (actionAddress.Value == "procedureNo")
|
|
|
{
|
|
|
- short n = 1;
|
|
|
- s7.Write(actionAddress.Address, n);
|
|
|
- Thread.Sleep(SLEEP_TIME);
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(req.data.procedureNo, 20));
|
|
|
}
|
|
|
- else if (actionAddress.Sort == 4)
|
|
|
- {
|
|
|
- short n = 0;
|
|
|
- s7.Write(actionAddress.Address, n);
|
|
|
- Thread.Sleep(SLEEP_TIME);
|
|
|
- }
|
|
|
+
|
|
|
+ Thread.Sleep(SLEEP_TIME);
|
|
|
}
|
|
|
}
|
|
|
s7.ConnectClose();
|
|
|
|
|
|
//插入回调
|
|
|
- TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartCoordinateMeasuringMachine.ToString(),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine), req.taskId, req.taskNodeId);
|
|
|
-
|
|
|
+ TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartThreeCoordinates.ToString(),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates), req.taskId, req.taskNodeId);
|
|
|
+
|
|
|
await _taskCallbackService.CreateOrUpdateAndCache(setCallBackValue(CcsActionAddresses , taskCallbackData));
|
|
|
- Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine) + "启动三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
- , EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
+ Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates) + "启动三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
+ , EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
return responseData;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "启动三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
@@ -1956,11 +2028,9 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
CcsAction actionQuery = new CcsAction();
|
|
|
actionQuery.OperateType = ActionTypeEnum.ReadRFID.ToString();
|
|
|
- actionQuery.Ip = req.url;
|
|
|
- actionQuery.OrderIndex = req.data.orderIndex;
|
|
|
+ actionQuery.Ip = req.url;
|
|
|
List<CcsAction> actions = _ccsActionService.GetList(actionQuery);
|
|
|
- CcsAction actionInfo = actions[0];
|
|
|
- string Content = req.data.content;
|
|
|
+ CcsAction actionInfo = actions[0];
|
|
|
|
|
|
Plc s7 = DevicePlcS7.S7(req.url, ProtocalTypeEnum.S7_1500.ToString());
|
|
|
if (s7.IsConnected != true)
|
|
@@ -2024,10 +2094,8 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
CcsAction actionQuery = new CcsAction();
|
|
|
actionQuery.OperateType = ActionTypeEnum.WriteRFID.ToString();
|
|
|
- actionQuery.Ip = req.url;
|
|
|
- actionQuery.OrderIndex = req.data.orderIndex;
|
|
|
- CcsAction actionInfo = _ccsActionService.GetList(actionQuery).FirstOrDefault();
|
|
|
- string Content = req.data.content;
|
|
|
+ actionQuery.Ip = req.url;
|
|
|
+ CcsAction actionInfo = _ccsActionService.GetList(actionQuery).FirstOrDefault();
|
|
|
|
|
|
Plc s7 = DevicePlcS7.S7(req.url, ProtocalTypeEnum.S7_1500.ToString());
|
|
|
if (s7.IsConnected != true)
|