| | |
| | | //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.Substring(0, 2) == "3A") |
| | | if (data.Substring(0, 2) == "3a") |
| | | { |
| | | //数据序号 |
| | | data = data.Substring(16, 2); |
| | |
| | | bool result = false; |
| | | if (data.Equals("01")) |
| | | { |
| | | var reservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "RGV库区").FirstOrDefault(); |
| | | var reservoirs = Settings.ReservoirAreas.Where(s => s.areaName == "立库入库区").FirstOrDefault(); |
| | | result = TaskProcess.tcpOffline(loc, reservoirs.areaCode); |
| | | } |
| | | else if (data.Equals("02")) |
| | |
| | | } |
| | | //2A 00 01 00 01 05 73 00 02 01 01 A8 |
| | | // 输入的十六进制字符串数组 |
| | | string[] hexValues = { "2A", "00", "01", "00", "01", "05", "73", "00", "02", data, "01" }; |
| | | string[] hexValues = { "2a", "00", "01", "00", "01", "05", "73", "00", "02", data, "01" }; |
| | | // 计算总和 |
| | | int sum = hexValues.Sum(hex => Convert.ToInt32(hex, 16)); |
| | | string returndata = hexValues.ToString() + sum; |
| | |
| | | } |
| | | } |
| | | //rgv安全交互 |
| | | else if (data.Substring(0, 4) == "3F00") |
| | | else if (data.Substring(0, 4) == "3f00") |
| | | { |
| | | //无信号不管 |
| | | if (data.Trim() != "3F00102030400D0A") |
| | | { |
| | | ////无信号不管 |
| | | //if (data.Trim() != "3f001020304050600d0a") |
| | | //{ |
| | | 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); |
| | | } |
| | | rgvSafeInteraction = data.Substring(4,12); |
| | | //var reservoirs = Settings.SafeInteractions.Where(s => s.ip == ip).FirstOrDefault(); |
| | | ////1允许卸货 2卸货完成确认 |
| | | //string datastr = ""; |
| | | //switch (reservoirs.pointCode) |
| | | //{ |
| | | // case "RGV1": |
| | | // datastr = data.Substring(5, 1); |
| | | // break; |
| | | // case "RGV2": |
| | | // datastr = data.Substring(7, 1); |
| | | // break; |
| | | // case "RGV3": |
| | | // datastr = data.Substring(9, 1); |
| | | // break; |
| | | // case "RGV4": |
| | | // datastr = data.Substring(11, 1); |
| | | // break; |
| | | // case "RGV5": |
| | | // datastr = data.Substring(13, 1); |
| | | // break; |
| | | // case "RGV6": |
| | | // datastr = data.Substring(15, 1); |
| | | // break; |
| | | //} |
| | | |
| | | //接受信号存到内存 |
| | | 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}"); |
| | | } |
| | | ////接受信号存到内存 |
| | | //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}"); |
| | | //} |
| | | |
| | | |
| | | } |