/* * configure the thread from the finder parameters. * @param rf is an instance of the ResourceFinder perhaps constructed from the command line. * @return true iff successful. */ bool configure(const ResourceFinder& rf) { remote = ((ResourceFinder&)rf).find("remote").asString(); // LATER: can use the rf.getName() here instead of searching again. ConstString name = ((ResourceFinder&)rf).find("name").asString(); local = "/"; local += ((name != "") ? name : defaultname); carrier = ((ResourceFinder&)rf).find("stream").asString(); outname = "/"; outname += ((name != "") ? name : defaultname); outname += ":out"; width = ((ResourceFinder&)rf).find("width").asInt(); height = ((ResourceFinder&)rf).find("height").asInt(); if (width == 0 && height == 0) { width = height = defaultSize; } else if (width == 0 && height != 0) { width = height; } else if (height == 0 && width != 0) { height = width; } writer.attach(out); return true; }
/* * main thread loop, sync'ed on the input port. */ virtual void run() { while (!isStopping()) { if (active) { lpImage->getLogpolarImage(lp); ImageOf<PixelRgb>& datum = writer.get(); datum.resize(width, height); // then remap trsf.logpolarToCart(datum, lp); // then write to out port writer.write(true); } else { Time::delay(2.0); } } }
void testWriteBuffer() { report(0,"testing write buffering"); Port input, output, altInput; input.open("/in"); altInput.open("/in2"); output.open("/out"); output.addOutput("/in"); report(0,"beginning..."); BinPortable<int> bin; PortWriterBuffer<BinPortable<int> > binOut; binOut.attach(output); int val1 = 15; int val2 = 30; BinPortable<int>& active = binOut.get(); active.content() = val1; binOut.write(); output.addOutput("/in2"); BinPortable<int>& active2 = binOut.get(); active2.content() = val2; binOut.write(); input.read(bin); checkEqual(val1,bin.content(),"successful transmit"); altInput.read(bin); checkEqual(val2,bin.content(),"successful transmit"); while (output.isWriting()) { report(0,"waiting for port to stabilize"); Time::delay(0.2); } report(0,"port stabilized"); output.close(); report(0,"shut down output buffering"); }