| | |
| | | }
|
| | |
|
| | | //添加设备的缓存
|
| | | var listDriveDevice = new List<CommonDevice>();
|
| | | for (int i = 0; i < listDevice.Count; i++)
|
| | | {
|
| | | var device = listDevice[i];
|
| | |
| | | }
|
| | | //获取设备的固定属性
|
| | | HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < listDevice.Count; i++)
|
| | | {
|
| | | var device = listDevice[i];
|
| | | //对未命名的虚拟设备重新命名
|
| | | if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
|
| | | {
|
| | | //根据设备类型获取名称
|
| | | var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | this.ReName(device, dName, ShowErrorMode.NO);
|
| | | });
|
| | | listDriveDevice.Add(device);
|
| | | }
|
| | | }
|
| | | if (listDriveDevice.Count > 0)
|
| | | {
|
| | | //如果虚拟设备还没有名字的话
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //如果不这样放在一个线程里,有可能对Dictionary产生影响
|
| | | foreach (var myDevice in listDriveDevice)
|
| | | {
|
| | | //根据设备类型获取名称
|
| | | var dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | | this.ReName(myDevice, dName, ShowErrorMode.NO);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | //只有完全获取的时候,才会去处理删除的问题
|
| | |
| | | public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
|
| | | {
|
| | | //和彪哥、设备和产品部同事确认:
|
| | | //简约多功能面板[不显示多余的回路,只显示携带的2个继电器和1个温湿度传感器
|
| | | //简约多功能面板[不显示多余的回路,只显示携带的2个继电器,1个温度传感器,1个湿度传感器
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (var dev in listDevice)
|
| | | {
|
| | | if (dev.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | if (dev.DeviceEpoint == 64)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | }
|
| | | else if (dev.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | if (dev.DeviceEpoint == 65)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | |
| | | return -1;
|
| | | });
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取新风、简约环境面板全部回路的设备对象
|
| | | /// </summary>
|
| | | /// <param name="listDevice"></param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetPanelMatchEpointByMac(List<CommonDevice> listDevice, bool sort = true)
|
| | | { |
| | | var list = new List<CommonDevice>();
|
| | | foreach (var dev in listDevice)
|
| | | {
|
| | | if (dev.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | else if (dev.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | list.Add(dev);
|
| | | } |
| | | }
|
| | | if (sort == false)
|
| | | {
|
| | | return list;
|
| | | } |
| | | list.Sort((obj1, obj2) => {
|
| | |
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | }); |
| | | return list;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取设备信息_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 读取单个端点回路设备信息
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public CommonDevice.DeviceInfoData ReadDeviceEpointDeviceInfo(CommonDevice device)
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 80 } };
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetStatusRecord", jObject.ToString(), "GetStatusRecord_Respon");
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(result.ReceiptData);
|
| | | return info;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设置设备功能类型___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设置设备功能类型到网关
|
| | | /// </summary>
|
| | | /// <param name="device">设备回路</param>
|
| | | /// <param name="functionType">功能类型</param>
|
| | | /// <returns></returns>
|
| | | public bool SendDeviceFunctionTypeToGateway(CommonDevice device, DeviceFunctionType functionType)
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 110 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "FunctionType", (int)functionType } };
|
| | | jObject.Add("Data", data);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Device/SetEPDeviceFunctionType", jObject.ToString(), "Device/SetEPDeviceFunctionTypeRespon");
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var resultData = Newtonsoft.Json.Linq.JObject.Parse(result.ReceiptData);
|
| | | if (resultData.Property("Result") != null)
|
| | | {
|
| | | //0:修改成功 1:修改失败
|
| | | return resultData["Result"].ToString() == "0";
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取设备名称_______________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | //空调都叫室内机
|
| | | return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo;
|
| | | }
|
| | | else if (device.Type == DeviceType.FreshAir)
|
| | | {
|
| | | //新风面板中的按键叫新风
|
| | | return Language.StringByID(R.MyInternationalizationString.FreshAir);
|
| | | }
|
| | | else if (device.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | //新风面板湿度传感器
|
| | | return Language.StringByID(R.MyInternationalizationString.HumiditySensor);
|
| | | }
|
| | | } |
| | |
|
| | | //获取设备类型
|
| | | var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | |
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceBelongId16) + epointNo;
|
| | | }
|
| | | }
|
| | | else if (device.Type == DeviceType.FreshAirHumiditySensor)
|
| | | {
|
| | | //新风面板/简约多功能/简约环境面板湿度传感器
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
|
| | | }
|
| | | else if (device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
|
| | | if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
|
| | | || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
|
| | | || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | //新风面板中的Thermostat为温度传感器
|
| | | return Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
|
| | | //新风面板/简约多功能/简约环境面板 温度传感器
|
| | | return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
|
| | | }
|
| | | else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
|
| | | {
|
| | |
| | | //根据设备类型创建设备对象的实例
|
| | | if (deviceType == DeviceType.ColorDimmableLight) { device = new ColorDimmableLight(); }
|
| | | else if (deviceType == DeviceType.DimmableLight) { device = new DimmableLight(); }
|
| | | else if (deviceType == DeviceType.ColorDimmerSwitch) { device = new ColorDimmerSwitch(); }
|
| | | else if (deviceType == DeviceType.LevelControlSwitch) { device = new LevelControlSwitch(); }
|
| | | else if (deviceType == DeviceType.OnOffSwitch) { device = new Panel(); }
|
| | | else if (deviceType == DeviceType.OnOffOutput) { device = new ToggleLight(); }
|
| | | else if (deviceType == DeviceType.AirSwitch) { device = new AirSwitch(); }
|
| | | else if (deviceType == DeviceType.WindowCoveringDevice) { device = new Rollershade(); }
|
| | | else if (deviceType == DeviceType.WindowCoveringController) { device = new WindowCoveringController(); }
|
| | | else if (deviceType == DeviceType.IASZone) { device = new IASZone(); }
|
| | | else if (deviceType == DeviceType.Repeater) { device = new Repeater(); }
|
| | | else if (deviceType == DeviceType.Thermostat) { device = new AC(); }
|