|
@@ -413,7 +413,7 @@ namespace NB_IOT_TCP_HP_SOCKET
|
|
|
|
|
|
ResMsg msg = ProtocolAnalysisTools.UnOuterPack(bytes, psp);
|
|
|
|
|
|
- if (!msg.Result)
|
|
|
+ if (!msg.Result || psp.Data.Length == 0)
|
|
|
{
|
|
|
AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 外包解包失败 \n {msg.Message}", lbErrorData);
|
|
|
|
|
@@ -476,18 +476,21 @@ namespace NB_IOT_TCP_HP_SOCKET
|
|
|
protocol2.Type = psp.Type;
|
|
|
protocol2.PackNum = psp.PackNum;
|
|
|
|
|
|
-
|
|
|
- if (!ProtocolAnalysisTools.OuterPack(protocol2, out buffer3).Result)
|
|
|
- {
|
|
|
+ if (psp.Type != FrameType.Battery_Param) {
|
|
|
|
|
|
- AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应打包失败 ", lbErrorData);
|
|
|
+
|
|
|
+ if (!ProtocolAnalysisTools.OuterPack(protocol2, out buffer3).Result)
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应打包失败 ", lbErrorData);
|
|
|
|
|
|
- AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData);
|
|
|
- server.Send(clientInfo.ConnId, buffer3, buffer3.Length);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData);
|
|
|
+ server.Send(clientInfo.ConnId, buffer3, buffer3.Length);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
StartOrResumeSendThread();
|
|
@@ -958,7 +961,7 @@ namespace NB_IOT_TCP_HP_SOCKET
|
|
|
if (rs)
|
|
|
{
|
|
|
PSProtocol protocol2 = new PSProtocol(psp.DestNumber, psp.SourceNumber, backParamSendCode);
|
|
|
- protocol2.Type = FrameType.Battery_EndComm;
|
|
|
+ protocol2.Type = psp.Type;
|
|
|
|
|
|
if (ProtocolAnalysisTools.OuterPack(protocol2, out byte[] buffer3).Result)
|
|
|
{
|
|
@@ -989,7 +992,7 @@ namespace NB_IOT_TCP_HP_SOCKET
|
|
|
if (result)
|
|
|
{
|
|
|
PSProtocol protocol2 = new PSProtocol(psp.DestNumber, psp.SourceNumber, backParamSendCode);
|
|
|
- protocol2.Type = FrameType.Battery_EndComm;
|
|
|
+ protocol2.Type = psp.Type;
|
|
|
|
|
|
if (ProtocolAnalysisTools.OuterPack(protocol2, out byte[] buffer3).Result)
|
|
|
{
|
|
@@ -1217,7 +1220,12 @@ namespace NB_IOT_TCP_HP_SOCKET
|
|
|
backValveSate = "ERROR";
|
|
|
break;
|
|
|
}
|
|
|
- sql = "select Top 1 ID,isnull(阀门设置状态,'') as valveSetState,isnull(阀门状态,'') as valveState,isnull(考核表编码,'') as devCode from 设备信息 where 通讯设备ID=" + dt.Rows[0]["transId"].ToString();
|
|
|
+
|
|
|
+ sql = "declare @sql varchar(200) if col_length('设备信息','阀门状态') is null begin set @sql = 'alter table 设备信息 add 阀门状态 varchar(20)' EXEC(@sql) end";
|
|
|
+ sql += " if col_length('设备信息', '阀门状态更新时间') is null begin set @sql = 'alter table 设备信息 add 阀门状态更新时间 datetime' EXEC(@sql) end ";
|
|
|
+ DBHelper.Query(sql);
|
|
|
+
|
|
|
+ sql = "select Top 1 ID,isnull(阀门状态,'') as valveState,isnull(考核表编码,'') as devCode from 设备信息 where 通讯设备ID=" + dt.Rows[0]["transId"].ToString();
|
|
|
DataTable dataTable = DBHelper.ExecuteDataTable(sql, CommandType.Text, null);
|
|
|
int num = dataTable.Rows.Count;
|
|
|
if (num > 0)
|