wxr
2024-06-18 dd01259a0590b6e6954470aa6ddb7658baa79fa7
OnPro/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using System.Linq;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
@@ -21,6 +22,10 @@
        /// </summary>
        private Button btnDelay =null;
        /// <summary>
        /// 当前设备
        /// </summary>
        private Function device;
        /// <summary>
        /// 定义一个记录选中设备状态列表;
        /// </summary>
        private List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>();
@@ -31,6 +36,7 @@
        public void Show(Entity.Function device, int index, bool edit)
        {
            #region 界面布局
            this.device = device;
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            LogicView.TopView topView = new LogicView.TopView();
            this.AddChidren(topView.FLayoutView());
@@ -42,7 +48,7 @@
            FrameLayout fLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(74),
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64),
            };
            this.AddChidren(fLayout);
@@ -56,8 +62,54 @@
            #region  编辑设备状态
            switch (device.spk)
            {
                //开关灯光
                //插座(有USB)
                case SPK.PanelSocket:
                    {
                        #region 界面
                        ///总控开关
                        LogicView.FunTypeView view1 = new LogicView.FunTypeView();
                        view1.btnText.TextID = StringId.switchLogic;
                        //view1.btnState.Name = "总控开关";
                        fLayout.AddChidren(view1.FLayoutView());
                        ///设备延时iewv
                        DelayView(fLayout, view1.frameLayout.Bottom);
                        #endregion
                        #region 点击事件
                        ///总控开关点击事件
                        view1.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, view1.btnState, 2);
                        };
                        if (edit)
                        {
                            //显示编辑之前的设备状态
                            GetEditDeviceState(device, index, view1.btnState, null, null, null);
                        }
                        #endregion
                    }
                    break;
                case SPK.CommonSeries:
                    #region 界面
                    ///开关
                    LogicView.FunTypeView SerriesSwitchView = new LogicView.FunTypeView();
                    SerriesSwitchView.btnText.TextID = StringId.switchLogic;
                    fLayout.AddChidren(SerriesSwitchView.FLayoutView());
                    #endregion
                    ///开关点击事件
                    SerriesSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                    {
                        SwitchViewMethod(device, SerriesSwitchView.btnState, 2);
                    };
                    break;
                //开关灯光
                case SPK.OtherCommon:
                case SPK.AirSwitch:
                case SPK.LightSwitch:
                case SPK.ElectricSocket:
                //机械手
                case SPK.MechanicalArm:
                    {
                        #region 界面
                        ///开关
@@ -84,8 +136,8 @@
                    break;
                //灯光开关 亮度
                case SPK.LightDimming:
                //case SPK.LightRGB:
                //case SPK.LightRGBW:
                    //case SPK.LightRGB:
                    //case SPK.LightRGBW:
                    {
                        #region 界面
                        ///开关
@@ -670,6 +722,29 @@
                                }
                            }
                            break;
                        //音乐
                        case SPK.MusicStandard:
                        case SPK.AvMusic:
                            {
                                string volume = "volume";
                                var dicObj = dicSateteList.Find((dic) => dic.ContainsValue(volume));
                                if (dicObj != null)
                                {
                                    //有配置音乐音量属性,要重新排列,音量在前面
                                    var dicList = new List<Dictionary<string, string>>();
                                    dicList.Add(dicObj);//先添加音量属性
                                    var diclist = dicSateteList.FindAll((dic) => !dic.ContainsValue(volume));
                                    dicList.AddRange(diclist);//再添加其它属性
                                    dicSateteList = dicList;//重新赋值
                                }
                            }
                            break;
                        case SPK.GroupControl:
                            {
                                outputDevice.target_type = "5";
                            }
                            break;
                    }
                    outputDevice.status.AddRange(dicSateteList);
@@ -717,7 +792,7 @@
            LogicView.FunTypeView delayView = new LogicView.FunTypeView();
            delayView.frameLayout.Y = bottomY;
            delayView.btnText.TextID = StringId.Delay;
            delayView.btnState.Text = strdelay + "s";
            delayView.btnState.Text = LogicMethod.Current.getTimeStr(strdelay);
            fLayout.AddChidren(delayView.FLayoutView());
            ///赋值对象
            this.btnDelay = delayView.btnState;
@@ -727,9 +802,9 @@
                InpOrOutLogicMethod inpOrOutLogicMethod = new InpOrOutLogicMethod();
                inpOrOutLogicMethod.Delayed(this, strdelay, (value) =>
                {
                    selectedState = "delay_" + strdelay;
                    strdelay = value.ToString();
                    delayView.btnState.Text = strdelay + "s";
                    delayView.btnState.Text = LogicMethod.Current.getTimeStr(strdelay);
                    selectedState = "delay_" + strdelay;
                });
            };
