Former-commit-id: 7517e58c6ca65cde0185346090b5c311e3748fbb
TangShanKaiPing
wanggang 6 years ago
parent 70cdfe4b57
commit fb752089cb

@ -9,13 +9,13 @@ namespace Application.Domain.Entities
static DeviceId()
{
List.Add(new DeviceId { RawDeviceId = 0x0002, Name = "0x0002", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "On/Off Output" });
List.Add(new DeviceId { RawDeviceId = 0x0009, Name = "0x0009", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Mains Power Outlet" });
List.Add(new DeviceId { RawDeviceId = 0x0051, Name = "0x0051", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Smart plug" });
List.Add(new DeviceId { RawDeviceId = 0x0106, Name = "0x0106", Category = "传感器", Icon = "socket", RawCategory = "Lighting", EName = "Light Sensor" });
List.Add(new DeviceId { RawDeviceId = 0x0202, Name = "0x0202", Category = "电器", Icon = "socket", RawCategory = "Closures", EName = "Window Covering Device" });
List.Add(new DeviceId { RawDeviceId = 0x0309, Name = "0x0309", Category = "传感器", Icon = "socket", RawCategory = "HVAC", EName = "PM2.5 Sensor" });
List.Add(new DeviceId { RawDeviceId = 0x0402, Name = "0x0402", Category = "传感器", Icon = "socket", RawCategory = "Intruder Alarm Systems", EName = "IAS Zone" });
List.Add(new DeviceId { RawDeviceId = 0x0002, Name = "开关", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "On/Off Output" });
List.Add(new DeviceId { RawDeviceId = 0x0009, Name = "插座", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Mains Power Outlet" });
List.Add(new DeviceId { RawDeviceId = 0x0051, Name = "智能插座", Category = "电器", Icon = "socket", RawCategory = "Generic", EName = "Smart plug" });
List.Add(new DeviceId { RawDeviceId = 0x0106, Name = "光强检测器", Category = "监测", Icon = "socket", RawCategory = "Lighting", EName = "Light Sensor" });
List.Add(new DeviceId { RawDeviceId = 0x0202, Name = "一路可调窗帘", Category = "电器", Icon = "socket", RawCategory = "Closures", EName = "Window Covering Device" });
List.Add(new DeviceId { RawDeviceId = 0x0309, Name = "粉尘检测器", Category = "监测", Icon = "socket", RawCategory = "HVAC", EName = "PM2.5 Sensor" });
List.Add(new DeviceId { RawDeviceId = 0x0402, Name = "报警器", Category = "监测", Icon = "socket", RawCategory = "Intruder Alarm Systems", EName = "IAS Zone" });
}
public string Name { get; set; }

@ -102,6 +102,8 @@ namespace FBeeService
/// <param name="sn"></param>
/// <param name="data"></param>
private void X01(string sn, byte[] data)
{
try
{
using (var ms = new MemoryStream(data))
{
@ -113,11 +115,13 @@ namespace FBeeService
{
var profileId = ms.ReadInt();
var deviceId = ms.ReadInt();
var deviceType = DeviceId.List.FirstOrDefault(o => o.RawDeviceId == deviceId);
if (deviceType != null)
{
var deviceRepo = scope.ServiceProvider.GetService<IRepository<FBeeDevice>>();
var device = deviceRepo.Table().FirstOrDefault(o => o.Sn == sn && o.Address == address);
if (device == null)
{
var deviceType = DeviceId.List.FirstOrDefault(o => o.RawDeviceId == deviceId);
device = new FBeeDevice
{
Sn = sn,
@ -146,12 +150,33 @@ namespace FBeeService
device.SNLength = ms.ReadByte();
device.RawSN = ms.ReadHexString(device.SNLength);
device.ZoneType = ms.ReadInt();
if (device.DeviceId == 0x402)
{
if (device.ZoneType == 0x0028)
{
device.Name = "烟雾传感器";
}
else if (device.ZoneType == 0x000d)
{
device.Name = "红外感应器";
}
}
device.Battery = ms.ReadByte();
device.EpCount = ms.ReadByte();
device.Data = ms.ReadHexString(4);
device.RawValue = BitConverter.ToString(data);
deviceRepo.SaveChanges();
}
else
{
Console.WriteLine("uknown device type");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

Loading…
Cancel
Save