| | |
| | | } |
| | | else |
| | | { |
| | | ////远程通讯 |
| | | //if (Ins.GatewayOnline_Local == false && Ins.GatewayOnline_Cloud == true) |
| | | //{ |
| | | // DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest(); |
| | | // //ALink控制、Bus控制使用同一个接口控制,由云端负责解析 |
| | | // var apiControlData = function.GetApiControlData(commandDictionary); |
| | | // var actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | // actionObjs.Add(apiControlData); |
| | | // var pack = httpServer.ControlDevice(actionObjs); |
| | | //} |
| | | //本地通讯 |
| | | if (Ins.GatewayOnline_Local) |
| | | { |
| | |
| | | } |
| | | |
| | | var count = 0; |
| | | var logString = open ? "打开\r\n" : "关闭\r\n"; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, open ? "on" : "off"); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | foreach (var temp in functions) |
| | | //一端口全开全关需要延时发送 |
| | | if (DB_ResidenceData.Instance.GatewayType == 0) |
| | | { |
| | | logString += temp.spk + ":" + temp.sid + "\r\n"; |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | MainPage.Log(logString); |
| | | logString = ""; |
| | | } |
| | | foreach (var temp in functions) |
| | | { |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | var result = pm.ControlDevice(new List<ApiAlinkControlActionObj>() { apiControlData }); |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | MainPage.Log(logString); |
| | | else |
| | | { |
| | | foreach (var temp in functions) |
| | | { |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | } |
| | | } |
| | | |
| | | public void SendApiReadCommand(List<string> functionIds) |