| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Linq; |
| | |
| | | { |
| | | return ReadMessage监控值(byteMessage); |
| | | } |
| | | else if (byteMessage[2] == 0x32) |
| | | { |
| | | return ReadMessage监控值(byteMessage); |
| | | } |
| | | //else if (byteMessage[2] == 0x46) |
| | | //{ |
| | | // return ReadMessage监控值(byteMessage); |
| | | //} |
| | | else |
| | | { |
| | | return null; |
| | |
| | | |
| | | return commandSend; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取查询指令(监控值) |
| | |
| | | private static List<Model.MonitorDataDockingReceiveRecord> ReadMessage监控值(byte[] byteMessage) |
| | | { |
| | | var list = new List<Model.MonitorDataDockingReceiveRecord>(); |
| | | |
| | | |
| | | byte start = 0x1A; |
| | | if (byteMessage == null || byteMessage.Length < 5 + (56 - start) * 2) |
| | | { |
| | | return null; |
| | | } |
| | | try |
| | | { |
| | | //显示消息 |
| | |
| | | //DisplayMessage(string.Format(" 设备地址: {0} (0x{1})", byteMessage[0], Convert.ToString(byteMessage[0], 16))); |
| | | //DisplayMessage(string.Format(" 功能码: {0} ", byteMessage[1])); |
| | | |
| | | byte start = 0x1A; |
| | | |
| | | string msg; |
| | | var now = DateTime.Now; |
| | | //当前管网压力 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1575030496453332992, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########当前管网压力 -----> {0} Mpa 数据二进制{1}", GetInt2Byte(byteMessage, 3, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1575030496453332992, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt2Byte(byteMessage, 3, out msg) * 0.001).ToString() |
| | | }); |
| | | |
| | | //变频频率 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1575030605857558528, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########变频频率 -----> {0} Hz 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (27 - start) * 2, out msg) * 0.1, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1575030605857558528, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt2Byte(byteMessage, 3 + (27 - start) * 2, out msg) * 0.1).ToString() |
| | | }); |
| | | |
| | | //变频电流 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301190702632960, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########变频电流 -----> {0} A 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (28 - start) * 2, out msg) * 0.1, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301190702632960, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt2Byte(byteMessage, 3 + (28 - start) * 2, out msg) * 0.1).ToString() |
| | | }); |
| | | |
| | | //真空当前压力 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1575030435430404096,RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########真空当前压力 -----> {0} Mpa 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (29 - start) * 2, out msg) * 0.001, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1575030435430404096, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt2Byte(byteMessage, 3 + (29 - start) * 2, out msg) * 0.001).ToString() |
| | | }); |
| | | |
| | | //A相电压 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301249292865536, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########A相电压 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (30 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301249292865536, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetDouble1(byteMessage, 3 + (30 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //B相电压 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301287175819264, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########B相电压 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (32 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301287175819264, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetDouble1(byteMessage, 3 + (32 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //C相电压 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301332780486656, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########C相电压 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (34 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301332780486656, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetDouble1(byteMessage, 3 + (34 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //A相电流 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301384118767616, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########A相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (36 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301384118767616, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = |
| | | GetDouble1(byteMessage, 3 + (36 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //B相电流 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301478792597504, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########B相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (38 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301478792597504, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetDouble1(byteMessage, 3 + (38 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //C相电流 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301691439616000, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########C相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (40 - start) * 2, out msg), msg) }); |
| | | |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582301691439616000, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = |
| | | GetDouble1(byteMessage, 3 + (40 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //变频泵状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303421711650816, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########变频泵状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (42 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303421711650816, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (42 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //真空泵状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303241251721216, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########真空泵状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (43 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303241251721216, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (43 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | ////电动阀开阀状态 |
| | | //list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301332780486656, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | // SrcValue = string.Format("########电动阀开阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (44 - start) * 2, out msg), msg) }); |
| | | // SrcValue = string.Format("########电动阀开阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (44 - start) * 2, out msg).ToString() }); |
| | | |
| | | ////电动阀关阀状态 |
| | | //list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582301332780486656, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | // SrcValue = string.Format("########电动阀关阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (45 - start) * 2, out msg), msg) }); |
| | | // SrcValue = string.Format("########电动阀关阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (45 - start) * 2, out msg).ToString() }); |
| | | |
| | | //电磁阀状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303081771700224, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########电磁阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (46 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303081771700224, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (46 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //水位状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303471342850048, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########水位状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (47 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303471342850048, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (47 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //超压状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303606781120512, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########超压状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (48 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303606781120512, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (48 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //报警状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303637420511232, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########报警状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (49 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303637420511232, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (49 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //变频器状态 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1582303671927050240, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########变频器状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (50 - start) * 2, out msg), msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1582303671927050240, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetInt2Byte(byteMessage, 3 + (50 - start) * 2, out msg).ToString() |
| | | }); |
| | | |
| | | //当前液位 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1575388386963886080, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########当前液位 -----> {0} 数据二进制{1} ", GetInt2Byte(byteMessage, 3 + (51 - start) * 2, out msg) * 0.01, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1575388386963886080, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt2Byte(byteMessage, 3 + (51 - start) * 2, out msg) * 0.01).ToString() |
| | | }); |
| | | |
| | | //瞬时流量 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1575030320913321984, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########瞬时流量 -----> {0} 数据二进制{1} ", GetInt4Byte(byteMessage, 3 + (52 - start) * 2, out msg) * 0.001, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1575030320913321984, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt4Byte(byteMessage, 3 + (52 - start) * 2, out msg) * 0.001).ToString() |
| | | }); |
| | | |
| | | //累计流量 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1584475350807744512, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########累计流量 -----> {0} 数据二进制{1} ", GetInt4Byte(byteMessage, 3 + (54 - start) * 2, out msg) * 1.0, msg) }); |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1584475350807744512, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = (GetInt4Byte(byteMessage, 3 + (54 - start) * 2, out msg) * 1.0).ToString() |
| | | }); |
| | | |
| | | //累计流量有功功率 |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() { SysId = 1584475756476633088, RecordType = Model.eMonitorType.General, SrcTime = now, |
| | | SrcValue = string.Format("########有功功率 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (56 - start) * 2, out msg), msg) }); |
| | | |
| | | //当前管网压力:26 |
| | | //3 = 3+(26-26)*2 |
| | | /* DisplayMessage(string.Format("########当前管网压力 -----> {0} Mpa 数据二进制{1}", GetInt2Byte(byteMessage, 3, out msg), msg));//0.001Mpa |
| | | |
| | | //变频频率:27 |
| | | //5 = 3+(27-26)*2 |
| | | DisplayMessage(string.Format("########变频频率 -----> {0} Hz 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (27 - start) * 2, out msg) * 0.1, msg));//0.1HZ |
| | | |
| | | //变频电流:28 |
| | | DisplayMessage(string.Format("########变频电流 -----> {0} A 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (28 - start) * 2, out msg) * 0.1, msg));//0.1A |
| | | //真空当前压力:29 |
| | | DisplayMessage(string.Format("########真空当前压力 -----> {0} Mpa 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (29 - start) * 2, out msg) * 0.001, msg));//0.001Mpa |
| | | //A相电压:30 |
| | | //3 = 3+(30-26)*2 |
| | | DisplayMessage(string.Format("########A相电压 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (30 - start) * 2, out msg), msg)); |
| | | //B相电压:32 |
| | | DisplayMessage(string.Format("########B相电压 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (32 - start) * 2, out msg), msg)); |
| | | //C相电压:34 |
| | | DisplayMessage(string.Format("########C相电压 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (34 - start) * 2, out msg), msg)); |
| | | |
| | | //A相电流:36 |
| | | DisplayMessage(string.Format("########A相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (36 - start) * 2, out msg), msg)); |
| | | //B相电流:38 |
| | | DisplayMessage(string.Format("########B相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (38 - start) * 2, out msg), msg)); |
| | | //C相电流:40 |
| | | DisplayMessage(string.Format("########C相电流 -----> {0} 数据二进制{1}", GetDouble1(byteMessage, 3 + (40 - start) * 2, out msg), msg)); |
| | | |
| | | //变频泵状态:42 |
| | | DisplayMessage(string.Format("########变频泵状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (42 - start) * 2, out msg), msg)); |
| | | //真空泵状态 :43 //变频泵状态:42 |
| | | DisplayMessage(string.Format("########真空泵状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (43 - start) * 2, out msg), msg)); |
| | | //电动阀开阀状态 :44 |
| | | DisplayMessage(string.Format("########电动阀开阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (44 - start) * 2, out msg), msg)); |
| | | //电动阀关阀状态 :45 |
| | | DisplayMessage(string.Format("########电动阀关阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (45 - start) * 2, out msg), msg)); |
| | | //电磁阀状态 :46 |
| | | DisplayMessage(string.Format("########电磁阀状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (46 - start) * 2, out msg), msg)); |
| | | //水位状态:47 |
| | | DisplayMessage(string.Format("########水位状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (47 - start) * 2, out msg), msg)); |
| | | //超压状态:48 |
| | | DisplayMessage(string.Format("########超压状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (48 - start) * 2, out msg), msg)); |
| | | //报警状态:49 |
| | | DisplayMessage(string.Format("########报警状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (49 - start) * 2, out msg), msg)); |
| | | //变频器状态:50 |
| | | DisplayMessage(string.Format("########变频器状态 -----> {0} 数据二进制{1}", GetInt2Byte(byteMessage, 3 + (50 - start) * 2, out msg), msg)); |
| | | |
| | | |
| | | |
| | | //当前液位:51 |
| | | DisplayMessage(string.Format("########当前液位 -----> {0} 数据二进制{1} ", GetInt2Byte(byteMessage, 3 + (51 - start) * 2, out msg) * 0.01, msg)); |
| | | //瞬时流量:52 |
| | | DisplayMessage(string.Format("########瞬时流量 -----> {0} 数据二进制{1} ", GetInt4Byte(byteMessage, 3 + (52 - start) * 2, out msg) * 0.001, msg)); |
| | | //累计流量:54 |
| | | DisplayMessage(string.Format("########累计流量 -----> {0} 数据二进制{1} ", GetInt4Byte(byteMessage, 3 + (54 - start) * 2, out msg) * 1.0, msg)); |
| | | //有功功率:56 |
| | | DisplayMessage(string.Format("########有功功率 -----> {0} 数据二进制{1} ", GetDouble1(byteMessage, 3 + (56 - start) * 2, out msg), msg)); |
| | | |
| | | */ |
| | | list.Add(new Model.MonitorDataDockingReceiveRecord() |
| | | { |
| | | SysId = 1584475756476633088, |
| | | RecordType = Model.eMonitorType.General, |
| | | SrcTime = now, |
| | | SrcValue = GetDouble1(byteMessage, 3 + (56 - start) * 2, out msg).ToString() |
| | | }); |
| | | } |
| | | catch //(Exception err) |
| | | { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | #region MyRegion |
| | | private static int GetInt2Byte(byte[] byteMessage, int startPosition, out string info) |
| | | { |