| | |
| | | {
|
| | | CommonDevice device = null;
|
| | | //反序列化为指定的类,不然数据会丢失而导致无法强转
|
| | | try |
| | | try
|
| | | {
|
| | | device = CommonDevice.CommonDeviceByFilePath(file);
|
| | | //读取它的内容
|
| | | var fileData = HdlFileLogic.Current.ReadFileTextContent(System.IO.Path.Combine(Config.Instance.FullPath, file));
|
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(fileData);
|
| | | if (jobject.Property("DeviceID") == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | device = CommonDevice.CommonDeviceByByteString(Convert.ToInt32(jobject["DeviceID"].ToString()), fileData);
|
| | | }
|
| | | catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
|
| | |
|
| | |
| | | }
|
| | | this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
|
| | |
|
| | | //对应旧版本的设备文件 Device_OnoffOutput_abcdfrtgg_01
|
| | | bool bolSave = file.Split(new string[] { "_" }, StringSplitOptions.None).Length == 4;
|
| | | if (bolSave == true)
|
| | | {
|
| | | //删掉这个文件,重新生成
|
| | | HdlAutoBackupLogic.DeleteFile(file);
|
| | | Global.DeleteFilebyHomeId(file);
|
| | | }
|
| | |
|
| | | //检测Ui图片是否正确,这个图片本地是否存在?
|
| | | if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(device.IconPath)) == true)
|
| | | {
|
| | | //不存在的话,重新生成
|
| | | device.IconPath = string.Empty;
|
| | | device.ReSave();
|
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
|
| | |
|
| | | bolSave = false;
|
| | | }
|
| | | //重新生成文件
|
| | | if (bolSave == true)
|
| | | {
|
| | | device.ReSave();
|
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
|
| | | }
|
| | |
| | | {
|
| | | strMsg = itemName + "没有实装(1)";
|
| | | }
|
| | | device = CommonDevice.CommonDeviceByByteString(itemName, "{}");
|
| | | device = CommonDevice.CommonDeviceByByteString(itemValue, "{}");
|
| | | if (device == null)
|
| | | {
|
| | | strMsg += "\r\n" + itemName + "没有实装(2)";
|
| | |
| | | //新风的湿度传感器不显示
|
| | | return false;
|
| | | }
|
| | | if (((int)i_device.Type).ToString() == i_device.Type.ToString())
|
| | | {
|
| | | //此设备id在DeviceType里面还没有注册,则不能显示出来
|
| | | return false;
|
| | | }
|
| | |
|
| | | //如果是新风面板或环境面板,则都不显示任何回路
|
| | | var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
|
| | | {
|
| | | return false;
|
| | |
| | | return false;
|
| | | }
|
| | | //根据新Type重新New对象
|
| | | var newDevice = CommonDevice.CommonDeviceByByteString(newDeviceType.ToString(), deviceData);
|
| | | var newDevice = CommonDevice.CommonDeviceByByteString((int)newDeviceType, deviceData);
|
| | | if (newDevice == null)
|
| | | {
|
| | | //好像有点可能
|
| | |
| | | /// <returns></returns>
|
| | | public CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType)
|
| | | {
|
| | | CommonDevice device = null;
|
| | |
|
| | | //根据设备类型创建设备对象的实例
|
| | | 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(); }
|
| | | else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); }
|
| | | else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
|
| | | else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
|
| | | else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
|
| | | else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
|
| | | else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); }
|
| | | else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); }
|
| | | else if (deviceType == DeviceType.Transverter) { device = new Transverter(); }
|
| | | else if (deviceType == DeviceType.DimmerSwitch) { device = new DimmerSwitch(); }
|
| | | else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
|
| | | else { return null; }
|
| | | var device = CommonDevice.CommonDeviceByByteString((int)deviceType, "{\"DeviceID\":" + (int)deviceType + "}");
|
| | | if (device == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | device.DeviceEpointName = string.Empty;
|
| | | device.DeviceName = string.Empty;
|