Exemplo n.º 1
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");
    }
Exemplo n.º 2
0
    /* 
     * 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);
            }
        }
    }