예제 #1
0
        /// <summary>
        /// Refresh the Status
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStatus_Click(object sender, EventArgs e)
        {
            if (_con.IsConnected)
            {
                uint status = 0;

                if (_con.ReadModbusRegisterUInt32(0x0001, ref status))
                {
                    byte[] byteStatus = BitConverter.GetBytes(status);
                    //Update the Status - see [5815,0000 table 3]
                    laBoomAngle.Text = byteStatus[3].ToString(CultureInfo.InvariantCulture) + "°";
                    if ((byteStatus[2] & 0x80) == 0x80)
                    {
                        laStatus.Text = "Boom in position open";
                    }
                    else if ((byteStatus[2] & 0x10) == 0x10)
                    {
                        laStatus.Text = "Boom in position closed";
                    }
                    else
                    {
                        laStatus.Text = String.Empty;
                    }
                }
            }
        }
        public static string BoomBarriorStstus(string BoomBarrierIP, cMGCConnector _con)
        {
            string Boomstatus = "";

            if (BoomBarriorConnection(BoomBarrierIP, _con) == "Conneted")
            {
                if (_con.IsConnected)
                {
                    uint status = 0;

                    if (_con.ReadModbusRegisterUInt32(0x0001, ref status))
                    {
                        byte[] byteStatus = BitConverter.GetBytes(status);
                        //Update the Status - see [5815,0000 table 3]
                        //laBoomAngle.Text = byteStatus[3].ToString(CultureInfo.InvariantCulture) + "°";
                        if ((byteStatus[2] & 0x80) == 0x80)
                        {
                            Boomstatus = "Boom in position open";
                        }
                        else if ((byteStatus[2] & 0x10) == 0x10)
                        {
                            Boomstatus = "Boom in position closed";
                        }
                        else
                        {
                            Boomstatus = String.Empty;
                        }
                    }
                    string closeConnection = BoomBarriorConnection(BoomBarrierIP, _con);
                }
            }
            else
            {
                Boomstatus = "BoomBarrier Not Connected";
            }
            return(Boomstatus);
        }