| | |
| | | /// </summary> |
| | | public void ControlBusScenes(Scene scene) |
| | | { |
| | | if (Control.Ins.IsRemote) |
| | | { |
| | | foreach (var f in scene.functions) |
| | | { |
| | | var count = 0; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | foreach (var temp in f.status) |
| | | { |
| | | if (f.localFunction == null) |
| | | { |
| | | continue; |
| | | } |
| | | d.Add(temp.key, temp.value); |
| | | var apiControlData = f.localFunction.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | } |
| | | } |
| | | else |
| | | if(Control.Ins.GatewayOnline_Local) |
| | | { |
| | | foreach (var f in scene.functions) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | foreach (var f in scene.functions) |
| | | { |
| | | var count = 0; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | foreach (var temp in f.status) |
| | | { |
| | | if (f.localFunction == null) |
| | | { |
| | | continue; |
| | | } |
| | | d.Add(temp.key, temp.value); |
| | | var apiControlData = f.localFunction.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | var light = function as Light; |
| | | switch (light.spk) |
| | | { |
| | | case SPK.LightCCT: |
| | | byte b0 = 100;//开关操作依据on_off字段,实际开关值依据brightness,当on_off为打开,brightness不能为0 |
| | | if (light.trait_on_off.curValue.ToString() == "off") |
| | | { |
| | | b0 = 0; |
| | | } |
| | | else |
| | | { |
| | | b0 = (byte)light.brightness == 0 ? (byte)100 : (byte)light.brightness; |
| | | } |
| | | var bytes0 = new byte[] { function.bus.LoopId, |
| | | b0, |
| | | 254, 0,Convert.ToByte(light.fadeTime) ,2, |
| | | (byte)((int)light.Attr_CCT.curValue/256),(byte)((int)light.Attr_CCT.curValue%256), |
| | | (byte)light.BlueColor, |
| | | 0,0}; |
| | | ControlBytesSend(Command.SetLogicLoopColor, subnetId, deviceId, bytes0, 1); |
| | | break; |
| | | case SPK.LightRGB: |
| | | MainPage.Log($"rgb level : {light.brightness}"); |
| | | byte b = 100;//开关操作依据on_off字段,实际开关值依据brightness,当on_off为打开,brightness不能为0 |
| | | if (light.trait_on_off.curValue.ToString() == "off") |
| | | { |
| | |
| | | ControlBytesSend(Command.ReadLightAllLoopBrightness, subnetId, deviceId, new byte[] { }); |
| | | break; |
| | | case SPK.LightRGB: |
| | | ControlBytesSend(Command.ReadLogicLoopColor, subnetId, deviceId, new byte[] { function.bus.LoopId}); |
| | | break; |
| | | case SPK.LightCCT: |
| | | ControlBytesSend(Command.ReadLogicLoopColor, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |