Пример #1
0
static Flow proxyToFlow(const Pothos::Proxy &flowProxy)
{
    Flow flow;
    flow.src = proxyToPort(flowProxy.get("src"));
    flow.dst = proxyToPort(flowProxy.get("dst"));
    return flow;
}
Пример #2
0
static Port proxyToPort(const Pothos::Proxy &portProxy)
{
    Port port;
    port.name = portProxy.call<std::string>("get:name");
    port.obj = portProxy.get("obj");
    port.uid = portProxy.call<std::string>("get:uid");
    port.objName = portProxy.call<std::string>("get:objName");
    return port;
}
Пример #3
0
static Pothos::BufferChunk convertNumpyArrayToBufferChunk(const Pothos::Proxy &npArray)
{
    //extract shape and data type information
    const auto shape = npArray.get<Pothos::ProxyVector>("shape");
    const size_t numBytes = npArray.get<size_t>("nbytes");
    const size_t dimension = (shape.size() > 1)? shape.at(1).convert<size_t>() : 1;
    const auto dtypeName = npArray.get("dtype").get<std::string>("name");
    const Pothos::DType dtype(dtypeName, dimension);
    const size_t address = npArray.get("__array_interface__").call("get", "data").call("__getitem__", 0);

    //create a shared buffer that holds the numpy array
    auto sharedBuff = Pothos::SharedBuffer(address, numBytes, npArray.getHandle());

    //now create a buffer chunk of that shared buffer with matching dtype
    auto chunk = Pothos::BufferChunk(sharedBuff);
    chunk.dtype = dtype;
    return chunk;
}