Esempio n. 1
0
static void test_inheritance0(Pothos::ProxyEnvironment::Sptr env)
{
    Pothos::ManagedClass()
        .registerConstructor<MyBaseClass0>()
        .registerMethod(POTHOS_FCN_TUPLE(MyBaseClass0, negateInt))
        .commit("MyBaseClass0");

    //prove that base class can work
    auto myBase0 = env->findProxy("MyBaseClass0").callProxy("new");
    POTHOS_TEST_EQUAL(-42, myBase0.call<int>("negateInt", 42));

    Pothos::ManagedClass()
        .registerConstructor<MyDerivedClass0>()
        .registerBaseClass<MyDerivedClass0, MyBaseClass0>()
        .commit("MyDerivedClass0");

    //prove that derived class has the base methods
    auto myDerived0 = env->findProxy("MyDerivedClass0").callProxy("new");
    POTHOS_TEST_EQUAL(-42, myDerived0.call<int>("negateInt", 42));

    //runtime registration does not associate the module
    //therefore to be safe, we unregister these classes now
    Pothos::PluginRegistry::remove("/managed/MyBaseClass0");
    Pothos::PluginRegistry::remove("/managed/MyDerivedClass0");
}
Esempio n. 2
0
/***********************************************************************
 * 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;
}
Esempio n. 3
0
/***********************************************************************
 * 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;
}
Esempio n. 4
0
/***********************************************************************
 * 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;
}
Esempio n. 5
0
    WaveMonitor(const Pothos::ProxyEnvironment::Sptr &remoteEnv)
    {
        _display.reset(new WaveMonitorDisplay());
        _display->setName("Display");

        auto registry = remoteEnv->findProxy("Pothos/BlockRegistry");
        _trigger = registry.callProxy("/comms/wave_trigger");
        _trigger.callVoid("setName", "Trigger");

        //register calls in this topology
        this->registerCall(this, POTHOS_FCN_TUPLE(WaveMonitor, setNumInputs));
        this->registerCall(this, POTHOS_FCN_TUPLE(WaveMonitor, setRateLabelId));

        //display setters
        _topologyToDisplaySetter["setTitle"] = "setTitle";
        _topologyToDisplaySetter["setSampleRate"] = "setSampleRate";
        _topologyToDisplaySetter["setNumPoints"] = "setNumPoints";
        _topologyToDisplaySetter["setAutoScale"] = "setAutoScale";
        _topologyToDisplaySetter["setYRange"] = "setYRange";
        _topologyToDisplaySetter["enableXAxis"] = "enableXAxis";
        _topologyToDisplaySetter["enableYAxis"] = "enableYAxis";
        _topologyToDisplaySetter["setYAxisTitle"] = "setYAxisTitle";
        _topologyToDisplaySetter["setChannelLabel"] = "setChannelLabel";
        _topologyToDisplaySetter["setChannelStyle"] = "setChannelStyle";

        //trigger setters
        _topologyToTriggerSetter["setDisplayRate"] = "setEventRate";
        _topologyToTriggerSetter["setNumPoints"] = "setNumPoints";
        _topologyToTriggerSetter["setAlignment"] = "setAlignment";
        _topologyToTriggerSetter["setTriggerSource"] = "setSource";
        _topologyToTriggerSetter["setTriggerWindows"] = "setNumWindows";
        _topologyToTriggerSetter["setTriggerHoldOff"] = "setHoldOff";
        _topologyToTriggerSetter["setTriggerSlope"] = "setSlope";
        _topologyToTriggerSetter["setTriggerMode"] = "setMode";
        _topologyToTriggerSetter["setTriggerLevel"] = "setLevel";
        _topologyToTriggerSetter["setTriggerPosition"] = "setPosition";
        _topologyToTriggerSetter["setTriggerLabelId"] = "setLabelId";

        //connect to internal display block
        for (const auto &pair : _topologyToDisplaySetter)
        {
            this->connect(this, pair.first, _display, pair.second);
        }

        //connect to the internal trigger block
        for (const auto &pair : _topologyToTriggerSetter)
        {
            this->connect(this, pair.first, _trigger, pair.second);
        }

        //connect stream ports
        this->connect(_trigger, 0, _display, 0);
    }
Esempio n. 6
0
    Periodogram(const Pothos::ProxyEnvironment::Sptr &remoteEnv)
    {
        _display.reset(new PeriodogramDisplay());
        _display->setName("Display");

        auto registry = remoteEnv->findProxy("Pothos/BlockRegistry");
        _trigger = registry.callProxy("/comms/wave_trigger");
        _trigger.callVoid("setName", "Trigger");
        _trigger.callVoid("setMode", "PERIODIC");

        //register calls in this topology
        this->registerCall(this, POTHOS_FCN_TUPLE(Periodogram, setNumInputs));
        this->registerCall(this, POTHOS_FCN_TUPLE(Periodogram, setDisplayRate));
        this->registerCall(this, POTHOS_FCN_TUPLE(Periodogram, setNumFFTBins));
        this->registerCall(this, POTHOS_FCN_TUPLE(Periodogram, setFreqLabelId));
        this->registerCall(this, POTHOS_FCN_TUPLE(Periodogram, setRateLabelId));

        //connect to internal display block
        this->connect(this, "setTitle", _display, "setTitle");
        this->connect(this, "setSampleRate", _display, "setSampleRate");
        this->connect(this, "setCenterFrequency", _display, "setCenterFrequency");
        this->connect(this, "setNumFFTBins", _display, "setNumFFTBins");
        this->connect(this, "setWindowType", _display, "setWindowType");
        this->connect(this, "setReferenceLevel", _display, "setReferenceLevel");
        this->connect(this, "setDynamicRange", _display, "setDynamicRange");
        this->connect(this, "setAutoScale", _display, "setAutoScale");
        this->connect(this, "setAverageFactor", _display, "setAverageFactor");
        this->connect(this, "enableXAxis", _display, "enableXAxis");
        this->connect(this, "enableYAxis", _display, "enableYAxis");
        this->connect(this, "setYAxisTitle", _display, "setYAxisTitle");
        this->connect(_display, "frequencySelected", this, "frequencySelected");

        //connect to the internal snooper block
        this->connect(this, "setDisplayRate", _trigger, "setEventRate");
        this->connect(this, "setNumFFTBins", _trigger, "setNumPoints");

        //connect stream ports
        this->connect(_trigger, 0, _display, 0);

    }
/***********************************************************************
 * buffer chunk to/from numpy
 **********************************************************************/
static Pothos::Proxy convertBufferChunkToNumpyArray(Pothos::ProxyEnvironment::Sptr env, const Pothos::BufferChunk &buffer)
{
    auto module = env->findProxy("Pothos.Buffer");
    auto dtype = module.get("dtype_to_numpy")(buffer.dtype);
    return module.get("pointer_to_ndarray")(buffer.address, buffer.elements(), dtype);
}