黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
ZigbeeApp/Shared/Phone/Common/Logic/HdlDevicePanelLogic.cs
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace Shared.Phone.UserCenter
namespace Shared.Phone
{
    /// <summary>
    /// 干接点的逻辑
@@ -65,7 +65,7 @@
            Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
            var result = this.GetPanelColorInfoAsync(panel, keyNum);
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -93,7 +93,7 @@
            Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
            var result = this.GetPanelColorInfoAsync(panel, keyNum);
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -119,7 +119,7 @@
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //这里特殊,这里是按回路分的
                return TemplateData.TemplateDeviceDataLogic.Current.GetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyNum);
                return HdlTemplateDeviceDataLogic.Current.GetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyNum);
            }
            //发送数据 keyNum转为16进制 范围:01~10
            var passData = "0504040101" + Convert.ToString((int)keyNum, 16).ToUpper().PadLeft(2, '0');
@@ -217,7 +217,7 @@
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //这个也是特殊,按回路来分
                return TemplateData.TemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, null);
                return HdlTemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, null);
            }
            //获取配置按键指示灯颜色的命令字符
            var sendData = this.GetPanelColorCommandText(device.DeviceAddr, keyColorData, keyNumStatus);
@@ -232,7 +232,7 @@
            tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
            //添加缓存
            TemplateData.TemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, result.JsonData[0]);
            return new CommonDevice.ResponseAllData { responseData = tempD };
        }
@@ -392,7 +392,7 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.GetDeviceLightSettion(device.DeviceAddr, 200);
                return HdlTemplateDeviceDataLogic.Current.GetDeviceLightSettion(device.DeviceAddr, 200);
            }
            //获取发送的命令字符
            var passData = "050604010101";
@@ -428,7 +428,7 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, null);
                return HdlTemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, null);
            }
            //获取修改面板的亮度调节的命令字符
            var sendData = this.GetPanelLevelCommadText(device.DeviceAddr, directionsLevel, backlightLevel);
@@ -443,7 +443,7 @@
                //设置亮度调节失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
@@ -462,7 +462,7 @@
            }
            //修改缓存
            TemplateData.TemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, result.JsonData[0]);
            return true;
        }
@@ -550,7 +550,7 @@
            var result = await panel.GetProximitySensorAsync();
            panel = null;
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -585,7 +585,7 @@
            panel = null;
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -597,7 +597,7 @@
                //接近传感配置失败
                string msg = Language.StringByID(R.MyInternationalizationString.SetPannelProximityFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
@@ -627,7 +627,7 @@
            panel = null;
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -639,7 +639,7 @@
                //矫正温度失败
                string msg = Language.StringByID(R.MyInternationalizationString.DataCorrectionFailed);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
@@ -659,7 +659,7 @@
            //如果当前住宅是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.GetDeviceEnergyConservationMode(device.DeviceAddr, 200);
                return HdlTemplateDeviceDataLogic.Current.GetDeviceEnergyConservationMode(device.DeviceAddr, 200);
            }
            //发送命令
            string passData = "050804010101";
@@ -678,7 +678,7 @@
                //获取按键面板节能模式信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelEnergyConservationInfoFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return null;
@@ -725,7 +725,7 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, null);
                return HdlTemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, null);
            }
            //获取设置设备的节能模式的命令字符
            var sendData = this.GetDeviceEnergyConservationModeCommandText(device.DeviceAddr, modeEnable, modeTime, level);
@@ -740,7 +740,7 @@
                //节能模式配置失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowTipMsg(msg);
                return false;
@@ -755,7 +755,7 @@
            }
            //修改缓存
            TemplateData.TemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, result.JsonData[0]);
            return true;
        }
@@ -863,7 +863,7 @@
            var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(device);
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -875,7 +875,7 @@
                //获取设备配置信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceConfigureInfoFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return null;
@@ -918,7 +918,7 @@
        /// <returns></returns>
        public async Task<List<int>> GetDryContactFunction(Panel panel, int level1 = -1, int level2 = -1, bool reLevel3 = false)
        {
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(panel);
            if (dicDryContactFunction.ContainsKey(mainkeys) == false)
            {
                //创建对象
@@ -995,7 +995,7 @@
        {
            var result = await panel.GetPanelPrivateFunctionsAsync(parameter);
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -1007,7 +1007,7 @@
                //获取按键功能类信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelFunctionInfoFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return null;
@@ -1031,7 +1031,7 @@
        {
            var result = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(panel, (Panel.KeyMode)i_value);
            //共通错误检测
            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
            string error = HdlCheckLogic.Current.CheckGatewayErrorCode(result);
            if (error != null)
            {
                this.ShowErrorMsg(error);
@@ -1043,7 +1043,7 @@
                //设备属性变更失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeChangedFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return false;
@@ -1096,7 +1096,7 @@
            //如果是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.GetPanelVibrationInfo(device.DeviceAddr, 200);
                return HdlTemplateDeviceDataLogic.Current.GetPanelVibrationInfo(device.DeviceAddr, 200);
            }
            //发送数据
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
@@ -1108,7 +1108,7 @@
            {
                //获取震动反馈配置信息失败
                string errorMsg = Language.StringByID(R.MyInternationalizationString.uGetVibrationFeedbackSettionFail);
                errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
                errorMsg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
                this.ShowTipMsg(errorMsg);
                return null;
            }
@@ -1131,7 +1131,7 @@
            //如果是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, null);
                return HdlTemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, null);
            }
            //获取编辑面板震动功能的命令字符
            var sendData = this.GetPanelVibrationCommandText(device.DeviceAddr, datainfo);
@@ -1140,12 +1140,12 @@
            {
                //设置震动反馈配置信息失败
                string errorMsg = Language.StringByID(R.MyInternationalizationString.uSetVibrationFeedbackSettionFail);
                errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
                errorMsg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
                this.ShowTipMsg(errorMsg);
                return false;
            }
            //添加缓存
            TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, result.JsonData[0]);
            HdlTemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, result.JsonData[0]);
            return true;
        }
@@ -1204,7 +1204,7 @@
        /// <returns></returns>
        private List<int> GetDryContactFunctionFromLocation(Panel panel, int level1 = -1, int level2 = -1)
        {
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(panel);
            if (dicDryContactFunction.ContainsKey(mainkeys) == false)
            {
                return null;
@@ -1254,7 +1254,7 @@
        /// <param name="level2"></param>
        private void SetDryContactFunctionToMemory(Panel panel, List<int> listLevel, int level1, int level2)
        {
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(panel);
            if (dicDryContactFunction.ContainsKey(mainkeys) == false)
            {
                //创建对象
@@ -1300,7 +1300,7 @@
        /// </summary>
        private void SaveDryContactFunctionToLocaltion()
        {
            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DryContactFunctionFile, dicDryContactFunction);
            HdlFileLogic.Current.SaveFileContent(HdlFileNameResourse.DryContactFunctionFile, dicDryContactFunction);
        }
        /// <summary>
@@ -1309,7 +1309,7 @@
        private void LoadDryContactFunctionFromLocaltion()
        {
            this.dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
            byte[] filebyte = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.DryContactFunctionFile);
            byte[] filebyte = HdlFileLogic.Current.ReadFileByteContent(HdlFileNameResourse.DryContactFunctionFile);
            if (filebyte == null)
            {
                return;