当前位置: 首页>>代码示例>>C#>>正文


C# Reader.Connect方法代码示例

本文整理汇总了C#中Reader.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Reader.Connect方法的具体用法?C# Reader.Connect怎么用?C# Reader.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reader的用法示例。


在下文中一共展示了Reader.Connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: thingMagicReaderToolStripMenuItem_Click

 private void thingMagicReaderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         try
         {
             string software = (string)rdr.ParamGet("/reader/version/software");
             MessageBox.Show(string.Concat("Hardware: M6e", "  ", "Software: ", software), "About ThingMagic Reader...", MessageBoxButtons.OK);
         }
         catch (NullReferenceException)
         {
             reader = Reader.Create(string.Concat("tmr:///", readerAddress.Text));
             reader.Connect();
             rdr = (SerialReader)reader;
             string software = (string)rdr.ParamGet("/reader/version/software");
             MessageBox.Show(string.Concat("Hardware: M6e", "  ", "Software: ", software), "About ThingMagic Reader...", MessageBoxButtons.OK);
             rdr.Destroy();
         }
     }
     catch
     {
         MessageBox.Show("Connection to ThingMagic Reader not established", "Error!", MessageBoxButtons.OK);
     }
 }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:24,代码来源:Form1.cs

示例2: run

        private void run(String reader_uri, String mode) 
        {
            //Create the reader
            reader = Reader.Create(reader_uri);

            try
            {
                //Uncomment this line to add default transport listener.
                //reader.Transport += reader.SimpleTransportListener;

                //Connect to the reader
                reader.Connect();

                //Set up the reader configuration
                setupReaderConfiguration();

                ////Read a tag to ensure that the tag can be seen
                //TagReadData[] trd = this.reader.Read(100);
                //displayTags(trd);

                Gen2.IDS.SL900A.GetSensorValue tagop = null;
                if (mode.Equals("TEMP"))
                {
                    //Create a tag op to retrieve the TEMP sensor value
                    tagop = new Gen2.IDS.SL900A.GetSensorValue(Gen2.IDS.SL900A.Sensor.TEMP);
                }
                else if (mode.Equals("EXT1"))
                {
                    //Create a tag op to retrieve the EXT1 sensor value
                    tagop = new Gen2.IDS.SL900A.GetSensorValue(Gen2.IDS.SL900A.Sensor.EXT1);
                }
                else if (mode.Equals("EXT2"))
                {
                    //Create a tag op to retrieve the EXT2 sensor value
                    tagop = new Gen2.IDS.SL900A.GetSensorValue(Gen2.IDS.SL900A.Sensor.EXT2);
                }
                else if (mode.Equals("BATTV"))
                {
                    //Create a tag op to retrieve the BATTV sensor value
                    tagop = new Gen2.IDS.SL900A.GetSensorValue(Gen2.IDS.SL900A.Sensor.BATTV);
                }
                else
                {
                    //Print that an invalid input was detected
                    Console.WriteLine(String.Format("{0} is not a valid sensor", mode));
                    //Exit the program
                    Environment.Exit(1);
                }

                //Perform an SL900A Get Sensor Value TEMP
                Gen2.IDS.SL900A.SensorReading sensorReading = performSensorReading(tagop);

                //Print the raw sensor value info
                Console.WriteLine(String.Format("ADError:{0} Value:{1} RangeLimit:{2} Raw: {3}", sensorReading.ADError, sensorReading.Value, sensorReading.RangeLimit, sensorReading.Raw));
                //Print the converted sensor value
                if (mode.Equals("TEMP"))
                {
                    Console.WriteLine(String.Format("Temp: {0} C", getCelsiusTemp(sensorReading)));
                }
                else if (mode.Equals("EXT1") || mode.Equals("EXT2"))
                {
                    Console.WriteLine(String.Format("Voltage: {0} V", getVoltage(sensorReading)));
                }
            }
            catch (Exception ex) 
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            finally
            {
                //Destroy reader
                this.reader.Destroy();
            }
            
        }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:75,代码来源:SL900AGetSensorValue.cs

