|
@@ -1508,19 +1508,20 @@ namespace IMCS.CCS.Services
|
|
|
actionQuery.Ip = req.url;
|
|
|
List<CcsAction> actions = _ccsActionService.GetList(actionQuery);
|
|
|
CcsAction actionInfo = actions[0];
|
|
|
- string TypeNo = "";
|
|
|
- string SmallTypeNo = "";
|
|
|
- string OrderNo = "";
|
|
|
- string TaskNo = "";
|
|
|
- string ProductNo = "";
|
|
|
- string BatchNo = "";
|
|
|
- string SerialNo = "";
|
|
|
+ string TypeNo = req.data.TypeNo;
|
|
|
+ string SmallTypeNo = req.data.SmallTypeNo;
|
|
|
+ string OrderNo = req.data.OrderNo;
|
|
|
+ string TaskNo = req.data.TaskNo;
|
|
|
+ string ProductNo = req.data.TaskNo;
|
|
|
+ string BatchNo = req.data.BatchNo;
|
|
|
+ string SerialNo = req.data.SerialNo;
|
|
|
|
|
|
|
|
|
- Plc s7 = DevicePlcS7.S7(req.url, ProtocalTypeEnum.S7_1500.ToString());
|
|
|
- if (s7.IsConnected != true)
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ HslCommunication.OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
{
|
|
|
- s7.Close();
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.StartLabelMachine + "启动打标机异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.StartLabelMachine));
|
|
|
responseData.result = "false";
|
|
@@ -1531,50 +1532,49 @@ namespace IMCS.CCS.Services
|
|
|
actionAddressQuery.ActionId = actionInfo.Id;
|
|
|
List<CcsActionAddress> CcsActionAddresses = _ccsActionAddressService.GetList(actionAddressQuery);
|
|
|
|
|
|
- //查询写入地址列表
|
|
|
- string[] sArray;
|
|
|
+ //查询写入地址列表
|
|
|
List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString()).ToList();
|
|
|
foreach (CcsActionAddress actionAddress in CcsActionAddressWrites)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
|
{
|
|
|
- sArray = actionAddress.Address.Split('.');
|
|
|
+
|
|
|
if (actionAddress.Sort == 1)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(TypeNo, 1));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(TypeNo));
|
|
|
}else if (actionAddress.Sort == 2)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(SmallTypeNo, 1));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(SmallTypeNo));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 3)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(OrderNo, 128));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(OrderNo, 128));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 4)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(TaskNo, 128));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(TaskNo, 128));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 5)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(ProductNo, 128));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(ProductNo, 128));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 6)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(BatchNo, 32));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(BatchNo, 32));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 7)
|
|
|
{
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]) + 2, ToolUtils.ReturnBtyesWtitString(SerialNo, 6));
|
|
|
+ s7.Write(actionAddress.Address, ToolUtils.ReturnBtyesWtitString(SerialNo, 100));
|
|
|
}
|
|
|
else if (actionAddress.Sort == 8 || actionAddress.Sort == 9)
|
|
|
{
|
|
|
- s7.Write(ToolUtils.AddressConvertDBW(actionAddress.Address), actionAddress.Value);
|
|
|
+ s7.Write(actionAddress.Address, Convert.ToInt16(actionAddress.Value));
|
|
|
}
|
|
|
- Thread.Sleep(1500);
|
|
|
+ Thread.Sleep(100);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- s7.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ s7.ConnectClose();
|
|
|
|
|
|
//插入回调
|
|
|
TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartLabelMachine.ToString(),
|
|
@@ -1773,13 +1773,13 @@ namespace IMCS.CCS.Services
|
|
|
taskCallbackData.Description = stationId;
|
|
|
taskCallbackData.CallbackFailValue3 = req.data.workId;
|
|
|
await _taskCallbackService.CreateOrUpdateAndCache(taskCallbackData);
|
|
|
- Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates) + "放三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
+ Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates) + "放测量三坐标成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
, EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
return responseData;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- Log.Instance.WriteLogAdd(ActionTypeEnum.SendThreeCoordinates + "放三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.SendThreeCoordinates + "放测量三坐标故障===>>" + ex.Message + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.SendThreeCoordinates));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
@@ -1846,12 +1846,23 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
//查询写入地址列表
|
|
|
List<CcsActionAddress> CcsActionAddressWrites = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE.ToString()).ToList();
|
|
|
- foreach (CcsActionAddress actionAddress in CcsActionAddressWrites)
|
|
|
+ if (req.data.Location == "373")
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
|
+ s7.Write("DB200.46", Convert.ToInt16("373"));
|
|
|
+ s7.Write("DB200.48", Convert.ToInt16("16"));
|
|
|
+ Thread.Sleep(SLEEP_TIME);
|
|
|
+ s7.Write("DB200.50", Convert.ToInt16("1"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (CcsActionAddress actionAddress in CcsActionAddressWrites)
|
|
|
{
|
|
|
- s7.Write(actionAddress.Address, Convert.ToInt16(string.IsNullOrEmpty(actionAddress.Value) ? req.data.Location : actionAddress.Value)); ;
|
|
|
- Thread.Sleep(SLEEP_TIME);
|
|
|
+ if (!string.IsNullOrEmpty(actionAddress.Address))
|
|
|
+ {
|
|
|
+ s7.Write(actionAddress.Address, Convert.ToInt16(string.IsNullOrEmpty(actionAddress.Value) ? req.data.Location : actionAddress.Value)); ;
|
|
|
+
|
|
|
+ Thread.Sleep(SLEEP_TIME);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|