From 51f5f7a47d394163dccf2441cd04c2a19ceeda34 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 08 一月 2024 09:41:59 +0800 Subject: [PATCH] Merge branch 'Dev-Google-V2.4.3' into Google-2023-11-17-1 --- HDL_ON/DAL/DriverLayer/UdpSocket.cs | 349 +++++++------- HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs | 139 ++++- HDL-ON_iOS/HDL-ON_iOS.csproj | 2 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs | 17 HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalPage.cs | 15 HDL_ON/Common/ApiUtlis.cs | 2 HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png | 0 HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png | 0 HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_on.png | 0 HDL_ON/Entity/Function/Sensor.cs | 12 HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs | 2 HDL-ON_Android/HDL-ON_Android.csproj | 5 HDL-ON_iOS/Info.plist | 4 HDL_ON/DAL/DriverLayer/AsyncUdpServer.cs | 453 +++++++++++++++++++ HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs | 86 ++ HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPage.cs | 11 HDL_ON/DAL/DriverLayer/Packet.cs | 64 +- HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png | 0 HDL_ON/DAL/DriverLayer/Control.cs | 1 HDL_ON/UI/MainPage.cs | 2 HDL_ON/UI/UI1-Login/LoginPage.cs | 9 HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_on.png | 0 HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs | 2 HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs | 52 ++ HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_off.png | 0 HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs | 27 + HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs | 66 ++ HDL_ON/Entity/Function/Function.cs | 3 HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png | 0 HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_off.png | 0 HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs | 2 HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs | 33 + HDL_ON/DAL/Server/HttpServerRequest.cs | 6 33 files changed, 1,054 insertions(+), 310 deletions(-) diff --git a/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png b/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png new file mode 100644 index 0000000..50c019c --- /dev/null +++ b/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png Binary files differ diff --git a/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png b/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png new file mode 100644 index 0000000..c4b3c8b --- /dev/null +++ b/HDL-ON_Android/Assets/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png Binary files differ diff --git a/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_off.png b/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_off.png index 55fe174..4dd5fff 100644 --- a/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_off.png +++ b/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_off.png Binary files differ diff --git a/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_on.png b/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_on.png index 4dd5fff..55fe174 100644 --- a/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_on.png +++ b/HDL-ON_Android/Assets/Phone/FunctionIcon/Light/LightScene/gp_all_on.png Binary files differ diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj index 964aa91..bf61895 100644 --- a/HDL-ON_Android/HDL-ON_Android.csproj +++ b/HDL-ON_Android/HDL-ON_Android.csproj @@ -175,6 +175,9 @@ <Reference Include="Shared.Droid"> <HintPath>..\DLL\Android\Shared.Droid.dll</HintPath> </Reference> + <Reference Include="HdlEzvizDroid"> + <HintPath>..\..\..\HdlEzvizDroid.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> @@ -597,6 +600,8 @@ <AndroidAsset Include="Assets\Phone\FunctionIcon\Light\LightScene\gp_all_on_home.png" /> <AndroidAsset Include="Assets\Phone\FunctionIcon\Light\LightScene\gp_all_on.png" /> <AndroidAsset Include="Assets\Phone\LogicIcon\electricaltvhisense.png" /> + <AndroidAsset Include="Assets\Phone\FunctionIcon\EnvirSensor\Pm10Icon.png" /> + <AndroidAsset Include="Assets\Phone\FunctionIcon\EnvirSensor\Pm10Bg.png" /> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\values\colors.xml" /> diff --git a/HDL-ON_iOS/HDL-ON_iOS.csproj b/HDL-ON_iOS/HDL-ON_iOS.csproj index bb57d01..a7c966e 100644 --- a/HDL-ON_iOS/HDL-ON_iOS.csproj +++ b/HDL-ON_iOS/HDL-ON_iOS.csproj @@ -1778,6 +1778,8 @@ <BundleResource Include="Resources\Phone\FunctionIcon\Light\LightScene\gp_all_on_home.png" /> <BundleResource Include="Resources\Phone\FunctionIcon\Light\LightScene\gp_all_on.png" /> <BundleResource Include="Resources\Phone\LogicIcon\electricaltvhisense.png" /> + <BundleResource Include="Resources\Phone\FunctionIcon\EnvirSensor\Pm10Bg.png" /> + <BundleResource Include="Resources\Phone\FunctionIcon\EnvirSensor\Pm10Icon.png" /> </ItemGroup> <ItemGroup> <ITunesArtwork Include="iTunesArtwork" /> diff --git a/HDL-ON_iOS/Info.plist b/HDL-ON_iOS/Info.plist index efc71dc..d8aee60 100644 --- a/HDL-ON_iOS/Info.plist +++ b/HDL-ON_iOS/Info.plist @@ -11,7 +11,7 @@ <key>CFBundleName</key> <string>On Pro</string> <key>CFBundleShortVersionString</key> - <string>2.4.2</string> + <string>2.4.3</string> <key>CFBundleURLTypes</key> <array> <dict> @@ -36,7 +36,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>2.4.2</string> + <string>2.4.3</string> <key>LSApplicationQueriesSchemes</key> <array> <string>weixinULAPI</string> diff --git a/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png b/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png new file mode 100644 index 0000000..50c019c --- /dev/null +++ b/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Bg.png Binary files differ diff --git a/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png b/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png new file mode 100644 index 0000000..c4b3c8b --- /dev/null +++ b/HDL-ON_iOS/Resources/Phone/FunctionIcon/EnvirSensor/Pm10Icon.png Binary files differ diff --git a/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_off.png b/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_off.png index 55fe174..4dd5fff 100644 --- a/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_off.png +++ b/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_off.png Binary files differ diff --git a/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_on.png b/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_on.png index 4dd5fff..55fe174 100644 --- a/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_on.png +++ b/HDL-ON_iOS/Resources/Phone/FunctionIcon/Light/LightScene/gp_all_on.png Binary files differ diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index cb434bc..86bdfdc 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -536,7 +536,7 @@ //======================瀹夐槻==================== GetSecurityList(); - //===================璇诲彇閫昏緫鍒楄〃========================== + //===================璇诲彇閫昏緫鍒楄〃==================== Logic.LogicList.Clear();//涓婚〉涓嬫媺寮哄埗鍒锋柊鑷姩鍖栧垪琛� MainView.GetLogicList();//璇诲彇鑷姩鍖栧垪琛� }) diff --git a/HDL_ON/DAL/DriverLayer/AsyncUdpServer.cs b/HDL_ON/DAL/DriverLayer/AsyncUdpServer.cs new file mode 100644 index 0000000..097344b --- /dev/null +++ b/HDL_ON/DAL/DriverLayer/AsyncUdpServer.cs @@ -0,0 +1,453 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace HDL_ON.DAL.DriverLayer +{ + //class AsyncUdpServer + /// <summary> + /// UdpClient 瀹炵幇寮傛UDP鏈嶅姟鍣� + /// </summary> + public class AsyncUdpServer + { + #region Fields + /// <summary> + /// 鏈嶅姟鍣ㄧ▼搴忓厑璁哥殑鏈�澶у鎴风杩炴帴鏁� + /// </summary> + private int _maxClient; + + /// <summary> + /// 褰撳墠鐨勮繛鎺ョ殑瀹㈡埛绔暟 + /// </summary> + //private int _clientCount; + + /// <summary> + /// 鏈嶅姟鍣ㄤ娇鐢ㄧ殑寮傛UdpClient + /// </summary> + private UdpClient _server; + + /// <summary> + /// 瀹㈡埛绔細璇濆垪琛� + /// </summary> + //private List<AsyncUDPState> _clients; + + private bool disposed = false; + + /// <summary> + /// 鏁版嵁鎺ュ彈缂撳啿鍖� + /// </summary> + private byte[] _recvBuffer; + + #endregion + + #region Properties + + /// <summary> + /// 鏈嶅姟鍣ㄦ槸鍚︽鍦ㄨ繍琛� + /// </summary> + public bool IsRunning { get; private set; } + /// <summary> + /// 鐩戝惉鐨処P鍦板潃 + /// </summary> + public IPAddress Address { get; private set; } + /// <summary> + /// 鐩戝惉鐨勭鍙� + /// </summary> + public int Port { get; private set; } + /// <summary> + /// 閫氫俊浣跨敤鐨勭紪鐮� + /// </summary> + public Encoding Encoding { get; set; } + + #endregion + + #region 鏋勯�犲嚱鏁� + + /// <summary> + /// 寮傛UdpClient UDP鏈嶅姟鍣� + /// </summary> + /// <param name="listenPort">鐩戝惉鐨勭鍙�</param> + public AsyncUdpServer(int listenPort) + : this(IPAddress.Any, listenPort, 10240) + { + } + + /// <summary> + /// 寮傛UdpClient UDP鏈嶅姟鍣� + /// </summary> + /// <param name="localEP">鐩戝惉鐨勭粓缁撶偣</param> + public AsyncUdpServer(IPEndPoint localEP) + : this(localEP.Address, localEP.Port, 10240) + { + } + + /// <summary> + /// 寮傛UdpClient UDP鏈嶅姟鍣� + /// </summary> + /// <param name="localIPAddress">鐩戝惉鐨処P鍦板潃</param> + /// <param name="listenPort">鐩戝惉鐨勭鍙�</param> + /// <param name="maxClient">鏈�澶у鎴风鏁伴噺</param> + public AsyncUdpServer(IPAddress localIPAddress, int listenPort, int maxClient) + { + this.Address = localIPAddress; + this.Port = listenPort; + this.Encoding = Encoding.Default; + + _maxClient = maxClient; + //_clients = new List<AsyncUDPSocketState>(); + _server = new UdpClient(new IPEndPoint(this.Address, this.Port)); + uint IOC_IN = 0x80000000; + uint IOC_VENDOR = 0x18000000; + uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; + + _server.Client.IOControl((int)SIO_UDP_CONNRESET, new byte[] { Convert.ToByte(false) }, null); + + _recvBuffer = new byte[_server.Client.ReceiveBufferSize]; + } + + #endregion + + #region Method + /// <summary> + /// 鍚姩鏈嶅姟鍣� + /// </summary> + /// <returns>寮傛TCP鏈嶅姟鍣�</returns> + public void Start() + { + try + { + if (!IsRunning) + { + IsRunning = true; + _server.EnableBroadcast = true; + _server.BeginReceive(ReceiveDataAsync, null); + } + } + catch (Exception e) { } + } + + /// <summary> + /// 鍋滄鏈嶅姟鍣� + /// </summary> + public void Stop() + { + try + { + //if (IsRunning) + { + IsRunning = false; + _server.Close(); + //TODO 鍏抽棴瀵规墍鏈夊鎴风鐨勮繛鎺� + + } + } + catch (Exception e) { } + } + + /// <summary> + /// 鎺ユ敹鏁版嵁鐨勬柟娉� + /// </summary> + /// <param name="ar"></param> + private void ReceiveDataAsync(IAsyncResult ar) + { + bool isReceive = false; + try + { + var udpState = new AsyncUDPState(); + IPEndPoint remote = null; + udpState.buffer = _server.EndReceive(ar, ref remote); ; + udpState.remote = remote; + udpState.udpClient = _server; + + isReceive = true; + receive(); + + //瑙﹀彂鏁版嵁鏀跺埌浜嬩欢 + RaiseDataReceived(udpState); + } + catch (Exception) + { + //TODO 澶勭悊寮傚父 + RaiseOtherException(null); + } + finally + { + if (!isReceive) + { + receive(); + } + } + } + + void receive() + { + if (IsRunning && _server != null) + { + int count = 10; + while (0 < count--) + { + try + { + _server.BeginReceive(ReceiveDataAsync, null); + break; + } + catch (Exception e) + { + System.Threading.Thread.Sleep(100); + } + } + } + + } + + /// <summary> + /// 鍙戦�佹暟鎹� + /// </summary> + /// <param name="msg"></param> + /// <param name="remote"></param> + public void Send(byte[] data, IPEndPoint remote) + { + try + { + RaisePrepareSend(null); + _server.BeginSend(data, data.Length, remote, new AsyncCallback(SendCallback), null); + } + catch (Exception) + { + //TODO 寮傚父澶勭悊 + RaiseOtherException(null); + } + } + + private void SendCallback(IAsyncResult ar) + { + //if (ar.IsCompleted) + { + try + { + _server.EndSend(ar); + //娑堟伅鍙戦�佸畬姣曚簨浠� + RaiseCompletedSend(null); + } + catch (Exception) + { + //TODO 鏁版嵁鍙戦�佸け璐ヤ簨浠� + RaiseOtherException(null); + } + } + + } + #endregion + + #region 浜嬩欢 + /// <summary> + /// 鎺ユ敹鍒版暟鎹簨浠� + /// </summary> + public event EventHandler<AsyncUDPEventArgs> DataReceived; + + private void RaiseDataReceived(AsyncUDPState state) + { + if (DataReceived != null) + { + DataReceived(this, new AsyncUDPEventArgs(state)); + } + } + + /// <summary> + /// 鍙戦�佹暟鎹墠鐨勪簨浠� + /// </summary> + public event EventHandler<AsyncUDPEventArgs> PrepareSend; + + /// <summary> + /// 瑙﹀彂鍙戦�佹暟鎹墠鐨勪簨浠� + /// </summary> + /// <param name="state"></param> + private void RaisePrepareSend(AsyncUDPState state) + { + if (PrepareSend != null) + { + PrepareSend(this, new AsyncUDPEventArgs(state)); + } + } + + /// <summary> + /// 鏁版嵁鍙戦�佸畬姣曚簨浠� + /// </summary> + public event EventHandler<AsyncUDPEventArgs> CompletedSend; + + /// <summary> + /// 瑙﹀彂鏁版嵁鍙戦�佸畬姣曠殑浜嬩欢 + /// </summary> + /// <param name="state"></param> + private void RaiseCompletedSend(AsyncUDPState state) + { + if (CompletedSend != null) + { + CompletedSend(this, new AsyncUDPEventArgs(state)); + } + } + + /// <summary> + /// 缃戠粶閿欒浜嬩欢 + /// </summary> + public event EventHandler<AsyncUDPEventArgs> NetError; + /// <summary> + /// 瑙﹀彂缃戠粶閿欒浜嬩欢 + /// </summary> + /// <param name="state"></param> + private void RaiseNetError(AsyncUDPState state) + { + if (NetError != null) + { + NetError(this, new AsyncUDPEventArgs(state)); + } + } + + /// <summary> + /// 寮傚父浜嬩欢 + /// </summary> + public event EventHandler<AsyncUDPEventArgs> OtherException; + /// <summary> + /// 瑙﹀彂寮傚父浜嬩欢 + /// </summary> + /// <param name="state"></param> + private void RaiseOtherException(AsyncUDPState state, string descrip) + { + if (OtherException != null) + { + OtherException(this, new AsyncUDPEventArgs(descrip, state)); + } + } + private void RaiseOtherException(AsyncUDPState state) + { + RaiseOtherException(state, ""); + } + #endregion + + #region Close + /// <summary> + /// 鍏抽棴涓�涓笌瀹㈡埛绔箣闂寸殑浼氳瘽 + /// </summary> + /// <param name="state">闇�瑕佸叧闂殑瀹㈡埛绔細璇濆璞�</param> + public void Close(AsyncUDPState state) + { + if (state != null) + { + //_clients.Remove(state); + //_clientCount--; + //TODO 瑙﹀彂鍏抽棴浜嬩欢 + } + } + /// <summary> + /// 鍏抽棴鎵�鏈夌殑瀹㈡埛绔細璇�,涓庢墍鏈夌殑瀹㈡埛绔繛鎺ヤ細鏂紑 + /// </summary> + public void CloseAllClient() + { + //foreach (AsyncUDPSocketState client in _clients) + //{ + // Close(client); + //} + //_clientCount = 0; + //_clients.Clear(); + } + + #endregion + + #region 閲婃斁 + /// <summary> + /// Performs application-defined tasks associated with freeing, + /// releasing, or resetting unmanaged resources. + /// </summary> + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// <summary> + /// Releases unmanaged and - optionally - managed resources + /// </summary> + /// <param name="disposing"><c>true</c> to release + /// both managed and unmanaged resources; <c>false</c> + /// to release only unmanaged resources.</param> + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + try + { + Stop(); + if (_server != null) + { + _server = null; + } + } + catch (SocketException) + { + //TODO + RaiseOtherException(null); + } + } + disposed = true; + } + } + #endregion + } +} +public class AsyncUDPState +{ + // Client socket. + public UdpClient udpClient = null; + // Size of receive buffer. + public const int BufferSize = 1024; + // Receive buffer. + public byte[] buffer = new byte[BufferSize]; + // Received data string. + public StringBuilder sb = new StringBuilder(); + + public IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0); +} +/// <summary> +/// UdpClient 寮傛UDP鏈嶅姟鍣ㄤ簨浠跺弬鏁扮被 +/// </summary> +public class AsyncUDPEventArgs : EventArgs +{ + /// <summary> + /// 鎻愮ず淇℃伅 + /// </summary> + public string _msg; + + /// <summary> + /// 瀹㈡埛绔姸鎬佸皝瑁呯被 + /// </summary> + public AsyncUDPState _state; + + /// <summary> + /// 鏄惁宸茬粡澶勭悊杩囦簡 + /// </summary> + public bool IsHandled { get; set; } + + public AsyncUDPEventArgs(string msg) + { + this._msg = msg; + IsHandled = false; + } + public AsyncUDPEventArgs(AsyncUDPState state) + { + this._state = state; + IsHandled = false; + } + public AsyncUDPEventArgs(string msg, AsyncUDPState state) + { + this._msg = msg; + this._state = state; + IsHandled = false; + } + +} diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 5b31d17..5195709 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -1492,6 +1492,7 @@ FloorHeatingPage.UpdataStates(localFunction); break; case SPK.SensorPm25: + case SPK.SensorPm10: case SPK.SensorCO2: case SPK.SensorTVOC: case SPK.SensorTemperature: diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs index 0e8f8dc..dc75315 100644 --- a/HDL_ON/DAL/DriverLayer/Packet.cs +++ b/HDL_ON/DAL/DriverLayer/Packet.cs @@ -109,7 +109,7 @@ #if DEBUG #else - } + } catch (Exception ex) { MainPage.Log($"packet {ex.Message} "); @@ -192,7 +192,7 @@ light.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[light.bus.LoopId] == 0 ? "off" : "on"); if (light.trait_on_off.curValue.ToString() == "on") { - light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i+1].ToString()); + light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i + 1].ToString()); light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%"; } HomePage.UpdataFunctionStates(light); @@ -261,7 +261,8 @@ FunctionPage.UpdataStates(lightTeme); ClassificationPage.UpdataInfo(lightTeme); RGBPage.UpdataStates(lightTeme); - }else if(lightTeme.spk == SPK.LightCCT) + } + else if (lightTeme.spk == SPK.LightCCT) { lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off"); if (receiveBytes[1] > 0) @@ -345,21 +346,21 @@ case Command.ReadACModeACK: foreach (var function in FunctionList.List.Functions) { - if (function.bus == null || function.spk != SPK.AcStandard) - { - continue; - } + if (function.bus == null || function.spk != SPK.AcStandard) + { + continue; + } var acFunction = new AC(); if (function.bus.SubnetID == subnetID && - function.bus.DeviceID == deviceID && + function.bus.DeviceID == deviceID && function.bus.LoopId == receiveBytes[0]) { - Console.WriteLine(function.GetBusId()); + Console.WriteLine(function.GetBusId()); function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[1].ToString()); function.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[2].ToString()); - function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[8] == 1 ? "on" : "off"); - acFunction.SetMode(receiveBytes[9],function); - acFunction.SetFan(receiveBytes[10],function); + function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[8] == 1 ? "on" : "off"); + acFunction.SetMode(receiveBytes[9], function); + acFunction.SetFan(receiveBytes[10], function); function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[11].ToString()); function.lastState = ""; switch (function.GetAttrState(FunctionAttributeKey.Mode)) @@ -413,7 +414,7 @@ { function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[2]); function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] % 2 == 0 ? "off" : "on"); - new FloorHeating().SetModeIndex(receiveBytes[3],function); + new FloorHeating().SetModeIndex(receiveBytes[3], function); if (function.Fh_Mode_Temp.ContainsKey("normal")) { @@ -490,7 +491,8 @@ if (receiveBytes[9] > 128) { indoorTemp = 1 - (receiveBytes[9] - 128); - }else + } + else { indoorTemp = receiveBytes[9]; } @@ -544,8 +546,8 @@ { case SPK.SensorTemperature: byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] }; - sensor.SetAttrState(FunctionAttributeKey.Value,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); - sensor.SetAttrState(sensor.spk,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); + sensor.SetAttrState(FunctionAttributeKey.Value, Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); + sensor.SetAttrState(sensor.spk, Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString()); break; case SPK.SensorHumidity: sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString()); @@ -556,8 +558,8 @@ sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString()); break; case SPK.SensorPm25: - sensor.SetAttrState(FunctionAttributeKey.Value,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); - sensor.SetAttrState(sensor.spk,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); + sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); + sensor.SetAttrState(sensor.spk, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); break; case SPK.SensorCO2: sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString()); @@ -565,7 +567,7 @@ break; } EnvironmentalPage.LoadEvent_UpdataStatus(sensor); - //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); + //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); } } } @@ -602,17 +604,17 @@ switch (receiveBytes[3]) { case 1: - sensor.SetAttrState(FunctionAttributeKey.Value,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); - sensor.SetAttrState(sensor.spk,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); + sensor.SetAttrState(FunctionAttributeKey.Value, ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); + sensor.SetAttrState(sensor.spk, ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString()); break; case 2: - sensor.SetAttrState(FunctionAttributeKey.Value,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); - sensor.SetAttrState(sensor.spk,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); + sensor.SetAttrState(FunctionAttributeKey.Value, (-1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); + sensor.SetAttrState(sensor.spk, (-1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString()); break; case 3: byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] }; - sensor.SetAttrState(FunctionAttributeKey.Value,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); - sensor.SetAttrState(sensor.spk,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); + sensor.SetAttrState(FunctionAttributeKey.Value, (Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); + sensor.SetAttrState(sensor.spk, (Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString()); break; } switch (receiveBytes[4]) @@ -626,8 +628,8 @@ } break; } - - //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); + + //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor); EnvironmentalPage.LoadEvent_UpdataStatus(sensor); } } @@ -665,10 +667,10 @@ function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[1].ToString()); break; case 5: - acFunction.SetFan ( receiveBytes[1],function); + acFunction.SetFan(receiveBytes[1], function); break; case 6: - acFunction.SetMode ( receiveBytes[1],function); + acFunction.SetMode(receiveBytes[1], function); break; } @@ -752,7 +754,7 @@ #if DEBUG #else - } + } catch (Exception ex) { MainPage.Log($"Bus Rev Erorr : {ex.Message}"); @@ -827,7 +829,7 @@ default: break; } - Control_Udp.ReceiveRepeatManager(receiveFlag,usefulBytes); + Control_Udp.ReceiveRepeatManager(receiveFlag, usefulBytes); } catch (Exception ex) { diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs index df9662a..c4b37fd 100644 --- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs +++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs @@ -4,214 +4,219 @@ namespace HDL_ON.DriverLayer { - public class UdpSocket - { - static UdpSocket _busSocket; - public static UdpSocket _BusSocket + public class UdpSocket + { + static UdpSocket _busSocket; + public static UdpSocket _BusSocket { get { - if(_busSocket == null) + if (_busSocket == null) { - _busSocket = new UdpSocket(); + _busSocket = new UdpSocket(); } - return _busSocket; + return _busSocket; } } - //鏈湴Socket - private Socket busSocket; - public int Port = 0; - /// <summary> - /// 鍚姩Socket鎺ユ敹鍜屽彂閫佸姛鑳� - /// </summary> - public void Start (int port = 0) + //鏈湴Socket + private Socket busSocket; + public int Port = 0; + /// <summary> + /// 鍚姩Socket鎺ユ敹鍜屽彂閫佸姛鑳� + /// </summary> + public void Start(int port = 0) { - if (IsRunning) - { - if (port == Port) + if (IsRunning) + { + if (port == Port) { return; - } + } else { busSocket.Close(); - } + } } - if (port != 0) - Port = port; - if (Port == 0) - return; + if (port != 0) + Port = port; + if (Port == 0) + return; - busSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + busSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); busSocket.EnableBroadcast = true; - try { - busSocket.Bind(new IPEndPoint(IPAddress.Any, Port)); + try + { + busSocket.Bind(new IPEndPoint(IPAddress.Any, Port)); - busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); - relinkCount = 0; - } - catch (Exception ex){ - MainPage.Log ($"udp port bind error : {ex.Message}"); + busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188"))); + relinkCount = 0; + } + catch (Exception ex) + { + MainPage.Log($"udp port bind error : {ex.Message}"); - busSocket = null; + busSocket = null; return; } asyncBeginReceive(); - MainPage.Log ($"udp port : {port}"); + MainPage.Log($"udp port : {port}"); } - /// <summary> - /// 鍋滄Socket - /// </summary> - public void Stop() - { - if(busSocket == null) + /// <summary> + /// 鍋滄Socket + /// </summary> + public void Stop() + { + if (busSocket == null) { - return; + return; } - if (!IsRunning) - { - return; - } - try - { - busSocket.Close(); - relinkCount = 0; - } - catch { } - busSocket = null; - MainPage.Log("Socket鍏抽棴"); - } - - /// <summary> - /// 褰撳墠鐨凷ocket鏄惁杩愯 - /// </summary> - public bool IsRunning - { - get - { - return null == busSocket ? false : true; - } - } - - /// <summary> - /// 寮�濮嬪紓姝ユ帴鏀舵暟鎹� - /// </summary> - private void asyncBeginReceive() - { - if (!IsRunning) - { - return; - } - if(busSocket == null) + if (!IsRunning) { - return; + return; + } + try + { + busSocket.Close(); + relinkCount = 0; + } + catch { } + busSocket = null; + MainPage.Log("Socket鍏抽棴"); + } + + /// <summary> + /// 褰撳墠鐨凷ocket鏄惁杩愯 + /// </summary> + public bool IsRunning + { + get + { + return null == busSocket ? false : true; + } + } + + /// <summary> + /// 寮�濮嬪紓姝ユ帴鏀舵暟鎹� + /// </summary> + private void asyncBeginReceive() + { + if (!IsRunning) + { + return; + } + if (busSocket == null) + { + return; } - try { - Packet packet = new Packet (); - busSocket.BeginReceiveFrom (packet.Bytes, 0, packet.Bytes.Length, SocketFlags.None, ref packet.RemoteEndPoint, new AsyncCallback (asyncEndReceive), packet); - } - catch (Exception e) { - System.Threading.Thread.Sleep (1); - Console.WriteLine("asyncBeginReceive " + relinkCount ); - if (relinkCount == 0) - { - relinkCount = 1; - asyncBeginReceive(); - } + try + { + Packet packet = new Packet(); + busSocket.BeginReceiveFrom(packet.Bytes, 0, packet.Bytes.Length, SocketFlags.None, ref packet.RemoteEndPoint, new AsyncCallback(asyncEndReceive), packet); + } + catch (Exception e) + { + System.Threading.Thread.Sleep(1); + Console.WriteLine("asyncBeginReceive " + relinkCount); + if (relinkCount == 0) + { + relinkCount = 1; + asyncBeginReceive(); + } Console.WriteLine($"asyncBeginReceive {e.Message}"); - } - } - /// <summary> + } + } + /// <summary> /// 閲嶈繛娆℃暟 /// </summary> - private int relinkCount = 0; + private int relinkCount = 0; - /// <summary> - /// 寮傛鎺ユ敹鏁版嵁缁撴潫 - /// </summary> - /// <param name="iar"></param> - private void asyncEndReceive(IAsyncResult iar) - { - if (!IsRunning) - { - return; - } - try - { - if (busSocket == null) - { - return; - } - asyncBeginReceive(); - Packet packet = (Packet)iar.AsyncState; - int len = busSocket.EndReceiveFrom(iar, ref packet.RemoteEndPoint); - - byte[] bytes = packet.Bytes; - packet.Bytes = new byte[len]; - Array.Copy(bytes, 0, packet.Bytes, 0, packet.Bytes.Length); - - //MainPage.Log($"鎺ユ敹{packet.RemoteEndPoint}鏁版嵁"); - //mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊 - if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585) - { - Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString()); - } - else if (((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹� - { - packet.Manager(); - } - - } - catch (Exception ex) - { - MainPage.Log($"寮傛鎺ユ敹鏁版嵁缁撴潫 {ex.Message},{((Packet)iar.AsyncState).Bytes}"); - } - } - - /// <summary> - /// 寮傛鍙戦�佹暟鎹� - /// </summary> - /// <param name="tempPacket"></param> - public void AsyncBeginSend(Packet tempPacket) - { - try - { - if (!IsRunning) - { - tempPacket.HaveSendCount++; - return; - } - tempPacket.FlagDateTime = System.DateTime.Now; - tempPacket.HaveSendCount++; - busSocket.BeginSendTo(tempPacket.Bytes, 0, tempPacket.Bytes.Length, SocketFlags.None, tempPacket.RemoteEndPoint, new AsyncCallback(asyncEndSend), tempPacket); - } - catch (Exception ex) - { - MainPage.Log($"AsyncBeginSend error {ex.Message}"); - } - } - - /// <summary> - /// 寮傛鍙戦�佹暟鎹粨鏉� - /// </summary> - /// <param name="iar"></param> - private void asyncEndSend(IAsyncResult iar) - { - Packet tempUDPPacketBuffer = (Packet)iar.AsyncState; - try - { - int bytesSent = busSocket.EndSendTo(iar); - } - catch { - + /// <summary> + /// 寮傛鎺ユ敹鏁版嵁缁撴潫 + /// </summary> + /// <param name="iar"></param> + private void asyncEndReceive(IAsyncResult iar) + { + if (!IsRunning) + { + return; } - } - } + try + { + if (busSocket == null) + { + return; + } + asyncBeginReceive(); + Packet packet = (Packet)iar.AsyncState; + int len = busSocket.EndReceiveFrom(iar, ref packet.RemoteEndPoint); + + byte[] bytes = packet.Bytes; + packet.Bytes = new byte[len]; + Array.Copy(bytes, 0, packet.Bytes, 0, packet.Bytes.Length); + + //MainPage.Log($"鎺ユ敹{packet.RemoteEndPoint}鏁版嵁"); + //mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊 + if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585) + { + Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString()); + } + else if (((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹� + { + packet.Manager(); + } + + } + catch (Exception ex) + { + MainPage.Log($"寮傛鎺ユ敹鏁版嵁缁撴潫 {ex.Message},{((Packet)iar.AsyncState).Bytes}"); + } + } + + /// <summary> + /// 寮傛鍙戦�佹暟鎹� + /// </summary> + /// <param name="tempPacket"></param> + public void AsyncBeginSend(Packet tempPacket) + { + try + { + if (!IsRunning) + { + tempPacket.HaveSendCount++; + return; + } + tempPacket.FlagDateTime = System.DateTime.Now; + tempPacket.HaveSendCount++; + busSocket.BeginSendTo(tempPacket.Bytes, 0, tempPacket.Bytes.Length, SocketFlags.None, tempPacket.RemoteEndPoint, new AsyncCallback(asyncEndSend), tempPacket); + } + catch (Exception ex) + { + MainPage.Log($"AsyncBeginSend error {ex.Message}"); + } + } + + /// <summary> + /// 寮傛鍙戦�佹暟鎹粨鏉� + /// </summary> + /// <param name="iar"></param> + private void asyncEndSend(IAsyncResult iar) + { + Packet tempUDPPacketBuffer = (Packet)iar.AsyncState; + try + { + int bytesSent = busSocket.EndSendTo(iar); + } + catch + { + + } + } + } } \ No newline at end of file diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index 3b78fb1..731c865 100644 --- a/HDL_ON/DAL/Server/HttpServerRequest.cs +++ b/HDL_ON/DAL/Server/HttpServerRequest.cs @@ -710,7 +710,7 @@ if (mHomeGatewayRes.Count > 0) { DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];//缃戝叧鐘舵�� - DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes[0].gatewayStatus; + HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes[0].gatewayStatus; DB_ResidenceData.Instance.SaveResidenceData(); return revertObj.Code; } @@ -776,7 +776,7 @@ var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo>(revertObj.Data.ToString()); if (mHomeGatewayRes != null) { - DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes.gatewayStatus; + HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes.gatewayStatus; } } return revertObj.Code; @@ -1538,7 +1538,7 @@ } #endregion -#region 鑾峰彇澶╂皵閮ㄥ垎 + #region 鑾峰彇澶╂皵閮ㄥ垎 /// <summary> /// 鑾峰彇鎸囧畾缁忕含搴︾殑鍩庡競淇℃伅澶╂皵淇℃伅 /// </summary> diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index 011c185..7bcc154 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1499,6 +1499,7 @@ /// </summary> public const string Illuminance = "illuminance"; public const string Pm25 = "pm25"; + public const string Pm10 = "pm10"; public const string Tvoc = "tvoc"; /// <summary> /// 鐘舵��,浼犳劅鍣� @@ -2305,7 +2306,7 @@ /// <summary> /// 绾㈠鐑按鍣� /// </summary> - public const string HeaterIr = " ir.water_heater"; + public const string HeaterIr = "ir.water_heater"; /// <summary> /// 绾㈠椋庢墖 /// </summary> diff --git a/HDL_ON/Entity/Function/Sensor.cs b/HDL_ON/Entity/Function/Sensor.cs index b363c9f..8a06e8b 100644 --- a/HDL_ON/Entity/Function/Sensor.cs +++ b/HDL_ON/Entity/Function/Sensor.cs @@ -61,6 +61,10 @@ case SPK.SensorHumidity: attr = function.GetAttribute(FunctionAttributeKey.Humidity); break; + case SPK.SensorPm10: + attr = function.GetAttribute(FunctionAttributeKey.Pm10); + break; + } } double value = 0.0; @@ -98,6 +102,12 @@ switch (spk) { case SPK.SensorPm25: + _intervalValue.Add("0 ~ 50"); + _intervalValue.Add("51 ~ 100"); + _intervalValue.Add("101 ~ 150"); + _intervalValue.Add("151 ~"); + break; + case SPK.SensorPm10: _intervalValue.Add("0 ~ 35"); _intervalValue.Add("36 ~ 75"); _intervalValue.Add("76 ~ 115"); @@ -211,6 +221,7 @@ _levelColorList.Add(0xFFFF3D3D); break; case SPK.SensorTVOC: + case SPK.SensorPm10: _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFFD154); _levelColorList.Add(0xFFFF9D54); @@ -246,6 +257,7 @@ switch (spk) { case SPK.SensorPm25: + case SPK.SensorPm10: _levelTextList.Add(StringId.Great); _levelTextList.Add(StringId.Good); _levelTextList.Add(StringId.MildPollution); diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs index 9a57692..5685fc8 100644 --- a/HDL_ON/UI/MainPage.cs +++ b/HDL_ON/UI/MainPage.cs @@ -26,7 +26,7 @@ /// <summary> /// 鐗堟湰鍙� /// </summary> - public static string VersionString = "2.4.2"; + public static string VersionString = "2.4.3"; ///// <summary> ///// 瀹㈡埛绔被鍨� ///// </summary> diff --git a/HDL_ON/UI/UI1-Login/LoginPage.cs b/HDL_ON/UI/UI1-Login/LoginPage.cs index dde7691..6584a1e 100644 --- a/HDL_ON/UI/UI1-Login/LoginPage.cs +++ b/HDL_ON/UI/UI1-Login/LoginPage.cs @@ -318,7 +318,6 @@ //etAccount.Text = "18321091245"; //etAccount.Text = "13751916353"; etAccount.Text = "13549566666"; - etAccount.Text = "support7@hdlautomation.com"; etAccount.Text = "13375012446";//娴嬭瘯鏈嶅姟鍣� etAccount.Text = "15855403939"; etAccount.Text = "15006564444"; @@ -330,9 +329,11 @@ etAccount.Text = "13533335801"; etAccount.Text = "13682244600"; etAccount.Text = "marketing@australindo.co.id"; - etAccount.Text = "support7@hdlautomation.com"; etAccount.Text = "13922115008";//鍒樻�� etAccount.Text = "1272061968@qq.com"; + etAccount.Text = "info@hdlegypt.com"; + etAccount.Text = "support7@hdlautomation.com"; + etAccount.Text = "18402017839"; } @@ -365,9 +366,9 @@ } b = !b; etPassword.Text = "123456"; - if(etAccount.Text == "pjh@hdlchina.com.cn") + if(etAccount.Text == "info@hdlegypt.com") { - etPassword.Text = "hdl123"; + etPassword.Text = "@Hdl2020"; } else if(etAccount.Text == "18600200915") { diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs index 3d1935a..b5e6c38 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs @@ -745,6 +745,19 @@ break; case ShowFunction.Panel: break; + case ShowFunction.SecurityMonitoring: + if (!MainPage.NoLoginMode) + { + if (OnAppConfig.Instance.RequestHttpsHost.Contains("bahrain")) + { + functionCount = 0; + } + else + { + functionCount = 1; + } + } + break; case ShowFunction.Sensor: functionCount = FunctionList.List.GetArmSensorList().Count; break; @@ -757,6 +770,20 @@ case ShowFunction.SecurityCenter: functionCount = FunctionList.List.securities.Count; break; + case ShowFunction.Acst: + functionCount = FunctionList.List.GetAcstParentList().Count; + functionOnCount = FunctionList.List.GetAcstParentList().FindAll((obj) => obj.trait_on_off.curValue.ToString() == "on").Count; + break; + case ShowFunction.VideoDoorLock: + functionCount = FunctionList.List.GetVideoDoorLockList().Count; + functionOnCount = FunctionList.List.GetAcstParentList().FindAll((obj) => obj.GetAttrState("status").ToString() == "open" + || obj.GetAttrState("status").ToString() == "normal_open").Count; + + break; + case ShowFunction.Aks: + functionCount = FunctionList.List.GetVideoControlsList().Count; + functionOnCount = 1; + break; diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs index 1957662..7d2996e 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs @@ -1311,27 +1311,30 @@ if (indexeList.Count > 0) { dicSateteList.Clear(); - string s = string.Empty; + string userNameStr = string.Empty; + string seleUsrIdStr = string.Empty; string tag = string.Empty; - //鏁版嵁灏佽 + string[] arrayUserIds = new string[indexeList.Count]; + //寮�闂ㄧ被鍨� AddDictionary("open_type", "1", "integer"); for (int i = 0; i < indexeList.Count; i++) { - if (i > faceIdList.Count) { continue; } var indexe = indexeList[i]; var face = faceIdList[indexe]; - AddDictionary("user_id", face.userId, "string"); - s += face.userName; - s += ","; tag += face.userId; tag += "_"; + userNameStr += face.userName; + userNameStr += ","; + arrayUserIds[i] = face.userId; } + seleUsrIdStr = Newtonsoft.Json.JsonConvert.SerializeObject(arrayUserIds); + AddDictionary("user_id", seleUsrIdStr, "string", "[]"); //鐣岄潰鏄剧ず閫変腑鍊� - btnState.Text = s; + btnState.Text = InpOrOutLogicMethod.Current.RemoveLastStr(userNameStr); btnState.Tag = tag; } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs index c5fbf03..d1fc564 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs @@ -436,30 +436,43 @@ break; case SPK.doorgate: { - string s = string.Empty; - if (inputCondition.identifier == "door_call_cloud_event") - { - s = Language.StringByID(StringId.shipintonghuahujiao); - } - else - { - for (int b = 0; b < dicList.Count; b++) - { - var dic = dicList[b]; - var key = dic["key"].ToString(); - if (key != "user_id") - { - continue; - } - var userId = dic["value"].ToString(); - var FaceItem = this.GetFaceItem(userId, device.deviceId); - s += FaceItem.userName; - s += ","; + string s = string.Empty; + try + { + if (inputCondition.identifier == "door_call_cloud_event") + { + s = Language.StringByID(StringId.shipintonghuahujiao); + } + else + { + for (int b = 0; b < dicList.Count; b++) + { + var dic = dicList[b]; + var key = dic["key"].ToString(); + if (key != "user_id") + { + continue; + } + var value = dic["value"].ToString(); + if (!string.IsNullOrEmpty(value)) + { + var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(value); + for (int a = 0; a < list.Count; a++) + { + + var FaceItem = this.GetFaceItem(list[a], device.deviceId); + s += FaceItem.userName; + s += ","; + + } + } + + } } - } + catch { } inputView.btnState.Text = s; } break; @@ -1506,17 +1519,32 @@ case SPK.MusicStandard: case SPK.AvMusic: { + string on_off = GetKeyValue("on_off", dicList); string song_name = GetKeyValue("song_name", dicList); string volume = GetKeyValue("volume", dicList); - stateStr = song_name + ";" + Language.StringByID(StringId.volumeMusic) + volume; - if (stateStr.StartsWith(";")) + + if (!string.IsNullOrEmpty(on_off)) { - stateStr = stateStr.Substring(1, stateStr.Length - 1); + if (on_off == "on") + { + stateStr = Language.StringByID(StringId.onLogic); + } + else + { + stateStr = Language.StringByID(StringId.offLogic); + } } - else if (stateStr.EndsWith(Language.StringByID(StringId.volumeMusic))) + + if (!string.IsNullOrEmpty(song_name)) { - stateStr = stateStr.Substring(0, stateStr.Length - 3); + stateStr += "," + song_name; } + + if (!string.IsNullOrEmpty(volume)) + { + stateStr += "," + volume; + } + } break; case SPK.ElectricalTvHisense: @@ -2303,7 +2331,7 @@ foreach (var dic in dicList) { string value = dic["value"]; - if (value == "on"|| value == "open") + if (value == "on" || value == "open") { button1.Text = Language.StringByID(StringId.onLogic); } @@ -2494,38 +2522,61 @@ { foreach (var dic in dicList) { - if (dic["key"] == "song_name") + if (dic["key"] == "on_off") { - button1.Text = dic["value"]?.ToString(); + if (dic["value"] == "on") + { + button1.Text = Language.StringByID(StringId.onLogic); + } + else + { + button1.Text = Language.StringByID(StringId.offLogic); + } + } + else if (dic["key"] == "song_name") + { + button2.Text = dic["value"]?.ToString(); } else if (dic["key"] == "volume") { - button2.Text = dic["value"]?.ToString(); + button3.Text = dic["value"]?.ToString(); } } } break; case SPK.doorgate: { - string s = string.Empty; - string tag = string.Empty; - for (int b = 0; b < dicList.Count; b++) + try { - var dic = dicList[b]; - var key = dic["key"].ToString(); - if (key != "user_id") + string userNameStr = string.Empty; + string tag = string.Empty; + for (int b = 0; b < dicList.Count; b++) { - continue; + var dic = dicList[b]; + var key = dic["key"].ToString(); + if (key != "user_id") + { + continue; + } + var value = dic["value"].ToString(); + if (!string.IsNullOrEmpty(value)) + { + var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(value); + for (int i = 0; i < list.Count; i++) + { + + var FaceItem = this.GetFaceItem(list[i], device.deviceId); + userNameStr += FaceItem.userName; + userNameStr += ","; + tag += FaceItem.userId; + tag += "_"; + } + } } - var userId = dic["value"].ToString(); - var FaceItem = this.GetFaceItem(userId, device.deviceId); - s += FaceItem.userName; - s += ","; - tag += FaceItem.userId; - tag += "_"; + button2.Text = RemoveLastStr(userNameStr); + button2.Tag = tag; } - button2.Text = s; - button2.Tag = tag; + catch { } } break; case SPK.ElectricalTvHisense: diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs index 807103c..89cd452 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs @@ -109,7 +109,7 @@ /// <summary> /// 妫�娴嬬被鍨� 閰嶅悎condition_type=3鏃朵娇鐢�,娌℃湁璇ュ瓧娈点�佽鍊兼垨0: 鐘舵�佹娴�(姣忔鏀跺埌鐘舵�佸氨鎴愮珛),1:鍔ㄤ綔妫�娴�(闇�瑕佸垏鎹㈢姸鎬佹墠鎴愮珛); /// </summary> - public string detect_type = "0"; + public string detect_type = "1"; /// <summary> /// 浜轰綋绉诲姩浼犳劅鍣紙甯︽寔缁椂闂达級 /// </summary> diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs index 1bdd1b3..9a2e707 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs @@ -736,8 +736,13 @@ case SPK.AvMusic: { #region 鐣岄潰 + ///寮�鍏� + LogicView.FunTypeView switchVie = new LogicView.FunTypeView(); + switchVie.btnText.TextID = StringId.switchLogic; + fLayout.AddChidren(switchVie.FLayoutView()); //鎻愮ず璇煶 LogicView.FunTypeView funTypeView = new LogicView.FunTypeView(); + funTypeView.frameLayout.Y = switchVie.frameLayout.Bottom; funTypeView.btnText.TextID = StringId.tishiyin; fLayout.AddChidren(funTypeView.FLayoutView()); ///闊抽噺 @@ -754,9 +759,41 @@ ///璁惧寤舵椂iewv - DelayView(fLayout, volView.frameLayout.Bottom); + var delayView = DelayView(fLayout, volView.frameLayout.Bottom); + if (edit ) + { + Output outputs = Logic.currlogic.output[index]; + var dicList = outputs.status.Find((obj) => obj.ContainsValue(FunctionAttributeKey.OnOff)); + if (dicList != null) + { + if (dicList.ContainsValue( "off") || dicList.ContainsValue("pause")) + { + funTypeView.frameLayout.Visible = false; + volView.frameLayout.Visible = false; + delayView.frameLayout.Y = switchVie.frameLayout.Bottom; + } + } + } #endregion #region 鐐瑰嚮浜嬩欢 + ///寮�鍏崇偣鍑讳簨浠� + switchVie.btnClick.MouseUpEventHandler += (sender, e) => + { + SwitchViewMethod(device, switchVie.btnState, 2, (v) => { + if (v == "on") + { + funTypeView.frameLayout.Visible = true; + volView.frameLayout.Visible = true; + delayView.frameLayout.Y = volView.frameLayout.Bottom; + } + else + { + funTypeView.frameLayout.Visible = false; + volView.frameLayout.Visible = false; + delayView.frameLayout.Y = switchVie.frameLayout.Bottom; + } + }); + }; ///鎻愮ず璇煶鐐瑰嚮浜嬩欢 funTypeView.btnClick.MouseUpEventHandler += (sender, e) => { @@ -820,7 +857,7 @@ if (edit) { //鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬� - GetEditDeviceState(device, index, funTypeView.btnState, volView.btnState, null, null); + GetEditDeviceState(device, index, switchVie.btnState, funTypeView.btnState, volView.btnState, null); } #endregion @@ -991,6 +1028,23 @@ dicList.AddRange(diclist);//鍐嶆坊鍔犲叾瀹冨睘鎬� dicSateteList = dicList;//閲嶆柊璧嬪�� } + var onoffDic = dicSateteList.Find((obj) => obj.ContainsValue("on_off")); + if (onoffDic != null) + { + if (onoffDic.ContainsValue("off")) + { + for(int i =0;i<dicSateteList.Count;) + { + var d = dicSateteList[i]; + if(!d.ContainsValue("on_off") || d.ContainsValue("delay")) + { + dicSateteList.Remove(d); + continue; + } + i++; + } + } + } } break; case SPK.GroupControl: @@ -1041,7 +1095,7 @@ /// </summary> /// <param name="fLayout">鐖舵帶浠�</param> /// <param name="bottomY">鍦ㄥ摢涓帶浠朵笅闈�</param> - private void DelayView(FrameLayout fLayout, int bottomY) + private LogicView.FunTypeView DelayView(FrameLayout fLayout, int bottomY) { LogicView.FunTypeView delayView = new LogicView.FunTypeView(); delayView.frameLayout.Y = bottomY; @@ -1061,6 +1115,7 @@ selectedState = "delay_" + strdelay; }); }; + return delayView; } @@ -1070,7 +1125,8 @@ /// <param name="device"></param> /// <param name="button"></param> /// <param name="len">鏄剧ず閫夋嫨View鏁伴噺</param> - private void SwitchViewMethod(Entity.Function device, Button button, int len) + /// <param name="action">鐐瑰嚮鍥炶皟浜嬩欢锛岀敤鏉ョ粰闊充箰鍒锋柊鐣岄潰浣跨敤锛寃xr 2024-01-04 16:03:47</param> + private void SwitchViewMethod(Entity.Function device, Button button, int len,Action<string> action = null) { #region 鐣岄潰 FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence }; @@ -1131,11 +1187,11 @@ } break; - } //鏁版嵁灏佽 AddDictionary(key, value); + action?.Invoke(value); }); #endregion } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs index 08820bd..d925ad0 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs @@ -243,9 +243,38 @@ { scene.functions.Remove(temp); } - //else - { scene.functions.Insert(0, sceneFunction); + + + if (sceneFunction.localFunction.spk == SPK.MusicStandard) + { + for (var i = 0; i < sceneFunction.status.Count;) + { + var ddd = sceneFunction.status[i]; + if (string.IsNullOrEmpty(ddd.value)) + { + sceneFunction.status.Remove(ddd); + continue; + } + i++; + } + + if (sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.PlaylistName) == null) + { + if (isOnStatus) + { + var songNameStatus = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SongName); + { + if (songNameStatus != null) + { + if (string.IsNullOrEmpty(songNameStatus.value)) + { + sceneFunction.status.Add(new SceneFunctionStatus() { key = FunctionAttributeKey.PlaylistName, value = "hdl_special" }); + } + } + } + } + } } if (!string.IsNullOrEmpty(scene.userSceneId)) { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs index f27995e..9995fae 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs @@ -225,7 +225,31 @@ var regionId = (string)btnHomeName.Tag; dialog.Close(); LoadEvent_ChangeCurHome(home); - LoadContentView(); + new System.Threading.Thread(() => { + try + { + while (true) + { + if (Common.ApiUtlis.Ins.DownloadDataComplete) + { + System.Threading.Thread.Sleep(100); + } + else + { + Application.RunOnMainThread(() => + { + LoadContentView(); + }); + break; + } + } + } + catch { } + { + + } + }) { IsBackground = true }.Start(); + HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.ChangeCurrHome(home); }; } @@ -409,7 +433,31 @@ var regionId = (string)btnHomeName.Tag; dialog.Close(); LoadEvent_ChangeCurHome(home); - LoadContentView(); + new System.Threading.Thread(() => { + try + { + while (true) + { + if (Common.ApiUtlis.Ins.DownloadDataComplete) + { + System.Threading.Thread.Sleep(100); + } + else + { + Application.RunOnMainThread(() => + { + LoadContentView(); + }); + break; + } + } + } + catch { } + { + + } + }) + { IsBackground = true }.Start(); HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.ChangeCurrHome(home); }; } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPage.cs index da39b77..167272f 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPage.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPage.cs @@ -242,7 +242,7 @@ if (MainPage.Increase) { - bodyScrolView.Height = Application.GetRealHeight(541); + bodyScrolView.Height = Application.GetRealHeight(541-10); } headPortraitView = new FrameLayout() @@ -858,16 +858,9 @@ #endregion - bodyView.AddChidren(new Button() - { - Y = Application.GetRealHeight(622), - Height = 1, - BackgroundColor = CSS_Color.DividingLineColor, - }); - btnLogout = new Button() { - Y = Application.GetRealHeight(623), + Y = Application.GetRealHeight(624), Height = Application.GetRealHeight(50), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.SubheadingFontSize, diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs index b87fc59..6d7eb87 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs @@ -446,7 +446,7 @@ d.Add(FunctionAttributeKey.Mode, m); Control.Ins.SendWriteCommand(device, d); dialog.Close(); - if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan") + if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan" || device.GetAttrState(FunctionAttributeKey.Mode) == "dry") { setTempBar.IsClickable = false; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs index 0d4740a..e3e0903 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs @@ -186,7 +186,7 @@ string key = ene.name; if (list.ContainsKey(key)) { - list.Add(ene.name + DateTime.Now.ToLongTimeString(), tt.ToString()); + list.Add(ene.name + DateTime.Now.Ticks, tt.ToString()); } else { diff --git a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalPage.cs b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalPage.cs index 0309210..2f82535 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalPage.cs @@ -274,10 +274,7 @@ int index = 0; foreach (var sensor in FunctionList.List.GetEnvirSensorsList()) { - if (sensor.spk == SPK.SensorPm10) - { - continue; - } + if(SPK.EvironmentSensorList().Contains(sensor.spk) ) { foreach (var seTemp in sensor.attributes) @@ -375,6 +372,10 @@ case SPK.SensorPm25: imagePath = "FunctionIcon/EnvirSensor/Pm25Bg.png"; iconPath = "FunctionIcon/EnvirSensor/Pm25Icon.png"; + break; + case SPK.SensorPm10: + imagePath = "FunctionIcon/EnvirSensor/Pm25Bg.png"; + iconPath = "FunctionIcon/EnvirSensor/Pm10Icon.png"; break; case SPK.SensorTVOC: imagePath = "FunctionIcon/EnvirSensor/TvocBg.png"; @@ -588,6 +589,9 @@ { case SPK.SensorPm25: btnTitle.Text = "PM2.5(ug/m鲁)";//虏 + break; + case SPK.SensorPm10: + btnTitle.Text = "PM10(ug/m鲁)";//虏 break; case SPK.SensorTemperature: btnTitle.Text = Language.StringByID(StringId.Temp) + "(掳C)"; @@ -929,6 +933,9 @@ case SPK.SensorCO2: attr = updateTemp.GetAttribute(FunctionAttributeKey.Co2); break; + case SPK.SensorPm10: + attr = updateTemp.GetAttribute(FunctionAttributeKey.Pm10); + break; case SPK.SensorTemperature: attr = updateTemp.GetAttribute(FunctionAttributeKey.Temperature); break; diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs index 107c8a3..a8048f1 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs @@ -97,9 +97,6 @@ // function.CollectFunction(); //}; - - - //鍥為��鍒锋柊淇℃伅浜嬩欢 new TopViewDiv(bodyView, Language.StringByID(StringId.GroupControl)).LoadTopView_SettingIcon( () => { var page = new AddGroupControlPage(function, @@ -219,7 +216,7 @@ var btnOnText = new Button() { X = Application.GetRealWidth(100-9), - Y = Application.GetRealHeight(500), + Y = Application.GetRealHeight(495), Width = Application.GetMinRealAverage(50), Height = Application.GetMinRealAverage(32), TextColor = CSS_Color.TextualColor, @@ -242,7 +239,7 @@ var btnOffText = new Button() { X = Application.GetRealWidth(180 - 9), - Y = Application.GetRealHeight(500), + Y = Application.GetRealHeight(495), Width = Application.GetMinRealAverage(50), Height = Application.GetMinRealAverage(32), TextColor = CSS_Color.TextualColor, @@ -284,15 +281,15 @@ if (hadRGB) { - LoadRgbAttrView(hadCCT,hadColorful); + LoadRgbAttrView(hadCCT,hadColorful,btnOn,btnOff); } else if (hadCCT) { - LoadCctAttrView(attrView); + LoadCctAttrView(attrView, btnOn, btnOff); } else if (hadDimming) { - LoadDimmingAttrView(attrView); + LoadDimmingAttrView(attrView, btnOn, btnOff); } else { @@ -310,18 +307,26 @@ attrView.AddChidren(btnSwitchIcon); btnSwitchIcon.MouseUpEventHandler = (sender, e) => { + btnSwitchIcon.IsSelected = !btnSwitchIcon.IsSelected; if (btnSwitchIcon.IsSelected) - { - var d = new Dictionary<string, string>(); - d.Add(FunctionAttributeKey.OnOff, "off"); - function.Control(d); - } - else { var d = new Dictionary<string, string>(); d.Add(FunctionAttributeKey.OnOff, "on"); function.Control(d); } + else + { + var d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.OnOff, "off"); + function.Control(d); + } + }; + + btnOn.MouseUpEventHandler += (sender, e) => { + btnSwitchIcon.IsSelected = true; + }; + btnOff.MouseUpEventHandler += (sender, e) => { + btnSwitchIcon.IsSelected = false; }; } @@ -334,7 +339,7 @@ /// 鍔犺浇璋冨厜灞炴�ц缃帶浠� /// </summary> /// <param name="attrView"></param> - void LoadDimmingAttrView(VerticalScrolViewLayout attrView) + void LoadDimmingAttrView(VerticalScrolViewLayout attrView,Button btnOn,Button btnOff) { @@ -388,6 +393,9 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + btnBrightnessText.Text = dimmerBar.Progress + "%"; return; if (e == 0 && lastBrightness != 0) { @@ -420,10 +428,21 @@ } } + }; + + + btnOn.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 100; btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); btnBrightnessText.Text = dimmerBar.Progress + "%"; }; + btnOff.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 0; + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + btnBrightnessText.Text = dimmerBar.Progress + "%"; + }; + } int lastBrightness = 0; @@ -432,7 +451,7 @@ /// 鍔犺浇cct灞炴�ц缃帶浠� /// </summary> /// <param name="attrView"></param> - void LoadCctAttrView(VerticalScrolViewLayout attrView) + void LoadCctAttrView(VerticalScrolViewLayout attrView,Button btnOn,Button btnOff) { attrView.AddChidren(new Button { @@ -483,6 +502,8 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + btnBrightnessText.Text = dimmerBar.Progress + "%"; return; if (e == 0 && lastBrightness != 0) { @@ -517,8 +538,6 @@ } - btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); - btnBrightnessText.Text = dimmerBar.Progress + "%"; }; @@ -616,13 +635,29 @@ cctView.AddChidren(btnTempClolorMax); #endregion + + + + + btnOn.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 100; + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + btnBrightnessText.Text = dimmerBar.Progress + "%"; + }; + btnOff.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 0; + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + btnBrightnessText.Text = dimmerBar.Progress + "%"; + }; + + } /// <summary> /// 鍔犺浇rgb灞炴�ц缃帶浠� /// </summary> /// <param name="attrView"></param> - void LoadRgbAttrView(bool hadCCT,bool hadColorful) + void LoadRgbAttrView(bool hadCCT,bool hadColorful,Button btnOn,Button btnOff) { Light lightTemp = new Light(); int magriHeight = 0; @@ -805,6 +840,8 @@ dimmerBar.OnProgressChangedEvent = (sender, e) => { + //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + //btnBrightnessText.Text = dimmerBar.Progress + "%"; return; if (e == 0 && lastBrightness != 0) { @@ -1051,6 +1088,17 @@ #endregion } + btnOn.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 100; + //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + //btnBrightnessText.Text = dimmerBar.Progress + "%"; + }; + btnOff.MouseUpEventHandler += (sender, e) => { + dimmerBar.Progress = 0; + //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); + //btnBrightnessText.Text = dimmerBar.Progress + "%"; + }; + } -- Gitblit v1.8.0