void Run() { ModLibrary library = new ModLibrary(); Console.Out.WriteLine("Loading modules"); #if DEBUG cppProxy.CppProxyModuleDriver.DoDiscovery(@"..\..\..\Debug", library); #else cppProxy.CppProxyModuleDriver.DoDiscovery(@"..\..\..\Release", library); #endif Console.Out.WriteLine("Building schematic"); Layout.Schematic schem = new Layout.Schematic(); Layout.Schematic.Element radioElem = new Layout.Schematic.Element(Layout.ElementType.Module, "radio"); Layout.Schematic.Element frameElem = new Layout.Schematic.Element(Layout.ElementType.Module, "make frame"); Layout.Schematic.Element fftElem = new Layout.Schematic.Element(Layout.ElementType.Module, "fft"); Layout.Schematic.Element mag2Func = new Layout.Schematic.Element(Layout.ElementType.Function, "mag^2"); Layout.Schematic.Element divideByN = new Layout.Schematic.Element(Layout.ElementType.Function, "divide by N"); Layout.Schematic.Element dbFunc = new Layout.Schematic.Element(Layout.ElementType.Function, "dB"); Layout.Schematic.Element splitterElem = new Layout.Schematic.Element(Layout.ElementType.Module, "splitter"); Layout.Schematic.Element waterfallElem = new Layout.Schematic.Element(Layout.ElementType.Module, "waterfall"); Layout.Schematic.Element waveformElem = new Layout.Schematic.Element(Layout.ElementType.Module, "waveform"); // Layout.Schematic.Element chopElem = new Layout.Schematic.Element(Layout.ElementType.Function, "chop real frame"); Layout.Schematic.Element frameMin = new Layout.Schematic.Element(Layout.ElementType.FunctionOnIn, "frame min"); Layout.Schematic.Element identityElem = new Layout.Schematic.Element(Layout.ElementType.Module, "="); // Layout.Schematic.Element frameMax = new Layout.Schematic.Element(Layout.ElementType.FunctionOnIn, "frame max"); schem.connect(radioElem, "recv1", frameElem, 0); // schem.connect(radioElem, "wide", fftElem, 0); schem.connect(frameElem, fftElem); schem.connect(fftElem, divideByN); // schem.connect(fftElem, chopElem); // schem.connect(chopElem, divideByN); schem.connect(divideByN, mag2Func); schem.connect(mag2Func, dbFunc); schem.connect(dbFunc, splitterElem); schem.connect(splitterElem, waterfallElem); schem.connect(splitterElem, 1, waveformElem, 0); schem.connect(splitterElem, 2, frameMin, 0); // schem.connect(splitterElem, 3, frameMax, 0); schem.connect(frameMin, identityElem); Console.Out.WriteLine("Resolving schematic"); List <Layout.Schematic> options; try { options = schem.resolve(library); } catch (Layout.Schematic.ResolveFailure fail) { Console.Out.WriteLine("Schematic could not be resolved:"); foreach (KeyValuePair <Layout.Schematic.ResolveFailureReason, bool> entry in fail.reasons) { Console.Out.WriteLine("\t{0}", entry.Key.Message); } return; } Console.Out.WriteLine("Building circuit"); using (Layout.Circuit circuit = options[0].construct()) { Console.Out.WriteLine("Configuring circuit"); signals.IBlock hpsdr = (signals.IBlock)circuit.Entry(radioElem); signals.IAttributes attrs = hpsdr.Attributes; signals.OnChanged evt = new signals.OnChanged(OnChanged); foreach (signals.IAttribute attr in attrs) { attr.changed += evt; } attrs["recvRate"].Value = 48000; attrs["Recv1Freq"].Value = 10000000; signals.IBlock ident = (signals.IBlock)circuit.Entry(identityElem); signals.IOutEndpoint identOut = ident.Outgoing[0]; signals.IEPBuffer outBuff = identOut.CreateBuffer(); identOut.Connect(outBuff); cppProxy.ReceiveStream stream = new cppProxy.ReceiveStream(identOut.Type, outBuff); stream.data += new cppProxy.ReceiveStream.OnReceive(OnStreamDetail); Canvas canvas = new Canvas(); canvas.freq1.Attribute = attrs["Recv1Freq"]; canvas.panel1.WaveformBlock = (signals.IBlock)circuit.Entry(waveformElem); canvas.panel2.WaveformBlock = (signals.IBlock)circuit.Entry(waterfallElem); Thread canvasThread = canvas.Start(); Console.Out.WriteLine("Powering circuit"); circuit.Start(); canvasThread.Join(); Console.Out.WriteLine("Shutting down circuit"); circuit.Stop(); stream.Stop(); } // Console.Out.WriteLine(String.Format("{0} received total", packetsReceived)); int _i = 0; }
void Run() { ModLibrary library = new ModLibrary(); Console.Out.WriteLine("Loading modules"); #if DEBUG cppProxy.CppProxyModuleDriver.DoDiscovery(@"..\..\..\Debug", library); #else cppProxy.CppProxyModuleDriver.DoDiscovery(@"..\..\..\Release", library); #endif Console.Out.WriteLine("Building schematic"); Layout.Schematic schem = new Layout.Schematic(); Layout.Schematic.Element radioElem = new Layout.Schematic.Element(Layout.ElementType.Module, "radio"); Layout.Schematic.Element frameElem = new Layout.Schematic.Element(Layout.ElementType.Module, "make frame"); Layout.Schematic.Element fftElem = new Layout.Schematic.Element(Layout.ElementType.Module, "fft"); Layout.Schematic.Element mag2Func = new Layout.Schematic.Element(Layout.ElementType.Function, "mag^2"); Layout.Schematic.Element divideByN = new Layout.Schematic.Element(Layout.ElementType.Function, "divide by N"); Layout.Schematic.Element dbFunc = new Layout.Schematic.Element(Layout.ElementType.Function, "dB"); Layout.Schematic.Element splitterElem = new Layout.Schematic.Element(Layout.ElementType.Module, "splitter"); Layout.Schematic.Element waterfallElem = new Layout.Schematic.Element(Layout.ElementType.Module, "waterfall"); Layout.Schematic.Element waveformElem = new Layout.Schematic.Element(Layout.ElementType.Module, "waveform"); // Layout.Schematic.Element chopElem = new Layout.Schematic.Element(Layout.ElementType.Function, "chop real frame"); Layout.Schematic.Element frameMin = new Layout.Schematic.Element(Layout.ElementType.FunctionOnIn, "frame min"); Layout.Schematic.Element identityElem = new Layout.Schematic.Element(Layout.ElementType.Module, "="); // Layout.Schematic.Element frameMax = new Layout.Schematic.Element(Layout.ElementType.FunctionOnIn, "frame max"); schem.connect(radioElem, "recv1", frameElem, 0); // schem.connect(radioElem, "wide", fftElem, 0); schem.connect(frameElem, fftElem); schem.connect(fftElem, divideByN); // schem.connect(fftElem, chopElem); // schem.connect(chopElem, divideByN); schem.connect(divideByN, mag2Func); schem.connect(mag2Func, dbFunc); schem.connect(dbFunc, splitterElem); schem.connect(splitterElem, waterfallElem); schem.connect(splitterElem, 1, waveformElem, 0); schem.connect(splitterElem, 2, frameMin, 0); // schem.connect(splitterElem, 3, frameMax, 0); schem.connect(frameMin, identityElem); Console.Out.WriteLine("Resolving schematic"); List<Layout.Schematic> options; try { options = schem.resolve(library); } catch (Layout.Schematic.ResolveFailure fail) { Console.Out.WriteLine("Schematic could not be resolved:"); foreach (KeyValuePair<Layout.Schematic.ResolveFailureReason, bool> entry in fail.reasons) { Console.Out.WriteLine("\t{0}", entry.Key.Message); } return; } Console.Out.WriteLine("Building circuit"); using (Layout.Circuit circuit = options[0].construct()) { Console.Out.WriteLine("Configuring circuit"); signals.IBlock hpsdr = (signals.IBlock)circuit.Entry(radioElem); signals.IAttributes attrs = hpsdr.Attributes; signals.OnChanged evt = new signals.OnChanged(OnChanged); foreach (signals.IAttribute attr in attrs) attr.changed += evt; attrs["recvRate"].Value = 48000; attrs["Recv1Freq"].Value = 10000000; signals.IBlock ident = (signals.IBlock)circuit.Entry(identityElem); signals.IOutEndpoint identOut = ident.Outgoing[0]; signals.IEPBuffer outBuff = identOut.CreateBuffer(); identOut.Connect(outBuff); cppProxy.ReceiveStream stream = new cppProxy.ReceiveStream(identOut.Type, outBuff); stream.data += new cppProxy.ReceiveStream.OnReceive(OnStreamDetail); Canvas canvas = new Canvas(); canvas.freq1.Attribute = attrs["Recv1Freq"]; canvas.panel1.WaveformBlock = (signals.IBlock)circuit.Entry(waveformElem); canvas.panel2.WaveformBlock = (signals.IBlock)circuit.Entry(waterfallElem); Thread canvasThread = canvas.Start(); Console.Out.WriteLine("Powering circuit"); circuit.Start(); canvasThread.Join(); Console.Out.WriteLine("Shutting down circuit"); circuit.Stop(); stream.Stop(); } // Console.Out.WriteLine(String.Format("{0} received total", packetsReceived)); int _i = 0; }