From d4f8824babc446149671f17a0545066759ad082a Mon Sep 17 00:00:00 2001
From: wanggang <76527413@qq.com>
Date: Fri, 3 Apr 2020 16:29:45 +0800
Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=A3=9E=E6=AF=94=E8=AE=BE?=
=?UTF-8?q?=E5=A4=87=E8=BF=94=E5=9B=9E=E5=80=BC=E5=A4=84=E7=90=86=E5=87=BA?=
=?UTF-8?q?=E7=8E=B0=E5=BC=82=E5=B8=B8=E6=97=B6=E5=AF=BC=E8=87=B4=E6=8E=A5?=
=?UTF-8?q?=E5=8F=97=E4=B8=8A=E4=BC=A0=E6=95=B0=E6=8D=AE=E7=BA=BF=E7=A8=8B?=
=?UTF-8?q?=E9=80=80=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Former-commit-id: 296679a5354a8be0dd61e7275c1fab911cf96bfb
---
.../DeviceServices/FBee/FBeeService.cs | 25 +++++++++++++++----
projects/IoTNode/IoTNode.csproj | 2 +-
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs
index e6ddb567..abe25c3e 100644
--- a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs
+++ b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs
@@ -217,6 +217,14 @@ namespace IoTNode.DeviceServices.FBee
ex.PrintStack();
}
}
+ foreach (var item in Clients)
+ {
+ if (!gateways.Any(o => o.Number == item.Key))
+ {
+ Clients.Remove(item.Key, out TcpClientWrapper value);
+ value.Client.Dispose();
+ }
+ }
}
}
@@ -290,12 +298,19 @@ namespace IoTNode.DeviceServices.FBee
private void Handle(string sn, byte[] data)
{
- var length = 2 + data[1];
- if (data.Length > length)
+ try
{
- Handle(sn, data.Skip(length).ToArray());
+ var length = 2 + data[1];
+ if (data.Length > length)
+ {
+ Handle(sn, data.Skip(length).ToArray());
+ }
+ this.HandleInternal(sn, data.Take(length).ToArray());
+ }
+ catch (Exception ex)
+ {
+ ex.PrintStack();
}
- this.HandleInternal(sn, data.Take(length).ToArray());
}
private void HandleInternal(string sn, byte[] data)
@@ -1373,7 +1388,7 @@ namespace IoTNode.DeviceServices.FBee
tempBytes.AddRange(item.Value);
tempBytes.Add(0x00);
tempBytes.Add(0x00);
- var electricity = BitConverter.ToUInt64(tempBytes.ToArray()) / 10000f;
+ var electricity = BitConverter.ToInt64(tempBytes.ToArray()) / 10000f;
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Electricity, electricity.ToString("f2"), DeviceDataType.Float, "电量", "kWh", timestamp: timestamp));
}
else if (item.Key == 0x050b)
diff --git a/projects/IoTNode/IoTNode.csproj b/projects/IoTNode/IoTNode.csproj
index 7931462d..763b8b58 100644
--- a/projects/IoTNode/IoTNode.csproj
+++ b/projects/IoTNode/IoTNode.csproj
@@ -2,7 +2,7 @@
netcoreapp3.1
true
- 1.0.0-beta.403.1
+ 1.0.0-beta.403.3