@@ -747,10 +822,10 @@
            FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
            this.AddChidren(frame);
            LogicView.SwitchView switchView = new LogicView.SwitchView();
            switchView.FLayoutView(frame, len, button.Text, (strValue) =>
            switchView.FLayoutView(frame, len, button.Text, (value) =>
            {
                int id = 0;
                switch (strValue)
                switch (value)
                {
                    case "on":
                        {
@@ -768,13 +843,45 @@
                        }
                        break;
                }
                //界面显示选中值
                button.TextID = id;
                selectedState = device.spk + "_" + strValue;
                selectedState = device.spk + "_" + value;
                //设备属性值,云雀上定义好的;
                string keyVlaue = "on_off";
                string key = "on_off";
                switch (device.spk)
                {
                    case SPK.PanelSocket:
                        {
                            //if (button.Name == "总控开关")
                            //{
                            //    key = "on_off_master";
                            //}
                        }
                        break;
                    case SPK.GroupControl:
                        {
                            if (button.Name == "colorful")
                            {
                                key = "colorful";
                            }
                        }
                        break;
                    case SPK.ElectricalTvHisense:
                        {
                            if ("on" == value)
                            {
                                key = "wol";
                            }
                        }
                        break;
                }
                //数据封装
                AddDictionary(keyVlaue, strValue);
                AddDictionary(key, value);
            });
            #endregion
        }
@@ -803,6 +910,7 @@
                    case SPK.LightRGB:
                    case SPK.LightRGBW:
                    case SPK.LightCCT:
                    case SPK.GroupControl:
                        {
                            keyVlaue = "brightness";
                        }
@@ -819,6 +927,12 @@
                            }
                        }
                        break;
                    case SPK.ElectricalTvHisense:
                        {
                            keyVlaue = "set_volume";
                        }
                        break;
                }
                //数据封装
                AddDictionary(keyVlaue, brightnesValue); 
@@ -847,6 +961,7 @@
                switch (device.spk)
                {
                    case SPK.LightCCT:
                    case SPK.GroupControl:
                        {
                            keyVlaue = "cct";
                        }
@@ -880,6 +995,7 @@
                switch (device.spk)
                {
                    case SPK.LightRGB:
                    case SPK.GroupControl:
                        {
                            keyVlaue = "rgb";
                        }
@@ -895,8 +1011,6 @@
            });
        }
        /// <summary>
@@ -923,7 +1037,7 @@
            if (this.btnDelay != null)
            {
                ///延时显示文本
                this.btnDelay.Text = outputs.delay + "s";
                this.btnDelay.Text =LogicMethod.Current.getTimeStr(outputs.delay);
                this.strdelay = outputs.delay;
            }
            InpOrOutLogicMethod.Current.EditDeviceState(device, dicList, button1, button2, button3, button4, attribute);
@@ -931,29 +1045,45 @@
        /// <summary>
        /// 添加选中数据
        /// </summary>
        /// <param name="KeyValue">设备属性值,云雀上定义好的</param>
        /// <param name="selectedValue">状态值</param>
        private void AddDictionary(string KeyValue, string selectedValue)
        /// <param name="key">设备属性值,云雀上定义好的</param>
        /// <param name="value">状态值</param>
        private void AddDictionary(string key, string value)
        {
            //数据封装
            Dictionary<string, string> dic = new Dictionary<string, string>();
            LogicMethod.Current.dictionary(dic, "key", KeyValue);
            LogicMethod.Current.dictionary(dic, "value", selectedValue);
            AddDictionaryList(KeyValue, dic);
            LogicMethod.Current.dictionary(dic, "key", key);
            LogicMethod.Current.dictionary(dic, "value", value);
            AddDictionaryList(key, dic);
        }
        /// <summary>
        /// 更新数据列表
        /// </summary>
        /// <param name="keyValue">设备属性值,云雀上定义好的</param>
        /// <param name="key">设备属性值,云雀上定义好的</param>
        /// <param name="dictionary">添加选中数据</param>
        /// <returns></returns>
        private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary)
        private void AddDictionaryList(string key, Dictionary<string, string> dictionary)
        {
            if (this.device.spk == SPK.ElectricalTvHisense)
            {
                //特殊处理
                if (key == "on_off")
                {
                    key = "wol";
                }
                else if (key == "wol")
                {
                    key = "on_off";
                }
            }
            int indexValue = -1;
            for (int i = 0; i < dicSateteList.Count; i++)
            {
                var dic = dicSateteList[i];
                if (dic.ContainsValue(keyValue))
                if (dic.ContainsValue(key))
                {
                    //判断是否存在
                    indexValue = i;
@@ -975,6 +1105,7 @@
            }
        }
        /// <summary>
        /// 添加目标
        /// </summary>