Esempio n. 1
0
        private void GetDIOStatusTimer_Tick(object sender, EventArgs e)
        {
            DIO_API.PIN_STATUS PinStatus = new DIO_API.PIN_STATUS();
            if (ReadDIPin(ref PinStatus) == false)
            {
                GetDIOStatusTimer.Enabled = false;
                MessageBox.Show("Read Pin fail!");
                return;
            }

            ShowPinStatus(PinStatus);
        }
Esempio n. 2
0
        private bool ReadDIPin(ref DIO_API.PIN_STATUS PinStatus)
        {
            UInt16 LastErrCode;

            // Read data
            lock (LockReadWrite)
            {
                LastErrCode = DIO_API.DIO_ReadDIPin(ref PinStatus);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    //MessageBox.Show("Fails to read IO");
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 3
0
        private void ShowPinStatus(DIO_API.PIN_STATUS PinStatus)
        {
            if (PinStatus.bPin0)
            {
                PicBoxDI0.Image = TREK_V3_Sample_Code_DIO.Properties.Resources.bulb_on_64x64;
            }
            else
            {
                PicBoxDI0.Image = TREK_V3_Sample_Code_DIO.Properties.Resources.bulb_off_64x64;
            }

            if (PinStatus.bPin1)
            {
                PicBoxDI1.Image = TREK_V3_Sample_Code_DIO.Properties.Resources.bulb_on_64x64;
            }
            else
            {
                PicBoxDI1.Image = TREK_V3_Sample_Code_DIO.Properties.Resources.bulb_off_64x64;
            }
        }
Esempio n. 4
0
        private bool WriteDOPin()
        {
            UInt16 LastErrCode;

            DIO_API.PIN_STATUS PinStatus = new DIO_API.PIN_STATUS();
            PinStatus.bPin0 = RadioDO0.Checked ? true : false;
            PinStatus.bPin1 = RadioDO1.Checked ? true : false;
            PinStatus.bPin2 = RadioDO2.Checked ? true : false;
            PinStatus.bPin3 = RadioDO3.Checked ? true : false;

            lock (LockReadWrite)
            {
                LastErrCode = DIO_API.DIO_WriteDOPin(ref PinStatus);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to write IO");
                    return(false);
                }
            }

            return(true);
        }