| | |
| | | 16122=该内容不能省略 |
| | | 16123=Mini网关 |
| | | 16124=添加Mini网关 |
| | | 16125=插电后,长按网关HID/WCFG按键5秒{0}系统灯常亮60秒后则进入配网状态 |
| | | 16125=插电后,长按网关开关键5秒{0}系统灯常亮60秒后则进入配网状态 |
| | | 16128=色温 |
| | | 16129=Mini夜灯 |
| | | 16130=燃气泄露 |
| | |
| | | 16143=钥匙扣 |
| | | 16144=色值号为6位(由任意数字+字母组合) |
| | | 16145=长按此按键 |
| | | 16146=Mini网关最大只能添加16个设备 |
| | | 16147=开关键 |
| | | |
| | | ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★
|
| | | 18004=指定网关已经被绑定
|
old mode 100644
new mode 100755
| | |
| | | <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
| | | <AndroidSupportedAbis />
|
| | | <AndroidDexTool>d8</AndroidDexTool>
|
| | | <AotAssemblies>false</AotAssemblies>
|
| | | <EnableLLVM>false</EnableLLVM>
|
| | | <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
| | | <BundleAssemblies>false</BundleAssemblies>
|
| | | <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
| | | </PropertyGroup>
|
| | | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
| | |
| | | <MandroidI18n>cjk</MandroidI18n>
|
| | | <DefineConstants>Android,Release</DefineConstants>
|
| | | <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
| | | <AotAssemblies>false</AotAssemblies>
|
| | | <EnableLLVM>false</EnableLLVM>
|
| | | <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
| | | <BundleAssemblies>false</BundleAssemblies>
|
| | | <AndroidDexTool>d8</AndroidDexTool>
|
| | | <AndroidUseAapt2>false</AndroidUseAapt2>
|
| | | </PropertyGroup>
|
| | |
| | | <AndroidAsset Include="Assets\Phone\RealDevice\Repeater.png" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <AndroidAsset Include="Assets\Phone\RealDevice\SensorTemperatrueHumidity.png" />
|
| | | <AndroidAsset Include="Assets\Phone\RealDevice\SensorTemperatureHumidity.png" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <AndroidAsset Include="Assets\Phone\Center\MainBack1.png" />
|
old mode 100644
new mode 100755
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="0120072403" android:installLocation="auto" android:versionName="1.1.0120072403"> |
| | | <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.home" android:versionCode="0120080401" android:installLocation="auto" android:versionName="1.1.0120080401"> |
| | | <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" /> |
| | | <permission android:name="com.hdl.home.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> |
| | | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
old mode 100644
new mode 100755
Diff too large |
| | |
| | | <BundleResource Include="Resources\Phone\RealDevice\ButtonPanelFangyueFreshAir.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\AirSwitchCloudContr.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\ButtonPanelFour.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\SensorTemperatureHumidity.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\ButtonPanelCurtain.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\Repeater.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\SensorTemperatrueHumidity.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\ButtonPanelFangyueFour.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\ButtonPanelSimpleEnvironment.png" /> |
| | | <BundleResource Include="Resources\Phone\RealDevice\CommonDevice.png" /> |
| | |
| | | 16122=该内容不能省略 |
| | | 16123=Mini网关 |
| | | 16124=添加Mini网关 |
| | | 16125=插电后,长按网关HID/WCFG按键5秒{0}系统灯常亮60秒后则进入配网状态 |
| | | 16125=插电后,长按网关开关键5秒{0}系统灯常亮60秒后则进入配网状态 |
| | | 16128=色温 |
| | | 16129=Mini夜灯 |
| | | 16130=燃气泄露 |
| | |
| | | 16143=钥匙扣 |
| | | 16144=色值号为6位(由任意数字+字母组合) |
| | | 16145=长按此按键 |
| | | 16146=Mini网关最大只能添加16个设备 |
| | | 16147=开关键 |
| | | |
| | | ;★★★★下面这些是接口的返回信息翻译,从18000开始★★★★
|
| | | 18004=指定网关已经被绑定
|
| | |
| | | /// <summary> |
| | | /// 版本号 |
| | | /// </summary> |
| | | public static string CodeIDString = "1.1.0120072403"; |
| | | public static string CodeIDString = "1.1.0120080401"; |
| | | /// <summary> |
| | | /// 注册来源(0:HDL On 1:Zigbee) |
| | | /// </summary> |
| | |
| | | mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
|
| | | mainDevice.OutClusterList.Clear();
|
| | | mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
|
| | | mainDevice.AttributeStatus.Clear();
|
| | | mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
|
| | |
|
| | | //如果是温度传感器
|
| | | if (mainDevice.Type == DeviceType.TemperatureSensor)
|
| | |
| | | /// <summary>
|
| | | /// 湿度传感器(设备主键)
|
| | | /// </summary> |
| | | public string HumidityDevice = string.Empty; |
| | | /// <summary> |
| | | /// 温度 |
| | | /// </summary> |
| | | public decimal Temperatrue; |
| | | /// <summary> |
| | | /// 湿度 |
| | | /// </summary> |
| | | public decimal Humidity;
|
| | | public string HumidityDevice = string.Empty;
|
| | | /// <summary> |
| | | /// 是否是分享过来的房间 |
| | | /// 注:分享过来的房间不能删除,不能编辑该房间,不能对设备(功能)、场景进行增删改 |
| | |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | if (LocalDevice.Current.GetDevice(room.TemperatrueDevice) != null) |
| | | { |
| | | //这个设备要存在本地才行 |
| | | temperatureText.Text = room.Temperatrue == 0 ? "0.0℃" : room.Temperatrue.ToString() + "℃"; |
| | | if (this.temperDevice != null) |
| | | {
|
| | | //这个设备要存在本地才行
|
| | | decimal temperatrue = (decimal)temperDevice.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, temperDevice, null); |
| | | temperatureText.Text = temperatrue == 0 ? "0.0℃" : temperatrue.ToString() + "℃"; |
| | | } |
| | | roomTemperatureBackground.AddChidren(temperatureText); |
| | | temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60); |
| | |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | if (LocalDevice.Current.GetDevice(room.HumidityDevice) != null) |
| | | { |
| | | //这个设备要存在本地才行 |
| | | humidityText.Text = room.Humidity == 0 ? "0.0%" : room.Humidity.ToString() + "%"; |
| | |
|
| | | if (this.humidDevice != null) |
| | | {
|
| | | //这个设备要存在本地才行
|
| | | decimal humidity = (decimal)humidDevice.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, humidDevice, null); |
| | | humidityText.Text = humidity == 0 ? "0.0%" : humidity.ToString() + "%"; |
| | | } |
| | | roomTemperatureBackground.AddChidren(humidityText); |
| | | humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60); |
| | |
| | | if (report.DeviceAddr == temperDevice.DeviceAddr && report.DeviceEpoint == temperDevice.DeviceEpoint) |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | if (((TemperatureSensor)temperDevice).Temperatrue == 0) |
| | | {
|
| | | decimal temperatrue = (decimal)temperDevice.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, temperDevice, null); |
| | | if (temperatrue == 0) |
| | | { |
| | | temperatureText.Text = "0.0℃"; |
| | | } |
| | | else |
| | | { |
| | | temperatureText.Text = ((TemperatureSensor)temperDevice).Temperatrue + "℃"; |
| | | temperatureText.Text = temperatrue + "℃"; |
| | | } |
| | | }, ShowErrorMode.NO); |
| | | } |
| | |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | {
|
| | | decimal humidity = (decimal)humidDevice.GetType().InvokeMember("Humidity", System.Reflection.BindingFlags.GetField, null, humidDevice, null); |
| | | decimal humidity = (decimal)humidDevice.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, humidDevice, null); |
| | | if (humidity == 0) |
| | | { |
| | | humidityText.Text = "--%"; |
| | |
| | | var tempera = device as TemperatureSensor;
|
| | | if (tempera.SensorDiv == 1)
|
| | | {
|
| | | if (tempera.Temperatrue == 0)
|
| | | if (tempera.currentTemperature == 0)
|
| | | {
|
| | | return "--℃";
|
| | | return "0.0℃";
|
| | | }
|
| | | return $"{tempera.Temperatrue}℃";
|
| | | return $"{tempera.currentTemperature}℃";
|
| | | }
|
| | | else if (tempera.SensorDiv == 2)
|
| | | {
|
| | | if (tempera.Humidity == 0)
|
| | | if (tempera.currentHumidity == 0)
|
| | | {
|
| | | return "--%";
|
| | | }
|
| | | return $"{tempera.Humidity}%";
|
| | | return $"{tempera.currentHumidity}%";
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | //它不是升级固件, .bin是特殊的
|
| | | continue;
|
| | | }
|
| | | int testVersion = Convert.ToInt32(verInfo.FirmwareVersion.ToString().PadLeft(6, '0').Substring(2, 2));
|
| | | if (testVersion % 2 != 0)
|
| | | {
|
| | | //中间那个byte为奇数时,代表是测试版本,在显示最新版本时,不需要显示,但是在历史版本那里可以显示
|
| | | //中间那个byte为偶数时,代表是正式版本
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (verInfo.FirmwareVersion == nowVersion)
|
| | | {
|
| | | return verInfo;
|
| | |
| | | if (fileData != null)
|
| | | {
|
| | | //本地存放的固件原来的名字(因为设备升级时,它需要识别文件名字里面包含的特殊字符)
|
| | | //key:硬件版本_镜像ID_固件版本 value:固件原来的名字
|
| | | //key:全路径,硬件版本_镜像ID_固件版本 value:固件原来的名字
|
| | | dicFirmwareName = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(fileData);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | //保存固件
|
| | | var saveFile = System.IO.Path.Combine(firmwareDir, versionData.FileDiv + versionData.HwVersion + "_" + versionData.ImageType + "_" + versionData.FirmwareVersion + ".ota");
|
| | | HdlFileLogic.Current.SaveTextToFile(saveFile, Encoding.UTF8.GetString(byteData));
|
| | | HdlFileLogic.Current.SaveByteToFile(saveFile, byteData);
|
| | | dicFirmwareName[saveFile] = versionFirmware.Name;
|
| | |
|
| | | //进度值
|
| | |
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | |
|
| | | if (locadevice is LightBase)
|
| | | {
|
| | | //当接收到亮度值时,默认打开
|
| | | ((LightBase)locadevice).OnOffStatus = 1;
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | //温度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Temperatrue = temperatrue;
|
| | | ((TemperatureSensor)locadevice).currentTemperature = temperatrue;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | |
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | //温度值需要保存
|
| | | locadevice.ReSave();
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | //湿度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Humidity = humidity;
|
| | | ((TemperatureSensor)locadevice).currentHumidity = humidity;
|
| | | }
|
| | | //新风的湿度传感器
|
| | | else if (locadevice is HumiditySensor)
|
| | | {
|
| | | ((HumiditySensor)locadevice).Humidity = humidity;
|
| | | ((HumiditySensor)locadevice).currentHumidity = humidity;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | | {
|
| | | ((PMSensor)locadevice).currentHumidity = (int)humidity;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | //湿度值需要保存
|
| | | locadevice.ReSave();
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | newRoom.Id = i_room.Id;
|
| | | newRoom.FloorId = i_room.FloorId;
|
| | | newRoom.TemperatrueDevice = i_room.TemperatrueDevice;
|
| | | newRoom.Temperatrue = i_room.Temperatrue;
|
| | | newRoom.HumidityDevice = i_room.HumidityDevice;
|
| | | newRoom.Humidity = i_room.Humidity;
|
| | | newRoom.Name = i_room.Name;
|
| | | newRoom.BackgroundImage = i_room.BackgroundImage;
|
| | | newRoom.BackgroundImageType = i_room.BackgroundImageType;
|
| | |
| | | //关闭全部弹窗
|
| | | ShowMsgControl.CloseAllMsgDialog();
|
| | | //关闭所有打开了的界面
|
| | | CloseAllOpenForm();
|
| | | CloseAllOpenForm(null, false);
|
| | |
|
| | | //显示登陆画面
|
| | | var formLogin = new Login.AccountLoginForm();
|
| | |
| | | //收起左菜单
|
| | | CommonPage.Instance.CloseLeftMenu();
|
| | | //关闭所有打开了的界面
|
| | | CloseAllOpenForm();
|
| | | CloseAllOpenForm(null, false);
|
| | |
|
| | | //显示登陆画面
|
| | | var formLogin = new Login.AccountLoginForm();
|
| | |
| | | /// 关闭所有打开了的界面
|
| | | /// </summary>
|
| | | /// <param name="tagetFrom">目标界面,如果指定了的话,则关闭目标界面上层的全部界面(它自身不关闭)</param>
|
| | | public static void CloseAllOpenForm(string tagetFrom = null)
|
| | | /// <param name="refreshMainPage">当关闭的界面达到主页时,是否刷新主页</param>
|
| | | public static void CloseAllOpenForm(string tagetFrom = null, bool refreshMainPage = true)
|
| | | {
|
| | | while (UserView.HomePage.Instance.ChildrenCount > 0)
|
| | | {
|
| | |
| | | else if (view is UserView.UserPage)
|
| | | {
|
| | | //刷新主页
|
| | | UserView.UserPage.Instance.ReFreshControl();
|
| | | if (refreshMainPage == true)
|
| | | {
|
| | | UserView.UserPage.Instance.ReFreshControl();
|
| | | }
|
| | | return;
|
| | | }
|
| | | else
|
| | |
| | | /// 列表控件 |
| | | /// </summary> |
| | | private VerticalListControl listView = null; |
| | | /// <summary>
|
| | | /// 当前网关对象
|
| | | /// </summary> |
| | | private ZbGateway zbGateway = null; |
| | | /// <summary>
|
| | | /// mini网关是否能够添加设备
|
| | | /// </summary> |
| | | private bool MiniGatewayCanAddDevice = true; |
| | | |
| | | #endregion |
| | | |
| | |
| | | public void ShowForm() |
| | | { |
| | | //设定标题 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType)); |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType));
|
| | |
|
| | | this.zbGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId); |
| | | if (zbGateway != null && zbGateway.LinuxImageType == 11)
|
| | | {
|
| | | //初始化Mini网关的界面
|
| | | this.InitControlByMiniGateway();
|
| | | } |
| | | else
|
| | | {
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | //2按键触摸面板 |
| | | var objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName1); |
| | | var unSelectPic = "Device/ButtonPanelTwo.png"; |
| | | var arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries); |
| | | objectText = arry[0].Trim(); |
| | | this.AddMenuRow(objectText, unSelectPic, "PanelTwoButtonDirectionForm"); |
| | | |
| | | //3按键触摸面板 |
| | | objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName2); |
| | | arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries); |
| | | objectText = arry[0].Trim(); |
| | | unSelectPic = "Device/ButtonPanelThree.png"; |
| | | this.AddMenuRow(objectText, unSelectPic, "PanelThreeButtonDirectionForm"); |
| | | |
| | | //4按键触摸面板 |
| | | objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName3); |
| | | arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries); |
| | | objectText = arry[0].Trim(); |
| | | unSelectPic = "Device/ButtonPanelFour.png"; |
| | | this.AddMenuRow(objectText, unSelectPic, "PanelFourButtonDirectionForm"); |
| | | |
| | |
| | | unSelectPic = "Device/ThirdPartyDevice.png"; |
| | | var rowThrid = this.AddMenuRow(objectText, unSelectPic, string.Empty, false); |
| | | rowThrid.ButtonClickEvent += (sender, e) => |
| | | { |
| | | {
|
| | | if (this.MiniGatewayCanAddDevice == false)
|
| | | {
|
| | | //Mini网关最大只能添加16个设备
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg));
|
| | | return;
|
| | | } |
| | | var form = new Device.DeviceSearchForm(); |
| | | form.AddForm(string.Empty); |
| | | }; |
| | | |
| | | //调整列表控件的高度 |
| | | listView.AdjustRealHeight(Application.GetRealHeight(23)); |
| | | }
|
| | |
|
| | | #endregion |
| | |
|
| | | #region ■ mini网关___________________________ |
| | | |
| | | /// <summary>
|
| | | /// 初始化Mini网关的界面
|
| | | /// </summary> |
| | | private void InitControlByMiniGateway()
|
| | | {
|
| | | //mini夜灯只能限制加入16和设备
|
| | | this.ShowProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | int statu = 0;
|
| | | //重新获取设备列表
|
| | | var listDevice = Common.LocalDevice.Current.GetDeviceListFromGateway(zbGateway, ref statu, true, ShowErrorMode.NO);
|
| | | this.CloseProgressBar();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (statu != 1)
|
| | | {
|
| | | listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(zbGateway.GwId);
|
| | | }
|
| | | //检测mini网关的设备数
|
| | | this.CheckMiniGatewayDeviceCount(listDevice);
|
| | | //初始化界面
|
| | | this.InitMiddleFrame();
|
| | | });
|
| | | });
|
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 检测mini网关的设备数
|
| | | /// </summary>
|
| | | /// <param name="listDevice"></param> |
| | | private void CheckMiniGatewayDeviceCount(List<CommonDevice> listDevice)
|
| | | {
|
| | | var listMac = new HashSet<string>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | if (listMac.Contains(device.DeviceAddr) == false)
|
| | | {
|
| | | listMac.Add(device.DeviceAddr);
|
| | | }
|
| | | }
|
| | | MiniGatewayCanAddDevice = listMac.Count < 16;
|
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
|
| | | #region ■ 添加菜单栏_________________________ |
| | | |
| | |
|
| | | /// <summary> |
| | | /// 添加菜单栏 |
| | | /// </summary> |
| | |
| | | { |
| | | rowLayout.ButtonClickEvent += (sender, e) => |
| | | { |
| | | if (this.MiniGatewayCanAddDevice == false)
|
| | | {
|
| | | //Mini网关最大只能添加16个设备
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg));
|
| | | return;
|
| | | } |
| | | //反射目标界面 |
| | | this.LoadFormByFullName("Shared.Phone.UserCenter.DeviceDirection." + formName); |
| | | }; |
| | |
| | | //图片
|
| | | var framePic = new FrameLayout();
|
| | | framePic.Width = this.GetPictrueRealSize(395);
|
| | | framePic.Height = this.GetPictrueRealSize(223);
|
| | | framePic.Height = this.GetPictrueRealSize(327);
|
| | | framePic.Gravity = Gravity.CenterHorizontal;
|
| | | framePic.Y = Application.GetRealHeight(464);
|
| | | framePic.Y = Application.GetRealHeight(363);
|
| | | framePic.BackgroundImagePath = "Gateway/MiniGatewayDirection.png";
|
| | | bodyFrameLayout.AddChidren(framePic);
|
| | |
|
| | | //插电后,长按网关HID/WCFG按键5秒{0}系统灯常亮60秒后则进入配网状态
|
| | | //开关键
|
| | | var btnSwitch = new NormalViewControl(this.GetPictrueRealSize(400), this.GetPictrueRealSize(45), false);
|
| | | btnSwitch.X = framePic.X + this.GetPictrueRealSize(60);
|
| | | btnSwitch.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnSwitch.TextSize = 10;
|
| | | btnSwitch.TextID = R.MyInternationalizationString.uSwitchButton;
|
| | | bodyFrameLayout.AddChidren(btnSwitch);
|
| | | btnSwitch.Y = framePic.Y - btnSwitch.Height;
|
| | |
|
| | | //插电后,长按网关开关键5秒{0}系统灯常亮60秒后则进入配网状态
|
| | | string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddMiniGatewayMsg1).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | int yy = framePic.Bottom + Application.GetRealHeight(291);
|
| | | foreach (var msg in ArryMsg)
|
| | |
| | | btnGoback.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //让它退到主页
|
| | | UserCenterLogic.CloseAllOpenForm();
|
| | | UserCenterLogic.CloseAllOpenForm(null, true);
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭所有界面
|
| | | UserCenterLogic.CloseAllOpenForm();
|
| | | UserCenterLogic.CloseAllOpenForm(null, false);
|
| | | //切换到主页
|
| | | UserView.UserPage.Instance.ReFreshControl();
|
| | | });
|
| | |
| | | this.newRoom = new Common.Room();
|
| | | newRoom.FloorId = this.floorKeys;
|
| | | newRoom.BackgroundImage = btnPic.ImagePath;
|
| | | newRoom.Humidity = -1000;
|
| | | newRoom.Temperatrue = -1000;
|
| | |
|
| | | //添加全部菜单
|
| | | this.AddAllMenuRow(tableContr, btnPic);
|
| | |
| | | }
|
| | |
|
| | | newRoom.FloorId = this.floorKeys;
|
| | | if (newRoom.Humidity == -1000)
|
| | | {
|
| | | newRoom.Humidity = 0;
|
| | | }
|
| | | if (newRoom.Temperatrue == -1000)
|
| | | {
|
| | | newRoom.Temperatrue = 0;
|
| | | }
|
| | |
|
| | | //添加房间,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (newRoom.Temperatrue == -1000)
|
| | | {
|
| | | //没有获取得到过温度
|
| | | btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnTemper.Text = this.newRoom.Temperatrue == 0 ? "0.0℃" : this.newRoom.Temperatrue.ToString() + "℃";
|
| | | btnTemper.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | //获取中
|
| | | btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | |
|
| | | bool receiveData = false;
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A设备属性上报, ((report) =>
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
|
| | | if (newRoom.TemperatrueDevice != mainKeys || btnTemper == null)
|
| | | if (newRoom.TemperatrueDevice != mainKeys || btnTemper == null
|
| | | || report.DeviceStatusReport.CluterID != 1026)
|
| | | {
|
| | | return;
|
| | | }
|
| | | receiveData = true;
|
| | |
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | decimal temperatrue = (decimal)device.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, device, null);
|
| | | if (temperatrue == 0)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (data.AttriButeData == 0)
|
| | | {
|
| | | //0℃
|
| | | btnTemper.Text = "0.0℃";
|
| | | this.newRoom.Temperatrue = 0;
|
| | | }
|
| | | else if (data.AttriButeData > 32767)
|
| | | {
|
| | | //负数(特殊处理)
|
| | | string strValue = (data.AttriButeData - 65536).ToString();
|
| | | //小数点需要一位
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | this.newRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | btnTemper.Text = this.newRoom.Temperatrue.ToString() + "℃";
|
| | | }
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = data.AttriButeData.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | this.newRoom.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | btnTemper.Text = this.newRoom.Temperatrue.ToString() + "℃";
|
| | | }
|
| | | });
|
| | | //0
|
| | | btnTemper.Text = "0.0℃";
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | btnTemper.Text = temperatrue + "℃";
|
| | | }
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | |
|
| | | }));
|
| | | //发送获取温度的命令
|
| | | ((ZigBee.Device.TemperatureSensor)device).ReadTemperatureOrHumidity();
|
| | | device.ReadAttri(ZigBee.Device.Cluster_ID.TemperatureMeasurement, ZigBee.Device.AttriButeId.MeasuredValue);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //去获取设备列表的信息
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | var result = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
|
| | | if (result != null)
|
| | | {
|
| | | device.AttributeStatus.Clear();
|
| | | device.AttributeStatus.AddRange(result.AttributeStatus);
|
| | | device.ReSave();
|
| | | }
|
| | | if (receiveData == true)
|
| | | {
|
| | | //已经读取到数据
|
| | | return;
|
| | | }
|
| | |
|
| | | foreach (var data in device.AttributeStatus)
|
| | | {
|
| | | if (data.ClusterId == 1026
|
| | | && data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | {
|
| | | //处理网关返回的温度值
|
| | | decimal temperatrue = 0;
|
| | | this.AdjustTemperatrueValue(data.AttributeData, ref temperatrue);
|
| | |
|
| | | device.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.SetField, null, device, new object[] { temperatrue });
|
| | | device.ReSave();
|
| | |
|
| | | //制作虚假的属性上报
|
| | | var report = new ZigBee.Device.CommonDevice { DeviceAddr = device.DeviceAddr, DeviceEpoint = device.DeviceEpoint };
|
| | | report.DeviceStatusReport.CluterID = 1026;
|
| | | HdlGatewayReceiveLogic.Current.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnTemper.Text = temperatrue == 0 ? "0.0℃" : temperatrue.ToString() + "℃";
|
| | | });
|
| | | break;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 处理网关返回的温度值
|
| | | /// </summary>
|
| | | /// <param name="value">网关返回的属性值</param>
|
| | | /// <param name="temperatrue">转换成的温度值</param>
|
| | | private void AdjustTemperatrueValue(int value, ref decimal temperatrue)
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | //0℃
|
| | | temperatrue = 0;
|
| | | }
|
| | | else if (value > 32767)
|
| | | {
|
| | | //负数(特殊处理)
|
| | | string strValue = (value - 65536).ToString();
|
| | | //小数点需要一位
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = value.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (newRoom.Humidity == -1000)
|
| | | {
|
| | | //没有获取得到过湿度
|
| | | btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnHumi.Text = this.newRoom.Humidity == 0 ? "0.0%" : this.newRoom.Humidity.ToString() + "%";
|
| | | btnHumi.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | //获取中
|
| | | btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | |
|
| | | bool receiveData = false;
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A设备属性上报, (report) =>
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
|
| | | if (newRoom.HumidityDevice != mainKeys || btnHumi == null)
|
| | | if (newRoom.HumidityDevice != mainKeys || btnHumi == null
|
| | | || report.DeviceStatusReport.CluterID != 1029)
|
| | | {
|
| | | return;
|
| | | }
|
| | | foreach (var data in report.DeviceStatusReport.AttriBute)
|
| | | receiveData = true;
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | decimal humidity = (decimal)device.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, device, null);
|
| | | if (humidity == 0)
|
| | | {
|
| | | //0
|
| | | btnHumi.Text = "0.0%";
|
| | | }
|
| | | else
|
| | | {
|
| | | btnHumi.Text = humidity.ToString() + "%";
|
| | | }
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | | });
|
| | | //发送获取湿度的命令
|
| | | device.ReadAttri(ZigBee.Device.Cluster_ID.RelativeHumidityMeasurement, ZigBee.Device.AttriButeId.MeasuredValue);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //去获取设备列表的信息
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | var result = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
|
| | | if (result != null)
|
| | | {
|
| | | device.AttributeStatus.Clear();
|
| | | device.AttributeStatus.AddRange(result.AttributeStatus);
|
| | | device.ReSave();
|
| | | }
|
| | | if (receiveData == true)
|
| | | {
|
| | | //已经读取到数据
|
| | | return;
|
| | | }
|
| | |
|
| | | //初始值,取缓存数据
|
| | | foreach (var data in device.AttributeStatus)
|
| | | {
|
| | | if (data.ClusterId == 1029
|
| | | && data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | {
|
| | | //处理网关返回的湿度值
|
| | | decimal humidity = 0;
|
| | | this.AdjustHumidityValue(data.AttributeData, ref humidity);
|
| | |
|
| | | device.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.SetField, null, device, new object[] { humidity });
|
| | | device.ReSave();
|
| | |
|
| | | //制作虚假的属性上报
|
| | | var report = new ZigBee.Device.CommonDevice { DeviceAddr = device.DeviceAddr, DeviceEpoint = device.DeviceEpoint };
|
| | | report.DeviceStatusReport.CluterID = 1029;
|
| | | HdlGatewayReceiveLogic.Current.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | decimal humidity = (decimal)device.GetType().InvokeMember("Humidity", System.Reflection.BindingFlags.GetField, null, device, null);
|
| | | if (humidity == 0)
|
| | | {
|
| | | //0
|
| | | btnHumi.Text = "0.0%";
|
| | | this.newRoom.Humidity = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //记录湿度
|
| | | this.newRoom.Humidity = humidity;
|
| | | btnHumi.Text = this.newRoom.Humidity.ToString() + "%";
|
| | | }
|
| | | btnHumi.Text = humidity == 0 ? "0.0%" : humidity.ToString() + "%";
|
| | | });
|
| | | break;
|
| | | }
|
| | | }
|
| | | });
|
| | | //发送获取湿度的命令
|
| | | device.GetType().InvokeMember("ReadTemperatureOrHumidity", System.Reflection.BindingFlags.InvokeMethod, null, device, null);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 处理网关返回的湿度值
|
| | | /// </summary>
|
| | | /// <param name="value">网关返回的属性值</param>
|
| | | /// <param name="temperatrue">转换成的湿度值</param>
|
| | | /// <param name="valueText">转换成的湿度值的翻译文本</param>
|
| | | private void AdjustHumidityValue(int value, ref decimal humidity)
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | //0%
|
| | | humidity = 0;
|
| | | }
|
| | | //不会出现负数
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = value.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //弄一点初始值
|
| | | this.editorRoom = i_editorRoom;
|
| | | this.cloneRoom = HdlRoomLogic.Current.CloneRoomClass(i_editorRoom);
|
| | | if (i_editorRoom.HumidityDevice == string.Empty)
|
| | | {
|
| | | this.cloneRoom.Humidity = -1000;
|
| | | }
|
| | | if (i_editorRoom.TemperatrueDevice == string.Empty)
|
| | | {
|
| | | this.cloneRoom.Temperatrue = -1000;
|
| | | }
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorRoom));
|
| | |
| | | editorRoom.FloorId = cloneRoom.FloorId;
|
| | | editorRoom.Name = cloneRoom.Name;
|
| | | editorRoom.HumidityDevice = cloneRoom.HumidityDevice;
|
| | | if (cloneRoom.Humidity != -1000)
|
| | | {
|
| | | editorRoom.Humidity = cloneRoom.Humidity;
|
| | | }
|
| | | editorRoom.TemperatrueDevice = cloneRoom.TemperatrueDevice;
|
| | | if (cloneRoom.Temperatrue != -1000)
|
| | | {
|
| | | editorRoom.Temperatrue = cloneRoom.Temperatrue;
|
| | | }
|
| | | editorRoom.BackgroundImage = cloneRoom.BackgroundImage;
|
| | | editorRoom.BackgroundImageType = cloneRoom.BackgroundImageType;
|
| | | editorRoom.Save();
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (cloneRoom.Temperatrue == -1000)
|
| | | {
|
| | | //没有获取得到过温度
|
| | | btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnTemper.Text = this.cloneRoom.Temperatrue == 0 ? "0.0℃" : this.cloneRoom.Temperatrue.ToString() + "℃";
|
| | | btnTemper.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | //获取中
|
| | | btnTemper.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | |
|
| | | bool receiveData = false;
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A设备属性上报, ((report) =>
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
|
| | | if (cloneRoom.TemperatrueDevice != mainKeys || btnTemper == null)
|
| | | if (cloneRoom.TemperatrueDevice != mainKeys || btnTemper == null
|
| | | || report.DeviceStatusReport.CluterID != 1026)
|
| | | {
|
| | | return;
|
| | | }
|
| | | receiveData = true;
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainKeys);
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (((ZigBee.Device.TemperatureSensor)localDevice).Temperatrue == 0)
|
| | | decimal temperatrue = (decimal)device.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, device, null);
|
| | | if (temperatrue == 0)
|
| | | {
|
| | | //0℃
|
| | | //0
|
| | | btnTemper.Text = "0.0℃";
|
| | | this.cloneRoom.Temperatrue = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //记录温度
|
| | | this.cloneRoom.Temperatrue = ((ZigBee.Device.TemperatureSensor)localDevice).Temperatrue;
|
| | | btnTemper.Text = this.cloneRoom.Temperatrue.ToString() + "℃";
|
| | | btnTemper.Text = temperatrue + "℃";
|
| | | }
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | | }));
|
| | | //发送获取温度的命令
|
| | | ((ZigBee.Device.TemperatureSensor)device).ReadTemperatureOrHumidity();
|
| | | device.ReadAttri(ZigBee.Device.Cluster_ID.TemperatureMeasurement, ZigBee.Device.AttriButeId.MeasuredValue);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //去获取设备列表的信息
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | var result = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
|
| | | if (result != null)
|
| | | {
|
| | | device.AttributeStatus.Clear();
|
| | | device.AttributeStatus.AddRange(result.AttributeStatus);
|
| | | device.ReSave();
|
| | | }
|
| | | if (receiveData == true)
|
| | | {
|
| | | //已经读取到数据
|
| | | return;
|
| | | }
|
| | |
|
| | | foreach (var data in device.AttributeStatus)
|
| | | {
|
| | | if (data.ClusterId == 1026
|
| | | && data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | {
|
| | | //处理网关返回的温度值
|
| | | decimal temperatrue = 0;
|
| | | this.AdjustTemperatrueValue(data.AttributeData, ref temperatrue);
|
| | |
|
| | | device.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.SetField, null, device, new object[] { temperatrue });
|
| | | device.ReSave();
|
| | |
|
| | | //制作虚假的属性上报
|
| | | var report = new ZigBee.Device.CommonDevice { DeviceAddr = device.DeviceAddr, DeviceEpoint = device.DeviceEpoint };
|
| | | report.DeviceStatusReport.CluterID = 1026;
|
| | | HdlGatewayReceiveLogic.Current.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnTemper.Text = temperatrue == 0 ? "0.0℃" : temperatrue.ToString() + "℃";
|
| | | });
|
| | | break;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 处理网关返回的温度值
|
| | | /// </summary>
|
| | | /// <param name="value">网关返回的属性值</param>
|
| | | /// <param name="temperatrue">转换成的温度值</param>
|
| | | private void AdjustTemperatrueValue(int value, ref decimal temperatrue)
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | //0℃
|
| | | temperatrue = 0;
|
| | | }
|
| | | else if (value > 32767)
|
| | | {
|
| | | //负数(特殊处理)
|
| | | string strValue = (value - 65536).ToString();
|
| | | //小数点需要一位
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = value.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | if (cloneRoom.Humidity == -1000)
|
| | | {
|
| | | //没有获取得到过湿度
|
| | | btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnHumi.Text = this.cloneRoom.Humidity == 0 ? "0.0%" : this.cloneRoom.Humidity.ToString() + "%";
|
| | | btnHumi.Text += " " + Language.StringByID(R.MyInternationalizationString.Getting);
|
| | | }
|
| | | //获取中
|
| | | btnHumi.Text = Language.StringByID(R.MyInternationalizationString.Getting);
|
| | |
|
| | | bool receiveData = false;
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A设备属性上报, (report) =>
|
| | | {
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
|
| | | if (cloneRoom.HumidityDevice != mainKeys || btnHumi == null)
|
| | | if (cloneRoom.HumidityDevice != mainKeys || btnHumi == null
|
| | | || report.DeviceStatusReport.CluterID != 1029)
|
| | | {
|
| | | return;
|
| | | }
|
| | | receiveData = true;
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainKeys);
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | decimal humidity = (decimal)localDevice.GetType().InvokeMember("Humidity", System.Reflection.BindingFlags.GetField, null, localDevice, null);
|
| | | decimal humidity = (decimal)localDevice.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, localDevice, null);
|
| | | if (humidity == 0)
|
| | | {
|
| | | //0
|
| | | btnHumi.Text = "0.0%";
|
| | | this.cloneRoom.Humidity = 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | //记录湿度
|
| | | this.cloneRoom.Humidity = humidity;
|
| | | btnHumi.Text = this.cloneRoom.Humidity.ToString() + "%";
|
| | | btnHumi.Text = humidity.ToString() + "%";
|
| | | }
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | | });
|
| | | //发送获取湿度的命令
|
| | | device.GetType().InvokeMember("ReadTemperatureOrHumidity", System.Reflection.BindingFlags.InvokeMethod, null, device, null);
|
| | | device.ReadAttri(ZigBee.Device.Cluster_ID.RelativeHumidityMeasurement, ZigBee.Device.AttriButeId.MeasuredValue);
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //去获取设备列表的信息
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | var result = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
|
| | | if (result != null)
|
| | | {
|
| | | device.AttributeStatus.Clear();
|
| | | device.AttributeStatus.AddRange(result.AttributeStatus);
|
| | | device.ReSave();
|
| | | }
|
| | | if (receiveData == true)
|
| | | {
|
| | | //已经读到数据
|
| | | return;
|
| | | }
|
| | |
|
| | | //初始值,取缓存数据
|
| | | foreach (var data in device.AttributeStatus)
|
| | | {
|
| | | if (data.ClusterId == 1029
|
| | | && data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
|
| | | {
|
| | | //处理网关返回的湿度值
|
| | | decimal humidity = 0;
|
| | | this.AdjustHumidityValue(data.AttributeData, ref humidity);
|
| | |
|
| | | device.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.SetField, null, device, new object[] { humidity });
|
| | | device.ReSave();
|
| | |
|
| | | //制作虚假的属性上报
|
| | | var report = new ZigBee.Device.CommonDevice { DeviceAddr = device.DeviceAddr, DeviceEpoint = device.DeviceEpoint };
|
| | | report.DeviceStatusReport.CluterID = 1029;
|
| | | HdlGatewayReceiveLogic.Current.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnHumi.Text = humidity == 0 ? "0.0%" : humidity.ToString() + "%";
|
| | | });
|
| | | break;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 处理网关返回的湿度值
|
| | | /// </summary>
|
| | | /// <param name="value">网关返回的属性值</param>
|
| | | /// <param name="temperatrue">转换成的湿度值</param>
|
| | | /// <param name="valueText">转换成的湿度值的翻译文本</param>
|
| | | private void AdjustHumidityValue(int value, ref decimal humidity)
|
| | | {
|
| | | if (value == 0)
|
| | | {
|
| | | //0%
|
| | | humidity = 0;
|
| | | }
|
| | | //不会出现负数
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = value.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | //记录温度
|
| | | humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | public void ShowCategoryAutoListForm() |
| | | { |
| | | //关闭全部界面,直到主页为止 |
| | | UserCenterLogic.CloseAllOpenForm(); |
| | | UserCenterLogic.CloseAllOpenForm(null, false); |
| | | //强制显示自动化列表界面 |
| | | UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 2;
|
| | |
|
| | |
| | | //最后再断开mqtt连接 |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | list[i].DisConnectLocalMqttClient("1"); |
| | | list[i]?.DisConnectLocalMqttClient("1"); |
| | | } |
| | | list.Clear(); |
| | | oldHomeID = Shared.Common.Config.Instance.HomeId; |
| | |
| | | /// <summary> |
| | | /// 输出簇列表 |
| | | /// </summary> |
| | | public List<OutClusterObj> OutClusterList = new List<OutClusterObj>(); |
| | | public List<OutClusterObj> OutClusterList = new List<OutClusterObj>();
|
| | | /// <summary> |
| | | /// 用于记录设备最新上报的属性状态信息 |
| | | /// </summary> |
| | | public List<AttributeStatusObj> AttributeStatus = new List<AttributeStatusObj>(); |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public DateTime LastDateTime = DateTime.MinValue; |
| | |
| | | /// </summary> |
| | | public int AttributeId; |
| | | /// <summary> |
| | | /// 属性值,最大占用4个字节 |
| | | /// 属性值,这个东西不需要什么高位在后低位在前,它已经是转为了10进制 |
| | | /// </summary> |
| | | public int AttributeData; |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// 湿度 |
| | | /// </summary> |
| | | public decimal Humidity; |
| | | public decimal currentHumidity; |
| | |
|
| | | /// <summary> |
| | | /// 读取温/湿度 |
| | |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 当前温度 |
| | | /// 当前温度 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int currentTemperature = 0;
|
| | | /// <summary> |
| | | /// 当前湿度 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int currentHumidity = 0;
|
| | | /// <summary> |
| | | /// 当前PM2.5值 |
| | |
| | | /// <summary> |
| | | /// 温度 |
| | | /// </summary> |
| | | public decimal Temperatrue; |
| | | public decimal currentTemperature = 0; |
| | | /// <summary> |
| | | /// 湿度 |
| | | /// </summary> |
| | | public decimal Humidity; |
| | | public decimal currentHumidity = 0; |
| | | |
| | | public TemperatureSensor() |
| | | { |
| | |
| | | /// </summary> |
| | | public const int uAddMiniGateway = 16124;
|
| | | /// <summary>
|
| | | /// 插电后,长按网关HID/WCFG按键5秒{0}系统灯常亮60秒后则进入配网状态
|
| | | /// 插电后,长按网关开关键5秒{0}系统灯常亮60秒后则进入配网状态
|
| | | /// </summary>
|
| | | public const int uAddMiniGatewayMsg1 = 16125;
|
| | | /// <summary>
|
| | |
| | | /// 长按此按键
|
| | | /// </summary>
|
| | | public const int uLongPressThisButton = 16145;
|
| | | /// <summary>
|
| | | /// Mini网关最大只能添加16个设备
|
| | | /// </summary>
|
| | | public const int uMiniGatewayMaxDeviceCountMsg = 16146;
|
| | | /// <summary>
|
| | | /// 开关键
|
| | | /// </summary>
|
| | | public const int uSwitchButton = 16147;
|
| | |
|
| | |
|
| | | //★★★★下面这些是接口的返回信息翻译,从18000开始★★★★
|