public signals.IOutEndpoint OutputEP(signals.IBlock blk) { signals.Fingerprint print = blk.Fingerprint; if (this.epString == null) { if (epIdx < print.outputs.Length) { return(blk.Outgoing[epIdx]); } } else { if (print.inputNames != null) { for (int idx = 0; idx < print.outputs.Length; idx++) { if (print.outputNames[idx] != null && String.Compare(print.outputNames[idx], epString, true) == 0) { return(blk.Outgoing[idx]); } } } } throw new IndexOutOfRangeException(); }
public void Stop() { foreach (KeyValuePair <int, Element> entry in radio) { signals.IBlock blk = entry.Value.obj as signals.IBlock; if (blk != null) { blk.Stop(); } } }
public Element(signals.IBlock realBlock) { if (realBlock == null) { throw new ArgumentNullException("realBlock"); } type = ElementType.Module; name = realBlock.Name; nodeId = realBlock.NodeId; circuitId = 0; availObjects = new List <signals.ICircuitConnectible>(); availObjects.Add(realBlock); explicitAvail = true; }
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; }
public CppProxyBlock(signals.IBlockDriver driver, signals.IBlock parent, IntPtr native) { if (driver == null) throw new ArgumentNullException("driver"); if (native == IntPtr.Zero) throw new ArgumentNullException("native"); m_nativeRef = native; m_driver = driver; m_parent = parent; Registration.storeObject(native, this); m_native = (Native.IBlock)CppNativeProxy.CreateCallout(native, typeof(Native.IBlock)); interrogate(); }
public signals.IBlock[] Discover() { // discovery can be expensive, so we just use a large buffer rather than call things multiple times if (!m_canDiscover) throw new NotSupportedException("Driver cannot discover objects."); IntPtr[] ptrArr = new IntPtr[BufferSize]; GCHandle pin = GCHandle.Alloc(ptrArr, GCHandleType.Pinned); uint numObj; try { numObj = m_native.Discover(pin.AddrOfPinnedObject(), (uint)BufferSize); } finally { pin.Free(); } signals.IBlock[] objArr = new signals.IBlock[numObj]; for (int idx = 0; idx < numObj; idx++) { if (ptrArr[idx] != IntPtr.Zero) { signals.IBlock newObj = (signals.IBlock)Registration.retrieveObject(ptrArr[idx]); if (newObj == null) newObj = new CppProxyBlock(this, null, ptrArr[idx]); objArr[idx] = newObj; } } return objArr; }
protected override void Dispose(bool disposing) { WaveformBlock = null; // propery-set, detaches from attribute base.Dispose(disposing); }