| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.DAL; |
| | | using HDL_ON.DAL.Net; |
| | | using HDL_ON.Entity; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | //var jObject = new JObject { |
| | | //{ "DeviceAddr", 11}, |
| | | //{ "Epoint", 22}, |
| | | // { "Cluster_ID", 8 }, |
| | | // { "Command", 33}, |
| | | // { "SendMode", 2 } |
| | | //}; |
| | | //var data = new JObject { |
| | | // { "Level", 1 }, |
| | | // { "TransitionTime", 0 } |
| | | //}; |
| | | //jObject.Add("Data", data); |
| | | //return revBytes; |
| | | var commandObj = function.GetSendJObject(commandType); |
| | | var commandString = Newtonsoft.Json.JsonConvert.SerializeObject(commandObj); |
| | | var commandBytes = CommonPage.MyEncodingUTF8.GetBytes(commandString); |
| | | MqttCommon.MqttRemoteSend(commandBytes); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if(busSceneData.Key == function.sid) |
| | | { |
| | | switch(function.functionType) |
| | | switch (function.functionType) |
| | | { |
| | | case FunctionType.Curtain: |
| | | ControlBytesSend(Command.SetCurtainModelStutas, function.bus_Data.SubnetID, function.bus_Data.DeviceID, busSceneData.Value); |
| | |
| | | case FunctionType.RGB: |
| | | ControlBytesSend(Command.SetLogicLoopColor, function.bus_Data.SubnetID, function.bus_Data.DeviceID, busSceneData.Value); |
| | | break; |
| | | case FunctionType.FloorHeating: |
| | | var fh = function as FloorHeating; |
| | | if (fh.modeTemp.Count == 4) |
| | | { |
| | | byte b1 = fh.on_off == "on" ? (byte)1 : (byte)0; |
| | | if (fh.workMode > 0) |
| | | { |
| | | b1 += (byte)(16 + fh.workMode); |
| | | } |
| | | ControlBytesSend(Command.SetFloorHeat, function.bus_Data.SubnetID, function.bus_Data.DeviceID, new byte[] { fh.bus_Data.LoopID, b1, (byte)fh.curTempType, fh.curModeIndex, fh.modeTemp["ordinary"], fh.modeTemp["day"], fh.modeTemp["night"], fh.modeTemp["away"], 0, 0 }); |
| | | } |
| | | break; |
| | | case FunctionType.Socket: |
| | | var s = function as SwitchSocket; |
| | | ControlBytesSend(Command.SetSingleLight, function.bus_Data.SubnetID, function.bus_Data.DeviceID, new byte[] { s.bus_Data.LoopID, s.on_off == "on" ? (byte)100 : (byte)0 }); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <returns></returns> |
| | | static void ControlBusData(Function function, CommandType_A command) |
| | | { |
| | | //反馈: |
| | | //{ |
| | | //"Namespace": "HDL", "Command": "writeRespone", |
| | | //“Type”:”device”, "objects": [{ |
| | | //"sid": "0001002019101209000025670100010001”, "statue": "success” |
| | | //}] } |
| | | try |
| | | { |
| | | var subnetId = function.bus_Data.SubnetID; |
| | | var deviceId = function.bus_Data.DeviceID; |
| | | var loopId = function.bus_Data.LoopID; |
| | | |
| | | //var jobj = JObject.FromObject(commandString.GetValue("objects")); |
| | | //var functionType = jobj.GetValue("sid").ToString().Substring(22, 2);//截取24,25字符获取控制的设备的类型 |
| | | switch (command) |
| | | { |
| | | case CommandType_A.write: |