API_TestGetFrequencyConfiguration() public method

public API_TestGetFrequencyConfiguration ( byte &r_btChannelFlag, UInt32 &r_uiExactFrequecny ) : Result
r_btChannelFlag byte
r_uiExactFrequecny UInt32
return Result
Ejemplo n.º 1
0
        public RFTest(RFID_Explorer.mainForm r_form, LakeChabotReader rm_reader)
        {
            InitializeComponent();

            m_mainForm = r_form;
            m_reader   = rm_reader;

            //Initial value
            ckboxErrorKeepRunning.Checked = m_mainForm.bErrorKeepRunning;

            //Read Data from module
            m_reader.API_TestGetAntennaPortConfiguration(ref m_btPhysicalPort, ref m_usPowerLevel);
            m_reader.API_TestGetFrequencyConfiguration(ref m_btChannelFlag, ref m_uiExactFrequecny);
            m_reader.API_TestGetRandomDataPulseTime(ref m_uiPulseOnTime, ref m_uiPulseOffTime);

            //regionComboBox
            try
            {
                m_macRegion = m_reader.RegulatoryRegion;

            }
            catch (rfidReaderException exp)
            {
                cmbBoxRegion.Text = exp.Message;
            }
            cmbBoxRegion.Items.Add(m_macRegion);
            cmbBoxRegion.SelectedIndex = 0;

            //Frequency
            switch(m_macRegion)
            {
                case MacRegion.US:
                    foreach ( ENUM_RF_US item in Enum.GetValues(typeof(ENUM_RF_US)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.EU:
                    foreach ( ENUM_RF_EU item in Enum.GetValues(typeof(ENUM_RF_EU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.JP:
                    foreach ( ENUM_RF_JP item in Enum.GetValues(typeof(ENUM_RF_JP)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.EU2:
                    foreach ( ENUM_RF_EU2 item in Enum.GetValues(typeof(ENUM_RF_EU2)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.TW:
                    foreach ( ENUM_RF_TW item in Enum.GetValues(typeof(ENUM_RF_TW)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.CN:
                    foreach ( ENUM_RF_CN item in Enum.GetValues(typeof(ENUM_RF_CN)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.KR:
                    foreach ( ENUM_RF_KR item in Enum.GetValues(typeof(ENUM_RF_KR)) )
                    {
                       cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.AU:
                    foreach ( ENUM_RF_AU item in Enum.GetValues(typeof(ENUM_RF_AU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.BR:
                    foreach ( ENUM_RF_BR item in Enum.GetValues(typeof(ENUM_RF_BR)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.HK:
                    foreach ( ENUM_RF_HK item in Enum.GetValues(typeof(ENUM_RF_HK)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.MY:
                    foreach ( ENUM_RF_MY item in Enum.GetValues(typeof(ENUM_RF_MY)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.SG:
                    foreach ( ENUM_RF_SG item in Enum.GetValues(typeof(ENUM_RF_SG)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.TH:
                    foreach ( ENUM_RF_TH item in Enum.GetValues(typeof(ENUM_RF_TH)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.IL:
                    foreach ( ENUM_RF_IL item in Enum.GetValues(typeof(ENUM_RF_IL)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.RU:
                    foreach ( ENUM_RF_RU item in Enum.GetValues(typeof(ENUM_RF_RU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.IN:
                    foreach ( ENUM_RF_IN item in Enum.GetValues(typeof(ENUM_RF_IN)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.SA:
                    foreach ( ENUM_RF_SA item in Enum.GetValues(typeof(ENUM_RF_SA)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.JO:
                    foreach ( ENUM_RF_JO item in Enum.GetValues(typeof(ENUM_RF_JO)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                case MacRegion.MX:
                    foreach ( ENUM_RF_MX item in Enum.GetValues(typeof(ENUM_RF_MX)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    break;

                //clark 2011.9.13
                case MacRegion.CUSTOMER:
                    //Set cmbBoxFreq's type to Non-ReadOnly.
                    cmbBoxFreq.DropDownStyle = ComboBoxStyle.DropDown;
                    cmbBoxFreq.Items.Add( "000.000" );

                    string strCustomerRegion = "";
                    Result result = m_reader.API_MacGetCustomerRegion( ref strCustomerRegion );

                    cmbBoxRegion.Items.Clear();
                    switch(result)
                    {
                        case Result.OK:
                            //Show customer config name
                            cmbBoxRegion.Items.Add(strCustomerRegion);
                            break;

                        case Result.NOT_SUPPORTED:
                            cmbBoxRegion.Items.Add("Not support customer");
                            btnRfOn.Enabled      = false;
                            btnRfOff.Enabled     = false;
                            btnRF.Enabled = false;//btnRF Combine
                            btnInventory.Enabled = false;
                            btnPulse.Enabled     = false;
                            btnClear.Enabled     = false;
                            break;

                       case Result.FAILURE:
                       default:
                            cmbBoxRegion.Items.Add("Get customer fail");
                            btnRfOn.Enabled      = false;
                            btnRfOff.Enabled     = false;
                            btnRF.Enabled = false;//btnRF Combine
                            btnInventory.Enabled = false;
                            btnPulse.Enabled     = false;
                            btnClear.Enabled     = false;
                            break;
                    }
                    cmbBoxRegion.SelectedIndex = 0;
                    break;

                case MacRegion.UNKNOWN:
                default:
                    cmbBoxFreq.Items.Add(MacRegion.UNKNOWN);
                    btnRfOn.Enabled      = false;
                    btnRfOff.Enabled     = false;
                    btnRF.Enabled = false;//btnRF Combine
                    btnInventory.Enabled = false;
                    btnPulse.Enabled     = false;
                    btnClear.Enabled     = false;
                    break;
            }
            cmbBoxFreq.SelectedIndex   = 0;

            //RF Channel Radio Button
            if (m_btChannelFlag == 0)
                rdoBtnMultiChannel.Checked = true;
            else
                rdoBtnSingleChannel.Checked = true;

            //Port Radio Button
            if (AddAntPort() == false)
            {
                cmbBoxFreq.Items.Add(MacRegion.UNKNOWN);
                btnRfOn.Enabled      = false;
                btnRfOff.Enabled     = false;
                btnRF.Enabled = false;//btnRF Combine
                btnInventory.Enabled = false;
                btnPulse.Enabled     = false;
                cmbAntPort.Items.Add(ENUM_ANT_PORT.UNKNOWN);

                cmbAntPort.SelectedIndex = cmbAntPort.Items.IndexOf(ENUM_ANT_PORT.UNKNOWN);
                return;
            }

            //Pulse Time
            numPulseOnTime.Maximum  = PULSE_TIME_MAX/1000;
            numPulseOnTime.Minimum  = PULSE_TIME_MIN/1000;
            numPulseOffTime.Maximum = PULSE_TIME_MAX/1000;
            numPulseOffTime.Minimum = PULSE_TIME_MIN/1000;
            numPulseOnTime.Value    = (m_uiPulseOnTime > 0)  ? m_uiPulseOnTime/ 1000  : numPulseOnTime.Minimum;     //us to ms
            numPulseOffTime.Value   = (m_uiPulseOffTime > 0) ? m_uiPulseOffTime/ 1000 : numPulseOffTime.Minimum;   //us to ms

            //Set Event
            m_mainForm.CurrentContextChanged += new EventHandler(CurrentContextChanged);
            m_mainForm.BindAllFunctionControlers(FunctionStateChanged, true);
        }
Ejemplo n.º 2
0
        public ReturnLoss(RFID_Explorer.mainForm r_form, LakeChabotReader rm_reader)
        {
            InitializeComponent();

            string  strBmpPath = Path.Combine( Application.CommonAppDataPath, BMP_NAME);
            //string strBmpPath = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData),
            //                                  Application.CommonAppDataPath );  //;  //Path.GetTempFileName\
               // string strBmpPath = Path.Combine( Application.CommonAppDataPath, BMP_NAME);

            m_mainForm = r_form;
            m_reader   = rm_reader;

            //Read Data from module
            m_reader.API_TestGetAntennaPortConfiguration(ref m_btPhysicalPort, ref m_usPowerLevel);
            m_reader.API_TestGetFrequencyConfiguration(ref m_btChannelFlag, ref m_uiExactFrequecny);

            //Thread function
            dlgSetComboFreq      = new SET_COMBO_FREQ( SetComboFreq );
            dlgShowErrMsg        = new SHOW_ERR_MSG( ShowErrMsg );
            dlgShowPaint         = new SHOW_PAINT( ShowPaint );
            dlgSetCurValueToText = new SET_CUR_VALUE_TO_TEXT( SetCurValueToText );
            dlgDrawString        = new DRAW_STRING(DrawString);

            //Graphic
            PaintPanel.Controls.Add(picPaint);
            m_Graphics    = picPaint.CreateGraphics();                     //Link between Graphics and panel
            m_PaintBmp    = new Bitmap(picPaint.Width, picPaint.Height);   //Create BMP File
            m_PaintBmp.Save(strBmpPath);
            m_PaintBmp.Dispose();
            m_PaintImage  = Image.FromFile(strBmpPath);                      //Open BMP File
            m_GraphicsBmp = Graphics.FromImage(m_PaintImage);              //Link BMP File to Graphics Object
            //m_GraphicsBmp = Graphics.FromImage(m_PaintBmp);

            //regionComboBox
            try
            {
                m_macRegion = m_reader.RegulatoryRegion;

            }
            catch (rfidReaderException exp)
            {
                cmbBoxRegion.Text = exp.Message;
            }
            cmbBoxRegion.Items.Add(m_macRegion);
            cmbBoxRegion.SelectedIndex = 0;

            //Frequency
            switch(m_macRegion)
            {
                case MacRegion.US:
                    foreach ( ENUM_RF_US item in Enum.GetValues(typeof(ENUM_RF_US)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.EU:
                    foreach ( ENUM_RF_EU item in Enum.GetValues(typeof(ENUM_RF_EU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.JP:
                    foreach ( ENUM_RF_JP item in Enum.GetValues(typeof(ENUM_RF_JP)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.EU2:
                    foreach ( ENUM_RF_EU2 item in Enum.GetValues(typeof(ENUM_RF_EU2)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.TW:
                    foreach ( ENUM_RF_TW item in Enum.GetValues(typeof(ENUM_RF_TW)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.CN:
                    foreach ( ENUM_RF_CN item in Enum.GetValues(typeof(ENUM_RF_CN)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.KR:
                    foreach ( ENUM_RF_KR item in Enum.GetValues(typeof(ENUM_RF_KR)) )
                    {
                       cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.AU:
                    foreach ( ENUM_RF_AU item in Enum.GetValues(typeof(ENUM_RF_AU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.BR:
                    foreach ( ENUM_RF_BR item in Enum.GetValues(typeof(ENUM_RF_BR)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.HK:
                    foreach ( ENUM_RF_HK item in Enum.GetValues(typeof(ENUM_RF_HK)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.MY:
                    foreach ( ENUM_RF_MY item in Enum.GetValues(typeof(ENUM_RF_MY)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.SG:
                    foreach ( ENUM_RF_SG item in Enum.GetValues(typeof(ENUM_RF_SG)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.TH:
                    foreach ( ENUM_RF_TH item in Enum.GetValues(typeof(ENUM_RF_TH)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.IL:
                    foreach ( ENUM_RF_IL item in Enum.GetValues(typeof(ENUM_RF_IL)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.RU:
                    foreach ( ENUM_RF_RU item in Enum.GetValues(typeof(ENUM_RF_RU)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.IN:
                    foreach ( ENUM_RF_IN item in Enum.GetValues(typeof(ENUM_RF_IN)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.SA:
                    foreach ( ENUM_RF_SA item in Enum.GetValues(typeof(ENUM_RF_SA)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.JO:
                    foreach ( ENUM_RF_JO item in Enum.GetValues(typeof(ENUM_RF_JO)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                case MacRegion.MX:
                    foreach ( ENUM_RF_MX item in Enum.GetValues(typeof(ENUM_RF_MX)) )
                    {
                        cmbBoxFreq.Items.Add( String.Format("{0:000.000}", (float)item/1000) );
                    }
                    cmbBoxFreq.Items.Add( ENUM_RF_COMMON.CHANNEL_ALL );
                    break;

                //clark 2011.9.13
                case MacRegion.CUSTOMER:
                    //Set cmbBoxFreq's type to Non-ReadOnly.
                    cmbBoxFreq.DropDownStyle = ComboBoxStyle.DropDown;
                    cmbBoxFreq.Items.Add( "000.000" );

                    string strCustomerRegion = null;
                    Result result = m_reader.API_MacGetCustomerRegion( ref strCustomerRegion );

                    cmbBoxRegion.Items.Clear();
                    switch(result)
                    {
                        case Result.OK:
                            //Show customer config name
                            cmbBoxRegion.Items.Add(strCustomerRegion);
                            break;

                        case Result.NOT_SUPPORTED:
                            cmbBoxRegion.Items.Add("Not support customer");
                            btnRun.Enabled = false;
                            break;

                       case Result.FAILURE:
                       default:
                            cmbBoxRegion.Items.Add("Get customer fail");
                            btnRun.Enabled = false;
                            break;
                    }
                    cmbBoxRegion.SelectedIndex = 0;
                    break;

                case MacRegion.UNKNOWN:
                default:
                    cmbBoxFreq.Items.Add(MacRegion.UNKNOWN);
                    btnRun.Enabled      = false;
                    break;
            }

            //clark 2011.9.13
            if (m_macRegion != MacRegion.UNKNOWN)
            {
                //Customer doesn't support ENUM_RF_COMMON.CHANNEL_ALL
                if( m_macRegion == MacRegion.CUSTOMER)
                    cmbBoxFreq.SelectedIndex = 0;
                else
                    cmbBoxFreq.SelectedItem = ENUM_RF_COMMON.CHANNEL_ALL;
            }

            //Port Radio Button
            if (AddAntPort() == false)
            {
                cmbBoxFreq.Items.Add(MacRegion.UNKNOWN);
                btnRun.Enabled      = false;
                cmbAntPort.Items.Add(ENUM_ANT_PORT.UNKNOWN);

                cmbAntPort.SelectedIndex = cmbAntPort.Items.IndexOf(ENUM_ANT_PORT.UNKNOWN);
                return;
            }
        }