|
@@ -226,51 +226,85 @@ namespace NB_IOT_TCP_HP_SOCKET.WWKJUtil
|
|
|
int num3 = 0;
|
|
|
int num4 = 0;
|
|
|
int num5 = 0;
|
|
|
- while (num5 < strReturnData.Length)
|
|
|
- {
|
|
|
- if ((num5 == 11) && ((ch2 = ch = strReturnData[15 - num5]).ToString() == "1"))
|
|
|
- {
|
|
|
- num2++;
|
|
|
- }
|
|
|
- else if (strReturnData.Substring((strReturnData.Length - 1) - num5, 1) == "1")
|
|
|
+ if (cm.FunCode == 0x3d) {
|
|
|
+ for (int i = 0; i < cm._recordCount; i++)
|
|
|
{
|
|
|
- if (num5 < 11)
|
|
|
+ CellRecord item = new CellRecord();
|
|
|
+ CellMonitorConvertByType.ConvertData(data, 20 + ((i * (num + 1)) * 4), "int", "4", out string str3);
|
|
|
+ item.PickTime = RecordTime(str3);
|
|
|
+ int num7 = 0;
|
|
|
+ for (num5 = 0; num5 < strReturnData.Length; num5++)
|
|
|
{
|
|
|
- num3++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- num4++;
|
|
|
+ if (strReturnData.Substring((strReturnData.Length - 1) - num5, 1) == "1")
|
|
|
+ {
|
|
|
+
|
|
|
+ num7++;
|
|
|
+ if (num5 == 11) {
|
|
|
+ CellMonitorConvertByType.ConvertData(data, 20 + ((i * (num + 1)) * 4) + ((num7) * 4), "int", "", out string str5);
|
|
|
+ MonitorValue value2 = new MonitorValue();
|
|
|
+ value2.Name = "B" + num5.ToString();
|
|
|
+ value2.Value = str5;
|
|
|
+ item.Analog.Add(value2);
|
|
|
+ } else {
|
|
|
+ CellMonitorConvertByType.ConvertData(data, 20 + ((i * (num + 1)) * 4) + ((num7) * 4), "float", "", out string str5);
|
|
|
+ MonitorValue value2 = new MonitorValue();
|
|
|
+ value2.Name = "B" + num5.ToString();
|
|
|
+ value2.Value = str5;
|
|
|
+ item.Analog.Add(value2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ cm._record.Add(item);
|
|
|
}
|
|
|
- num5++;
|
|
|
- }
|
|
|
- for (int i = 0; i < cm._recordCount; i++)
|
|
|
- {
|
|
|
- CellRecord item = new CellRecord();
|
|
|
- CellMonitorConvertByType.ConvertData(data, 20 + ((i * (num + 1)) * 4), "int", "4", out string str3);
|
|
|
- item.PickTime = RecordTime(str3);
|
|
|
- int num7 = 0;
|
|
|
- int num8 = 0;
|
|
|
- for (num5 = 0; num5 < strReturnData.Length; num5++)
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ while (num5 < strReturnData.Length)
|
|
|
{
|
|
|
if ((num5 == 11) && ((ch2 = ch = strReturnData[15 - num5]).ToString() == "1"))
|
|
|
{
|
|
|
- num8 = 1;
|
|
|
- CellMonitorConvertByType.ConvertData(data, (20 + (((((1 + num3) + num4) + num2) * 4) * i)) + ((num3 + 1) * 4), "0101", "4", out string str4);
|
|
|
- item.Switch = OrgnizeSwitch(str4, strVol);
|
|
|
+ num2++;
|
|
|
}
|
|
|
else if (strReturnData.Substring((strReturnData.Length - 1) - num5, 1) == "1")
|
|
|
{
|
|
|
- num7++;
|
|
|
- CellMonitorConvertByType.ConvertData(data, (20 + ((i * (((num3 + num4) + num2) + 1)) * 4)) + ((num7 + num8) * 4), "float", "", out string str5);
|
|
|
- MonitorValue value2 = new MonitorValue();
|
|
|
- value2.Name = "A" + num5.ToString();
|
|
|
- value2.Value = str5;
|
|
|
- item.Analog.Add(value2);
|
|
|
+ if (num5 < 11)
|
|
|
+ {
|
|
|
+ num3++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ num4++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ num5++;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < cm._recordCount; i++)
|
|
|
+ {
|
|
|
+ CellRecord item = new CellRecord();
|
|
|
+ CellMonitorConvertByType.ConvertData(data, 20 + ((i * (num + 1)) * 4), "int", "4", out string str3);
|
|
|
+ item.PickTime = RecordTime(str3);
|
|
|
+ int num7 = 0;
|
|
|
+ int num8 = 0;
|
|
|
+ for (num5 = 0; num5 < strReturnData.Length; num5++)
|
|
|
+ {
|
|
|
+ if ((num5 == 11) && ((ch2 = ch = strReturnData[15 - num5]).ToString() == "1"))
|
|
|
+ {
|
|
|
+ num8 = 1;
|
|
|
+ CellMonitorConvertByType.ConvertData(data, (20 + (((((1 + num3) + num4) + num2) * 4) * i)) + ((num3 + 1) * 4), "0101", "4", out string str4);
|
|
|
+ item.Switch = OrgnizeSwitch(str4, strVol);
|
|
|
+ }
|
|
|
+ else if (strReturnData.Substring((strReturnData.Length - 1) - num5, 1) == "1")
|
|
|
+ {
|
|
|
+ num7++;
|
|
|
+ CellMonitorConvertByType.ConvertData(data, (20 + ((i * (((num3 + num4) + num2) + 1)) * 4)) + ((num7 + num8) * 4), "float", "", out string str5);
|
|
|
+ MonitorValue value2 = new MonitorValue();
|
|
|
+ value2.Name = "A" + num5.ToString();
|
|
|
+ value2.Value = str5;
|
|
|
+ item.Analog.Add(value2);
|
|
|
+ }
|
|
|
}
|
|
|
+ cm._record.Add(item);
|
|
|
}
|
|
|
- cm._record.Add(item);
|
|
|
}
|
|
|
return new ResMsg();
|
|
|
}
|
|
@@ -590,6 +624,47 @@ namespace NB_IOT_TCP_HP_SOCKET.WWKJUtil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else if(record2.Funcode == 0x3d) // 添加历史记录新指令 默认 老指令先发, 新指令再发,否则会丢数据,已约定好,2c 先发 3d后发
|
|
|
+ {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ List<CommData> dataList = record2.DataList;
|
|
|
+ sb.Append("Update ").Append(tablename).Append(" SET ");
|
|
|
+ for (int i = 0; i < dataList.Count; i++)
|
|
|
+ {
|
|
|
+ CommData commData = dataList[i];
|
|
|
+ sb.Append(commData.Name).Append("=");
|
|
|
+ if ((((commData.Value == null) || (commData.Value == "")) || ((commData.Value == "未知") || (commData.Value == "--"))) || (commData.Value == "非数字"))
|
|
|
+ {
|
|
|
+ sb.Append("0");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (commData.Tag == null || "".Equals(commData.Tag) || "BIT".Equals(commData.Tag.ToUpper()))
|
|
|
+ {
|
|
|
+ sb.Append("'").Append(commData.Value).Append("'");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sb.Append(commData.Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i < dataList.Count - 1) {
|
|
|
+ sb.Append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sb.Append("设备ID=").Append(deviceid).Append(" AND 采集时间 ='").Append(record2.RecordTime.ToString()).Append("'");
|
|
|
+
|
|
|
+ int rs = DBHelper.Query(sb.ToString());
|
|
|
+
|
|
|
+ if (rs > 0)
|
|
|
+ {
|
|
|
+ // 合并 最后状态
|
|
|
+ var record = lastData[deviceid];
|
|
|
+ record.DataList.AddRange(record2.DataList);
|
|
|
+ lastData[deviceid] = record;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|