添加智能插座即时功率,修复电量除数

Former-commit-id: 5674684a569d060fd6eff54638cf33261b170942
TangShanKaiPing
wanggang 5 years ago
parent cf418de57e
commit 88acbe8dcd

@ -293,7 +293,7 @@ namespace Infrastructure.Web
{ {
if (!context.Request.IsStatic()) if (!context.Request.IsStatic())
{ {
Debug.WriteLine(context.Request.Path); //Debug.WriteLine(context.Request.Path);
if (context.Request.Query.ContainsKey("access_token")) if (context.Request.Query.ContainsKey("access_token"))
{ {
context.Token = context.Request.Query["access_token"]; context.Token = context.Request.Query["access_token"];

@ -193,6 +193,7 @@ namespace IoTNode.DeviceServices.FBee
Clients.TryGetValue(gateway.Number, out TcpClientWrapper client); Clients.TryGetValue(gateway.Number, out TcpClientWrapper client);
if (client.Ip != gateway.Ip) if (client.Ip != gateway.Ip)
{ {
client.Ip = gateway.Ip;
this.Connect(client); this.Connect(client);
} }
else else
@ -687,7 +688,7 @@ namespace IoTNode.DeviceServices.FBee
} }
else if (deviceId == 0x0051) else if (deviceId == 0x0051)
{ {
//this.X8D07020000(sn, ieee); this.X8D07020000(sn, ieee);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -950,8 +951,8 @@ namespace IoTNode.DeviceServices.FBee
/// </summary> /// </summary>
public void X8D07020000(string sn, string ieee) public void X8D07020000(string sn, string ieee)
{ {
var list = new List<byte>() { 0x02, 0x07, 0x00, 0x00, 0x00 }; this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x00, 0x00, 0x00 }, 2);
this.Write(sn, RequestType.xa7, ieee, list, 2); this.Write(sn, RequestType.xa7, ieee, new List<byte>() { 0x02, 0x07, 0x0b, 0x05, 0x00 }, 2);
} }
// //
@ -1364,6 +1365,26 @@ namespace IoTNode.DeviceServices.FBee
} }
else if (deviceId == 0x0051) else if (deviceId == 0x0051)
{ {
foreach (var item in props)
{
if (item.Key == 0x0000)
{
var tempBytes = new List<byte>();
tempBytes.AddRange(item.Value);
tempBytes.Add(0x00);
tempBytes.Add(0x00);
var electricity = BitConverter.ToUInt64(tempBytes.ToArray()) / 10000f;
System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~electricity{electricity}");
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Electricity, electricity.ToString("f2"), DeviceDataType.Float, "电量", "kWh", timestamp: timestamp));
}
else if (item.Key == 0x050b)
{
var power = BitConverter.ToUInt16(item.Value.ToArray());
System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~power{power}");
this.UpdateData(deviceRepo, device, device.CreateData(Keys.Power, power, DeviceDataType.Float, "功率", "W", timestamp: timestamp));
}
System.Diagnostics.Debug.WriteLine($"~~~~~~~~~~~~~~~~~~~{item.Key.ToString("X")}:{System.BitConverter.ToString(item.Value)}");
}
if (clusterId == ClusterId.SummationDivisor) if (clusterId == ClusterId.SummationDivisor)
{ {
this.X8D07020000(sn, device.Number); this.X8D07020000(sn, device.Number);

@ -7,6 +7,7 @@
public const string EndPoint = "EndPoint"; public const string EndPoint = "EndPoint";
public const string Version = "Version"; public const string Version = "Version";
public const string Electricity = "Electricity"; public const string Electricity = "Electricity";
public const string Power = "Power";
public const string KeyPress = "KeyPress"; public const string KeyPress = "KeyPress";
public const string State = "State"; public const string State = "State";
public const string L1State = "L1State"; public const string L1State = "L1State";

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0-beta.402</Version> <Version>1.0.0-beta.403.1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.3" />

Loading…
Cancel
Save