old mode 100755
new mode 100644
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// R文件里面设备模块ID的翻译名字的前缀
|
| | | /// 设备的模块ID的枚举 keys:模块ID (Axxx代表是第三方设备) |
| | | /// </summary>
|
| | | public const string deviceModelIdName = "uDeviceModelId";
|
| | | /// <summary>
|
| | | /// R文件里面所有设备名字的ID
|
| | | /// </summary>
|
| | | public Dictionary<string, int> dicDeviceAllNameID = null;
|
| | | /// <summary>
|
| | | /// 设备的模块ID的枚举(keys:模块ID value:设备具体类型值-设备所属类型值(自定义的值,嘛,只要不重复就可以)
|
| | | /// </summary>
|
| | | private Dictionary<string, string> dicDeviceModelIdEnum = null;
|
| | | private Dictionary<string, DeviceNameContent> dicDeviceModelIdEnum = null;
|
| | | /// <summary>
|
| | | /// 需要转换的设备的模块ID(keys:旧模块ID,value:新模块ID)
|
| | | /// </summary>
|
| | |
| | | { |
| | | this.dicAllDevice.Clear(); |
| | | this.dicDeviceEpoint.Clear();
|
| | | |
| | | //初始化R文件里面设备默认名字的ID |
| | | this.InitDeviceDefultNameIDList(); |
| | |
|
| | | //初始化设备枚举
|
| | | this.InitDeviceModelIdEnum(); |
| | | |
| | | //获取本地全部的设备文件 |
| | | List<string> listFile = this.GetAllDeviceFile(); |
| | |
| | | /// <para>-1:异常 1:正常 2:设备信息缺损</para>
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
|
| | | /// <param name="useLocalConnect">是否强制使用本地连接发送</param>
|
| | | public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway, bool useLocalConnect)
|
| | | {
|
| | | //从网关获取全部的设备
|
| | | int statu = 0;
|
| | | List<CommonDevice> listDevice = new List<CommonDevice>();
|
| | | List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
|
| | | List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, useLocalConnect);
|
| | | if (list == null)
|
| | | {
|
| | | return -1;
|
| | |
| | | var tempDevice = this.dicOTADevice[mainKeys];
|
| | | //将DeviceInfo的属性设置到主属性中
|
| | | this.SetDeviceInfoToMain(tempDevice, device);
|
| | | //刷新设备功能类型(这个东西需要独立出来)
|
| | | this.RefreshDeviceFunctionType(tempDevice, device, false);
|
| | | device = tempDevice;
|
| | | }
|
| | |
|
| | |
| | | var tempDevice = this.dicAllDevice[mainKeys];
|
| | | //将DeviceInfo的属性设置到主属性中
|
| | | this.SetDeviceInfoToMain(tempDevice, device);
|
| | | //刷新设备功能类型(这个东西需要独立出来)
|
| | | this.RefreshDeviceFunctionType(tempDevice, device, false);
|
| | | device = tempDevice;
|
| | | }
|
| | | else
|
| | |
| | | return true;
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | | #region ■ 测试设备___________________________
|
| | |
|
| | |
| | | //其他的干接点叫干接点
|
| | | else
|
| | | {
|
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceBelongId16) + epointNo;
|
| | | var infoContent = this.GetDeviceModelIdNameInfo("A419");
|
| | | return infoContent != null ? infoContent.A官方名字 : string.Empty;
|
| | | }
|
| | | }
|
| | | else if (device.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | //新风面板/简约多功能/简约环境面板湿度传感器
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
|
| | | return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
|
| | | }
|
| | | else if (device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | |
| | | || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | //新风面板/简约多功能/简约环境面板 温度传感器
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
|
| | | return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
|
| | | }
|
| | | else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
|
| | | {
|
| | | //面板的温度探头叫 面板名字+温度
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.uTemperature);
|
| | | return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.uTemperature);
|
| | | }
|
| | | }
|
| | | //其他情况,使用它的默认名称
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + epointNo;
|
| | | return deviceInfoType.DeviceDefultName + epointNo;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | |
|
| | | //获取设备类型
|
| | | var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | | return Language.StringByID(deviceInfoType.DefultNameId);
|
| | | return deviceInfoType.DeviceDefultName;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | public string GetSimpleEpointName(CommonDevice device)
|
| | | {
|
| | | return device.DeviceEpointName;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化R文件里面设备默认名字的ID
|
| | | /// </summary>
|
| | | private void InitDeviceDefultNameIDList()
|
| | | {
|
| | | if (this.dicDeviceAllNameID != null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.dicDeviceAllNameID = new Dictionary<string, int>();
|
| | | Type type = typeof(R.MyInternationalizationString);
|
| | |
|
| | | var PropertyList = type.GetFields();
|
| | | foreach (var item in PropertyList)
|
| | | {
|
| | | if (item.Name.StartsWith(deviceModelIdName) == true
|
| | | || item.Name.StartsWith("uDeviceBelongId") == true)
|
| | | {
|
| | | this.dicDeviceAllNameID[item.Name] = Convert.ToInt32(item.GetValue(null));
|
| | | }
|
| | | }
|
| | |
|
| | | //初始化设备枚举
|
| | | this.InitDeviceModelIdEnum();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //获取自定义设备类型
|
| | | var myInfoType = this.GetMyDeviceEnumInfo(listDevice);
|
| | | //获取设备类型的翻译名字
|
| | | string strName = Language.StringByID(myInfoType.ObjectTypeNameId);
|
| | | string strName = myInfoType.ObjectTypeName;
|
| | | if (strName == string.Empty)
|
| | | {
|
| | | //加一层保险,未知设备
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | int ConcreteValue = Convert.ToInt32(strValue[0]);
|
| | | int BeloneValue = Convert.ToInt32(strValue[1]);
|
| | | var nameContent = this.dicDeviceModelIdEnum[modelKeys];
|
| | | //设置设备的【设备所属类型】
|
| | | info.BeloneType = (DeviceBeloneType)BeloneValue;
|
| | | if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + BeloneValue) == true)
|
| | | {
|
| | | //设备所属类型的翻译名字
|
| | | info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + BeloneValue];
|
| | | }
|
| | | info.BeloneType = (DeviceBeloneType)nameContent.BeloneTypeValue;
|
| | | info.BeloneText = nameContent.A所属名字;
|
| | |
|
| | | //设备具体类型
|
| | | info.ConcreteType = (DeviceConcreteType)ConcreteValue;
|
| | | if (info.ConcreteType.ToString() == ConcreteValue.ToString())
|
| | | info.ConcreteType = (DeviceConcreteType)nameContent.ConcreteTypeValue;
|
| | | if (info.ConcreteType.ToString() == nameContent.ConcreteTypeValue.ToString())
|
| | | {
|
| | | info.ConcreteType = DeviceConcreteType.UnKownDevice;
|
| | | }
|
| | | string keyName = deviceModelIdName + ConcreteValue;
|
| | | if (this.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //设备的官方名称
|
| | | info.ConcreteTextId = this.dicDeviceAllNameID[keyName];
|
| | | }
|
| | | //设备的官方名称
|
| | | info.ConcreteText = nameContent.A官方名字;
|
| | |
|
| | | //设备的类型翻译名称
|
| | | info.ObjectTypeNameId = Convert.ToInt32(strValue[2]);
|
| | | info.ObjectTypeName = nameContent.A类型名字;
|
| | |
|
| | | //设备默认名字
|
| | | info.DeviceDefultName = nameContent.A备注名字;
|
| | |
|
| | | return info;
|
| | | }
|
| | |
| | | || info.BeloneType == DeviceBeloneType.A彩灯)
|
| | | {
|
| | | //归为灯光
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
|
| | | info.BeloneType = DeviceBeloneType.A灯光;
|
| | | info.ConcreteType = DeviceConcreteType.Light;
|
| | | info.ObjectTypeNameId = 60007;//调光模块
|
| | |
|
| | | int value = (int)info.BeloneType;
|
| | | if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
|
| | | {
|
| | | //设备所属类型的翻译名字
|
| | | info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
|
| | | }
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A灯光;
|
| | | info.BeloneText = this.dicDeviceModelIdEnum["A418"].A官方名字;
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A418"].A类型名字;//调光模块
|
| | | }
|
| | | else if (info.BeloneType == DeviceBeloneType.A传感器
|
| | | || device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | //传感器合并
|
| | | info.BeloneType = DeviceBeloneType.A传感器;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
|
| | | info.ObjectTypeNameId = 60000;//传感器
|
| | |
|
| | | int value = (int)info.BeloneType;
|
| | | if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
|
| | | {
|
| | | //设备所属类型的翻译名字
|
| | | info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
|
| | | }
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A传感器;
|
| | | info.BeloneText = this.dicDeviceModelIdEnum["A402"].A官方名字;
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A类型名字;//传感器
|
| | | }
|
| | |
|
| | | return info;
|
| | |
| | | {
|
| | | if (listdevice.Count > 1)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A401"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A按键面板;
|
| | | info.ConcreteType = DeviceConcreteType.ButtonPanel;
|
| | | }
|
| | | else
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A419"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A干接点;
|
| | | info.ConcreteType = DeviceConcreteType.DryContact;
|
| | | }
|
| | | info.ObjectTypeNameId = 60003;//智能面板
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A401"].A类型名字;//智能面板
|
| | | }
|
| | | //3包含窗帘的话,当窗帘处理
|
| | | else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId100;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A400"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A窗帘;
|
| | | info.ConcreteType = DeviceConcreteType.Curtain;
|
| | | info.ObjectTypeNameId = 60002;//遮阳模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A400"].A类型名字;//遮阳模块
|
| | | }
|
| | | //4空气开关
|
| | | else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
|
| | | {
|
| | | //默认值
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A408"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A开关;
|
| | | info.ConcreteType = DeviceConcreteType.AirSwitch;
|
| | | info.ObjectTypeNameId = 60001;//开关模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A408"].A类型名字;//开关模块
|
| | |
|
| | | if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A开关;
|
| | | info.ConcreteType = DeviceConcreteType.Switch;
|
| | | }
|
| | | else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A插座;
|
| | | info.ConcreteType = DeviceConcreteType.Socket1;
|
| | | }
|
| | | else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A灯光;
|
| | | info.ConcreteType = DeviceConcreteType.Light;
|
| | | }
|
| | |
| | | else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
|
| | | {
|
| | | //默认值
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A403"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A继电器;
|
| | | info.ConcreteType = DeviceConcreteType.Relay;
|
| | | info.ObjectTypeNameId = 60001;//开关模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A403"].A类型名字;//开关模块
|
| | |
|
| | | if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A开关;
|
| | | info.ConcreteType = DeviceConcreteType.Switch;
|
| | | }
|
| | | else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A插座;
|
| | | info.ConcreteType = DeviceConcreteType.Socket1;
|
| | | }
|
| | | else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A灯光;
|
| | | info.ConcreteType = DeviceConcreteType.Light;
|
| | | }
|
| | |
| | | //6调光器
|
| | | else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2500;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A404"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A调光器;
|
| | | info.ConcreteType = DeviceConcreteType.DimmableLight;
|
| | | info.ObjectTypeNameId = 60007;//调光模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A404"].A类型名字;//调光模块
|
| | | }
|
| | | //7彩灯
|
| | | else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A410"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A彩灯;
|
| | | info.ConcreteType = DeviceConcreteType.ColorLight;
|
| | | info.ObjectTypeNameId = 60007;//调光模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A410"].A类型名字;//调光模块
|
| | | }
|
| | | //8空调
|
| | | else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3600;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A406"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A空调;
|
| | | info.ConcreteType = DeviceConcreteType.AirConditioner;
|
| | | info.ObjectTypeNameId = 60009;//空调模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A406"].A类型名字;//空调模块
|
| | | }
|
| | | //9中继器
|
| | | else if (dicType.ContainsKey(DeviceType.Repeater) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3900;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A407"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A中继器;
|
| | | info.ConcreteType = DeviceConcreteType.Repeater;
|
| | | info.ObjectTypeNameId = 60006;//系统设备
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A407"].A类型名字;//系统设备
|
| | | }
|
| | | //10转换器
|
| | | else if (dicType.ContainsKey(DeviceType.Transverter) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4200;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A409"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A转换器;
|
| | | info.ConcreteType = DeviceConcreteType.Converter;
|
| | | info.ObjectTypeNameId = 60008;//转换器
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A409"].A类型名字;//转换器
|
| | | }
|
| | | //11智能门锁
|
| | | else if (dicType.ContainsKey(DeviceType.DoorLock) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2800;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A405"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A智能门锁;
|
| | | info.ConcreteType = DeviceConcreteType.IntelligentLocks;
|
| | | info.ObjectTypeNameId = 60010;//智能门锁
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A405"].A类型名字;//智能门锁
|
| | | }
|
| | | //12包含传感器的话,当传感器处理
|
| | | else if (dicType.ContainsKey(DeviceType.IASZone) == true)
|
| | | {
|
| | | info.BeloneType = DeviceBeloneType.A传感器;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
|
| | | info.ObjectTypeNameId = 60000;//传感器
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A官方名字;
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A类型名字;//传感器
|
| | | //设置传感器具体的类型
|
| | | this.SetSensorDeviceSpecificType(ref info, listdevice);
|
| | | }
|
| | |
| | | {
|
| | | //设置传感器具体的类型
|
| | | info.BeloneType = DeviceBeloneType.A温湿度传感器;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A411"].A官方名字;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
|
| | | }
|
| | | else if (temperatrue == true && humidity == false)
|
| | | {
|
| | | //设置传感器具体的类型
|
| | | info.BeloneType = DeviceBeloneType.A温度传感器;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A412"].A官方名字;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
|
| | | }
|
| | | else if (temperatrue == false && humidity == true)
|
| | | {
|
| | | //设置传感器具体的类型
|
| | | info.BeloneType = DeviceBeloneType.A湿度传感器;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId12;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A413"].A官方名字;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
|
| | | }
|
| | | info.ObjectTypeNameId = 60000;//传感器
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A411"].A类型名字;//传感器
|
| | | }
|
| | | //14新风设备
|
| | | else if (dicType.ContainsKey(DeviceType.FreshAir) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId2310;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A414"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A新风;
|
| | | info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
|
| | | info.ObjectTypeNameId = 60011;//新风
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A414"].A类型名字;//新风
|
| | | }
|
| | | //15 PM2.5传感器设备
|
| | | else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A415"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.APM2点5空气质量传感器;
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
|
| | | info.ObjectTypeNameId = 60000;//传感器
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A415"].A类型名字;//传感器
|
| | | }
|
| | | //16色温灯
|
| | | else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
|
| | | {
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A420"].A官方名字;
|
| | | info.BeloneType = DeviceBeloneType.A彩灯;
|
| | | info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
|
| | | info.ObjectTypeNameId = 60007;//调光模块
|
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A420"].A类型名字;//调光模块
|
| | | }
|
| | |
|
| | | int value = (int)info.BeloneType;
|
| | | if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
|
| | | {
|
| | | //设备所属类型的翻译名字
|
| | | info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
|
| | | }
|
| | | //设备所属类型的翻译名字
|
| | | info.BeloneText = info.ConcreteText;
|
| | | info.DeviceDefultName = info.ConcreteText;
|
| | |
|
| | | return info;
|
| | | }
|
| | |
| | | {
|
| | | //运动传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Motion;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uMotionSensor;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uMotionSensor);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 40)
|
| | | {
|
| | | //烟雾传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Fire;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1302;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorFire);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 42)
|
| | | {
|
| | | //水侵传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Water;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1304;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorWater);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 43)
|
| | | {
|
| | | //燃气传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_CarbonMonoxide;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1300;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorCarbonMonoxide);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 44)
|
| | | {
|
| | | //紧急按钮
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_EmergencyButton;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1305;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorEmergencyButton);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 277)
|
| | | {
|
| | | //钥匙扣
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_Keyfob;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uKeyfob;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uKeyfob);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22)
|
| | | {
|
| | | //门窗传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1301;
|
| | | info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorDoorWindow);
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 541)
|
| | | {
|
| | | //球型移动传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_SphericalMotion;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1205;
|
| | | info.ConcreteText = this.dicDeviceModelIdEnum["MSPIRB-ZB.10"].A官方名字;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// 从缓存变量检测设备是否在线
|
| | | /// </summary>
|
| | | /// <param name="i_device"></param>
|
| | | /// <param name="checkAll">是否检测全部回路</param>
|
| | | /// <returns></returns>
|
| | | public bool CheckDeviceIsOnline(CommonDevice i_device)
|
| | | public bool CheckDeviceIsOnline(CommonDevice i_device, bool checkAll = true)
|
| | | {
|
| | | if (checkAll == false)
|
| | | {
|
| | | //不检测全部回路
|
| | | return i_device.IsOnline == 1 || i_device.IsOnline == 2;
|
| | | }
|
| | | var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取模块ID所指向的各种名字信息
|
| | | /// </summary>
|
| | | /// <param name="strKey"></param>
|
| | | /// <returns></returns>
|
| | | public DeviceNameContent GetDeviceModelIdNameInfo(string strKey)
|
| | | {
|
| | | if (this.dicDeviceModelIdEnum.ContainsKey(strKey) == false)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | return this.dicDeviceModelIdEnum[strKey];
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 附加设备的版本代号(返回Ver.XXX)
|
| | | /// </summary>
|
| | | /// <param name="versionValue">版本号</param>
|
| | |
| | | /// <param name="msg"></param>
|
| | | private void ShowErrorMsg(string msg)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Error, msg);
|
| | | contr.Show();
|
| | |
| | | /// <param name="msg"></param>
|
| | | private void ShowTipMsg(string msg)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | contr.Show();
|
| | |
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
|
| | | /// <param name="ignoreTime">是否无视时间(此变量是给获取在线状态用的),true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
|
| | | /// <param name="useLocalConnect">是否使用本地连接发送</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | /// <returns></returns> |
| | | public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES) |
| | | public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES) |
| | | {
|
| | | if (ignoreTime == false)
|
| | | {
|
| | | if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
|
| | | {
|
| | | //不无视时间,返回本地设备列表
|
| | | statu = 1;
|
| | | return this.GetDeviceByGatewayID(zbGateway.GwId);
|
| | | }
|
| | | }
|
| | | zbGateway.LastDateTime = DateTime.Now;
|
| | |
|
| | | //如果切换到了别的界面,则不显示错误信息
|
| | | string nowFormId = UserCenterResourse.NowActionFormID;
|
| | |
|
| | |
| | | statu = -1;
|
| | | return null;
|
| | | }
|
| | | //需要变更功能类型的回路
|
| | | var listFucDevice = new List<CommonDevice>();
|
| | |
|
| | | //是否达成中断的时机
|
| | | bool canBreak = false;
|
| | |
| | | {
|
| | | //刷新属性
|
| | | this.SetDeviceInfoToMain(localDevice, device);
|
| | | if (this.RefreshDeviceFunctionType(localDevice, device, false) == true)
|
| | | {
|
| | | //需要发送功能类型给网关
|
| | | listFucDevice.Add(localDevice);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | try
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
|
| | | realWay.Send("GetDeviceInfo", jObject.ToString());
|
| | | if (useLocalConnect == false)
|
| | | {
|
| | | realWay.Send("GetDeviceInfo", jObject.ToString());
|
| | | }
|
| | | else
|
| | | {
|
| | | //强制使用本地连接
|
| | | realWay.SendLocation("GetDeviceInfo", Encoding.UTF8.GetBytes(jObject.ToString()));
|
| | | }
|
| | | }
|
| | | catch { canBreak = true; }
|
| | |
|
| | |
| | | {
|
| | | statu = 1;
|
| | | } |
| | | if (listFucDevice.Count > 0)
|
| | | {
|
| | | //如果存在需要变更的功能类型
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | for (int i = 0; i < listFucDevice.Count; i++)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(listFucDevice[i], listFucDevice[i].DfunctionType);
|
| | | System.Threading.Thread.Sleep(100);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | return listDevice; |
| | | }
|
| | |
|
| | |
| | | #region ■ 创建新设备对象相关_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 根据设备类型创建设备对象的实例
|
| | | /// 根据设备类型创建设备对象的实例(数据在DeviceInfo中)
|
| | | /// </summary>
|
| | | /// <param name="deviceType">设备类型</param>
|
| | | /// <param name="jobject">主题Data</param>
|
| | |
| | | {
|
| | | return null;
|
| | | }
|
| | | this.SetMacName(device, string.Empty);
|
| | | this.SetEpointName(device, string.Empty);
|
| | |
|
| | | //设置设备主键类
|
| | | this.SetNewDeviceMainKeys(device, jobject);
|
| | | device.CurrentGateWayId = gwId;
|
| | |
|
| | | //将DeviceInfo的属性设置到主属性中
|
| | | this.SetDeviceInfoToMain(device, device);
|
| | |
|
| | | return device;
|
| | | }
|
| | |
| | | mainDevice.SerialNumber = device.DeviceInfo.ProductCode;
|
| | | //设备功能类型
|
| | | mainDevice.DfunctionType = (DeviceFunctionType)device.DeviceInfo.FunctionType;
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A不指定)
|
| | | {
|
| | | //式样变更:功能类型不允许选择为空 网关默认的FunctionType为0
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A未定义;
|
| | | }
|
| | |
|
| | | mainDevice.InClusterList.Clear();
|
| | | mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
|
| | |
| | | ((TemperatureSensor)mainDevice).SensorDiv = 1;
|
| | | }
|
| | | }
|
| | | }
|
| | | //如果是调光器
|
| | | else if (mainDevice.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //调光器固定灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | | //如果是色温灯
|
| | | else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //色温灯固定灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLightTemperature.png";
|
| | | }
|
| | | }
|
| | | //如果是三路继电器的回路的话,默认为灯光
|
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //2020.05.13变更:继电器都默认为灯光
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是空气开关的话
|
| | | else if (mainDevice.Type == DeviceType.AirSwitch)
|
| | | {
|
| | | //空气开关默认为开关
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A开关;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
|
| | | {
|
| | | //空气开关默认为开关
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是彩灯的话
|
| | | else if (mainDevice.Type == DeviceType.ColorDimmableLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //彩灯默认为开关
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLight.png";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据功能类型,重新设置设备回路图标
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ResetIconPathByDeviceFunctionType(CommonDevice device)
|
| | | {
|
| | | if (device.IsCustomizeImage == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 刷新设备功能类型___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 刷新设备的功能类型,如果返回true,代表需要另外调用【SendDeviceFunctionTypeToGateway】函数,sendFucType为true时自动调用
|
| | | /// </summary>
|
| | | /// <param name="mainDevice">主设备对象</param>
|
| | | /// <param name="device">设置源设备对象</param>
|
| | | /// <param name="sendFucType">当需要变更时,是否发送功能类型到网关(此变量给获取设备列表有特殊含义)</param>
|
| | | public bool RefreshDeviceFunctionType(CommonDevice mainDevice, CommonDevice device, bool sendFucType)
|
| | | {
|
| | | //如果是调光器
|
| | | if (mainDevice.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | }
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //调光器固定灯光
|
| | | if (sendFucType == true)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | | //如果是色温灯
|
| | | else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLightTemperature.png";
|
| | | }
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //色温灯固定灯光
|
| | | if (sendFucType == true)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | | //如果是三路继电器的回路的话,默认为灯光
|
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | //2020.05.13变更:继电器都默认为灯光
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //继电器默认为灯光
|
| | | if (sendFucType == true)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | //如果是空气开关的话
|
| | | else if (mainDevice.Type == DeviceType.AirSwitch)
|
| | | {
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | //空气开关默认为开关
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A开关;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
|
| | | {
|
| | | //空气开关默认为开关
|
| | | if (sendFucType == true)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | //如果是彩灯的话
|
| | | else if (mainDevice.Type == DeviceType.ColorDimmableLight)
|
| | | {
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLight.png";
|
| | | }
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //彩灯默认为开关
|
| | | if (sendFucType == true)
|
| | | {
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据功能类型,重新设置设备回路图标
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ResetIconPathByDeviceFunctionType(CommonDevice device)
|
| | | {
|
| | | if (device.IsCustomizeImage == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | //----------------------------------分割线(设备模块ID)---------------------------------------------
|
| | |
|
| | | #region ■ 自定义设备模块ID___________________
|
| | |
| | | /// </summary>
|
| | | private void InitDeviceModelIdEnum()
|
| | | {
|
| | | //*********************************************************************
|
| | | //新设备添加方法:
|
| | | //1、在最下面添加 DeviceConcreteType ,然后是 DeviceBeloneType
|
| | | //2、以设备的具体类型为名字DeviceConcreteType(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
|
| | | //3、如果需要共有图片,则在这个函数的最底下添加
|
| | | //4、显示的模块ID需要交换的话,则在这个函数的最底下添加
|
| | | //*********************************************************************
|
| | |
|
| | | if (this.dicDeviceModelIdEnum != null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.dicDeviceModelIdEnum = new Dictionary<string, string>();
|
| | | this.dicDeviceModelIdEnum = new Dictionary<string, DeviceNameContent>();
|
| | |
|
| | | //*********************************************************************
|
| | | //新设备添加方法:
|
| | | //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType , 然后是 设备类型的翻译ID
|
| | | //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
|
| | | //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
|
| | | //4、添加R文件(uDeviceModelId),添加Language文件
|
| | | //5、如果需要共有图片,则在这个函数的最底下添加
|
| | | //*********************************************************************
|
| | |
|
| | | //前言:因为zigbeehome的设备拥有四种名字:
|
| | | //1、设备官方名称 ----它由DeviceConcreteType的数值所决定(个人中心专用)
|
| | | //2、设备入网后的默认名称 ----它不需要在代码里面定义,它直接在Language文件里面定义
|
| | | // 范围:50000开始,它的规则是DeviceConcreteType对应的R文件里面的ID的数值+20000,
|
| | | //3、设备所属名称 ----它有DeviceBeloneType的数值所决定
|
| | | //4、设备类型名称 ----它由【设备类型的翻译ID】所决定,这个值是个人中心专用,
|
| | | // 它是Language文件里面的 60000之后的那些值
|
| | |
|
| | | //定义规则:模块ID(已翻译) = 设备具体类型值 - 设备所属类型值 - 设备类型的翻译ID
|
| | | //设备具体类型值:DeviceConcreteType(在这个文件最下面进行定义)
|
| | | //设备所属类型值: DeviceBeloneType(自定义的值,嘛,只要不重复就可以,在这个文件最下面进行定义)
|
| | | //设备类型的翻译ID:这个值是个人中心专用,它是Language文件里面的 60000之后的那些值
|
| | |
|
| | | //=========★★开合帘类(100-199)★★=========
|
| | | this.dicDeviceModelIdEnum["MWM65B-ZB.20"] = "100-100-60002";//智能开合帘电机
|
| | | this.dicDeviceModelIdEnum["MVSM35B-ZB.20"] = "101-100-60002";//智能管状电机
|
| | |
|
| | | //=========★★按键面板类(200-1199)★★=========
|
| | | this.dicDeviceModelIdEnum["MPT4/R4-ZB.18"] = "200-200-60003";//4按键触摸面板(带4路继电器底座)
|
| | | this.dicDeviceModelIdEnum["MPT3/R3-ZB.18"] = "201-200-60003";//3按键触摸面板
|
| | | this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200-60003";//2按键触摸面板
|
| | | this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200-60003";//12按键触摸面板
|
| | | this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200-60003";//4按键触摸面板(只带电源底座)
|
| | | this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200-60003";//简约4按键面板
|
| | | this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200-60003";//简约3按键面板
|
| | | this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200-60003";//简约2按键面板
|
| | | this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200-60003";//简约4按键场景面板
|
| | | this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200-60003";//简约2路窗帘面板
|
| | | this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200-60003";//方悦单开双控面板
|
| | | this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200-60003";//方悦双开四控面板
|
| | | this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200-60003";//方悦四开八控面板
|
| | | this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//方悦新风面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//方悦环境面板
|
| | | this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//窗帘面板
|
| | | this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//简约多功能面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//简约环境面板
|
| | |
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
|
| | | this.dicDeviceModelIdEnum["MSPIRB-ZB.10"] = "1205-1200-60000";//球型移动传感器
|
| | |
|
| | | //=========★★安防类传感器类(1300-2299)★★=========
|
| | | //这里是麦乐克的
|
| | | this.dicDeviceModelIdEnum["MULTI-GASE--EA07"] = "1300-1200-60000";//燃气传感器
|
| | | this.dicDeviceModelIdEnum["MULTI-MECI--EA01"] = "1301-1200-60000";//门窗磁传感器
|
| | | this.dicDeviceModelIdEnum["MULTI-FIRE--EA05"] = "1302-1200-60000";//烟雾传感器
|
| | | this.dicDeviceModelIdEnum["MULTI-MOTI--EA04"] = "1303-1200-60000";//红外传感器
|
| | | this.dicDeviceModelIdEnum["MULTI-WATE--EA02"] = "1304-1200-60000";//水浸传感器
|
| | | this.dicDeviceModelIdEnum["MULTI-BURO--EA06"] = "1305-1200-60000";//紧急按键
|
| | | //这里是河东的
|
| | | this.dicDeviceModelIdEnum["MSG01/M-ZB.10"] = "1300-1200-60000";//燃气传感器
|
| | | this.dicDeviceModelIdEnum["MSDC01/M-ZB.10"] = "1301-1200-60000";//门窗磁传感器
|
| | | this.dicDeviceModelIdEnum["MSS01/M-ZB.10"] = "1302-1200-60000";//烟雾传感器
|
| | | this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//红外传感器
|
| | | this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//水浸传感器
|
| | | this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键
|
| | | this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
|
| | |
|
| | | //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
|
| | | this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5空气质量传感器 |
| | |
|
| | | //=========★★继电器类(2300-2499)★★=========
|
| | | this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块
|
| | | this.dicDeviceModelIdEnum["MFA01-ZB.10"] = "2310-2300-60011";//方悦新风小模块
|
| | |
|
| | | //=========★★调光器类(2500-2799)★★=========
|
| | | this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500-60007";//1路调光器小模块
|
| | |
|
| | | //=========★★智能门锁类(2800-????)★★=========
|
| | | this.dicDeviceModelIdEnum["H06C"] = "2800-2800-60010";//智能门锁(H06C)
|
| | | this.dicDeviceModelIdEnum["S-one"] = "2802-2800-60010";//智能门锁(S-one)
|
| | |
|
| | | //=========★★空调类(3600-3899)★★=========
|
| | | this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600-60009";//zigbee空调网关模块
|
| | |
|
| | | //=========★★中继器类(3900-3999)★★=========
|
| | | this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900-60006"; //zigbee中继器
|
| | |
|
| | | //=========★★空气开关类(4100-4199)★★=========
|
| | | this.dicDeviceModelIdEnum["MBCI01-ZB.10"] = "4100-4100-60001";//zigbee微断云控制器
|
| | |
|
| | | //=========★★转换器类(4200-4699)★★=========
|
| | | this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200-60008";//zigbee转buspro协议转换器
|
| | | this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200-60008";//zigbee转485协议转换器
|
| | |
|
| | |
|
| | | var listText = this.GetDeviceNameFileContent();
|
| | | foreach (var dataText in listText)
|
| | | {
|
| | | if (dataText == string.Empty || dataText.StartsWith(";") == true)
|
| | | {
|
| | | //这是注释
|
| | | continue;
|
| | | }
|
| | | string[] strArry1 = dataText.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (strArry1.Length != 2)
|
| | | {
|
| | | //非法设置
|
| | | continue;
|
| | | }
|
| | | string[] strArry2 = strArry1[1].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (strArry2.Length < 6)
|
| | | {
|
| | | //非法设置
|
| | | continue;
|
| | | }
|
| | | var content = new DeviceNameContent();
|
| | | content.ConcreteTypeValue = Convert.ToInt32(strArry2[0].Trim());
|
| | | content.A官方名字 = strArry2[1].Trim();
|
| | | content.A备注名字 = strArry2[2].Trim();
|
| | | content.BeloneTypeValue= Convert.ToInt32(strArry2[3].Trim());
|
| | | content.A所属名字 = strArry2[4].Trim();
|
| | | content.A类型名字 = strArry2[5].Trim();
|
| | | this.dicDeviceModelIdEnum[strArry1[0].Trim()] = content;
|
| | | }
|
| | |
|
| | | //✩✩✩✩✩需要交换的模块ID✩✩✩✩✩
|
| | | this.dicDeviceModelIdChanged = new Dictionary<string, string>();
|
| | |
| | | this.dicDeviceModelIdChanged["MULTI-MOTI--EA04"] = "MSPIR01/M-ZB.10";//红外传感器
|
| | | this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//水浸传感器
|
| | | this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//紧急按键
|
| | |
|
| | |
|
| | |
|
| | | //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
|
| | | //两者都是DeviceConcreteType
|
| | |
| | | this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//方悦新风小模块图片 沿用 3路继电器的图标
|
| | | }
|
| | |
|
| | | #endregion
|
| | | /// <summary>
|
| | | /// 获取设备名字文件的内容
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private List<string> GetDeviceNameFileContent()
|
| | | {
|
| | | System.IO.StreamReader streamReader = null;
|
| | | var listText = new List<string>();
|
| | | try
|
| | | { |
| | | #if iOS |
| | | string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null); |
| | | streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8); |
| | | string text;
|
| | | while ((text = streamReader.ReadLine()) != null)
|
| | | {
|
| | | listText.Add(text.Trim());
|
| | | }
|
| | | return listText; |
| | | #endif |
| | | #if Android |
| | | var stream = Application.Activity.Assets.Open("DeviceName.ini");
|
| | | streamReader = new System.IO.StreamReader(stream, Encoding.UTF8);
|
| | | string text;
|
| | | while ((text = streamReader.ReadLine()) != null)
|
| | | {
|
| | | listText.Add(text.Trim());
|
| | | }
|
| | | stream.Close();
|
| | | return listText;
|
| | | #endif
|
| | | }
|
| | | catch
|
| | | {
|
| | | return listText;
|
| | | }
|
| | | finally
|
| | | {
|
| | | try
|
| | | {
|
| | | streamReader?.Close();
|
| | | }
|
| | | catch
|
| | | {
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | |
|
| | | #region ■ 自定义设备类型_________________________
|
| | | #region ■ 自定义设备类型_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值)</para>
|
| | | /// <para>变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
|
| | | /// <para>设备的具体【设备类型】,变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
|
| | | /// </summary>
|
| | | public enum DeviceConcreteType
|
| | | {
|
| | | //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值
|
| | |
|
| | | /// <summary>
|
| | | /// 未知设备
|
| | | /// </summary>
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceBeloneType值)</para>
|
| | | /// <para>这个值是瞎写的,没什么特殊意义</para>
|
| | | /// <para>设备所属枚举,这个值是瞎写的,没什么特殊意义</para>
|
| | | /// </summary>
|
| | | public enum DeviceBeloneType
|
| | | {
|
| | |
| | | A干接点 = 16,
|
| | | }
|
| | |
|
| | | #endregion
|
| | | #endregion
|
| | | }
|