Example #1
0
        //****************************************//
        //              Buttons Test              //
        //****************************************//
        /// <summary>
        /// I2C Command 2 test;
        /// Test "Left button down", "Right button down", "Buttons release" functions;
        /// </summary>
        public void I2CSwitchTest()
        {
            byte I2CCommand = 0x02;
            byte I2CAddress = DeviceConfig.Items.I2C_ADDRESS;
            byte nToRead    = 5;

            byte[,] RcvDataCH1, RcvDataCH2;

            TestMode_GPIO_Down();
            PowerON();

            try
            {
                //Button Release
                m_Agilent.SetChannel("202", 0x0);
                m_Agilent.SetChannel("204", 0x0);


                //Set Left Button Down
                m_Agilent.SetChannel("202", 0xFF);
                m_Agilent.SetChannel("204", 0x0);


                m_MPQ.Address = MPQ_ADDRESS1;
                m_MPQ.I2CInit(DUT14_PortEnables, MPQ_IO_VOLTAGE, MPQ_POLARITY);
                System.Threading.Thread.Sleep(MPQ_DELAY);
                m_MPQ.I2CRun(I2CCommand, I2CAddress, nToRead, out RcvDataCH1);


                m_MPQ.Address = MPQ_ADDRESS2;
                m_MPQ.I2CInit(DUT58_PortEnalbes, MPQ_IO_VOLTAGE, MPQ_POLARITY);
                System.Threading.Thread.Sleep(MPQ_DELAY);
                m_MPQ.I2CRun(I2CCommand, I2CAddress, nToRead, out RcvDataCH2);

                for (byte port = 0; port < 4; port++)
                {
                    m_DUTArray[port].LeftButtonStatus     = RcvDataCH1[port, 4];
                    m_DUTArray[port + 4].LeftButtonStatus = RcvDataCH2[port, 4];
                }

                //Set Right Button Down
                m_Agilent.SetChannel("202", 0x0);
                m_Agilent.SetChannel("204", 0xFF);
                m_MPQ.Address = MPQ_ADDRESS1;

                System.Threading.Thread.Sleep(MPQ_DELAY);
                m_MPQ.I2CRun(I2CCommand, I2CAddress, nToRead, out RcvDataCH1);


                m_MPQ.Address = MPQ_ADDRESS2;
                System.Threading.Thread.Sleep(MPQ_DELAY);
                m_MPQ.I2CRun(I2CCommand, I2CAddress, nToRead, out RcvDataCH2);

                for (byte port = 0; port < 4; port++)
                {
                    m_DUTArray[port].RightButtonStatus     = RcvDataCH1[port, 4];
                    m_DUTArray[port + 4].RightButtonStatus = RcvDataCH2[port, 4];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //Button Release
            m_Agilent.SetChannel("202", 0x0);
            m_Agilent.SetChannel("204", 0x0);

            PowerOFF();
            //TestMode_GPIO_Up();

            foreach (DUT dut in m_DUTArray)
            {
                if (dut.LeftButtonStatus != 0x04 || dut.RightButtonStatus != 0x05) //dut.LeftButtonStatus!=0x04
                {
                    if (dut.ErrorCode == 0)
                    {
                        dut.ErrorCode = DeviceConfig.ErrorCode.ERROR_TACTILE_SWITCH;
                    }
                }
            }

            UpdateDUT_Enables();
        }