wei
2021-07-09 068c68295cad1967f7aafb4e5e951260ef03d4ce
HDL_ON/UI/UI2/FuntionControlView/Light/RelayPageBLL.cs
@@ -11,19 +11,22 @@
        /// </summary>
        public static void UpdataState(Function updataTemp)
        {
            Application.RunOnMainThread(() =>
            Application.RunOnMainThread((Action)(() =>
            {
                try
                {
                    if (bodyView == null)
                        return;
                    bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = updataTemp.trait_on_off.curValue.ToString() == "on";
                    if (updataTemp.spk == bodyView.function.spk && updataTemp.sid == bodyView.function.sid)
                    {
                        bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = updataTemp.trait_on_off.state.ToString() == "on";
                    }
                }
                catch (Exception ex)
                {
                    MainPage.Log($"RelayPage error {ex.Message}");
                }
            });
            }));
        }
        /// <summary>
        /// 加载事件列表
@@ -62,9 +65,9 @@
                btnSwitch.IsSelected = btnSwitchIcon.IsSelected = !btnSwitchIcon.IsSelected;
                new System.Threading.Thread(() =>
                {
                    function.trait_on_off.curValue = btnSwitchIcon.IsSelected ? "on" : "off";
                    function.trait_on_off.state = btnSwitchIcon.IsSelected ? "on" : "off";
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add("on_off", function.trait_on_off.curValue.ToString());
                    d.Add("on_off", function.trait_on_off.state.ToString());
                    DriverLayer.Control.Ins.SendWriteCommand(function, d);
                })
                { IsBackground = true }.Start();
@@ -74,13 +77,33 @@
                btnSwitchIcon.IsSelected = btnSwitch.IsSelected = !btnSwitch.IsSelected;
                new System.Threading.Thread(() =>
                {
                    function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    function.trait_on_off.state = btnSwitch.IsSelected ? "on" : "off";
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add("on_off", function.trait_on_off.curValue.ToString());
                    d.Add("on_off", function.trait_on_off.state.ToString());
                    DriverLayer.Control.Ins.SendWriteCommand(function, d);
                    //Control.Send(CommandType_A.write, function);
                })
                { IsBackground = true }.Start();
                //new System.Threading.Thread(() =>
                //{
                //    bool fff = false;
                //    while (true)
                //    {
                //        System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                //        if (fff)
                //        {
                //            d.Add("on_off", "off");
                //        }
                //        else
                //        {
                //            d.Add("on_off", "on");
                //        }
                //        fff = !fff;
                //        DriverLayer.Control.Ins.SendWriteCommand(function, d);
                //        //System.Threading.Thread.Sleep(100);
                //    }
                //})
                //{ IsBackground = true }.Start();
            };
        }