xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI2/FuntionControlView/Electrical/AirSwitchPage.cs
@@ -34,6 +34,13 @@
        /// 开关按钮
        /// </summary>
        Button btnSwitch;
        /// <summary>
        /// 运行状态-动态加载
        /// </summary>
        Button btnRunStatus;
        #endregion
        #region 区域变量
@@ -74,7 +81,6 @@
                btnFromFloor_Out = btnFromFloorOut;
            }
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            //new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.Lights), function);
            controlView = new FrameLayout()
            {
@@ -136,6 +142,62 @@
            };
            controlView.AddChidren(btnSwitchIcon);
            //运行状态
            if(function.GetAttribute("run_status")!= null)
            {
                btnRunStatus = new Button()
                {
                    Y = Application.GetRealHeight(300),
                    Height = Application.GetRealHeight(58),
                    TextAlignment = TextAlignment.Center,
                    TextSize = CSS_FontSize.TextFontSize,
                };
                //controlView.AddChidren(btnRunStatus); //状态无法测试,暂时隐藏--2021-10-14 13:58:48 董泽斌
                UpdataRunStatus();
            }
            if (function.GetAttribute("power")!= null)
            {
                Button btnEnergyIcon = new Button()
                {
                    Y = Application.GetRealHeight(377),
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(32),
                    Height = Application.GetRealWidth(32),
                    UnSelectedImagePath = "FunctionIcon/Electrical/AirSwitch/EnergyIcon.png"
                };
                controlView.AddChidren(btnEnergyIcon);
                Button btnEnergyText = new Button()
                {
                    Y = Application.GetRealHeight(400),
                    Gravity = Gravity.CenterHorizontal,
                    Height = Application.GetRealWidth(47),
                    TextAlignment = TextAlignment.Center,
                    TextID = StringId.EnergyMonitoring,
                    TextColor = CSS_Color.TextualColor,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                };
                controlView.AddChidren(btnEnergyText);
                EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                    var skipView = new EnergyMainPage();
                    MainPage.BasePageView.AddChidren(skipView);
                    skipView.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                btnEnergyIcon.MouseUpEventHandler = eventHandler;
                btnEnergyText.MouseUpEventHandler = eventHandler;
            }
            btnSwitch = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
@@ -148,7 +210,7 @@
            };
            controlView.AddChidren(btnSwitch);
            new TopViewDiv(bodyView, Language.StringByID(StringId.Electric)).LoadTopView_FunctionTop(function, actionRefresh);
            new TopViewDiv(bodyView, Language.StringByID(StringId.Electric)).LoadTopView_FunctionTop(function, actionRefresh,false);
            new System.Threading.Thread(() =>
            {
                DriverLayer.Control.Ins.SendReadCommand(function);
@@ -176,6 +238,11 @@
                    if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
                    {
                        bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
                        if (updataTemp.GetAttribute("run_status") != null)
                        {
                            bodyView.UpdataRunStatus();
                        }
                    }
                }
                catch (Exception ex)
@@ -185,6 +252,138 @@
            });
        }
        /// <summary>
        /// 更新运行状态
        /// </summary>
        void UpdataRunStatus()
        {
            if (btnRunStatus == null)
                return;
            var runStatus = function.GetAttrState("run_status");
            if (Language.CurrentLanguage == "Chinese")
            {
                switch (runStatus)
                {
                    //* RUN:正常工作中
                    case "RUN":
                        btnRunStatus.Text = "工作中";
                        btnRunStatus.TextColor = CSS_Color.MainColor;
                        break;
                    //* HV:过压预警
                    case "HV":
                        btnRunStatus.Text = "过压预警";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* LV:欠压预警
                    case "LV":
                        btnRunStatus.Text = "欠压预警";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* HC:过流预警
                    case "HC":
                        btnRunStatus.Text = "过流预警";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* HT:过温预警
                    case "HT":
                        btnRunStatus.Text = "过温预警";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* LEAK:漏电预警
                    case "LEAK":
                        btnRunStatus.Text = "漏电预警";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* ERR_HV:过压报警
                    case "ERR_HV":
                        btnRunStatus.Text = "过压报警";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_LV:欠压报警
                    case "ERR_LV":
                        btnRunStatus.Text = "欠压报警";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_HC:过流报警
                    case "ERR_HC":
                        btnRunStatus.Text = "过流报警";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_HT:过温报警
                    case "ERR_HT":
                        btnRunStatus.Text = "过温报警";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_LEAK:漏电报警
                    case "ERR_LEAK":
                        btnRunStatus.Text = "漏电报警";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                }
            }
            else
            {
                switch (runStatus)
                {
                    //* RUN:正常工作中
                    case "RUN":
                        btnRunStatus.Text = "At work";
                        btnRunStatus.TextColor = CSS_Color.MainColor;
                        break;
                    //* HV:过压预警
                    case "HV":
                        btnRunStatus.Text = "Overvoltage warning";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* LV:欠压预警
                    case "LV":
                        btnRunStatus.Text = "Undervoltage warning";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* HC:过流预警
                    case "HC":
                        btnRunStatus.Text = "Overcurrent warning";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* HT:过温预警
                    case "HT":
                        btnRunStatus.Text = "Overtemperature warning";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* LEAK:漏电预警
                    case "LEAK":
                        btnRunStatus.Text = "Leakage warning";
                        btnRunStatus.TextColor = 0xFFFC9C04;
                        break;
                    //* ERR_HV:过压报警
                    case "ERR_HV":
                        btnRunStatus.Text = "Overvoltage alarm";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_LV:欠压报警
                    case "ERR_LV":
                        btnRunStatus.Text = "Undervoltage alarm";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_HC:过流报警
                    case "ERR_HC":
                        btnRunStatus.Text = "Overcurrent alarm";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_HT:过温报警
                    case "ERR_HT":
                        btnRunStatus.Text = "Overtemperature alarm";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                    //* ERR_LEAK:漏电报警
                    case "ERR_LEAK":
                        btnRunStatus.Text = "Leakage alarm";
                        btnRunStatus.TextColor = 0xFFFF8080;
                        break;
                }
            }
        }
        /// <summary>
        /// 加载事件列表
        /// </summary>
        void LoadEventList()