示例3: btnConnect_Click

        private void btnConnect_Click(object sender, EventArgs e)
        {

            try
            {
                if (btnConnect.Text.Equals("Connect"))
                {
                    String model = string.Empty;
                    string readeruri = comboBox1.SelectedItem.ToString();
                    objReader = Reader.Create(string.Concat("eapi:///", readeruri));
                    objReader.Connect();
                    model = (string)objReader.ParamGet("/reader/version/model");
                    Reader.Region regionToSet = (Reader.Region)objReader.ParamGet("/reader/region/id");
                    if (objReader is SerialReader)
                    {
                        if (regionToSet == Reader.Region.UNSPEC)
                        {
                            if (model.Equals("M6e PRC"))
                            {
                                regionToSet = Reader.Region.PRC;
                            }
                            else
                            {
                                regionToSet = Reader.Region.NA;
                            }
                        }
                    }
                    objReader.ParamSet("/reader/region/id", regionToSet);

                    if (model.Equals("M6e Micro"))
                    {
                        SimpleReadPlan plan = new SimpleReadPlan(new int[] { 1, 2 }, TagProtocol.GEN2);
                        objReader.ParamSet("/reader/read/plan", plan);
                    }
                    btnConnect.Text = "Disconnect";
                    btnReadOnce.Enabled = true;
                    comboBox1.Enabled = false;
                    btnRefresh.Enabled = false;
                    lblReadTimeout.Enabled = true;
                    tbxReadTimeout.Enabled = true;
                    UpdateGrid();
                }
                else
                {
                    objReader.Destroy();
                    objReader = null;
                    btnReadOnce.Enabled = false;
                    comboBox1.Enabled = true;
                    lblReadTimeout.Enabled = false;
                    tbxReadTimeout.Enabled = false;
                    btnConnect.Text = "Connect";
                    btnRefresh.Enabled = true;
                    lblTotalTagCount.Text = "0";
                    lblUniqueTagCount.Text = "0";
                }
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "Error");
                objReader.Destroy();
                objReader = null;
                btnReadOnce.Enabled = false;
                btnConnect.Text = "Connect";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Reader message");
            }

        }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:70,代码来源:Form1.cs

