| | |
| | | public class Control |
| | | { |
| | | |
| | | |
| | | static Control _control; |
| | | public static Control Ins |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 安防控制 |
| | | /// </summary> |
| | | public void ControlArm() |
| | | { |
| | | DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest(); |
| | | //var pack = httpServer.GetSecurityAlarmLogList |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 发送命令 |
| | |
| | | //远程通讯 |
| | | else |
| | | { |
| | | //Bug修复:一端口远程控制调光设备的调光属性时,无法控制到0,反复横跳。 |
| | | //因为On + 远程控制发送给云端使用的是link协议数据,杨涛中转给高胜处理时候逻辑上有冲突,导致无法单独控制亮度值,需要同时发送开关值与亮度值。 |
| | | if (DB_ResidenceData.Instance.GatewayType == 0) |
| | | { |
| | | if (commandDictionary.Count == 1) |
| | | { |
| | | if (commandDictionary.ContainsKey(FunctionAttributeKey.Brightness)) |
| | | { |
| | | commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on"); |
| | | } |
| | | } |
| | | if(function.spk == SPK.LightCCT) |
| | | { |
| | | if (!commandDictionary.ContainsKey(FunctionAttributeKey.CCT)) |
| | | { |
| | | commandDictionary.Add(FunctionAttributeKey.CCT, function.GetAttrState(FunctionAttributeKey.CCT)); |
| | | } |
| | | } |
| | | } |
| | | DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest(); |
| | | //ALink控制、Bus控制使用同一个接口控制,由云端负责解析 |
| | | var apiControlData = function.GetApiControlData(commandDictionary); |
| | |
| | | } |
| | | |
| | | 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) |
| | |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 安防控制 |
| | | /// </summary> |
| | | public void ControlSecurity(SecurityAlarm securityAlarm,string state) |
| | | { |
| | | if (!Ins.GatewayOnline_Local)//网关本地不在线 |
| | | { |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var result = pm.SetSecurityStatus(new List<SecurityState>() { new SecurityState() { |
| | | gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId, |
| | | sid = securityAlarm.sid, status = state, userSecurityId = securityAlarm.userSecurityId |
| | | } }); |
| | | } |
| | | else |
| | | { |
| | | Dictionary<string, string> keys = new Dictionary<string, string>(); |
| | | keys.Add("sid", securityAlarm.sid); |
| | | keys.Add("status", state); |
| | | var aLinkData = new AlinkReadFunctionStatusObj() |
| | | { |
| | | id = Ins.msg_id.ToString(), |
| | | objects = new List<Dictionary<string, string>>() |
| | | { |
| | | keys |
| | | }, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlSeurity, aLinkJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id); |
| | | } |
| | | } |
| | | |
| | |
| | | //} |
| | | receiveObj.BodyDataString = res[1]; |
| | | |
| | | if (receiveObj.Topic == CommunicationTopic.SearchLoaclGatewayReply) |
| | | if (receiveObj.Topic == CommunicationTopic.SearchLoaclGatewayReply || receiveObj.Topic == CommunicationTopic.GatewayBroadcast) |
| | | { |
| | | |
| | | var bodyJObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]); |
| | | if (bodyJObj == null) |
| | | { |
| | |
| | | { |
| | | //TODO 暂时不传正确的数据上去,如果后面要优化前面这些代码 |
| | | UpdataFunctionStatus(receiveObj.BodyDataString, null); |
| | | } |
| | | else if (receiveObj.Topic == CommunicationTopic.ct.ControlSeurity +"_reply" |
| | | || receiveObj.Topic == CommunicationTopic.ct.ReadSecurityStatus + "_reply" |
| | | || receiveObj.Topic == CommunicationTopic.ct.SecurityStatusUp) |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityStatusObj>(receiveObj.BodyDataString); |
| | | if (temp != null) |
| | | { |
| | | Control_Udp.ReceiveRepeatManager(temp.id, null); |
| | | foreach (var updataSecurity in temp.objects) |
| | | { |
| | | var updataLocalSecurity = FunctionList.List.securities.Find((obj) => obj.sid == updataSecurity.sid); |
| | | if (updataLocalSecurity != null) |
| | | { |
| | | updataLocalSecurity.status = updataSecurity.status; |
| | | } |
| | | } |
| | | HomePage.LoadEvent_RefreshSecurityStatus(); |
| | | ArmCenterPage.LoadEvent_RefreshSecurityStatus(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.SensorEnvironment: |
| | | case SPK.SensorEnvironment2: |
| | | case SPK.SensorEnvironment3: |
| | | if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Temperature)) |
| | | { |
| | | HomePage.LoadEvent_RefreshEnvirIndoorTemp(); |
| | | } |
| | | if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Humidity)) |
| | | { |
| | | HomePage.LoadEvent_RefreshEnvirIndoorHumi(); |
| | | } |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | SocketPage.UpdataState(localFunction); |
| | | break; |