コード例 #1
0
        public ActiveHomeDeviceStatus Query_PLC(string address)
        {
            if (string.IsNullOrEmpty(address))
            {
                return(ActiveHomeDeviceStatus.DISCONNECTED);
            }

            ActiveHomeDeviceStatus status = ActiveHomeDeviceStatus.DISCONNECTED;

            try
            {
                string strAction = "QUERYPLC";
                string command   = "On";
                string strData   = address + " " + command;

                object Code        = mActiveHome.SendAction(strAction, strData, null, null);
                int    status_code = (int)Code;
                if (status_code == 0)
                {
                    status = ActiveHomeDeviceStatus.OFF;
                }
                else if (status_code == 1)
                {
                    status = ActiveHomeDeviceStatus.ON;
                }
            }
            catch
            {
            }
            return(status);
        }
コード例 #2
0
        private void btnCheckStatus_Click(object sender, EventArgs e)
        {
            string address = txtLampAddress.Text;
            ActiveHomeDeviceStatus status_code = ActiveHomeController.Instance.Query_PLC(address);

            if (status_code == ActiveHomeDeviceStatus.OFF)
            {
                StatusTextBox.AppendText(address + " is OFF\r\n");
            }
            else if (status_code == ActiveHomeDeviceStatus.ON)
            {
                StatusTextBox.AppendText(address + " is ON\r\n");
            }
        }