Пример #1
0
        private void button_Initialize_Click(object sender, EventArgs e)
        {
            if (Reader == null)
            {
                Reader = new RFIDClass();
            }

            //Initialize variables
            Reader.PortName      = "COM" + numericUpDown_PortNumber.Value + ":";
            Reader.ProtocolType  = 3;
            Reader.InterfaceType = 1356;
            switch (comboBox_PortType.SelectedIndex)
            {
            case 0:    //Serial
                Reader.PortType = 0;
                break;

            case 1:    //BT
                Reader.PortType = 2;
                break;

            case 2:    //USB
                Reader.PortType = 4;
                break;
            }

            //Open communication interface
            Reader.Reader_OpenInterface();
            textBox_DriverVersion.Text = String.Format("Version: {0:X2}.{1:X2}", Reader.Version_Main_Driver_Engine, Reader.Version_Sub_Driver_Engine);

            if (Reader.Port_Initialized == 1)
            {
                numericUpDown_PortNumber.Enabled = false;
                comboBox_PortType.Enabled        = false;
                timer_CheckReader.Enabled        = true;
                (sender as Button).Enabled       = false;
            }
        }
Пример #2
0
        private void timer_Scan_Tick(object sender, EventArgs e)
        {
            //Initialize variables
            uint serNum   = 0;
            byte pc       = 0;
            byte vc       = 0;
            byte numSizes = 0;

            byte[] sizes    = new byte[10];
            byte[] xtraData = new byte[32];
            int    result   = 0xFF;

            //Get iID-L Sensor Information
            //  Reader.Port_Handle -> Communication handle
            //  0 -> parameter (Reserved)
            //  0 -> driver parameter (Reserved)
            //  serNum -> pointer where the TELID Serial number will be load
            //  pc -> pointer where the TELID Product code will be load
            //  vc -> pointer where the TELID Version code will be load
            //  numSizes -> number of physical sizes the TELID can read
            //  sizes -> type of physical sizes the TELID can read
            //  xtraData -> pointer where additional sensor data will be load (needed for "get_sensor_data")
            result = RFIDClass.iidl_c_get_sensor_information(Reader.Port_Handle, 0, 0, ref serNum, ref pc, ref vc, ref numSizes, sizes, xtraData);
            if (result == 0)
            {
                //Result OK
                label_SerialNumber.Text = String.Format("{0}", serNum);
                byte    numSensor    = 0;
                float[] sensorValues = new float[10];

                if (this.radioButton_AutoSensor.Checked)
                {
                    //Get iID-L Sensor Data
                    //  Reader.Port_Handle -> Communication handle
                    //  0 -> parameter (Reserved)
                    //  0 -> driver parameter (Reserved)
                    //  serNum -> pointer where the TELID Serial number will be load
                    //  pc -> pointer where the TELID Product code will be load
                    //  vc -> pointer where the TELID Version code will be load
                    //  numSizes -> number of physical sizes the TELID can read
                    //  sizes -> type of physical sizes the TELID can read
                    //  xtraData -> pointer where additional sensor data will be load (needed for "get_sensor_data")
                    //  numSensor -> number of sensor values calculated by the function (size of "sensorValues")
                    //  sensorValues -> sensor values as float
                    result = RFIDClass.iidl_c_get_sensor_data(Reader.Port_Handle, 0, 0, serNum, pc, vc, ref numSizes, sizes, xtraData, ref numSensor, sensorValues);
                }
                else
                {
                    //Get parameters from UI
                    byte   bSensorType   = microsensys.DevTools.Converter.StringConverter.HexStringToByte(this.textBox_SensorType.Text);
                    byte   bPhysicalSize = microsensys.DevTools.Converter.StringConverter.HexStringToByte(this.textBox_PhysicalSize.Text);
                    byte[] bParams       = microsensys.DevTools.Converter.StringConverter.HexStringToByteArray(this.textBox_ParamArray.Text);
                    byte   bParamLength  = Convert.ToByte(bParams.GetLength(0));

                    //Get iID-L Sensor Data
                    //  Reader.Port_Handle -> Communication handle
                    //  0 -> driver parameter (Reserved)
                    //  bPhysicalSize -> physical size to read
                    //  bParamLength -> length of parameters
                    //  bParams -> parameters
                    //  serNum -> pointer where the TELID Serial number will be load
                    //  pc -> pointer where the TELID Product code will be load
                    //  vc -> pointer where the TELID Version code will be load
                    //  numSizes -> number of physical sizes the TELID can read
                    //  sizes -> type of physical sizes the TELID can read
                    //  xtraData -> pointer where additional sensor data will be load (needed for "get_sensor_data")
                    //  numSensor -> number of sensor values calculated by the function (size of "sensorValues")
                    //  sensorValues -> sensor values as float
                    result = RFIDClass.iidl_c_get_sensor_data_extended(Reader.Port_Handle, 0, bPhysicalSize, bSensorType, bParamLength, bParams, serNum, pc, vc, ref numSizes, sizes, xtraData, ref numSensor, sensorValues);
                }

                Console.WriteLine("Sensor Data result" + result);
                if (result == 0)
                {
                    //Result OK
                    label_LastTime.Text           = String.Format("{0:T}", DateTime.Now);
                    richTextBox_SensorValues.Text = "";
                    if (numSensor != numSizes)
                    {
                        return;
                    }

                    //Write each sensor value into UI
                    for (int i = 0; i < numSensor; i++)
                    {
                        richTextBox_SensorValues.Text += String.Format("{0} {1}\n", sensorValues[i], GetUnit(sizes[i]));
                    }
                    panel_ResultSensor.BackColor = Color.Green;
                    return;
                }
            }
            panel_ResultSensor.BackColor = Color.Red;
        }