Example #1
0
        public Program()
        {
            try
            {
                reader.Connect(SolutionConstants.ReaderHostname);

                Console.WriteLine("WAM with Location: " + SolutionConstants.ReaderHostname);

                for (int i = 0; i < INTERATIONS; i++)
                {
                    // WAM Role
                    Console.WriteLine("Running WAM. Please wait " + WAM_ROLE_DURATION / 1000 + " Sec." + " Session=" + WAM_SESSION + " Target=" + WAM_SEARCH_MODE);
                    SetupWamMode();
                    System.Threading.Thread.Sleep(WAM_ROLE_DURATION);
                    ShutdownWamMode();
                    Console.WriteLine("WAM Results:  TagsRead=" + WamTags.Count);
                    foreach (var item in WamTags)
                    {
                        Tag tag = item.Value;
                        Console.WriteLine(item.Key + "  Ant=" + tag.AntennaPortNumber + "\tRSSI=" + tag.PeakRssiInDbm);
                    }
                    Console.WriteLine();
                    WamTags.Clear();

                    // Location Role
                    Console.WriteLine("Running Location. Please wait " + LOCATION_ROLE_DURATION / 1000 + " sec.");
                    SetupLocationMode();
                    System.Threading.Thread.Sleep(LOCATION_ROLE_DURATION);
                    ShutdownLocationMode();
                    Console.WriteLine("Location Results: " + LocTags.Count + " Tags Read");
                    foreach (var item in LocTags)
                    {
                        LocationReport tag = item.Value;
                        Console.WriteLine(item.Key + "\tReadCount=" + tag.ConfidenceFactors.ReadCount + "\tX=" + tag.LocationXCm + "\tY=" + tag.LocationYCm);
                    }
                    LocTags.Clear();
                    Console.WriteLine();
                    // Wait for tag percistance to complete before starting WAM again
                    if ((i < INTERATIONS - 1) && (WAM_SESSION == 2 || WAM_SESSION == 3))
                    {
                        Console.WriteLine("Wait " + SESSION_2_OR_3_PERSISTENCE / 1000 + " Sec. for tag percistance to complete before starting WAM again");
                        System.Threading.Thread.Sleep(SESSION_2_OR_3_PERSISTENCE);
                    }
                }
                // Apply the default settings before exiting.
                reader.ApplyDefaultSettings();
                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #2
0
        static void OnConnectAsyncComplete(ImpinjReader reader, ConnectAsyncResult result, string errorMessage)
        {
            // This event handler is called asynchronously
            // when the connection attempt has completed.

            // Check the result of the connection attempt
            if (result == ConnectAsyncResult.Success)
            {
                // Successfully connection to the reader. Now configure  and start it.
                Console.WriteLine("Successfully connected to {0}", reader.Address);
                reader.ApplyDefaultSettings();
                Console.WriteLine("Starting reader...");
                //reader.Start();
                SetReport(reader);
                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
                textWriter.Close();

                //cleanup
                reader.Stop();
                reader.Disconnect();
                Console.WriteLine("Reader stopped. Press enter to exit.");
            }
            else
            {
                // Failed to connect to the reader
                Console.WriteLine("Failure while connecting to {0} : {1}", reader.Address, errorMessage);
            }
        }
Example #3
0
        private void UpdateReaderSettings()
        {
            System.Diagnostics.Debug.WriteLine("Updating Reader Settings... ");
            reader.ApplyDefaultSettings();

            settings = reader.QuerySettings();
            settings.Antennas.GetAntenna(1).IsEnabled          = true;
            settings.Antennas.GetAntenna(1).RxSensitivityInDbm = SolutionConstants.RxSensitivity;
            settings.Antennas.GetAntenna(1).TxPowerInDbm       = SolutionConstants.TxPower;

            settings.Report.IncludeAntennaPortNumber = true;
            settings.Report.IncludePeakRssi          = true;
            settings.Report.IncludeChannel           = true;
            settings.Report.IncludeCrc = true;
            settings.Report.IncludeDopplerFrequency = true;
            settings.Report.IncludeFastId           = true;
            settings.Report.IncludeFirstSeenTime    = true;
            settings.Report.IncludeGpsCoordinates   = true;
            settings.Report.IncludeLastSeenTime     = true;
            settings.Report.IncludePhaseAngle       = true;
            settings.Report.IncludeSeenCount        = true;
            settings.Report.Mode = ReportMode.Individual;

            reader.ApplySettings(settings);
        }
Example #4
0
        private void CloseXArray(ImpinjReader reader)
        {
            // Apply the default settings before exiting.
            reader.ApplyDefaultSettings();

            // Disconnect from the reader.
            reader.Disconnect();
        }
Example #5
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Apply the default settings.
                reader.ApplyDefaultSettings();

                // Start reading.
                reader.Start();


                Console.WriteLine("Writing to the tag. Press enter when the operation is complete.");
                // Write random words to user memory
                TagData data = GetRandomData(NUM_WORDS_USER_MEMORY);
                BulkWrite(null, MemoryBank.User, 0, data);
                Console.ReadLine();

                // Remove all operation sequences from the reader that haven't executed.
                reader.DeleteAllOpSequences();

                Console.WriteLine("Reading from the tag. Press enter when the operation is complete.");
                // Read all of User memory
                BulkRead(null, MemoryBank.User, 0, NUM_WORDS_USER_MEMORY);
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            // Defines the sources of configuration information for the
            // application.
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            // Create the configuration object that the application will
            // use to retrieve configuration information.
            var configuration = builder.Build();

            // Retrieve the configuration information.
            configValue = configuration.GetConnectionString("MainDisplayDB");

            Console.WriteLine("a. The read tag will automatically be served to the Teleprompt Screen, if the screen is empty");
            Console.WriteLine("b. If the screen is not empty, await the read tag to queue until available");
            Console.WriteLine("c. If the screen is empty and there's queue waiting. Pop the queue and load to Teleprompt screen");

            try
            {
                reader.Connect(SolutionConstants.ReaderHostname);

                reader.TagsReported += OnTagsReported;

                reader.ApplyDefaultSettings();

                reader.Start();

                Console.WriteLine("\n\nEnter word. 'Yallah!' to quit.\n\n\n");

                string quitline = Console.ReadLine();

                if (quitline.ToLower() == "yallah!")
                {
                    Console.WriteLine("\n\nExiting!!!");

                    reader.Stop();

                    reader.Disconnect();
                }
            }
            catch (OctaneSdkException e)
            {
                Console.WriteLine("Octane SDK exception: {0}", e.Message);

                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception : {0}", e.Message);

                Console.ReadLine();
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            try
            {
                // This example show the minimum program required to read tags.
                // If you require more control over the reader settings,
                // take a look at the ReadTags example.

                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example

                /*if (args.Length != 1)
                 * {
                 *  Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                 *  return;
                 * }
                 * string hostname = args[0];*/
                string hostname = "speedwayr-10-9f-bb.local";
                reader.Connect(hostname);

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Apply the default settings.
                reader.ApplyDefaultSettings();

                // Start reading.
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Apply the default settings.
                reader.ApplyDefaultSettings();

                // Start reading.
                reader.Start();


                Console.WriteLine("Writing to the tag. Press enter when the operation is complete.");
                // Write random words to user memory
                TagData data = GetRandomData(NUM_WORDS_USER_MEMORY);
                BulkWrite(null, MemoryBank.User, 0, data);
                Console.ReadLine();

                // Remove all operation sequences from the reader that haven't executed.
                reader.DeleteAllOpSequences();

                Console.WriteLine("Reading from the tag. Press enter when the operation is complete.");
                // Read all of User memory
                BulkRead(null, MemoryBank.User, 0, NUM_WORDS_USER_MEMORY);
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #9
0
        public void ApplySettings()
        {
            try
            {
                Console.WriteLine("Starting Configuration...");
                impinjReader.ApplyDefaultSettings();

                settings = impinjReader.QueryDefaultSettings();

                settings.TagPopulationEstimate = 50;

                Console.WriteLine("Setting Session 0");

                settings.Session    = 1;
                settings.ReaderMode = ReaderMode.AutoSetStaticFast;

                settings.SearchMode = SearchMode.SingleTarget;

                Console.WriteLine(" Setting Automode...");
                settings.AutoStart.Mode = AutoStartMode.None;
                settings.AutoStop.Mode  = AutoStopMode.None;



                Console.WriteLine("Setting Report Mode...");
                settings.Report.Mode = ReportMode.Individual;
                settings.Report.IncludeAntennaPortNumber = true;
                settings.Report.IncludeSeenCount         = true;
                settings.Report.IncludePeakRssi          = true;
                settings.Report.IncludeChannel           = false;
                settings.Report.IncludeFirstSeenTime     = false;
                settings.Report.IncludeLastSeenTime      = false;
                settings.Report.IncludePhaseAngle        = false;


                SettingAntennas();

                impinjReader.ApplySettings(settings);

                Console.WriteLine("All Set!");

                impinjReader.TagsReported += TagsReportedHandler;
            }
            catch (OctaneSdkException ex)
            {
                Console.WriteLine("OctaneSdk detected {0}", ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fail to setup {0}", ex);
            }
        }
Example #10
0
 private static void Reader_ConnectAsyncComplete(ImpinjReader reader, ConnectAsyncResult result, string errorMessage)
 {
     if (result == ConnectAsyncResult.Success)
     {
         reader.ApplyDefaultSettings();
         reader.Start();
         Console.WriteLine("Started...");
     }
     else
     {
         Console.WriteLine(errorMessage);
     }
 }
Example #11
0
        private void connect()
        {
            rdr      = new ImpinjReader();
            rdr.Name = ReaderIP + ":" + reader_port;
            Console.WriteLine("connecting to: " + ReaderIP + ":" + reader_port);
            //rdr.Connect(reader_ip, reader_port);
            rdr.Connect(ReaderIP);

            rdr.ApplyDefaultSettings();
            rdr.TagsReported += OnTagsReported;
            LoadSettings();
            rdr.Start();
            startedEvent(this, EventArgs.Empty);
        }
Example #12
0
        public bool connect()
        {
#if DEBUG
            return(false);
#endif
            bool re = false;

            if (mReaderType == READER_TYPE.READER_IMP)
            {
                try
                {
                    mReaderIMP = new ImpinjReader();
                    mReaderIMP.TagsReported += this.tagsReportedIMP;

                    mReaderIMP.Connect(mIp);
                    mReaderIMP.ApplyDefaultSettings();

                    configIMP(mPower);

                    re = true;
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            if (mReaderType == READER_TYPE.READER_TM)
            {
                try
                {
                    Reader.SetSerialTransport("tcp", SerialTransportTCP.CreateSerialReader);
                    mReaderTM          = Reader.Create(string.Format("tcp://{0}", mIp));
                    mReaderTM.TagRead += tagsReportedTM;

                    mReaderTM.Connect();

                    configTM(mPower);

                    re = true;
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            return(re);
        }
Example #13
0
        public void connect()
        {
            rdr      = new ImpinjReader();
            rdr.Name = reader_ip + ":" + reader_port;
            Console.WriteLine("connecting to: " + reader_ip + ":" + reader_port);
            //rdr.Connect(reader_ip, reader_port);
            rdr.Connect(reader_ip);

            rdr.ApplyDefaultSettings();
            rdr.TagsReported += OnTagsReported;
            ReadSettingsFromFile();
            rdr.Start();
            statusLabel.ForeColor = Color.Green;
            statusLabel.Text      = "Status: Connected";
        }
Example #14
0
        public Form1()
        {
            InitializeComponent();
            //Activamos el RFID como demo
            bool myResult = myReader.Activation("Demo");

            //Conectamos el RFID ME
            myReader.Connect("RFIDME");
            this.cbDispositivo.DropDownStyle = ComboBoxStyle.DropDownList;
            this.KeyPreview            = true;
            this.lboxLog.SelectionMode = SelectionMode.None;


            try
            {
                //Conectamos el Speedway
                reader.Connect(ReaderHostname);
                //Se aplican los valores por defecto al speedway
                reader.ApplyDefaultSettings();
                //Se inicia el speedway
                //reader.Start();
                //Instanciamos settings y le asignamos los settings actuales
                Settings settings = reader.QuerySettings();
                //Se agrega el número de puerto de antena al reporte
                settings.Report.IncludeAntennaPortNumber = true;
                //Se ajusta el modo de lectura al mas óptimo
                settings.ReaderMode = ReaderMode.AutoSetDenseReader;
                //Se captura el hostname en la caja de texto tbIPSpeedway
                tbIPSpeedway.Text = reader.Address;
            }
            catch
            {
                //En caso el speedway no esté conectado se muestra un mensaje
                MessageBox.Show("El speedway no está conectado");
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            ushort i;

            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Turn the general purpose outputs
                // (GPOs) on one at a a time
                Console.WriteLine("Setting general purpose outputs...");
                for (i = 1; i <= 4; i++)
                {
                    reader.SetGpo(i, true);
                    Thread.Sleep(1500);
                    reader.SetGpo(i, false);
                }

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            try
            {
                // This example show the minimum program required to read tags.
                // If you require more control over the reader settings,
                // take a look at the ReadTags example.

                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Apply the default settings.
                reader.ApplyDefaultSettings();

                // Start reading.
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #17
0
        static void Main(string[] args)
        {
            ushort i;

            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Turn the general purpose outputs
                // (GPOs) on one at a a time
                Console.WriteLine("Setting general purpose outputs...");
                for (i = 1; i <= 4; i++)
                {
                    reader.SetGpo(i, true);
                    Thread.Sleep(1500);
                    reader.SetGpo(i, false);
                }

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Prompt user for QT mode.
                Console.WriteLine("Select a QT mode\n");
                Console.WriteLine("1 : Public");
                Console.WriteLine("2 : Private");
                ushort choice = ushort.Parse(Console.ReadLine());

                if (choice == 1)
                {
                    // Put the tag into QT public mode.
                    Console.WriteLine("Putting the tag into QT public mode.");
                    SetQtMode(QtDataProfile.Public, QtAccessRange.ShortRange);
                }
                else if (choice == 2)
                {
                    // Put the tag into QT private mode.
                    Console.WriteLine("Putting the tag into QT private mode.");
                    SetQtMode(QtDataProfile.Private, QtAccessRange.NormalRange);
                }

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }

            // Wait for the user to press enter.
            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
Example #19
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                string executingPath = Path.GetFullPath(Path.Combine(Assembly.GetExecutingAssembly().Location, ".."));

                // Query the reader features and print the results.
                Console.WriteLine("Reader Features");
                Console.WriteLine("---------------");
                FeatureSet features = reader.QueryFeatureSet();
                Console.WriteLine("Model name : {0}", features.ModelName);
                Console.WriteLine("Model number : {0}", features.ModelNumber);
                Console.WriteLine("Reader model : {0}", features.ReaderModel.ToString());
                Console.WriteLine("Firmware version : {0}", features.FirmwareVersion);
                Console.WriteLine("Antenna count : {0}\n", features.AntennaCount);

                // Write the reader features to file.
                string featuresFile = Path.Combine(executingPath, "features.xml");
                features.Save(featuresFile);

                // Query the current reader status.
                Console.WriteLine("Reader Status");
                Console.WriteLine("---------------");
                Status status = reader.QueryStatus();
                Console.WriteLine("Is connected : {0}", status.IsConnected);
                Console.WriteLine("Is singulating : {0}", status.IsSingulating);
                Console.WriteLine("Temperature : {0}° C\n", status.TemperatureInCelsius);

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Display the current reader settings.
                DisplayCurrentSettings();

                // Save the settings to file in XML format.
                Console.WriteLine("Saving settings to file.");
                Settings settings     = reader.QuerySettings();
                string   settingsFile = Path.Combine(executingPath, "settings.xml");
                settings.Save(settingsFile);

                // Wait here, so we can edit the
                // settings.xml file in a text editor.
                Console.WriteLine("Edit settings.xml and press enter.");
                Console.ReadLine();

                // Load the modified settings from file.
                Console.WriteLine("Loading settings from file.");
                settings = Settings.Load(settingsFile);

                // Apply the settings we just loaded from file.
                Console.WriteLine("Applying settings from file.\n");
                reader.ApplySettings(settings);

                // Display the settings again to show the changes.
                DisplayCurrentSettings();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #20
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Create a tag operation sequence.
                // You can add multiple read, write, lock, kill and QT
                // operations to this sequence.
                TagOpSequence seq = new TagOpSequence();

                // Specify a target tag.
                // This is very important, since a block permalock
                // operation is irreversible.
                // The target tag is selected by EPC.
                seq.TargetTag.MemoryBank = MemoryBank.Epc;
                seq.TargetTag.BitPointer = BitPointers.Epc;
                // The EPC of the target tag.
                seq.TargetTag.Data = TARGET_EPC;


                // Define a Block Permalock operation.
                TagBlockPermalockOp blockLockOp = new TagBlockPermalockOp();
                // Define which block(s) to lock.
                // A BlockPermalockMask can be created from a single
                // block number or an array of block numbers.
                // This mask permalocks block zero.
                blockLockOp.BlockMask = BlockPermalockMask.FromBlockNumber(0);
                // Add the block permalock operation to the tag operation sequence.
                seq.Ops.Add(blockLockOp);

                // Add the tag operation sequence to the reader.
                // The reader supports multiple sequences.
                reader.AddOpSequence(seq);

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #21
0
        public bool connect()
        {
#if DEBUG
            return(false);
#endif
            bool re = false;

            if (mReaderType == READER_TYPE.READER_IMP)
            {
                try
                {
                    mReaderIMP = new ImpinjReader();
                    mReaderIMP.TagsReported += this.tagsReportedIMP;

                    mReaderIMP.Connect(mIp);
                    mReaderIMP.ApplyDefaultSettings();

                    configIMP(mPower);

                    re = true;
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            if (mReaderType == READER_TYPE.READER_TM)
            {
                try
                {
                    Reader.SetSerialTransport("tcp", SerialTransportTCP.CreateSerialReader);
                    mReaderTM          = Reader.Create(string.Format("tcp://{0}", mIp));
                    mReaderTM.TagRead += tagsReportedTM;

                    mReaderTM.Connect();

                    configTM(mPower);

                    re = true;
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            if (mReaderType == READER_TYPE.READER_DLX_PM)
            {
                try
                {
                    mReaderDLXPM = new RfidUARTLinkExtend();
                    mReaderDLXPM.RadioInventory += tagsReportedDLXPM;

                    if (mReaderDLXPM.ConnectRadio(mComPort, 115200) == operateResult.ok)
                    {
                        AntennaPortConfiguration portConfig = new AntennaPortConfiguration();
                        portConfig.powerLevel            = (uint)mPower;
                        portConfig.numberInventoryCycles = 8192;
                        portConfig.dwellTime             = 2000;
                        mReaderDLXPM.SetAntennaPortConfiguration(mComPort, 0, portConfig);
                        mReaderDLXPM.SetCurrentLinkProfile(mComPort, 1);
                        SingulationAlgorithmParms singParm = new SingulationAlgorithmParms();
                        singParm.singulationAlgorithmType = SingulationAlgorithm.Dynamicq;
                        singParm.startQValue         = 4;
                        singParm.minQValue           = 0;
                        singParm.maxQValue           = 15;
                        singParm.thresholdMultiplier = 4;
                        singParm.toggleTarget        = 1;
                        mReaderDLXPM.SetCurrentSingulationAlgorithm(mComPort, singParm);
                        mReaderDLXPM.SetTagGroupSession(mComPort, Session.S0);

                        re = true;
                    }
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            if (mReaderType == READER_TYPE.READER_DLX_PM)
            {
                try
                {
                    mReaderXDPM = new RfidReader();
                    mReaderXDPM.OnTagsReported += tagsReportedXDPM;
                    re = mReaderXDPM.OpenReader(mIp, 2048, SynchronizationContext.Current, "M6E").Success;
                    configXDPM(mPower);
                }
                catch (Exception)
                {
                    re = false;
                }
            }

            return(re);
        }
Example #22
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Create a tag operation sequence.
                // You can add multiple read, write, lock, kill and QT
                // operations to this sequence.
                TagOpSequence seq = new TagOpSequence();

                // Specify a target tag.
                // This is very important, since a kill operation is irreversible.
                target = new TargetTag();
                // Select a target tag based on the EPC.
                target.MemoryBank = MemoryBank.Epc;
                target.BitPointer = BitPointers.Epc;
                // The EPC of the target tag.
                target.Data = TARGET_EPC;

                // Apply the target tag to the tag operation sequence.
                seq.TargetTag = target;

                // Define a tag write operation that sets the kill password.
                // Tags cannot be killed with a zero password, so we must
                // set the password to a non-zero value first.
                TagWriteOp writeOp = new TagWriteOp();
                // Assumes that current access password is not set
                // (zero is the default)
                writeOp.AccessPassword = null;
                // The kill password is in the Reserved memory bank.
                writeOp.MemoryBank = MemoryBank.Reserved;
                // A pointer to the start of the kill password.
                writeOp.WordPointer = WordPointers.KillPassword;
                // The new kill password to write.
                writeOp.Data = TagData.FromHexString(KILL_PW);

                // Add this tag write op to the tag operation sequence.
                seq.Ops.Add(writeOp);

                // Add the tag operation sequence to the reader.
                // The reader supports multiple sequences.
                reader.AddOpSequence(seq);

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #23
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Create a tag operation sequence.
                // You can add multiple read, write, lock, kill and QT
                // operations to this sequence.
                TagOpSequence seq = new TagOpSequence();

                // Create a tag read operation.
                TagReadOp readOp = new TagReadOp();
                // Read from user memory
                readOp.MemoryBank = MemoryBank.User;
                // Read two (16-bit) words
                readOp.WordCount = 2;
                // Starting at word 0
                readOp.WordPointer = 0;

                // Add this tag read op to the tag operation sequence.
                seq.Ops.Add(readOp);

                // Specify a target tag based on the EPC.
                seq.TargetTag.MemoryBank = MemoryBank.Epc;
                seq.TargetTag.BitPointer = BitPointers.Epc;
                // Setting this to null will specify any tag.
                // Replace this line with the one below it to target a particular tag.
                seq.TargetTag.Data = null;
                //seq.TargetTag.Data = TagData.FromHexString("11112222333344445555666677778888");

                // Add the tag operation sequence to the reader.
                // The reader supports multiple sequences.
                reader.AddOpSequence(seq);

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #24
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                // Assign the LocationReported event handler.
                // This specifies which method to call
                // when a location report is available.
                reader.LocationReported += OnLocationReported;

                // Get the default settings
                // We'll use these as a starting point
                // and then modify the settings we're
                // interested in.
                Settings settings = reader.QueryDefaultSettings();

                // Put the spatial reader into location mode
                settings.SpatialConfig.Mode = SpatialMode.Location;

                // Enable all three report types
                settings.SpatialConfig.Location.EntryReportEnabled  = true;
                settings.SpatialConfig.Location.UpdateReportEnabled = true;
                settings.SpatialConfig.Location.ExitReportEnabled   = true;

                // Set spatial reader placement parameters

                // The mounting height of the spatial reader, in centimeters
                settings.SpatialConfig.Placement.HeightCm = 457;
                // These settings aren't required in a single spatial reader environment
                // They can be set to zero (which is the default)
                settings.SpatialConfig.Placement.FacilityXLocationCm = 0;
                settings.SpatialConfig.Placement.FacilityYLocationCm = 0;
                settings.SpatialConfig.Placement.OrientationDegrees  = 0;

                // Set spatial reader location parameters
                settings.SpatialConfig.Location.ComputeWindowSeconds = 10;
                settings.ReaderMode = ReaderMode.AutoSetDenseReaderDeepScan;
                settings.Session    = 2;
                settings.SpatialConfig.Location.TagAgeIntervalSeconds = 20;

                // Specify how often we want to receive location reports
                settings.SpatialConfig.Location.UpdateIntervalSeconds = 5;

                // Set this to true if the maximum transmit power is desired, false if a custom value is desired
                settings.SpatialConfig.Location.MaxTxPower = false;

                // If MaxTxPower is set to false, then a custom power can be used. Provide a power in .25 dBm increments
                settings.SpatialConfig.Location.TxPowerInDbm = 25.25;

                // Disable antennas targeting areas from which we may not want location reports,
                // in this case we're disabling antennas 10 and 15
                List <ushort> disabledAntennas = new List <ushort> {
                    10, 15
                };
                settings.SpatialConfig.Location.DisabledAntennaList = disabledAntennas;

                // Uncomment this is you want to filter tags

                /*
                 * // Setup a tag filter.
                 * // Only the tags that match this filter will respond.
                 * // We want to apply the filter to the EPC memory bank.
                 * settings.Filters.TagFilter1.MemoryBank = MemoryBank.Epc;
                 * // Start matching at the third word (bit 32), since the
                 * // first two words of the EPC memory bank are the
                 * // CRC and control bits. BitPointers.Epc is a helper
                 * // enumeration you can use, so you don't have to remember this.
                 * settings.Filters.TagFilter1.BitPointer = BitPointers.Epc;
                 * // Only match tags with EPCs that start with "3008"
                 * settings.Filters.TagFilter1.TagMask = "3008";
                 * // This filter is 16 bits long (one word).
                 * settings.Filters.TagFilter1.BitCount = 16;
                 *
                 * // Set the filter mode. Use only the first filter
                 * settings.Filters.Mode = TagFilterMode.OnlyFilter1;
                 */

                // Apply the newly modified settings.
                reader.ApplySettings(settings);

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Apply the default settings before exiting.
                reader.ApplyDefaultSettings();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #25
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Pass in a reader hostname or IP address as a
                // command line argument when running the example
                if (args.Length != 1)
                {
                    Console.WriteLine("Error: No hostname specified.  Pass in the reader hostname as a command line argument when running the Sdk Example.");
                    return;
                }
                string hostname = args[0];
                reader.Connect(hostname);

                reader.DirectionReported += OnDirectionReported;

                // Get the default settings
                // We'll use these as a starting point
                // and then modify the settings we're
                // interested in.
                Settings settings = reader.QueryDefaultSettings();

                // Put the spatial reader into direction mode
                settings.SpatialConfig.Mode = SpatialMode.Direction;

                // Retrieve the DirectionConfig object stored on the reader so that we can
                // modify the settings we are interested in.
                DirectionConfig directionConfig = settings.SpatialConfig.Direction;

                // Tells the spatial reader to perform tag reads more quickly at the expense of sensitivity.
                directionConfig.Mode = DirectionMode.HighSensitivity;

                // Enable the sectors you want to track tags in here. Note that you may only enable
                // non-adjacent sectors (e.g. 2 and 4, but not 2 and 3). Further note that sectors 2
                // and 9 are also considered adjacent.
                List <ushort> enabledSectorIDs = new List <ushort> {
                    2, 4, 6
                };
                // xSpans can only enable sectors 2 and 3
                if (reader.IsXSpan)
                {
                    enabledSectorIDs = new List <ushort> {
                        2, 3
                    }
                }
                ;
                directionConfig.EnabledSectorIDs = enabledSectorIDs;

                // Enable any reports you are interested in here. Entry reports are generated when
                // a tag is first read.  Updates are sent every "update interval" seconds indicating
                // that a tag is still visible to the reader. Exit reports are sent when a tag that
                // was seen previously, has not been read for "tag age interval" seconds. Both
                // "update interval" and "tag age interval" are set below to two and four seconds
                // respectively.
                directionConfig.EntryReportEnabled  = true;
                directionConfig.UpdateReportEnabled = true;
                directionConfig.ExitReportEnabled   = true;

                // Set this to true if the maximum transmit power is desired, false if a custom value is desired
                directionConfig.MaxTxPower = false;

                // If MaxTxPower is set to false, then a custom power can be used. Provide a power in .25 dBm increments
                directionConfig.TxPowerInDbm = 25.25;

                // Tells the spatial reader we want to track tags in as wide of an area as possible,
                // though a NARROW field of view is also available.
                directionConfig.FieldOfView = DirectionFieldOfView.Narrow;

                // Sets our application to only receive tag updates (or heartbeats) every two seconds.
                directionConfig.UpdateIntervalSeconds = 2;

                // Sets our application to only receive a tag's exit report after it has not been read
                // in any sector for four seconds.
                directionConfig.TagAgeIntervalSeconds = 4;

                // Sets a user limit on the tag population
                directionConfig.TagPopulationLimit = 20;

                // Define this is you want to filter tags
#if USE_FILTERING
                // Setup a tag filter.
                // Only the tags that match this filter will respond.
                // We want to apply the filter to the EPC memory bank.
                settings.Filters.TagFilter1.MemoryBank = MemoryBank.Epc;
                // Start matching at the third word (bit 32), since the
                // first two words of the EPC memory bank are the
                // CRC and control bits. BitPointers.Epc is a helper
                // enumeration you can use, so you don't have to remember this.
                settings.Filters.TagFilter1.BitPointer = BitPointers.Epc;
                // Only match tags with EPCs that start with "3008"
                settings.Filters.TagFilter1.TagMask = "3008";
                // This filter is 16 bits long (one word).
                settings.Filters.TagFilter1.BitCount = 16;

                // Set the filter mode. Use only the first filter
                settings.Filters.Mode = TagFilterMode.OnlyFilter1;
#endif

                // Pushes our specified configuration to the reader. If the set of enabled sectors violates the rules specified above,
                // an OctaneSDKException will be thrown here.
                reader.ApplySettings(settings);

                // Initiates our application and we should start to receive direction reports.
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // The application will terminate when the "Enter" key is pressed.
                reader.ApplyDefaultSettings();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #26
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Create a tag operation sequence.
                // You can add multiple read, write, lock, kill and QT
                // operations to this sequence.
                TagOpSequence seq = new TagOpSequence();

                // Specify a target tag based on the EPC.
                seq.TargetTag.MemoryBank = MemoryBank.Epc;
                seq.TargetTag.BitPointer = BitPointers.Epc;
                // Setting this to null will specify any tag.
                // Replace this line with the one below it to target a particular tag.
                seq.TargetTag.Data = null;
                //seq.TargetTag.Data = "11112222333344445555666677778888";

                // If you are using Monza 4, Monza 5 or Monza X tag chips,
                // uncomment these two lines. This enables 32-bit block writes
                // which significantly improves write performance.
                //seq.BlockWriteEnabled = true;
                //seq.BlockWriteWordCount = 2;

                // Create a tag write operation.
                TagWriteOp writeOp = new TagWriteOp();
                // Write to user memory
                writeOp.MemoryBank = MemoryBank.User;
                // Write two (16-bit) words
                //writeOp.Data = TagData.FromHexString("ABBAD00D");
                writeOp.Data = TagData.FromHexString("415543313041303031313631");
                // Starting at word 0
                writeOp.WordPointer = 0x23;

                // Add this tag write op to the tag operation sequence.
                seq.Ops.Add(writeOp);

                // Add the tag operation sequence to the reader.
                // The reader supports multiple sequences.
                reader.AddOpSequence(seq);

                // Start the reader
                reader.Start();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #27
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                Console.WriteLine("Connecting to the reader.");
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Get the default settings
                // We'll use these as a starting point
                // and then modify the settings we're
                // interested in.
                Settings settings = reader.QueryDefaultSettings();

                // Set the start trigger to Immediate.
                // This will allow the reader to start as soon as it boots up.
                settings.AutoStart.Mode = AutoStartMode.Immediate;

                // Tell the reader to hold all tag reports and events
                // when we disconnect from the reader.
                settings.HoldReportsOnDisconnect = true;

                // Tell the reader to include the antenna number
                // and timestamp in all tag reports. Other fields
                // can be added to the reports in the same way by
                // setting the appropriate Report.IncludeXXXXXXX property.
                settings.Report.IncludeAntennaPortNumber = true;
                settings.Report.IncludeFirstSeenTime     = true;

                // Apply the newly modified settings.
                Console.WriteLine("Configuring the reader.");
                reader.ApplySettings(settings);

                // The current configuration will be saved to to persistent storage.
                // The saved parameters then become the reader's power-on defaults.
                // If AutoStart mode is set to Immediate, the reader will
                // automatically start after booting up.
                Console.WriteLine("Press enter to save settings and reboot");
                Console.ReadLine();
                reader.SaveSettings();

                // Disconnect from the reader
                Console.WriteLine("Disconnecting from reader.");
                reader.Disconnect();

                // Issue an RShell command to reboot.
                // Open up an RShell connection on the reader.
                // Specify the reader address, user name, password and connection timeout.
                string reply;
                reader.RShell.Open(SolutionConstants.ReaderHostname, "root", "impinj", 5000);
                RShellCmdStatus status = reader.RShell.Send("reboot", out reply);
                // Close the RShell connection.
                reader.RShell.Close();

                // Check the status of the RShell command.
                if (status == RShellCmdStatus.Success)
                {
                    Console.WriteLine("Reader rebooting...\n");
                    Thread.Sleep(15000);

                    Console.Write("Waiting for reader to come back online.");
                    // Ping the reader until it's back online.
                    while (!ReaderIsAvailable(SolutionConstants.ReaderHostname))
                    {
                        Console.Write(".");
                        Thread.Sleep(1000);
                    }

                    Console.WriteLine("\nThe reader is back online. Press enter to reconnect and get tag data.\n");
                    Console.ReadLine();
                    Console.WriteLine("Reconnecting to reader.");

                    // Reconnect to the reader.
                    reader.Connect(SolutionConstants.ReaderHostname);

                    // Enable tag reports and events.
                    reader.ResumeEventsAndReports();
                }
                else
                {
                    // Error executing RShell command. Print out reply.
                    Console.WriteLine("RShell command failed to execute.\n");
                    Console.WriteLine("RShell command reply : \n\n" + reply + "\n");
                }

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Apply the default settings.
                // This removes the saved settings.
                reader.ApplyDefaultSettings();

                // Stop reading.
                reader.Stop();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #28
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Query the reader features and print the results.
                Console.WriteLine("Reader Features");
                Console.WriteLine("---------------");
                FeatureSet features = reader.QueryFeatureSet();
                Console.WriteLine("Model name : {0}", features.ModelName);
                Console.WriteLine("Model number : {0}", features.ModelNumber);
                Console.WriteLine("Reader model : {0}", features.ReaderModel.ToString());
                Console.WriteLine("Firmware version : {0}", features.FirmwareVersion);
                Console.WriteLine("Antenna count : {0}\n", features.AntennaCount);

                // Write the reader features to file.
                features.Save("features.xml");

                // Query the current reader status.
                Console.WriteLine("Reader Status");
                Console.WriteLine("---------------");
                Status status = reader.QueryStatus();
                Console.WriteLine("Is connected : {0}", status.IsConnected);
                Console.WriteLine("Is singulating : {0}", status.IsSingulating);
                Console.WriteLine("Temperature : {0}° C\n", status.TemperatureInCelsius);

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Display the current reader settings.
                DisplayCurrentSettings();

                // Save the settings to file in XML format.
                Console.WriteLine("Saving settings to file.");
                Settings settings = reader.QuerySettings();
                settings.Save("settings.xml");

                // Wait here, so we can edit the
                // settings.xml file in a text editor.
                Console.WriteLine("Edit settings.xml and press enter.");
                Console.ReadLine();

                // Load the modified settings from file.
                Console.WriteLine("Loading settings from file.");
                settings = Settings.Load("settings.xml");

                // Apply the settings we just loaded from file.
                Console.WriteLine("Applying settings from file.\n");
                reader.ApplySettings(settings);

                // Display the settings again to show the changes.
                DisplayCurrentSettings();

                // Wait for the user to press enter.
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();

                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
Example #29
0
        private void button2_Click(object sender, EventArgs e)
        {
            // The sender can be the textbox (address) or the button (connect).

            TextBox addressText = this.Controls.Find("addressText", true)[0] as TextBox;
            string  address     = addressText.Text;

            if (!ValidateIPv4(address))
            {
                string            message = "Endereço IPV4 inválido.";
                string            caption = "Erro";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                DialogResult      result;

                // Displays the MessageBox.
                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    // Closes the parent form.
                    // this.Close();
                    addressText.Focus();
                    return;
                }
            }

            try
            {
                ImpinjReader reader = new ImpinjReader();

                reader.ConnectionLost += OnConnectionLost;

                reader.ConnectionLost += new ImpinjReader.ConnectionLostHandler((ImpinjReader reader2) => {
                    Console.Write("Connection lost");
                });

                if (readers.ContainsKey(address))
                {
                    string            message = "O leitor já está conectado.";
                    string            caption = "Erro";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    DialogResult      result;

                    // Displays the MessageBox.
                    result = MessageBox.Show(message, caption, buttons);

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        // Closes the parent form.
                        // this.Close();
                        addressText.Focus();
                        return;
                    }
                }

                reader.Connect(address);
                readers.Add(address, reader);

                Settings settings = reader.QueryDefaultSettings();
                settings.ReaderMode = ReaderMode.AutoSetDenseReader;

                ReportConfig report = settings.Report;
                report.IncludeAntennaPortNumber = true;
                report.IncludeFirstSeenTime     = true;
                report.IncludeLastSeenTime      = true;
                report.IncludeSeenCount         = true;
                report.Mode = ReportMode.Individual;

                AntennaConfigGroup antennas = settings.Antennas;
                antennas.DisableAll();

                antennas.EnableById(new ushort[] { 1 });
                AntennaConfig antennaConfig = antennas.GetAntenna(1);
                antennaConfig.MaxRxSensitivity   = true;
                antennaConfig.RxSensitivityInDbm = -70;
                antennaConfig.MaxTxPower         = true;
                antennaConfig.TxPowerInDbm       = 20.0;

                // Assign the TagsReported event handler.
                // This specifies which method to call
                // when tags reports are available.
                reader.TagsReported += OnTagsReported;

                // Apply the custom settings.
                reader.ApplySettings(settings);
                // Apply the default settings.
                reader.ApplyDefaultSettings();

                // Start reading.
                reader.Start();
            }
            catch (OctaneSdkException ex)
            {
                Console.Write(ex.ToString());
                return;
            }

            Control[]   controls = this.Controls.Find("LogTextArea", true);
            RichTextBox logs     = controls[0] as RichTextBox;

            logs.Invoke(new Action(() => {
                addressText.Clear();
                logs.AppendText("Leitor: " + address + " foi conectado com sucesso.\n");
            }));
        }
Example #30
0
        static void Main(string[] args)
        {
            try
            {
                // Connect to the reader.
                // Change the ReaderHostname constant in SolutionConstants.cs
                // to the IP address or hostname of your reader.
                reader.Connect(SolutionConstants.ReaderHostname);

                // Assign the TagOpComplete event handler.
                // This specifies which method to call
                // when tag operations are complete.
                reader.TagOpComplete += OnTagOpComplete;

                // Configure the reader with the default settings.
                reader.ApplyDefaultSettings();

                // Create a tag operation sequence.
                // You can add multiple read, write, lock, kill and QT
                // operations to this sequence.
                TagOpSequence seq = new TagOpSequence();

                // Define a tag write operation that sets the access password.
                TagWriteOp writeOp = new TagWriteOp();
                // Assumes that current access password is not set
                // (zero is the default)
                writeOp.AccessPassword = null;
                // The access password is in the Reserved memory bank.
                writeOp.MemoryBank = MemoryBank.Reserved;
                // A pointer to the start of the access password.
                writeOp.WordPointer = WordPointers.AccessPassword;
                // The new access password to write.
                writeOp.Data = TagData.FromHexString("11112222");

                // Add this tag write op to the tag operation sequence.
                seq.Ops.Add(writeOp);

                // Create a tag lock operation to lock the
                // access password and User memory.
                TagLockOp lockOp = new TagLockOp();
                lockOp.AccessPasswordLockType = TagLockState.Lock;
                lockOp.UserLockType           = TagLockState.Lock;

                // Add this tag lock op to the tag operation sequence.
                seq.Ops.Add(lockOp);

                // Add the tag operation sequence to the reader.
                // The reader supports multiple sequences.
                reader.AddOpSequence(seq);

                // Start the reader
                reader.Start();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }

            // Wait for the user to press enter.
            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();

            // Stop reading.
            reader.Stop();

            // Disconnect from the reader.
            reader.Disconnect();
        }