public void Execute(IJobExecutionContext context)
        {
            var driver = new Rs485Driver();

            driver.InstallRelayOutputState(context.JobDetail.JobDataMap.GetIntValue("start"), false);
            driver.Disconnect();
        }
        public void Execute(IJobExecutionContext context)
        {
            var driver = new Rs485Driver();

            driver.InstallRelayOutputState(context.JobDetail.JobDataMap.GetIntValue("address"), true);
            Thread.Sleep(5000);
            driver.InstallRelayOutputState(context.JobDetail.JobDataMap.GetIntValue("start"), true);
            driver.Disconnect();
        }
        /// <summary>
        /// 同步设置电器开关
        /// </summary>
        /// <param name="address"></param>
        /// <param name="state"></param>
        public void ControllerHomeAutomation(int address, bool state)
        {
            var driver = new Rs485Driver();

            try
            {
                driver.Connect(new NetArg("192.168.0.233", 10001));
            }
            catch (Exception e)
            {
                MessageBox.Show($"连接不上设备", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            switch (address)
            {
            case 0:
                if (state)
                {
                    driver.InstallRelayOutputState(0, true);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(13, true);
                }
                else
                {
                    driver.InstallRelayOutputState(13, false);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(0, false);
                }
                break;

            case 6:
                if (state)
                {
                    driver.InstallRelayOutputState(6, true);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(18, true);
                }
                else
                {
                    driver.InstallRelayOutputState(18, false);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(6, false);
                }
                break;

            case 10:
                if (state)
                {
                    driver.InstallRelayOutputState(10, true);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(17, true);
                }
                else
                {
                    driver.InstallRelayOutputState(17, false);
                    Thread.Sleep(10000);
                    driver.InstallRelayOutputState(10, false);
                }
                break;

            case 5:
                if (state)
                {
                    driver.InstallRelayOutputState(5, true);
                    Thread.Sleep(8000);
                    driver.InstallRelayOutputState(15, true);
                    Thread.Sleep(500);
                    driver.InstallRelayOutputState(15, false);
                    Thread.Sleep(1500);
                    driver.InstallRelayOutputState(14, true);
                }
                else
                {
                    driver.InstallRelayOutputState(14, false);
                    driver.InstallRelayOutputState(5, false);
                }
                break;

            default: driver.InstallRelayOutputState(address, state); break;
            }
        }