File was renamed from Home0630/Shared/Common/Device.cs |
| | |
| | | }
|
| | |
|
| | | //添加设备的缓存
|
| | | 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) + ")";
|
| | |
|
| | | listDriveDevice.Add(device);
|
| | | }
|
| | | }
|
| | | if (listDriveDevice.Count > 0)
|
| | | {
|
| | | //如果虚拟设备还没有名字的话
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | this.ReName(device, dName, ShowErrorMode.NO);
|
| | | });
|
| | | //如果不这样放在一个线程里,有可能对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);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | //只有完全获取的时候,才会去处理删除的问题
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 同步设备___________________________
|
| | | /// <summary>
|
| | | /// 同步设备并且刷新缓存(同步失败时,会显示信息)
|
| | | /// </summary>
|
| | | /// <param name="litdevice">设备对象(MAC地址必须要相同)</param>
|
| | | public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice)
|
| | | { |
| | | //虚拟住宅的话,不需要删除网关的设备 |
| | | if (Config.Instance.Home.IsVirtually == false)
|
| | | { |
| | | //同步 |
| | | var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint);
|
| | | if (result == null || result.result != 0)
|
| | | {
|
| | | //同步删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region ■ 测试设备___________________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 检测设备是否拥有一键同步功能
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool DeviceIsCanSynchronization(CommonDevice device)
|
| | | { |
| | | //获取设备类型的 |
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | | if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) |
| | | { |
| | | return true; |
| | | }
|
| | | return false;
|
| | | }
|
| | |
| | | {
|
| | | return list;
|
| | | }
|
| | | list.Sort((obj1, obj2) => {
|
| | | list.Sort((obj1, obj2) => |
| | | {
|
| | |
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint) |
| | | { |
| | |
| | |
|
| | | #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.uDeviceCircuit) + epointNo;
|
| | | }
|
| | | //徐梅于20200630调整这里代码,请合并
|
| | | if (device.Type == DeviceType.Thermostat)
|
| | | {
|
| | | //空调都叫室内机
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | | //如果是新风面板的新风设备,则不显示
|
| | | else if (i_device.Type == DeviceType.FreshAir)
|
| | | {
|
| | | var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | if (myInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //2020.03.30追加式样:如果是面板的温度探头,不显示
|
| | | else if (i_device.Type == DeviceType.TemperatureSensor && ((TemperatureSensor)i_device).SensorDiv == 1)
|
| | | {
|
| | |
| | | {
|
| | | //新风的湿度传感器不显示
|
| | | return false;
|
| | | } |
| | | |
| | | //如果是新风面板或环境面板,则都不显示任何回路 |
| | | var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device }); |
| | | if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment) |
| | | { |
| | | return false; |
| | | } |
| | | else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) |
| | | { |
| | | if (i_device.Type != DeviceType.OnOffOutput) |
| | | { |
| | | return false; |
| | | } |
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | /// 简约环境面板 |
| | | /// </summary>
|
| | | ButtonPanel_SimpleEnvironment = 230,
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | /// <summary>
|
| | | /// 传感器
|