|
@@ -1614,7 +1614,7 @@ namespace IMCS.CCS.Services
|
|
|
s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.QueryThreeCoordinatesFreePos + "三坐标检测空闲位置===>>"+ actionAddress.Address + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.QueryThreeCoordinatesFreePos));
|
|
|
- responseData.result = actionAddress.Address;
|
|
|
+ responseData.result = Enum.GetName(typeof(ThreeCoordinatesPosEnum), actionAddress.Sort); //actionAddress.Address;
|
|
|
return responseData;
|
|
|
}
|
|
|
}
|
|
@@ -1634,9 +1634,9 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 启动三坐标
|
|
|
+ /// 放三坐标滑台
|
|
|
/// </summary>
|
|
|
- public async Task<ResponseECSData> StartThreeCoordinates(RequestData<WorkData> req)
|
|
|
+ public async Task<ResponseECSData> SendThreeCoordinates(RequestData<WorkData> req)
|
|
|
{
|
|
|
ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId);
|
|
|
try
|
|
@@ -1647,14 +1647,14 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
if (device == null)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.SendThreeCoordinates + "设备已离线===>>" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
|
|
|
|
CcsAction actionQuery = new CcsAction();
|
|
|
- actionQuery.OperateType = ActionTypeEnum.StartThreeCoordinates.ToString();
|
|
|
+ actionQuery.OperateType = ActionTypeEnum.SendThreeCoordinates.ToString();
|
|
|
actionQuery.Ip = req.url;
|
|
|
CcsAction actionInfo = _ccsActionService.GetList(actionQuery).FirstOrDefault();
|
|
|
|
|
@@ -1663,8 +1663,8 @@ namespace IMCS.CCS.Services
|
|
|
if (!ConnectionResult.IsSuccess)
|
|
|
{
|
|
|
s7.ConnectClose();
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.SendThreeCoordinates + "启动三坐标异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
@@ -1673,33 +1673,24 @@ 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)
|
|
|
+ string stationId = req.data.stationId;
|
|
|
+ int key = 0;
|
|
|
+ if(stationId == "L")
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(actionAddress.Address) && !string.IsNullOrEmpty(actionAddress.Value))
|
|
|
- {
|
|
|
- var operateResult = s7.ReadInt16(actionAddress.Address);
|
|
|
- if (operateResult.ToString() == actionAddress.Value)
|
|
|
- {
|
|
|
- freeActionAdress = actionAddress;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ key = (int)ThreeCoordinatesPosEnum.L;
|
|
|
}
|
|
|
- //判断是否存在空闲滑台
|
|
|
- if(freeActionAdress == null)
|
|
|
+ else if (stationId == "M")
|
|
|
{
|
|
|
- s7.ConnectClose();
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标异常===>>" + "当前没有空闲位置" + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
- responseData.result = "false";
|
|
|
- return responseData;
|
|
|
+ key = (int)ThreeCoordinatesPosEnum.M;
|
|
|
}
|
|
|
+ else if (stationId == "R")
|
|
|
+ {
|
|
|
+ key = (int)ThreeCoordinatesPosEnum.R;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//根据sort顺序,查询左中右空闲位置,写入地址列表
|
|
|
- List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString() && o.Sort == freeActionAdress.Sort).ToList();
|
|
|
+ List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString() && o.Sort == key).ToList();
|
|
|
foreach (CcsActionAddress actionAddress in CcsActionAddressWrites)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
@@ -1718,22 +1709,35 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
Thread.Sleep(SLEEP_TIME);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询写入地址列表
|
|
|
+ List<CcsActionAddress> CcsActionAddressWriteSends = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE_SEND.ToString()).ToList();
|
|
|
+ foreach (CcsActionAddress actionAddress in CcsActionAddressWriteSends)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
|
+ {
|
|
|
+ string Address = ToolUtils.AddressConvertDBW(actionAddress.Address);
|
|
|
+ s7.Write(Address, Convert.ToInt16(string.IsNullOrEmpty(actionAddress.Value) ? req.data.location : actionAddress.Value)); ;
|
|
|
+ Thread.Sleep(SLEEP_TIME);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
s7.ConnectClose();
|
|
|
|
|
|
//插入回调
|
|
|
- TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartThreeCoordinates.ToString(),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates), req.taskId, req.taskNodeId);
|
|
|
+ TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.SendThreeCoordinates.ToString(),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates), req.taskId, req.taskNodeId);
|
|
|
|
|
|
await _taskCallbackService.CreateOrUpdateAndCache(setCallBackValue(CcsActionAddresses , taskCallbackData));
|
|
|
- Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates) + "启动三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
- , EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
+ Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates) + "放三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
+ , EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
return responseData;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.StartThreeCoordinates + "启动三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
- EnumHelper.GetDescription(ActionTypeEnum.StartThreeCoordinates));
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.SendThreeCoordinates + "放三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|