|
@@ -10,7 +10,9 @@ using System;
|
|
|
using S7.Net;
|
|
|
using IMCS_CCS.Utils;
|
|
|
using Newtonsoft.Json;
|
|
|
-using IMCS_CCS.Utils.DeviceProtocol;
|
|
|
+using IMCS_CCS.Utils.DeviceProtocol;
|
|
|
+using HslCommunication.Profinet.Siemens;
|
|
|
+using HslCommunication;
|
|
|
|
|
|
namespace IMCS.CCS.Services
|
|
|
{
|
|
@@ -1062,25 +1064,30 @@ namespace IMCS.CCS.Services
|
|
|
List<CcsAction> actions = _ccsActionService.GetList(actionQuery);
|
|
|
CcsAction actionInfo = actions[0];
|
|
|
|
|
|
- Plc s7 = DevicePlcS7.S7(req.url, ProtocalTypeEnum.S7_1500.ToString());
|
|
|
- if (s7.IsConnected != true)
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
{
|
|
|
- s7.Close();
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.StartCleanMachine + "启动故障===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.StartCleanMachine));
|
|
|
responseData.result = "false";
|
|
|
return responseData;
|
|
|
}
|
|
|
|
|
|
- string Address1 = ToolUtils.AddressConvertDBW(actionInfo.Address);
|
|
|
- s7.Write(Address1, true);
|
|
|
+ //string Address1 = ToolUtils.AddressConvertDBW(actionInfo.Address);
|
|
|
+ s7.Write(actionInfo.Address, true);
|
|
|
+ //s7.Write(Address1, true);
|
|
|
Thread.Sleep(SLEEP_TIME);
|
|
|
-
|
|
|
- string Address2 = ToolUtils.AddressConvertDBW(actionInfo.Address2);
|
|
|
- s7.Write(Address2, true);
|
|
|
+ s7.Write(actionInfo.Address, false);
|
|
|
Thread.Sleep(SLEEP_TIME);
|
|
|
- s7.Write(Address2, false);
|
|
|
- s7.Close();
|
|
|
+ //string Address2 = ToolUtils.AddressConvertDBW(actionInfo.Address2);
|
|
|
+ //s7.Write(Address2, true);
|
|
|
+ s7.Write(actionInfo.Address2, true);
|
|
|
+ Thread.Sleep(SLEEP_TIME);
|
|
|
+ s7.Write(actionInfo.Address2, false);
|
|
|
+ //s7.Write(Address2, false);
|
|
|
+ s7.ConnectClose();
|
|
|
|
|
|
//插入回调
|
|
|
TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartCleanMachine.ToString(),
|
|
@@ -1236,10 +1243,11 @@ namespace IMCS.CCS.Services
|
|
|
List<CcsAction> actions = _ccsActionService.GetList(actionQuery);
|
|
|
CcsAction actionInfo = actions[0];
|
|
|
|
|
|
- Plc s7 = DevicePlcS7.S7(req.url, ProtocalTypeEnum.S7_1500.ToString());
|
|
|
- if (s7.IsConnected != true)
|
|
|
+ SiemensS7Net s7 = DevicePlcS7.SiemensS7(req.url);
|
|
|
+ OperateResult ConnectionResult = s7.ConnectServer();
|
|
|
+ if (!ConnectionResult.IsSuccess)
|
|
|
{
|
|
|
- s7.Close();
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "启动三坐标异常===>>" + "PLC连接不上" + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
responseData.result = "false";
|
|
@@ -1249,11 +1257,22 @@ namespace IMCS.CCS.Services
|
|
|
//条件判断
|
|
|
if (!string.IsNullOrEmpty(actionInfo.CheckAddress))
|
|
|
{
|
|
|
- string CheckAddress = ToolUtils.AddressConvertDBW(actionInfo.CheckAddress);
|
|
|
- var operateResult = ((ushort)s7.Read(CheckAddress)).ConvertToShort();
|
|
|
- if (actionInfo.CheckType ? (operateResult.ToString() == actionInfo.CheckValue) : (operateResult.ToString() != actionInfo.CheckValue))
|
|
|
+ var operateResult = s7.ReadInt16(actionInfo.CheckAddress);
|
|
|
+ if (actionInfo.CheckType ? (operateResult.Content.ToString() == actionInfo.CheckValue) : (operateResult.Content.ToString() != actionInfo.CheckValue))
|
|
|
{
|
|
|
- s7.Close();
|
|
|
+ s7.ConnectClose();
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "机器人报警===>>" + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
+ responseData.result = "false";
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(actionInfo.CheckAddress2))
|
|
|
+ {
|
|
|
+ var operateResult = s7.ReadInt16(actionInfo.CheckAddress2);
|
|
|
+ if (actionInfo.CheckType2 ? (operateResult.Content.ToString() == actionInfo.CheckValue2) : (operateResult.Content.ToString() != actionInfo.CheckValue2))
|
|
|
+ {
|
|
|
+ s7.ConnectClose();
|
|
|
Log.Instance.WriteLogAdd(ActionTypeEnum.StartCoordinateMeasuringMachine + "启动三坐标未就绪===>>" + JsonConvert.SerializeObject(req),
|
|
|
EnumHelper.GetDescription(ActionTypeEnum.StartCoordinateMeasuringMachine));
|
|
|
responseData.result = "false";
|
|
@@ -1262,24 +1281,19 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
|
|
|
string Address1 = ToolUtils.AddressConvertDBW(actionInfo.Address);
|
|
|
- string[] sArray = Address1.Split('.');
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]), ToolUtils.ReturnBtyesWtitString(req.data.workId, 40));
|
|
|
|
|
|
+ s7.Write(actionInfo.Address, ToolUtils.ReturnBtyesWtitString(req.data.workId, 40));
|
|
|
Thread.Sleep(SLEEP_TIME);
|
|
|
|
|
|
- sArray = actionInfo.Address2.Split('.');
|
|
|
- string Address2 = ToolUtils.AddressConvertDBW(actionInfo.Address2);
|
|
|
- s7.WriteBytes(DataType.DataBlock, Convert.ToInt16(sArray[0].Substring(2)), Convert.ToInt16(sArray[1]), ToolUtils.ReturnBtyesWtitString(req.data.workType, 20));
|
|
|
-
|
|
|
+ s7.Write(actionInfo.Address2, ToolUtils.ReturnBtyesWtitString(req.data.workType, 20));
|
|
|
short n = 1;
|
|
|
- sArray = actionInfo.Address3.Split('.');
|
|
|
- string Address3 = ToolUtils.AddressConvertDBW(actionInfo.Address3);
|
|
|
- s7.Write(Address3, n);
|
|
|
+
|
|
|
+ s7.Write(actionInfo.Address3, n);
|
|
|
Thread.Sleep(SLEEP_TIME);
|
|
|
|
|
|
n = 0;
|
|
|
- s7.Write(Address3, n);
|
|
|
- s7.Close();
|
|
|
+ s7.Write(actionInfo.Address3, n);
|
|
|
+ s7.ConnectClose();
|
|
|
|
|
|
//插入回调
|
|
|
TaskCallback taskCallbackData = new TaskCallback(req.url, ActionTypeEnum.StartCoordinateMeasuringMachine.ToString(),
|
|
@@ -1754,4 +1768,5 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|