public void run(long time) { try { this.util.setDeviceMode(this.device, "Alarm mode", false); this.util.setReadMode(this.device, "EPC_EAS_ALARM", false); util.startStopDevice(device, true, false); } catch (Exception e) { Console.WriteLine(e.StackTrace); } ConcurrentQueue <String> queue = new ConcurrentQueue <String>(); List <String> tagDataList = new List <String>(); Console.WriteLine("Device[" + device.id + "] Reading the 3177 port... "); TCPReader tcpReader = new TCPReader(this.address, queue, this.util); Thread tcpReaderThread = new Thread(new ThreadStart(tcpReader.run)); tcpReaderThread.Start(); Console.WriteLine("Done."); Stopwatch stopwatch2 = new Stopwatch(); stopwatch2.Start(); while (stopwatch2.ElapsedMilliseconds < time) { while (queue.IsEmpty) { try { Thread.Sleep(20); } catch (Exception exc) { Console.WriteLine("Thread sleeping failure: " + exc.Source); } } if (!queue.IsEmpty) { string tag; while (queue.TryDequeue(out tag)) { string dTag = tag; this.util.processAlarmMessages(this.device, dTag, this.epcToAlarm); } } } tcpReader.Shutdown(); try { util.startStopDevice(device, false, false); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
public void run(long inventoryTime) { try { this.util.setDeviceMode(device, "Autonomous", false); util.startStopDevice(device, true, false); } catch (Exception e) { Console.WriteLine(e.StackTrace); } ConcurrentQueue <String> queue = new ConcurrentQueue <String>(); List <String> tagDataList = new List <String>(); Console.WriteLine("Device[" + device.id + "] Reading the 3177 port... "); TCPReader tcpReader = new TCPReader(this.address, queue, this.util); Thread tcpReaderThread = new Thread(new ThreadStart(tcpReader.run)); tcpReaderThread.Start(); Console.WriteLine("Done."); Stopwatch stopwatch2 = new Stopwatch(); stopwatch2.Start(); while (stopwatch2.ElapsedMilliseconds < inventoryTime) { while (queue.IsEmpty) { try { Thread.Sleep(20); } catch (Exception exc) { Console.WriteLine("Thread sleeping failure: " + exc.Source); } } if (!queue.IsEmpty) { string tag; while (queue.TryDequeue(out tag)) { string dTag = tag; this.util.processTCPdata(dTag, tagDataList); HashSet <String> hashset = new HashSet <String> (); foreach (String tagData in tagDataList) { //Console.WriteLine("epc: " + tagData); hashset.Add(tagData); } tagDataList.Clear(); Console.WriteLine("read: " + hashset.ToList().ToString()); } } } tcpReader.Shutdown(); try { util.startStopDevice(device, false, false); } catch (Exception e) { Console.WriteLine(e.StackTrace); } }