JLChen
2021-08-21 af9c3e0b3b1eb370e966b3ca9db3f62848d4189b
HDL_ON/DAL/DriverLayer/Control.cs
@@ -26,7 +26,6 @@
    public class Control
    {
       
        static Control _control;
        public static Control Ins
        {
@@ -323,6 +322,15 @@
                }
            }
        }
        /// <summary>
        /// 安防控制
        /// </summary>
        public void ControlArm()
        {
            DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
            //var pack = httpServer.GetSecurityAlarmLogList
        }
        /// <summary>
        /// 发送命令
@@ -357,15 +365,6 @@
                            commandDictionary[FunctionAttributeKey.Brightness] = "0";
                        }
                    }
                }
            }
            //Bug修复:一端口远程控制调光设备的调光属性时,无法控制到0,反复横跳。
            //因为On + 远程控制发送给云端使用的是link协议数据,杨涛中转给高胜处理时候逻辑上有冲突,导致无法单独控制亮度值,需要同时发送开关值与亮度值。
            if (DB_ResidenceData.Instance.GatewayType == 0)
            {
                if(commandDictionary.Count == 1 && commandDictionary.ContainsKey(FunctionAttributeKey.Brightness))
                {
                    commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on");
                }
            }
@@ -443,6 +442,25 @@
                //远程通讯
                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);
@@ -604,6 +622,39 @@
        }
        /// <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);
            }
        }
        /// <summary>
        /// a协议控制场景
        /// </summary>
        /// <param name="scene"></param>
@@ -695,8 +746,9 @@
                //}
                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)
                    {
@@ -726,6 +778,14 @@
                {
                    //TODO 暂时不传正确的数据上去,如果后面要优化前面这些代码
                    UpdataFunctionStatus(receiveObj.BodyDataString, null);
                }
                else if (receiveObj.Topic == CommunicationTopic.ct.ControlSeurity +"_reply")
                {
                    var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(receiveObj.BodyDataString);
                    if (temp != null)
                    {
                        Control_Udp.ReceiveRepeatManager(temp.id, null);
                    }
                }
                else
                {
@@ -912,6 +972,8 @@
                                EnvironmentalPage.LoadEvent_UpdataStatus(localFunction);
                                break;
                            case SPK.SensorEnvironment:
                            case SPK.SensorEnvironment2:
                            case SPK.SensorEnvironment3:
                                if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Temperature))
                                {
                                    HomePage.LoadEvent_RefreshEnvirIndoorTemp();