/// <summary> /// 带参构造函数2 /// </summary> /// <param name="func"></param> public RfidTool(Action <RfidOptions> func) { reader = new ImpinjReader(); option = new RfidOptions(); func(option); RedirectStandardOut += Console.WriteLine; }
//array to hold the margin test settings //public double currentPower = 0; public void ConnectReader(ImpinjReader reader, string hostname, double startPower) { try { Console.WriteLine("Attempting to connect to reader: " + hostname); reader.Connect(hostname); //connected = true; Console.WriteLine("Loading Margin Test Settings onto the reader"); Settings settings = reader.QueryDefaultSettings(); settings.Report.IncludeAntennaPortNumber = true; settings.Report.Mode = ReportMode.Individual; settings.Antennas.TxPowerInDbm = startPower; settings.Report.IncludeFastId = true; settings.Session = 0; settings.SearchMode = SearchMode.SingleTarget; reader.ApplySettings(settings); Console.WriteLine("Successfully connected, settings Applied"); } catch (OctaneSdkException err) { System.Diagnostics.Trace. WriteLine("An Octane Exception has occurred: {0}", err.Message); } catch (Exception err) { System.Diagnostics.Trace. WriteLine("An Exception has occured: {0}", err.Message); } }
public void OnTagsReported7(ImpinjReader sender, TagReport report) { // We've read the tag we want write to, so // we're not interested in tag reports any more. // Unsubscribe from the event. reader.TagsReported -= OnTagsReported7; // Change the EPC of the first tag we read to a random value. Tag tag = report.Tags[0]; TextBox.CheckForIllegalCrossThreadCalls = false; //string nuevoEPC = tbNEPCSpeedway.Text; tbEPCSpeedway.Text = tag.Epc.ToHexString(); //ProgramEpc(tag.Epc.ToHexString(), tag.PcBits, nuevoEPC); //MessageBox.Show("El nuevo tag es:" + tag.Epc.ToHexString()); try { if (cbIncSpeedway.Checked == true) { tbNEPCSpeedway.Text = (Int64.Parse(tbEPCSpeedway.Text) + Int64.Parse(nuSpeedway.Value.ToString())).ToString().PadLeft(24, '0'); } else { tbNEPCSpeedway.Text = tag.Epc.ToHexString(); } } catch { } }
private void DisplayTag(ImpinjReader reader, TagReport report) { foreach (Tag tag in report) { //TODO: добавить метод AsyncEvent.ExternalEvent } }
// This event handler will be called when tag // operations have been executed by the reader. static void OnTagOpComplete(ImpinjReader reader, TagOpReport report) { string userData, tidData, epcData; userData = tidData = epcData = ""; // Loop through all the completed tag operations foreach (TagOpResult result in report) { // Was this completed operation a tag read operation? if (result is TagReadOpResult) { // Cast it to the correct type. TagReadOpResult readResult = result as TagReadOpResult; // Save the EPC epcData = readResult.Tag.Epc.ToHexString(); // Are these the results for User memory or TID? if (readResult.OpId == opIdUser) { userData = readResult.Data.ToHexString(); } else if (readResult.OpId == opIdTid) { tidData = readResult.Data.ToHexString(); } } } // Print out the results after both Optimized Read operations have completed. Console.WriteLine("EPC : {0}, TID : {1}, User : {2}", epcData, tidData, userData); }
public RealReader() { _reader = new ImpinjReader(); _reader.TagsReported += OnTagsReported; _reader.KeepaliveReceived += OnKeepaliveReceived; _reader.ConnectionLost += OnConnectionLost; }
static void ConnectAsync(ImpinjReader reader) { try { // Assign the ConnectAsyncComplete event handler. // This specifies which method to call // when the connection attempt has completed. reader.ConnectAsyncComplete += OnConnectAsyncComplete; // Attempt to connect to this reader asynchronously. // This method return immediately. // An event will be raised when the connect attempt has succeeded or failed. Console.WriteLine("Attempting connection to {0}", SolutionConstants.ReaderHostname); reader.ConnectAsync(SolutionConstants.ReaderHostname); // Wait for the user to press enter. Console.WriteLine("Press enter to exit."); Console.ReadLine(); } 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); } }
// This event handler will be called when tag // operations have been executed by the reader. static void OnTagOpComplete(ImpinjReader reader, TagOpReport report) { // Loop through all the completed tag operations foreach (TagOpResult result in report) { if (result is TagWriteOpResult) { // These are the results of settings the access password. // Cast it to the correct type. TagWriteOpResult writeResult = result as TagWriteOpResult; // Print out the results. Console.WriteLine("Set access password complete."); Console.WriteLine("EPC : {0}", writeResult.Tag.Epc); Console.WriteLine("Status : {0}", writeResult.Result); Console.WriteLine("Number of words written : {0}", writeResult.NumWordsWritten); } else if (result is TagLockOpResult) { // Cast it to the correct type. // These are the results of locking the access password or user memory. TagLockOpResult lockResult = result as TagLockOpResult; // Print out the results. Console.WriteLine("Lock operation complete."); Console.WriteLine("EPC : {0}", lockResult.Tag.Epc); Console.WriteLine("Status : {0}", lockResult.Result); } } }
static void OnTagsReported(ImpinjReader sender, TagReport report) { // This event handler is called asynchronously // when tag reports are available. // Loop through each tag in the report // and print the data. foreach (Tag tag in report) { if (tag.IsFastIdPresent) { // Print the model specific details that can be determined from the TID. Console.WriteLine("Antenna : {0}\nEPC : {1}\nTID : {2}\n" + "Model Name : {3}\nEPC memory size (bits) : {4}\n" + "User memory size (bits) : {5}\nSupports QT : {6}\n\n", tag.AntennaPortNumber, tag.Epc, tag.Tid, tag.ModelDetails.ModelName, tag.ModelDetails.EpcSizeBits, tag.ModelDetails.UserMemorySizeBits, tag.ModelDetails.SupportsQt); } else { // Fast ID not available. // Chip is not a Monza 4 or later. Console.WriteLine("Antenna : {0}\nEPC : {1}\nTID : Fast ID not available\n\n", tag.AntennaPortNumber, tag.Epc); } } }
static void Main(string[] args) { Reader readerObject = new Reader(); ImpinjReader reader = new ImpinjReader(); Stopwatch s = new Stopwatch(); /* * ARGUMENTS IN ORDER: * 0: Hostname * 1: Start Power * 2: End Power * 3: Step Size * 4: Power Duration * 5: CSV File name */ // variable initialization string hostname = args[0]; double startPower = Convert.ToDouble(args[1]); double endPower = Convert.ToDouble(args[2]); double stepSize = Convert.ToDouble(args[3]); int duration = Convert.ToInt32(args[4]); string tagName = args[5]; double currentPower = startPower; // start the margin test readerObject.ConnectReader(reader, hostname, currentPower); // creating event for when a tag is reportedi reader.TagsReported += onTagsReported; while (currentPower <= endPower) { if (reader.IsConnected) { reader.Start(); s.Start(); while (s.Elapsed < TimeSpan.FromSeconds(duration)) { //Console.WriteLine("This is a test"); } s.Reset(); reader.Stop(); WriteFileName(tagsRead, tagName, currentPower); // clearing list contents to make room for the next powerlevel tagsRead.Clear(); // updating the power setting before running the test again currentPower = readerObject.UpdateSettings(reader, currentPower, stepSize); } else { Console.Write("Reader not connected! "); System.Environment.Exit(1); } Console.WriteLine("Finished A power cycle"); } Console.WriteLine("Margin test completed. Moving Outputs to /data"); reader.Disconnect(); }
public void OnTagsReported10(ImpinjReader sender, TagReport report) { // This event handler is called asynchronously // when tag reports are available. // Loop through each tag in the report // and print the data. //reader.TagsReported -= OnTagsReported10; foreach (Tag tag in report) { ListBox.CheckForIllegalCrossThreadCalls = false; lbSpeedway.Items.Add("Antena: " + tag.AntennaPortNumber + " Tag: " + tag.Epc.ToString()); try { WebRequest req = WebRequest.Create(@"http://52.43.37.169:8080/eventos/rest/r420/leer/" + Regex.Replace(tag.Epc.ToString(), @"\s+", "") + "/" + tbEventoSW.Text); req.Method = "POST"; req.Timeout = 5000; HttpWebResponse resp = req.GetResponse() as HttpWebResponse; req.Abort(); } catch { AutoClosingMessageBox.Show("Tag : " + tag.Epc + " no enviado", "Mensaje", 1000); // System.Diagnostics.Debug.WriteLine("Tag : " + tag.Epc + " no enviado"); } } }
static void OnTagsReported(ImpinjReader sender, TagReport report) { string key; // This event handler is called asynchronously // when tag reports are available. // Loop through each tag in the report // and print the data. foreach (Tag tag in report) { if (tag.IsFastIdPresent) { // If the TID is available through FastID, use it as the key key = tag.Tid.ToHexString(); } else { // Otherwise use the EPC key = tag.Epc.ToHexString(); } // If this tag hasn't been read before, print out the EPC and TID if (!tagsRead.ContainsKey(key)) { Console.WriteLine("EPC : {0}, TID : {1}", tag.Epc, tag.Tid); // Add this tag to the list of tags we've read. tagsRead.Add(key, tag); } } }
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); } }
//static string rawTagDisplay = null; public static string FormatReaderInfo(ImpinjReader reader, FeatureSet features, Settings settings, Status status) { string modelName = features.ModelName; string readerIP = reader.Address; string connectedStatus = status.IsConnected.ToString(); string modelNumber = features.ModelNumber.ToString(); string firmwareVersion = features.FirmwareVersion; string antennaCount = features.AntennaCount.ToString(); string isSingulating = status.IsSingulating.ToString(); float tempCelsius = status.TemperatureInCelsius; string enabledAntennaOne = settings.Antennas.GetAntenna(1).IsEnabled.ToString(); string rxSensitivity = settings.Antennas.GetAntenna(1).RxSensitivityInDbm.ToString(); string txPower = settings.Antennas.GetAntenna(1).TxPowerInDbm.ToString(); string currentTime = DateTime.Now.ToString("h:mm:ss tt"); string info = "CONNECTED TO READER: " + Environment.NewLine + Environment.NewLine + "Model Name: " + modelName + Environment.NewLine + "Address: " + readerIP + Environment.NewLine + "Model Number: " + modelNumber + Environment.NewLine + "Firmware Version: " + firmwareVersion + Environment.NewLine + "Antenna Ports: " + antennaCount + Environment.NewLine + "Is Singulating: " + isSingulating + Environment.NewLine + "Temp. Celsius: " + tempCelsius + Environment.NewLine + "Antenna (1) Enabled: " + enabledAntennaOne + Environment.NewLine + "Rx Sensitivity: " + rxSensitivity + Environment.NewLine + "txPower: " + txPower + Environment.NewLine + "Time: " + currentTime; return(info); }
// This event handler will be called when tag // operations have been executed by the reader. static void OnTagOpComplete(ImpinjReader reader, TagOpReport report) { // Loop through all the completed tag operations foreach (TagOpResult result in report) { // Was this completed operation QT set operation? if (result is TagQtSetOpResult) { // Cast it to a QT set result. TagQtSetOpResult qtSetResult = result as TagQtSetOpResult; // Print the status. Console.WriteLine("QT set operation complete. Status : {0}", qtSetResult.Result); } // Was this completed operation QT get operation? else if (result is TagQtGetOpResult) { // Cast it to a QT get result. TagQtGetOpResult qtGetResult = result as TagQtGetOpResult; // Print the status. Console.WriteLine("QT get operation complete. Status : {0}", qtGetResult.Result); Console.WriteLine(" Data Profile : {0}, Access Range : {1}", qtGetResult.DataProfile, qtGetResult.AccessRange); } } }
/// <summary> /// This event handler is called asynchronously /// when tag reports are available. /// Loop through each tag in the report /// and print the data. /// My Output to the file /// </summary> private void OnTagsReported(ImpinjReader sender, TagReport report) { foreach (Tag tag in report) { if (!ItemString.RFIDControlReaderState) { //System.Diagnostics.Debug.WriteLine("OnTagsReported:RFID 绘制结束stop"); continue; } else { try { //int rId = rFIDDatas.FindIndex(a => a.getID() == tag.Epc.ToString()); // System.Diagnostics.Debug.WriteLine("OnTagsReported:EPC" + tag.Epc.ToString()); if (tag.Epc.ToString() != ItemString.RFIDEPC) { continue; } int rId = 0; if (rFIDDatas.Count < 1) { // System.Diagnostics.Debug.WriteLine("OnTagsReported:add data:EPC" + tag.Epc.ToString()); rFIDDatas.Add(new RFIDData(Convert.ToString(ItemString.RFIDEPC))); } rFIDDatas[rId].addRSSPhaseTime(tag.PeakRssiInDbm, tag.PhaseAngleInRadians, TimeUtil.getReletiveToStartProgramSeconds()); addQueue(tag.PeakRssiInDbm, tag.PhaseAngleInRadians); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("OnTagsReported:出现异常 " + e.StackTrace); } } } }
public static void OnTagOpComplete(ImpinjReader reader, TagOpReport report) { // Loop through all the completed tag operations. foreach (TagOpResult result in report) { // Was this completed operation a tag write operation? if (result is TagWriteOpResult) { // Cast it to the correct type. TagWriteOpResult writeResult = result as TagWriteOpResult; if (writeResult.OpId == EPC_OP_ID) { Console.WriteLine("Write to EPC complete : {0}", writeResult.Result); } else if (writeResult.OpId == PC_BITS_OP_ID) { Console.WriteLine("Write to PC bits complete : {0}", writeResult.Result); } // Print out the number of words written Console.WriteLine("Number of words written : {0}", writeResult.NumWordsWritten); } } reader.TagsReported += EventHandlers.OnTagsReported; }
// This event handler will be called when tag // operations have been executed by the reader. static void OnTagOpComplete(ImpinjReader reader, TagOpReport report) { // Loop through all the completed tag operations foreach (TagOpResult result in report) { // Was this completed operation a tag read operation? if (result is TagReadOpResult) { // Cast it to the correct type. TagReadOpResult readResult = result as TagReadOpResult; // Process the read results HandleReadOpComplete(readResult); } // Was it a tag write operation? else if (result is TagWriteOpResult) { // Cast it to the correct type. TagWriteOpResult writeResult = result as TagWriteOpResult; // Process the write results HandleWriteOpComplete(writeResult); } } }
static void OnTagsReported(ImpinjReader sender, TagReport report) { // This event handler is called asynchronously // when tag reports are available. // Loop through each tag in the report // and print the data. DataRow workRow = table.NewRow(); foreach (Tag tag in report) { /*if (tag.Epc.ToString() == "E200 9366 C6B6 7BF1 9071 BDEF") * { * Console.WriteLine("EPC : {0} Timestamp : {1}", tag.Epc, tag.LastSeenTime); * //Console.WriteLine("RfDopplerFrequency : {0} ChannelInMhz : {1}", tag.RfDopplerFrequency, tag.ChannelInMhz); * Console.WriteLine("PeakRssiInDbm : {0} PhaseAngleInRadians : {1}", tag.PeakRssiInDbm, tag.PhaseAngleInRadians); * }*/ Console.WriteLine("EPC : {0} Timestamp : {1}", tag.Epc, tag.LastSeenTime); //Console.WriteLine("RfDopplerFrequency : {0} ChannelInMhz : {1}", tag.RfDopplerFrequency, tag.ChannelInMhz); Console.WriteLine("PeakRssiInDbm : {0} PhaseAngleInRadians : {1}", tag.PeakRssiInDbm, tag.PhaseAngleInRadians); workRow["EPC"] = tag.Epc; workRow["Timestamp"] = tag.LastSeenTime; workRow["ChannelInMhz"] = tag.ChannelInMhz; workRow["PeakRssiInDbm"] = tag.PeakRssiInDbm; workRow["PhaseAngleInRadians"] = tag.PhaseAngleInRadians; table.Rows.Add(workRow); } }
public void LaunchXArray(ImpinjReader reader, XArray xArray) { try { // Connect to the reader. // Change the ReaderHostname constant in SolutionConstants.cs // to the IP address or hostname of your reader. reader.Connect(xArray.Hostname); // Assign the LocationReported event handler. // This specifies which method to call // when a location report is available. reader.LocationReported += OnLocationReported; // Don't forget to define diagnostic method reader.DiagnosticsReported += OnDiagnosticsReported; // Apply the newly modified settings. reader.ApplySettings(GetPrepareSettings(reader, xArray)); // 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); } }
private void CloseXArray(ImpinjReader reader) { // Apply the default settings before exiting. reader.ApplyDefaultSettings(); // Disconnect from the reader. reader.Disconnect(); }
// The following specifies which methods to call when tags are reported or operations are complete. // The TagsReported handler method will handle all new incoming tags static void OnTagsReported(ImpinjReader sender, TagReport report) { foreach (Tag tag in report) { double phaseAngle; phaseAngle = tag.PhaseAngleInRadians; //DataRow row = DataDS.NewRow(); ////给列赋值 //DateTime dt = DateTime.Now; row["EPC"] = tag.Epc.ToString(); row["Doppler Shift"] = tag.RfDopplerFrequency.ToString("0.00"); row["Time"] = tag.FirstSeenTime.ToString(); row["Antenna"] = tag.AntennaPortNumber; row["Tx Power"] = txPowerValue; row["Current Frequency"] = tag.ChannelInMhz.ToString(); row["PeakRSSI"] = tag.PeakRssiInDbm.ToString(); row["Phase Angle"] = phaseAngle;//tag.PhaseAngleInRadians.ToString(); row["Phase"] = ((tag.PhaseAngleInRadians) / Math.PI) * 180; string EPCStr = tag.Epc.ToString(); EPCList.Add(tag.Epc.ToString()); PhaseList.Add(phaseAngle); TimeList.Add(tag.FirstSeenTime.ToString()); string EPCStr = tag.Epc.ToString(); //把有值的列添加到表 if (EPCStr.Contains("0093")) { IncomingTagNumber93 = IncomingTagNumber93 + 1; } else if (EPCStr.Contains("0012")) { IncomingTagNumber70 = IncomingTagNumber70 + 1; } else if (EPCStr.Contains("0078")) { IncomingTagNumber96 = IncomingTagNumber96 + 1; } //把有值的列添加到表 //if (EPCStr.Contains("0093")) //{ // IncomingTagNumber93 = IncomingTagNumber93 + 1; // RSS93.Add(tag.PeakRssiInDbm.ToString()); //} //else //{ //} //DataDS.Rows.Add(row); //DSForm.updateTaginfo((int)TagsEPC[tag.Epc.ToString()], (float)(tag.RfDopplerFrequency));//, tag.FirstSeenTime.LocalDateTime } }
// This event handler will be called when a location report is ready. void OnLocationReported(ImpinjReader reader, LocationReport report) { string EpcStr = report.Epc.ToHexString(); // Compute confidence. Make sure that the first cycle report came in before computing the Weighted averages. if (!CycleLengths.ContainsKey(reader.Address) || CycleLengths[reader.Address] == 0) { return; } // If first time if (!TagReadInfo.ContainsKey(EpcStr)) { TagReadInfo.Add(EpcStr, new TagReadInfo()); } double Mult = Math.Floor((double)COMPUTE_WINDOW_SEC * 1000000 / CycleLengths[reader.Address]); if (Mult == 0) { Mult = 1; } double Confidence = report.ConfidenceFactors.ReadCount / Mult; Console.WriteLine(reader.Address + " " + EpcStr + " x=" + report.LocationXCm + " y=" + report.LocationYCm + " conf=" + Confidence); // Weighted X double WgtX = Confidence * report.LocationXCm; TagReadInfo[EpcStr].WeightedX += WgtX; // Weighted Y double WgtY = Confidence * report.LocationYCm; TagReadInfo[EpcStr].WeightedY += WgtY; // TagReadCounts TagReadInfo[EpcStr].Confidence += Confidence; // Pick a reader to key off the Averaging calculation // Let's use the last one. if (reader.Address.Equals(xArrays[xArrays.Length - 1].Hostname)) { Console.Write("Weighted: " + EpcStr); if (TagReadInfo[EpcStr].Confidence != 0) { Console.Write(" x=" + Math.Floor(TagReadInfo[EpcStr].WeightedX / TagReadInfo[EpcStr].Confidence)); Console.WriteLine(" y=" + Math.Floor(TagReadInfo[EpcStr].WeightedY / TagReadInfo[EpcStr].Confidence)); } else { Console.WriteLine("Invalid Read. Confidence is 0"); } // Reinitialize variables TagReadInfo[EpcStr].WeightedX = 0; TagReadInfo[EpcStr].WeightedY = 0; TagReadInfo[EpcStr].Confidence = 0; } }
// This event handler is called asynchronously // when tag reports are available. static void OnTagsReported(ImpinjReader sender, TagReport report) { // Loop through each tag in the report // and print the data. foreach (Tag tag in report) { Console.WriteLine("EPC : {0}", tag.Epc); } }
private void OnTagsReported(ImpinjReader sender, TagReport report) { // Это событие которое обнавляет информацию в ListBox со считывателя во время считывания. //Action action = delegate()(снять) //{(снять) // UpdateListbox(report.Tags);(снять) //};(снять) //Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, action);(снять) }
/**************************************************************** * 处理标签报告 *****************************************************************/ public static void OnTagsReported(ImpinjReader sender, TagReport report) { try { foreach (Tag tag in report) { if (tag.Epc != null) { while (dtLock == true) { ; } dtLock = true; DataRow dr1 = dt.NewRow(); dr1["EPC"] = tag.Epc; dr1["RSS"] = tag.PeakRssiInDbm; dr1["Frequency"] = tag.ChannelInMhz; dr1["Phase"] = tag.PhaseAngleInRadians; dr1["Reader"] = sender.Name; //dr1["Address"] = sender.Address; dr1["Antenna"] = tag.AntennaPortNumber; dr1["SeenTime"] = tag.LastSeenTime; dt.Rows.Add(dr1); dtLock = false; switch (sender.Name) { case "Reader #1": case "1": ++c1; break; case "Reader #2": case "2": ++c2; break; case "Reader #3": case "3": ++c3; break; case "Reader #4": case "4": ++c4; break; default: break; } } } } catch (Exception ee) { MessageBox.Show(ee.Message + ee.StackTrace); } }
public double UpdateSettings(ImpinjReader reader, double power, double stepSize) { Settings settings = reader.QuerySettings(); settings.Antennas.TxPowerInDbm = power + stepSize; reader.ApplySettings(settings); Console.WriteLine("Power Level successfully changed"); return(power + stepSize); }
private void OnTagsReported(ImpinjReader sender, TagReport report) { Action action = delegate() { UpdateListbox(report.Tags); Console.WriteLine(report.Tags.Count); }; Dispatcher.BeginInvoke(DispatcherPriority.Normal, action); }
public ReaderImpinj() { impinjReader = new ImpinjReader { ConnectTimeout = 6000, }; Antennas = new int[] { 4, 5 }; _isReading = false; }
public FormValidar(string embarque, int anden) { _embarque = embarque; _anden = anden; InitializeComponent(); reader = new ImpinjReader(); iniciar(); LlenarDgv(); IniciarReader(_embarque, _anden); }
public void ConnectAndPrepareAllReaders() { foreach (string readerName in ReaderNames) { ImpinjReader reader = new ImpinjReader(); try { // Set the reader identity. It can be any object. // This is passed back with events and tag reports. reader.Name = readerName; //reader.ReaderIdentity = readerName; // Change the level of logging detail. The default is Error. //reader.LogLevel = LogLevel.Error; // Attach to events Reader.TagsReported += OnTagsReported; Reader.ReaderStarted += OnReaderStarted; Reader.ReaderStopped += OnReaderStopped; // Connect to the reader. The name is the host name // or IP address. Reader.Connect(_ReaderIP); // Clear the reader of any RFID operation and configuration. Reader.ApplyDefaultSettings(); // Query the default settings for the reader. Settings // include which antennas are enabled, when to report and // optional report fields. Typically you will prepare the // reader by getting the default settings and adjusting them. // // This example sets the reader to send a tag report // immediately on every tag observation. Message buffering // improves overall efficiency but introduces a small // delay before the application is notified of a tag. // Message buffering is enabled by default. Settings settings = Reader.QueryDefaultSettings(); settings.Report.Mode = ReportMode.Individual; settings.ReaderMode = ReaderMode.AutoSetDenseReader; // Adjust ช่องความถี่ settings.SearchMode = SearchMode.TagFocus; //จับสัญญาน ไวขึ้น settings.Session = 1; settings.AutoStart.Mode = AutoStartMode.GpiTrigger; settings.AutoStart.GpiPortNumber = 1; settings.AutoStart.GpiLevel = true; settings.AutoStop.Mode = AutoStopMode.GpiTrigger; settings.AutoStop.GpiPortNumber = 1; settings.AutoStop.GpiLevel = false; settings.Report.IncludeAntennaPortNumber = true; settings.Antennas.GetAntenna(1).IsEnabled = true; settings.Antennas.GetAntenna(2).IsEnabled = true; settings.Antennas.GetAntenna(3).IsEnabled = true; settings.Antennas.GetAntenna(4).IsEnabled = true; settings.Antennas.GetAntenna(1).MaxRxSensitivity = true; settings.Antennas.GetAntenna(1).TxPowerInDbm = 25; settings.Antennas.GetAntenna(2).MaxRxSensitivity = true; settings.Antennas.GetAntenna(2).TxPowerInDbm = 25; settings.Antennas.GetAntenna(3).MaxRxSensitivity = true; settings.Antennas.GetAntenna(3).TxPowerInDbm = 25; settings.Antennas.GetAntenna(4).MaxRxSensitivity = true; settings.Antennas.GetAntenna(4).TxPowerInDbm = 25; reader.ApplySettings(settings); // Add this reader to the list of readers. readers.Add(reader); } catch (Exception ex) { //Console.WriteLine("Exception {0} for reader {1}", ex, readerName); try { reader.Disconnect(); } catch (OctaneSdkException octaneSdkException) { //Console.WriteLine("OctaneSdk detected {0}", octaneSdkException); } catch (Exception exception) { //Console.WriteLine("Exception {0}", exception); } } } }
// This event handler gets called when the reader is stopped. static void OnReaderStopped(ImpinjReader reader, ReaderStoppedEvent e) { Console.WriteLine("Reader stopped : {0}", reader.Address); }
/// <summary> /// Called each time the reader disconnects. /// </summary> /// <param name="sender">The reader that sent the event.</param> /// <param name="args">Contains information about the event; the reader, timestamp and new /// reader state are properties of this object.</param> /// <summary> /// Called each time the reader starts. /// </summary> /// <param name="sender">The reader that sent the event.</param> /// <param name="args">Contains information about the event; the reader, timestamp and new /// operational state are properties of this object.</param> //public void StartedHandler(object sender, StartedEventArgs args) //{ // writeLog("Reader started as of {0} " + args.Timestamp); //} /// <summary> /// Called each time the reader stops. /// </summary> /// <param name="sender">The reader that sent the event.</param> /// <param name="args">Contains information about the event; the reader, timestamp and news /// operational state are properties of this object.</param> //public void StoppedHandler(object sender, StoppedEventArgs args) //{ // writeLog("Reader stopped as of {0} " + args.Timestamp); //} /// <summary> /// Called each time the reader singulates a tag, or a batch of tags. /// </summary> /// <param name="sender">The reader that sent the event.</param> /// <param name="args">Contains information about the event; the reader, timestamp and /// tag reports are properties of this object.</param> public void OnTagsReported(ImpinjReader sender, TagReport report) { ////panel1.Controls.Clear(); //double RSSI = Convert.ToDouble(ini.IniReadValue("setting", "RSSI")); //double RSSI2 = Convert.ToDouble(ini.IniReadValue("setting", "RSSI2")); //int portNumber = Convert.ToInt16(ini.IniReadValue("setting", "Port")); foreach (Tag tag in report.Tags) { // writeLog("Reader saw {0} on ant#{1} " + // tag.Epc + " " + tag.AntennaPortNumber + " " + tag.PeakRssiInDbm); // //TagAll += tag.Epc + '\n'; try { string strData = tag.Epc.ToString().Replace(" ","") + "##" + tag.AntennaPortNumber.ToString() + "##" + tag.PeakRssiInDbm.ToString() + "##" + ReaderSerialNo; if (VariablesENG.list.Contains(tag.Epc.ToString().Replace(" ", ""))) { } else { VariablesENG.list.RemoveAll(x => x.Contains(tag.Epc.ToString().Replace(" ", ""))); VariablesENG.list.Add(strData); } //VariablesENG.list.RemoveAll(x => x.Contains(tag.Epc.ToString().Replace(" ", ""))); // string strData2 = ""; // string strData3 = ""; // string strData4 = ""; // //CA.GetData(tag.Epc); // //var va = list.Find(x => x.Split('|')[1] == tag.Epc); // bool blnStatus = false; // if (tag.AntennaPortNumber == 1) // { // if (tag.PeakRssiInDbm >= RSSI) // { // strData = CA.GetData(tag.Epc); // Variables.list.RemoveAll(x => x.Contains(tag.Epc)); // Variables.list.Add(strData); // //Variables.list2.RemoveAll(x => x.Contains(tag.Epc)); // //Variables.list2.Add(strData); // } // } // if (tag.AntennaPortNumber == 2) // { // if (tag.PeakRssiInDbm >= RSSI2) // { // strData = CA.GetData(tag.Epc); // Variables.list.RemoveAll(x => x.Contains(tag.Epc)); // Variables.list.Add(strData); // //strData = CA.GetData(tag.Epc.Substring(0, 8)); // //Variables.list2.RemoveAll(x => x.Contains(tag.Epc.Substring(0,8))); // //Variables.list2.Add(strData); // } // } // if (tag.AntennaPortNumber == 3) // { // strData3 = CA.GetData(tag.Epc); // Variables.list3.RemoveAll(x => x.Contains(tag.Epc.Substring(0, 7))); // Variables.list3.Add(strData); // } // if (tag.AntennaPortNumber == 4) // { // strData4 = CA.GetData(tag.Epc); // Variables.list4.RemoveAll(x => x.Contains(tag.Epc.Substring(0, 7))); // Variables.list4.Add(strData); // } } catch (Exception ex) { } } }