| | |
| | | using HDL_ON.DAL; |
| | | using HDL_ON.DAL.Net; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI; |
| | | |
| | | namespace HDL_ON |
| | | { |
| | |
| | | /// </summary> |
| | | public static void Send(Function function) |
| | | { |
| | | switch(function.functionCategory) |
| | | switch (function.functionCategory) |
| | | { |
| | | case FunctionCategory.Scene: |
| | | ControlScene(function as Scene); |
| | |
| | | { |
| | | curtainState = 1; |
| | | } |
| | | else if (function.trait_on_off.value.ToString() =="off") |
| | | else if (function.trait_on_off.value.ToString() == "off") |
| | | { |
| | | curtainState = 2; |
| | | } |
| | |
| | | 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) |
| | |
| | | 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 }); |
| | |
| | | } |
| | | 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 发送命令立即更新UI |
| | | HomePage.UpdataFunctionStates(function); |
| | | RoomPage.UpdataStates(function); |
| | | FunctionPage.UpdataStates(function); |
| | | ClassificationPage.UpdataInfo(function); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |