コード例 #1
0
static void delayBlockTestCase(const int delayVal)
{
    auto feeder = Pothos::BlockRegistry::make("/blocks/feeder_source", "int");
    auto delay = Pothos::BlockRegistry::make("/blocks/delay");
    auto collector = Pothos::BlockRegistry::make("/blocks/collector_sink", "int");

    //setup
    std::cout << "delayBlockTestCase " << delayVal << std::endl;
    Pothos::BufferChunk buff0(typeid(int), 100);
    feeder.callVoid("feedBuffer", buff0);
    delay.callVoid("setDelay", delayVal);

    //run the topology
    std::cout << "run the topology\n";
    {
        Pothos::Topology topology;
        topology.connect(feeder, 0, delay, 0);
        topology.connect(delay, 0, collector, 0);
        topology.commit();
        POTHOS_TEST_TRUE(topology.waitInactive());
    }

    auto buff1 = collector.call<Pothos::BufferChunk>("getBuffer");
    POTHOS_TEST_EQUAL(buff1.elements(), size_t(100-delayVal));
}
コード例 #2
0
ファイル: Containers.cpp プロジェクト: hailynch/pothos
/***********************************************************************
 * Vector
 **********************************************************************/
static Pothos::Proxy convertVectorToJVector(Pothos::ProxyEnvironment::Sptr env, const Pothos::ProxyVector &vec)
{
    auto jVector = env->findProxy("java.util.Vector").callProxy("new");
    jVector.callVoid("setSize", vec.size());
    for (size_t i = 0; i < vec.size(); i++)
    {
        jVector.callVoid("set", i, vec[i]);
    }
    return jVector;
}
コード例 #3
0
ファイル: LuaInstance.cpp プロジェクト: theJ8910/Brimstone
void LuaInstance::postframe() {
    if( !isFunction( "postframe" ) )
        return;

    pushFunction( "postframe" );
    callVoid();
}
コード例 #4
0
ファイル: LuaInstance.cpp プロジェクト: theJ8910/Brimstone
void LuaInstance::stop() {
    if( !isFunction( "stop" ) )
        return;

    pushFunction( "stop" );
    callVoid();
}
コード例 #5
0
Pothos::ProxyEnvironment::Sptr EnvironmentEval::makeEnvironment(void)
{
    if (_zoneName == "gui") return Pothos::ProxyEnvironment::make("managed");

    const auto hostUri = getHostProcFromConfig(_zoneName, _config).first;

    //connect to the remote host and spawn a server
    auto serverEnv = Pothos::RemoteClient(hostUri).makeEnvironment("managed");
    auto serverHandle = serverEnv->findProxy("Pothos/RemoteServer")("tcp://"+Pothos::Util::getWildcardAddr(), false/*noclose*/);

    //construct the uri for the new server
    auto actualPort = serverHandle.call<std::string>("getActualPort");
    Poco::URI newHostUri(hostUri);
    newHostUri.setPort(std::stoul(actualPort));

    //connect the client environment
    auto client = Pothos::RemoteClient(newHostUri.toString());
    client.holdRef(Pothos::Object(serverHandle));
    auto env = client.makeEnvironment("managed");

    //determine log delivery address
    //FIXME syslog listener doesn't support IPv6, special precautions taken:
    const auto logSource = (not _zoneName.isEmpty())? _zoneName.toStdString() : newHostUri.getHost();
    const auto syslogListenPort = Pothos::System::Logger::startSyslogListener();
    Poco::Net::SocketAddress serverAddr(env->getPeeringAddress(), syslogListenPort);

    //deal with IPv6 addresses because the syslog server only binds to IPv4
    if (serverAddr.family() == Poco::Net::IPAddress::IPv6)
    {
        //convert IPv6 mapped ports to IPv4 format when possible
        if (serverAddr.host().isIPv4Mapped())
        {
            const Poco::Net::IPAddress v4Mapped(static_cast<const char *>(serverAddr.host().addr())+12, 4);
            serverAddr = Poco::Net::SocketAddress(v4Mapped, std::stoi(syslogListenPort));
        }

        //convert an IPv4 loopback address into an IPv4 loopback address
        else if (serverAddr.host().isLoopback())
        {
            serverAddr = Poco::Net::SocketAddress("127.0.0.1", syslogListenPort);
        }

        //otherwise warn because the forwarding will not work
        else
        {
            poco_warning_f1(Poco::Logger::get("PothosGui.EnvironmentEval.make"),
                "Log forwarding not supported over IPv6: %s", logSource);
            return env;
        }
    }

    //setup log delivery from the server process
    env->findProxy("Pothos/System/Logger").callVoid("startSyslogForwarding", serverAddr.toString());
    env->findProxy("Pothos/System/Logger").callVoid("forwardStdIoToLogging", logSource);
    serverHandle.callVoid("startSyslogForwarding", serverAddr.toString(), logSource);

    return env;
}
コード例 #6
0
ファイル: Containers.cpp プロジェクト: hailynch/pothos
/***********************************************************************
 * Map
 **********************************************************************/
static Pothos::Proxy convertMapToJMap(Pothos::ProxyEnvironment::Sptr env, const Pothos::ProxyMap &map)
{
    auto jMap = env->findProxy("java.util.HashMap").callProxy("new");
    for (const auto &entry : map)
    {
        jMap.callVoid("put", entry.first, entry.second);
    }
    return jMap;
}
コード例 #7
0
ファイル: Containers.cpp プロジェクト: hailynch/pothos
/***********************************************************************
 * Set
 **********************************************************************/
static Pothos::Proxy convertSetToJSet(Pothos::ProxyEnvironment::Sptr env, const Pothos::ProxySet &set)
{
    auto jSet = env->findProxy("java.util.HashSet").callProxy("new");
    for (const auto &entry : set)
    {
        jSet.callVoid("add", entry);
    }
    return jSet;
}
コード例 #8
0
/*!
 * Get a copier block for a domain crossing between mainPort and all connected subPorts.
 * If the copier block is not needed to handle this domain crossing, return a null Proxy.
 */
static Pothos::Proxy getCopierForDomainCrossing(
    const Port &mainPort,
    const std::vector<Port> &subPorts,
    const bool isInput
)
{
    if (isDomainCrossingAcceptable(mainPort, subPorts, isInput)) return Pothos::Proxy();
    auto registry = mainPort.obj.getEnvironment()->findProxy("Pothos/BlockRegistry");
    auto copier = registry.callProxy("/blocks/copier");
    copier.callVoid("setName", "DomainBridge");
    return copier;
}
コード例 #9
0
ファイル: LuaInstance.cpp プロジェクト: theJ8910/Brimstone
void LuaInstance::openLibraries() {
    //Limited list of libraries to load
    static const luaL_Reg acLibraries[] = {
        { "",               luaopen_base    },  //standard functions, e.g. print, load, loadfile, etc.
        { LUA_BITLIBNAME,   luaopen_bit     },  //bit operations
      //{ LUA_DBLIBNAME,    luaopen_debug   },  //debugging utilities; e.g. information about a function, access to local variables, etc
      //{ LUA_FFILIBNAME,   luaopen_ffi     },  //LuaJIT; allows binding to C functions from Lua
      //{ LUA_IOLIBNAME,    luaopen_io      },  //File I/O among other things
      //{ LUA_JITLIBNAME,   luaopen_jit     },  //LuaJIT; control JIT compilation (turn on/off from Lua, among other things)
        { LUA_MATHLIBNAME,  luaopen_math    },  //Mathematics library (sqrt, sin, cos, etc).
      //{ LUA_OSLIBNAME,    luaopen_os      },  //System date & time, delete, rename, execute, exit, etc
      //{ LUA_LOADLIBNAME,  luaopen_package },  //loadlib
        { LUA_STRLIBNAME,   luaopen_string  },  //string operations
        { LUA_TABLIBNAME,   luaopen_table   },  //table operations

        { nullptr, nullptr }                    //delimiter
    };

    //Load libraries
    for( const luaL_Reg* p = acLibraries; p->name != nullptr ; ++p ) {
        lua_pushcfunction( m_state, p->func );
        callVoid( p->name );
    }
}
コード例 #10
0
ファイル: TestFIRFilter.cpp プロジェクト: m0x72/pothos
static double filterToneGetRMS(
    const double sampRate,
    const double waveFreq,
    const size_t decim,
    const size_t interp
)
{
    auto env = Pothos::ProxyEnvironment::make("managed");
    auto registry = env->findProxy("Pothos/BlockRegistry");

    auto waveSource = registry.callProxy("/blocks/waveform_source", "complex128");
    waveSource.callVoid("setWaveform", "SINE");
    waveSource.callVoid("setFrequency", waveFreq);
    waveSource.callVoid("setSampleRate", sampRate);

    auto finiteRelease = registry.callProxy("/blocks/finite_release");
    finiteRelease.callVoid("setTotalElements", 4096);

    auto filter = registry.callProxy("/blocks/fir_filter", "complex128", "COMPLEX");
    filter.callVoid("setDecimation", decim);
    filter.callVoid("setInterpolation", interp);

    auto designer = registry.callProxy("/blocks/fir_designer");
    designer.callVoid("setSampleRate", (sampRate*interp)/decim);
    designer.callVoid("setFilterType", "COMPLEX_BAND_PASS");
    designer.callVoid("setFrequencyLower", waveFreq-0.1*sampRate);
    designer.callVoid("setFrequencyUpper", waveFreq+0.1*sampRate);
    designer.callVoid("setNumTaps", 100);

    auto probe = registry.callProxy("/blocks/stream_probe", "complex128");
    probe.callVoid("setMode", "RMS");

    //propagate the taps
    {
        Pothos::Topology topology;
        topology.connect(designer, "tapsChanged", filter, "setTaps");
        topology.commit();
        POTHOS_TEST_TRUE(topology.waitInactive());
    }

    //run the topology
    {
        Pothos::Topology topology;
        topology.connect(waveSource, 0, finiteRelease, 0);
        topology.connect(finiteRelease, 0, filter, 0);
        topology.connect(filter, 0, probe, 0);
        topology.commit();
        POTHOS_TEST_TRUE(topology.waitInactive());
    }

    return probe.call<double>("value");
}