private static void MorseSignalDetect(string outputFileName, CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader.Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(Frequency, SampleRate)) //.Chain(new SkipSample<float>(250000 / 1000)) .Chain(new LPF(Frequency, SampleRate, 1000f)) .Chain(new MoveAverage()) .Chain(new SignalCompare(0.2f)) .Chain(new SampleCounter()) .Chain(new SignalToByteArray(map, SIGNAL_LENGTH)) .Chain(new MorseDecode()) .Chain(new SignalReverse()) .Chain(new SaveToFilePipeline <IEnumerable <bool> >(outputFileName, x => { var data = from item in x select item ? "1" : "0"; return(DateTime.Now.ToString("s") + "," + string.Join(',', data)); }, "time,data") { ConsoleOutput = true }); ; reader.Start(server, cts.Token); }
private static void WeatherDataOutput(string outputFileName, CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader.Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(Frequency, SampleRate)) //.Chain(new SkipSample<float>(250000 / 1000)) .Chain(new LPF(Frequency, SampleRate, 1000f)) .Chain(new MoveAverage()) .Chain(new SignalCompare(0.2f)) .Chain(new SampleCounter()) .Chain(new SignalToByteArray(map, SIGNAL_LENGTH)) .Chain(new MorseDecode()) .Chain(new SignalReverse()) .Chain(new MisolWeatherStationDecoder()) //.Chain(new ResultToConsole<MisolWeahterData>()) .Chain(new SaveToFilePipeline <MisolWeahterData>(outputFileName, x => { return($"{DateTime.Now.ToString("s")},{Newtonsoft.Json.JsonConvert.SerializeObject(x)}"); }, "time,data") { ConsoleOutput = true }); ; reader.Start(server, cts.Token); }
public void run() { try { ConcurrentQueue <String> queue = new ConcurrentQueue <String>(); this.util.startStopDevice(device, false, false); this.util.setDeviceMode(this.device, "EPCBULK-EAS", true); util.startStopDevice(device, true, false); tcpReader = new TCPReader(this.util.getAddress(), queue, this.util); Thread tcpReaderThread = new Thread(new ThreadStart(tcpReader.run)); tcpReaderThread.Start(); while (true) { 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; Queue <string> parsedQueue = new Queue <string>(); this.util.parseXML(dTag, parsedQueue); var iterator = parsedQueue.GetEnumerator(); while (iterator.MoveNext()) { //Console.WriteLine("Dequeued item " + iterator.Current); string msg = iterator.Current; if (msg.Contains("<deviceEventMessage>") && msg.Contains("TAG_ALARM")) { XmlDocument xml = new XmlDocument(); xml.LoadXml(msg); Console.WriteLine(xml.OuterXml); } } } } } } catch (Exception e) { Console.WriteLine("[ERROR] The function 'parseXML' has failed"); Console.WriteLine(e.StackTrace); } }
private static void dumpSignalIQ(string output, CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader.Chain(new SignalPreProcessor()) //.Chain(new IQ2Wave(433900000, 250000)) //.Chain(new LPF(433900000f, 250000f, 1000f)) //.Chain(new SkipSample<Complex>(100)) //.Chain(new MoveAverage()) .Chain(new SaveToFilePipeline <Complex>(output, x => { return($"{x.Image},{x.Real}"); }, "I,Q")); reader.Start(server, cts.Token); }
private static void dumpSignalIQRAW(string output, CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader //.Chain(new SignalPreProcessor()) //.Chain(new IQ2Wave(Frequency, 250000)) //.Chain(new LPF(Frequency, 250000f, 1000f)) //.Chain(new SkipSample<Complex>(100)) //.Chain(new MoveAverage()) .Chain(new SaveToFilePipeline <byte[]>(output, x => { return($"{x}"); })); reader.Start(server, cts.Token); }
private static void dumpSignal(CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader.Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(Frequency, SampleRate)) .Chain(new LPF(Frequency, SampleRate, 1000f)) .Chain(new SkipSample <float>(SampleRate / 10000)) //.Chain(new MoveAverage()) .Chain(new SaveToFilePipeline <float>("output.csv", x => { return($"{x}"); })); reader.Start(server, cts.Token); }
static void Main(string[] args) { Dictionary <int, byte> map = new Dictionary <int, byte> { [0] = 0x0, [1] = 0x1 }; //map.Add(0, 0); //map.Add(1, 1); IConfiguration config = new ConfigurationBuilder() .AddJsonFile("config.json", true, false) .Build(); var c = config.GetSection("rtl_tcp").Get <RadioConfig>(); RadioConfig[] server = new RadioConfig[] { c }; TCPReader reader = new TCPReader(); var node = reader.Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(c.Frequency, c.SampleRate)) .Chain(new LPF(c.Frequency, c.SampleRate, 1000f)) .Chain(new MoveAverage()) .Chain(new SignalCompare(0.2f)) .Chain(new SampleCounter()) .Chain(new SignalToByteArray(map, SIGNAL_LENGTH)) .Chain(new MorseDecode()) .Chain(new SignalReverse()) .Chain(new MisolWeatherStationDecoder()) .Chain(new MQTTSink(config.GetSection("mqtt")?.Get <MQTTConfig>())) .Chain(new IoTHubDeviceSink(config.GetSection("iothub_device")?.Get <IoTHubDeviceSinkConfig>())) ; reader.Start(server, cts.Token); Console.WriteLine("Application Started, Press Enter to exit"); Console.ReadLine(); cts.Cancel(); Console.WriteLine("waiting for threads exit..."); PipelineManager.Default.WaitAllExit(); Console.WriteLine("done"); Environment.Exit(0); }
private static void simpleTest(CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader .Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(Frequency, SampleRate)) //.Chain(new LPF(Frequency, SampleRate, 1000f)) //.Chain(new MoveAverage()) //.Chain(new SignalCompare(0.2f)) //.Chain(new SampleCounter()) //.Chain(new SignalToByteArray(map, SIGNAL_LENGTH)) //.Chain(new MorseDecode()) //.Chain(new SignalReverse()) //.Chain(new MisolWeatherStationDecoder()) .Chain(new NullProcessor <float>()); reader.Start(server, cts.Token); }
private static void BitSignalDetect(string outputFileName, CancellationTokenSource cts) { TCPReader reader = new TCPReader(); reader.Chain(new SignalPreProcessor() { IQOutput = IQOutputEnum.IChannel }) .Chain(new IQ2Wave(Frequency, SampleRate)) //.Chain(new SkipSample<float>(250000 / 1000)) .Chain(new LPF(Frequency, SampleRate, 1000f)) .Chain(new MoveAverage()) .Chain(new SignalCompare(0.2f)) .Chain(new SampleCounter()) .Chain(new SignalToByteArray(map, SIGNAL_LENGTH)) .Chain(new SaveToFilePipeline <byte[]>(outputFileName, x => { return($"{BitConverter.ToString(x)}"); }) { ConsoleOutput = true }); ; reader.Start(server, cts.Token); }
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); } }