From 9b5399d3dd4299563821af0a7131f9a52402feea Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 11 九月 2020 17:42:19 +0800 Subject: [PATCH] 20209112 --- HDL_ON/DriverLayer/CommonPage.cs | 18 +--- HDL_ON/UI/UI2/FuntionControlView/Curtain/MotorCurtainPage.cs | 2 HDL_ON/Entity/Function/Light.cs | 58 ++++++++++++++ HDL_ON/UI/UI2/FuntionControlView/Curtain/RollingShutterPage.cs | 2 HDL_ON/DriverLayer/Control.cs | 64 ++------------- HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs | 20 ++++ .vs/HDL_APP_Project/xs/UserPrefs.xml | 53 +++++++++---- HDL_ON/UI/UI2/FuntionControlView/Curtain/CurtainModulePage.cs | 2 HDL_ON/Entity/FunctionList.cs | 2 HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs | 12 ++- 10 files changed, 140 insertions(+), 93 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index e21e2d9..5495675 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,26 +1,45 @@ -锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> - <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.61286FD1-B849-4457-AA51-F3CD79A395F6" /> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/FunctionList.cs"> +锘�<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default"> + <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.6242be7109c740c6cb8999a8904b6e0ea8d45192" /> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/Function/Light.cs"> <Files> - <File FileName="HDL_ON/DriverLayer/CommonPage.cs" Line="169" Column="67" /> - <File FileName="HDL_ON/Entity/Function/Light.cs" Line="91" Column="14" /> - <File FileName="HDL_ON/Entity/Function/AC.cs" Line="303" Column="17" /> - <File FileName="HDL_ON/Entity/Function/Curtain.cs" Line="26" Column="27" /> - <File FileName="HDL_ON/DAL/Net/TcpListener.cs" Line="215" Column="53" /> - <File FileName="HDL_ON/UI/UI0-Public/UpdataTcpResidenceDataDialog.cs" Line="47" Column="64" /> - <File FileName="HDL_ON/Entity/FunctionList.cs" Line="172" Column="44" /> + <File FileName="HDL_ON/DriverLayer/Control_Bus.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/DriverLayer/CommonPage.cs" /> + <File FileName="HDL_ON/DriverLayer/Control.cs" Line="267" Column="56" /> + <File FileName="HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs" /> + <File FileName="HDL_ON/UI/UI2/2-Classification/FunctionPage.cs" /> + <File FileName="HDL_ON/Entity/DB_ResidenceData.cs" /> + <File FileName="HDL_ON/Entity/FunctionList.cs" /> + <File FileName="HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs" Line="41" Column="9" /> + <File FileName="HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs" Line="64" Column="32" /> + <File FileName="HDL_ON/Entity/Function/Light.cs" Line="79" Column="10" /> </Files> <Pads> <Pad Id="ProjectPad"> <State name="__root__"> <Node name="HDL_APP_Project" expanded="True"> - <Node name="HDL-ON_Android" selected="True" /> + <Node name="HDL_ON" expanded="True"> + <Node name="DAL" expanded="True"> + <Node name="Net" expanded="True" /> + </Node> + <Node name="DriverLayer" expanded="True" /> + <Node name="Entity" expanded="True"> + <Node name="Function" expanded="True"> + <Node name="Light.cs" selected="True" /> + </Node> + </Node> + <Node name="UI" expanded="True"> + <Node name="UI0-Public" expanded="True" /> + <Node name="UI2" expanded="True"> + <Node name="2-Classification" expanded="True" /> + <Node name="3-Intelligence" expanded="True" /> + <Node name="FuntionControlView" expanded="True"> + <Node name="Curtain" expanded="True" /> + <Node name="Light" expanded="True" /> + </Node> + </Node> + </Node> + </Node> </Node> - </State> - </Pad> - <Pad Id="MonoDevelop.Debugger.WatchPad"> - <State> - <Value>function.function</Value> </State> </Pad> </Pads> @@ -31,7 +50,7 @@ <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String> <String>Shared.IOS/Shared.IOS.csproj</String> </DisabledProjects> - <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|iPhone" /> + <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" /> <MonoDevelop.Ide.ItemProperties.HDL-ON__Android AndroidDesignerPreferredTheme="AppTheme" AndroidDesignerPreferredDevice="Nexus 4" PreferredExecutionTarget="Android.SelectDevice" /> <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore> diff --git a/HDL_ON/DriverLayer/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs index 92167dd..f366770 100644 --- a/HDL_ON/DriverLayer/CommonPage.cs +++ b/HDL_ON/DriverLayer/CommonPage.cs @@ -65,15 +65,10 @@ return BitConverter.ToSingle(byteTemp, 0); } - static void Packet_ReceiveEvent(byte subnetID, byte deviceID, Command command, byte[] receiveBytes, string revGatewayIP) { try { - if(revGatewayIP == "172.16.2.237") - { - - } Control.controlLostCount = 0; switch (command) @@ -88,12 +83,6 @@ { if (updataObj.functionType != FunctionType.RGB) { - var newState = receiveBytes[2] == 0 ? "off" : "on"; - if (updataObj.trait_on_off.value.ToString() == newState) - { - //鐘舵�佷竴鏍凤紝涓嶇敤鍐嶅埛鏂伴〉闈� - break; - } if (updataObj.trait_on_off.value.ToString() == "on") { if (updataObj.functionType == FunctionType.Fan) @@ -255,12 +244,17 @@ FunctionPage.UpdataStates(curtain); HomePage.UpdataFunctionStates(curtain); ClassificationPage.UpdataInfo(curtain); - RollingShutterPage.UpdataState(curtain); switch (curtain.functionType) { case FunctionType.Curtain: CurtainModulePage.UpdataState(curtain); break; + case FunctionType.MotorCurtain: + MotorCurtainPage.UpdataState(curtain); + break; + case FunctionType.RollingShutter: + RollingShutterPage.UpdataState(curtain); + break; } } } diff --git a/HDL_ON/DriverLayer/Control.cs b/HDL_ON/DriverLayer/Control.cs index ed96608..f27acb1 100644 --- a/HDL_ON/DriverLayer/Control.cs +++ b/HDL_ON/DriverLayer/Control.cs @@ -3,6 +3,7 @@ using HDL_ON.DAL; using HDL_ON.DAL.Net; using HDL_ON.Entity; +using HDL_ON.UI; namespace HDL_ON { @@ -13,7 +14,7 @@ /// </summary> public static void Send(Function function) { - switch(function.functionCategory) + switch (function.functionCategory) { case FunctionCategory.Scene: ControlScene(function as Scene); @@ -114,7 +115,7 @@ { curtainState = 1; } - else if (function.trait_on_off.value.ToString() =="off") + else if (function.trait_on_off.value.ToString() == "off") { curtainState = 2; } @@ -154,7 +155,7 @@ case FunctionType.Relay: case FunctionType.Dimmer: byte brightness = 0; - if(function.trait_on_off.value.ToString() == "on") + if (function.trait_on_off.value.ToString() == "on") { var brightnessTrait = function.function.Find((obj) => obj.name == "brightness"); if (brightnessTrait != null) @@ -257,7 +258,7 @@ ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus_Data.LoopID, b1, - 0, 0 }); + 0, Convert.ToByte(light.fadeTime) }); break; case FunctionType.Relay: ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus_Data.LoopID, light.trait_on_off.value.ToString() == "on" ? (byte)100 : (byte)0, 0, 0 }); @@ -393,55 +394,12 @@ } break; } - - - foreach (var dic in commandDictionary) - { - switch (dic.Key) - { - case "on_off": - break; - case "brightness": - break; - case "color": - break; - default: - MainPage.Log($"鍔熻兘鏈敮鎸� : {dic.Key}"); - break; - //case "cct": - //case "delay": - //case "fade_time": - //case "open_level": - //case "lock": - //case "ico": - //case "mode": - //case "fan": - //case "temp": - //case "swing": - //case "set_ point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": - } - } - - - + #region 鍙戦�佸懡浠ょ珛鍗虫洿鏂癠I + HomePage.UpdataFunctionStates(function); + RoomPage.UpdataStates(function); + FunctionPage.UpdataStates(function); + ClassificationPage.UpdataInfo(function); + #endregion } catch (Exception ex) { diff --git a/HDL_ON/Entity/Function/Light.cs b/HDL_ON/Entity/Function/Light.cs index 170e572..0a95c65 100644 --- a/HDL_ON/Entity/Function/Light.cs +++ b/HDL_ON/Entity/Function/Light.cs @@ -79,6 +79,64 @@ } [Newtonsoft.Json.JsonIgnore] + Trait trait_fadeTime; + /// <summary> + /// 浜害鍊� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int fadeTime + { + get + { + if (trait_fadeTime == null) + { + trait_fadeTime = function.Find((obj) => obj.name == "fade_time"); + //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� + if (trait_fadeTime == null) + { + trait_fadeTime = new Trait() + { + name = "fade_time", + value_key = new List<string> { "up", "down" }, + max = 10, + min = 0, + }; + trait_fadeTime.value = 0; + function.Add(trait_fadeTime); + } + } + return Convert.ToInt32(trait_fadeTime.value); + } + set + { + try + { + if (trait_fadeTime == null) + { + trait_fadeTime = function.Find((obj) => obj.name == "fade_time"); + //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� + if (trait_fadeTime == null) + { + trait_fadeTime = new Trait() + { + name = "fade_time", + value_key = new List<string> { "up", "down" }, + max = 100, + min = 0, + }; + trait_fadeTime.value = 0; + function.Add(trait_fadeTime); + } + } + trait_fadeTime.value = value; + } + catch + { + } + } + } + + [Newtonsoft.Json.JsonIgnore] public Trait trait_color; /// <summary> /// RGB棰滆壊 diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs index 74a3890..55e8a52 100644 --- a/HDL_ON/Entity/FunctionList.cs +++ b/HDL_ON/Entity/FunctionList.cs @@ -102,7 +102,7 @@ /// </summary> public List<Function> GetAllDeviceFunctionList() { - if (deviceFunctionList == null) + if (deviceFunctionList == null|| deviceFunctionList.Count == 0) { deviceFunctionList = new List<Function>(); deviceFunctionList.AddRange(aCs); diff --git a/HDL_ON/UI/UI2/FuntionControlView/Curtain/CurtainModulePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Curtain/CurtainModulePage.cs index 7af1bfe..5e0f2d3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Curtain/CurtainModulePage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Curtain/CurtainModulePage.cs @@ -155,7 +155,7 @@ controlView.AddChidren(btnCurtainOpen); LoadEventList(); - new TopViewDiv(bodyView, Language.StringByID(StringId.LocationManagement)).LoadTopView(curtain, actionRefresh); + new TopViewDiv(bodyView,curtain.name).LoadTopView(curtain, actionRefresh); } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Curtain/MotorCurtainPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Curtain/MotorCurtainPage.cs index a1a1b0c..dca2d52 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Curtain/MotorCurtainPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Curtain/MotorCurtainPage.cs @@ -206,7 +206,7 @@ controlView.AddChidren(btnCurtainOpen); LoadEventList(); - new TopViewDiv(bodyView, Language.StringByID(StringId.LocationManagement)).LoadTopView(curtain,actionRefresh); + new TopViewDiv(bodyView, curtain.name).LoadTopView(curtain,actionRefresh); } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Curtain/RollingShutterPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Curtain/RollingShutterPage.cs index 370fbbc..893a5ca 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Curtain/RollingShutterPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Curtain/RollingShutterPage.cs @@ -206,7 +206,7 @@ controlView.AddChidren(btnCurtainOpen); LoadEventList(); - new TopViewDiv(bodyView, Language.StringByID(StringId.LocationManagement)).LoadTopView(curtain, actionRefresh); + new TopViewDiv(bodyView, curtain.name).LoadTopView(curtain, actionRefresh); } } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs index f7cc34d..c9b2eaf 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs @@ -35,6 +35,10 @@ /// </summary> Button btnBrightnessText; /// <summary> + /// 娓愬彉鏃堕棿淇敼 + /// </summary> + DiyImageSeekBar barFadeTime; + /// <summary> /// 寮�鍏虫寜閽� /// </summary> Button btnSwitch; @@ -189,7 +193,7 @@ }; controlView.AddChidren(btnGradualChangeMinValuesText); - var barGradualChange = new DiyImageSeekBar() + barFadeTime = new DiyImageSeekBar() { X = btnGradualChangeMinValuesText.Right, Y = Application.GetRealHeight(412 - 21) + Application.GetRealHeight(8), @@ -203,14 +207,14 @@ ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel, ProgressBarUnitSring = "s", MaxValue = 10, - Progress = 0, + Progress = light.fadeTime, SeekBarPadding = Application.GetRealWidth(20), }; - controlView.AddChidren(barGradualChange); + controlView.AddChidren(barFadeTime); var btnGradualChangeMaxValuesText = new Button() { - X = barGradualChange.Right, + X = barFadeTime.Right, Y = btnGradualChangeText.Bottom + Application.GetRealHeight(8), Width = Application.GetRealWidth(35), Height = Application.GetRealHeight(21), diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs index cc4fdb0..5ba2ea3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs @@ -32,8 +32,10 @@ { bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); } - //bodyView.dimmerBar.WaveColor = uFunction.on_off == "on" ? CSS.CSS_Color.AuxiliaryColor1 : CSS.CSS_Color.PromptingColor2; bodyView.btnSwitch.IsSelected = uFunction.trait_on_off.value.ToString() == "on"; + + bodyView.btnBrightnessText.Y = ((100 - uFunction.brightness) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40); + bodyView.btnBrightnessText.Text = uFunction.brightness + "%"; } } catch (Exception ex) @@ -48,10 +50,22 @@ LoadSwitchEvent(); LoadCollectionEvent(); LoadEvent_DimmerBar(); + LoadEvet_ChangeFadeTime(); //鍥為��鍒锋柊淇℃伅浜嬩欢 actionRefresh = () => { btnFunctionName.Text = btnFunctionName_Out.Text = light.name; btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = light.GetRoomListName(); + }; + } + /// <summary> + /// 淇敼鐏厜娓愬彉鏃堕棿 + /// </summary> + void LoadEvet_ChangeFadeTime() + { + barFadeTime.OnProgressChangedEvent = (sender, e) => + { + light.fadeTime = e; + light.SaveFunctionData(); }; } @@ -83,6 +97,7 @@ Control.SendWriteCommand(light, d); }; dimmerBar.OnProgressChangedEvent = (sender, e) => { + light.fadeTime = 0; if (!btnSwitch.IsSelected) { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); @@ -113,8 +128,6 @@ } } - MainPage.Log( dimmerBar.NowProgressY.ToString()); - //btnBrightnessText.Y = dimmerBar.NowProgressY + Application.GetRealWidth(40); btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(288 - 16 - 16) / 100) + Application.GetRealWidth(40); btnBrightnessText.Text = light.brightness + "%"; }; @@ -127,6 +140,7 @@ { btnSwitch.MouseUpEventHandler += (sender, e) => { + light.fadeTime = barFadeTime.Progress; btnSwitch.IsSelected = !btnSwitch.IsSelected; if (btnSwitch.IsSelected) { -- Gitblit v1.8.0