示例4: run

        private void run(String reader_uri)
        {
            try
            {
                String PARAM_STR_REGION = "/reader/region/id";
                String PARAM_STR_SESSION = "/reader/gen2/session";
                String PARAM_STR_READPLAN = "/reader/read/plan";

                Console.WriteLine(String.Format("Connecting to {0}", reader_uri));
                //Create the reader
                reader = Reader.Create(reader_uri);

                try
                {
                    //Uncomment this line to add default transport listener.
                    //reader.Transport += reader.SimpleTransportListener;

                    //Connect to the reader
                    reader.Connect();

                    //Set the region to NA
                    if (Reader.Region.UNSPEC == (Reader.Region)reader.ParamGet(PARAM_STR_REGION))
                    {
                        Reader.Region[] supportedRegions = (Reader.Region[])reader.ParamGet("/reader/region/supportedRegions");
                        if (supportedRegions.Length < 1)
                        {
                            throw new FAULT_INVALID_REGION_Exception();
                        }
                        else
                        {
                            reader.ParamSet(PARAM_STR_REGION, supportedRegions[0]);
                        }
                    }
                    //Set the session to session 0
                    reader.ParamSet(PARAM_STR_SESSION, Gen2.Session.S0);

                    //Get the region
                    Reader.Region region = (Reader.Region)reader.ParamGet(PARAM_STR_REGION);
                    Console.WriteLine("The current region is " + region);

                    //Get the session
                    Gen2.Session session = (Gen2.Session)reader.ParamGet(PARAM_STR_SESSION);
                    Console.WriteLine("The current session is " + session);

                    //Get the read plan
                    ReadPlan rp = (ReadPlan)reader.ParamGet(PARAM_STR_READPLAN);
                    Console.WriteLine("The current Read Plan is: " + rp);

                    //Create the Get Calibration Data tag operation
                    Gen2.IDS.SL900A.GetCalibrationData getCal_tagop = new Gen2.IDS.SL900A.GetCalibrationData();

                    //Use the Get Calibration Data (and SFE Parameters) tag op
                    Gen2.IDS.SL900A.CalSfe calSfe = (Gen2.IDS.SL900A.CalSfe)reader.ExecuteTagOp(getCal_tagop, null);

                    //Save the current Cal to restore it to the tag after the test
                    Gen2.IDS.SL900A.CalibrationData restore_cal = (Gen2.IDS.SL900A.CalibrationData)calSfe.Cal;

                    //Display the Calibration (and SFE Parameters) Data
                    Console.WriteLine("Detected Calibration: " + calSfe);

                    //Set the Calibration Data to 0x0123456789ABCD (56 bits)
                    byte[] test_cal_byte_array = new byte[7] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD };

                    Gen2.IDS.SL900A.CalibrationData test_cal = new Gen2.IDS.SL900A.CalibrationData(test_cal_byte_array, 0);

                    //Execute the Set Calibration Data command with test_cal to change its value 
                    reader.ExecuteTagOp(new Gen2.IDS.SL900A.SetCalibrationData(test_cal), null);

                    //Use Get Calibration Data to retrieve the new Calibration (and SFE Parameters) from the tag
                    Gen2.IDS.SL900A.CalSfe verification_calSfe = (Gen2.IDS.SL900A.CalSfe)reader.ExecuteTagOp(getCal_tagop, null);

                    //Get the Cal data from the CalSfe data
                    Gen2.IDS.SL900A.CalibrationData verification_cal = (Gen2.IDS.SL900A.CalibrationData)verification_calSfe.Cal;

                    //Print the verificationCal
                    Console.WriteLine("Verification Cal: " + verification_cal.ToString());

                    //Ensure that the Calibration Data we set matches the current Calibration Data
                    Console.WriteLine("Set Calibration Data Succeeded? " + test_cal.ToString().Equals(verification_cal.ToString()));

                    //Restore the starting Calibration Data
                    reader.ExecuteTagOp(new Gen2.IDS.SL900A.SetCalibrationData(restore_cal), null);

                    //Get CalSfe of the restored tag
                    Gen2.IDS.SL900A.CalSfe restored_calSfe = (Gen2.IDS.SL900A.CalSfe)reader.ExecuteTagOp(getCal_tagop, null);

                    //Make sure that CalSfe is now the same as it was before the test
                    Console.WriteLine("Restore Calibration Data Succeeded? " + calSfe.ToString().Equals(restored_calSfe.ToString()));
                }
                finally
                {
                    //Disconnect from the reader
                    reader.Destroy();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
        }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:100,代码来源:SL900ASetCalibrationData.cs

示例5: run

        private void run(String reader_uri)
        {
            try
            {
                String PARAM_STR_REGION = "/reader/region/id";
                String PARAM_STR_SESSION = "/reader/gen2/session";
                String PARAM_STR_READPLAN = "/reader/read/plan";

                Console.WriteLine(String.Format("Connecting to {0}", reader_uri));
                //Create the reader
                reader = Reader.Create(reader_uri);

                try
                {
                    //Uncomment this line to add default transport listener.
                    //reader.Transport += reader.SimpleTransportListener;

                    //Connect to the reader
                    reader.Connect();

                    //Set the region to NA
                    if (Reader.Region.UNSPEC == (Reader.Region)reader.ParamGet(PARAM_STR_REGION))
                    {
                        Reader.Region[] supportedRegions = (Reader.Region[])reader.ParamGet("/reader/region/supportedRegions");
                        if (supportedRegions.Length < 1)
                        {
                            throw new FAULT_INVALID_REGION_Exception();
                        }
                        else
                        {
                            reader.ParamSet(PARAM_STR_REGION, supportedRegions[0]);
                        }
                    }
                    //Set the session to session 0
                    reader.ParamSet(PARAM_STR_SESSION, Gen2.Session.S0);

                    //Get the region
                    Reader.Region region = (Reader.Region)reader.ParamGet(PARAM_STR_REGION);
                    Console.WriteLine("The current region is " + region);

                    //Get the session
                    Gen2.Session session = (Gen2.Session)reader.ParamGet(PARAM_STR_SESSION);
                    Console.WriteLine("The current session is " + session);

                    //Get the read plan
                    ReadPlan rp = (ReadPlan)reader.ParamGet(PARAM_STR_READPLAN);
                    Console.WriteLine("The current Read Plan is: " + rp);

                    //Create the Get Calibration Data tag operation
                    Gen2.IDS.SL900A.GetCalibrationData tagOp = new Gen2.IDS.SL900A.GetCalibrationData();

                    //Use the Get Calibration Data (and SFE Parameters) tag op
                    Gen2.IDS.SL900A.CalSfe calSfe = (Gen2.IDS.SL900A.CalSfe)reader.ExecuteTagOp(tagOp, null);

                    //Display the Calibration (and SFE Parameters) Data
                    Console.WriteLine(calSfe);

                    //Display the specific Calibration data gnd_switch
                    Console.WriteLine("gnd_switch: " + calSfe.Cal.GndSwitch);

                    //Display the specific SFE Parameter Verify Sensor ID
                    Console.WriteLine("Verify Sensor ID: " + calSfe.Sfe.VerifySensorID);
                }
                finally
                {
                    //Disconnect from the reader
                    reader.Destroy();
                }
            }
            catch (Exception e) {
                Console.WriteLine("Error: " + e.Message);
            }

        }
开发者ID:colombmo,项目名称:itsi-gamification,代码行数:74,代码来源:SL900AGetCalibrationData.cs


注:本文中的Reader.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。