コード例 #1
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            //while (true)
            {
                DEVICE_STATUS st = new DEVICE_STATUS();

                if (HighLevelInterface.CheckStatus(tbIpAddress.Text, ref st) == Result.OK)
                {
                    lbConnect.Text   = st.IsConnected ? "CONNECTED" : "LISTENING";
                    lbElapsed.Text   = st.GetElapsedTime().ToString();
                    lbKeepAlive.Text = st.IsKeepAlive ? "ON" : "OFF";
                    lbPower.Text     = st.IsPowerOn ? "ON" : "OFF";
                    lbReset.Text     = st.IsErrorReset ? "ON" : "OFF";
                    lbCrcFilter.Text = st.IsCRCFilter ? "ON" : "OFF";
                    tsStatus.Text    = "CheckStatus OK!";
                }
                else
                {
                    lbConnect.Text   = "UNKNOWN";
                    lbElapsed.Text   = "UNKNOWN";
                    lbKeepAlive.Text = "UNKNOWN";
                    lbPower.Text     = "UNKNOWN";
                    lbReset.Text     = "UNKNOWN";
                    lbCrcFilter.Text = "UNKNOWN";
                    tsStatus.Text    = "CheckStatus Failed!";
                }
                bool gpi0 = false, gpi1 = false;
                if (HighLevelInterface.GetGPIStatus(tbIpAddress.Text, ref gpi0, ref gpi1) == Result.OK)
                {
                    lbGPI0.Text   = gpi0 ? "ON" : "OFF";
                    lbGPI1.Text   = gpi1 ? "ON" : "OFF";
                    tsStatus.Text = "CheckGPI1Status OK!";
                }
                else
                {
                    lbGPI0.Text   = "UNKNOWN";
                    lbGPI1.Text   = "UNKNOWN";
                    tsStatus.Text = "CheckGPI1Status Failed!";
                }
                if (HighLevelInterface.GetGPOStatus(tbIpAddress.Text, ref gpi0, ref gpi1) == Result.OK)
                {
                    lbGPO0.Text   = gpi0 ? "ON" : "OFF";
                    lbGPO1.Text   = gpi1 ? "ON" : "OFF";
                    tsStatus.Text = "CheckGPI1Status OK!";
                }
                else
                {
                    lbGPO0.Text   = "UNKNOWN";
                    lbGPO1.Text   = "UNKNOWN";
                    tsStatus.Text = "CheckGPI1Status Failed!";
                }
                GPIOTrigger gpi0Trigger = GPIOTrigger.OFF, gpi1Trigger = GPIOTrigger.OFF;
                if (HighLevelInterface.GetGPIInterrupt(tbIpAddress.Text, ref gpi0Trigger, ref gpi1Trigger) == Result.OK)
                {
                    lbGPI0Interrupt.Text = gpi0Trigger.ToString();
                    lbGPI1Interrupt.Text = gpi1Trigger.ToString();
                    tsStatus.Text        = "GetGPIInterrupt OK!";
                }
                else
                {
                    lbGPI0Interrupt.Text = "UNKNOWN";
                    lbGPI1Interrupt.Text = "UNKNOWN";
                    tsStatus.Text        = "GetGPIInterrupt Failed!";
                }
                Application.DoEvents();
                System.Threading.Thread.Sleep(1);
            }
        }