| | |
| | | using System.Linq; |
| | | using System.Threading; |
| | | using static HH.WCS.JuShi.LISTA.process.HttpModel; |
| | | using static HH.WCS.JuShi.util.Settings; |
| | | |
| | | namespace HH.WCS.JuShi.process |
| | | { |
| | |
| | | /// </summary> |
| | | internal class DeviceProcess |
| | | { |
| | | public static string rgvSafeInteraction = null; |
| | | internal static void Analysis(string data, string ip) |
| | | { |
| | | if (data != null) |
| | | { |
| | | //按钮盒 |
| | | //收 |
| | | //3A 00 01 00 01 05 73 00 02 01 01 B8 |
| | | //发 |
| | | //2A 00 01 00 01 05 73 00 02 01 01 A8 |
| | | if (data != null) |
| | | if (data.Substring(0, 2) == "3A") |
| | | { |
| | | //数据序号 |
| | | data = data.Substring(16, 2); |
| | |
| | | { |
| | | PlcHelper.SendHex(ip, returndata); |
| | | } |
| | | } |
| | | //rgv安全交互 |
| | | else if (data.Substring(0, 4) == "3F00") |
| | | { |
| | | //无信号不管 |
| | | if (data.Trim() != "3F00102030400D0A") |
| | | { |
| | | LogHelper.Info($"RGV安全交互接收信号{data}"); |
| | | var reservoirs = Settings.SafeInteractions.Where(s => s.ip == ip).FirstOrDefault(); |
| | | //1允许卸货 2卸货完成确认 |
| | | string datastr = ""; |
| | | if (reservoirs.pointCode == "RGV1") |
| | | { |
| | | datastr = data.Substring(5, 1); |
| | | } |
| | | else if (reservoirs.pointCode == "RGV2") |
| | | { |
| | | datastr = data.Substring(7, 1); |
| | | } |
| | | else if (reservoirs.pointCode == "RGV3") |
| | | { |
| | | datastr = data.Substring(9, 1); |
| | | } |
| | | else if (reservoirs.pointCode == "RGV4") |
| | | { |
| | | datastr = data.Substring(11, 1); |
| | | } |
| | | |
| | | //接受信号存到内存 |
| | | if (rgvSafeInteraction != null) |
| | | { |
| | | //string转成list |
| | | var jsonList = JsonConvert.DeserializeObject<List<SafeInteraction>>(rgvSafeInteraction); |
| | | var list = jsonList.Where(s => s.ip == ip).First(); |
| | | if (list != null) |
| | | { |
| | | //不为空就先删再加上 |
| | | jsonList.Remove(list); |
| | | } |
| | | jsonList.Add(new SafeInteraction { ip = ip, data = datastr }); |
| | | rgvSafeInteraction = JsonConvert.SerializeObject(jsonList); |
| | | } |
| | | else |
| | | { |
| | | //第一次进 |
| | | var safeInteractions = new List<SafeInteraction>{new SafeInteraction { ip = ip, data = datastr }}; |
| | | rgvSafeInteraction = JsonConvert.SerializeObject(safeInteractions); |
| | | } |
| | | LogHelper.Info($"RGV安全交互 存入内存参数{rgvSafeInteraction}"); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |