Пример #1
0
epics::pvData::PVStructure::shared_pointer RpcClient::request(const epics::pvData::PVStructurePtr& pvRequest, double timeout) 
{
    try {
        epics::pvAccess::RPCClient::shared_pointer client = getRpcClient(pvRequest, timeout);
#if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 430
        epics::pvData::PVStructure::shared_pointer response = client->request(pvRequest, timeout);
#endif // if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 430

#if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 435
        // When client goes out of scope, it will destroy resources.
        bool lastRequest = false;
        epics::pvData::PVStructure::shared_pointer response = client->request(pvRequest, lastRequest);
#endif // if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 435

#if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 440
        epics::pvData::PVStructure::shared_pointer response = client->request(pvRequest, timeout);
#endif // if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION == 440

        return response;
    }
    catch (const epics::pvAccess::RPCRequestException& ex) {
        throw PvaException(ex.what());
    }
    catch (std::exception& ex) {
        throw PvaException(ex.what());
    }
    catch (...) {
        throw PvaException("Unexpected error caught in RpcClient::request().");
    }
}
Пример #2
0
double PvScalar::toDouble() const
{
    epics::pvData::ScalarType scalarType = PyPvDataUtility::getScalarType(ValueFieldKey, pvStructurePtr);
    double value;
    switch (scalarType) {
        case epics::pvData::pvBoolean: {
            value = pvStructurePtr->getSubField<epics::pvData::PVBoolean>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvByte: {
            value = pvStructurePtr->getSubField<epics::pvData::PVByte>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUByte: {
            value = pvStructurePtr->getSubField<epics::pvData::PVUByte>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvShort: {
            value = pvStructurePtr->getSubField<epics::pvData::PVShort>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUShort: {
            value = pvStructurePtr->getSubField<epics::pvData::PVUShort>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvInt: {
            value = pvStructurePtr->getSubField<epics::pvData::PVInt>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUInt: {
            value = pvStructurePtr->getSubField<epics::pvData::PVUInt>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvLong: {
            value = pvStructurePtr->getSubField<epics::pvData::PVLong>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvULong: {
            value = pvStructurePtr->getSubField<epics::pvData::PVULong>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvFloat: {
            value = pvStructurePtr->getSubField<epics::pvData::PVFloat>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvDouble: {
            value = pvStructurePtr->getSubField<epics::pvData::PVDouble>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvString: {
            std::string s = pvStructurePtr->getSubField<epics::pvData::PVString>(ValueFieldKey)->get();
            value = atof(s.c_str());
            break;
        }
        default: {
            throw PvaException("Unrecognized scalar type: %d", scalarType);
        }
    }
    return value;
}
Пример #3
0
std::string PvScalar::toString() const
{
    std::ostringstream oss;
    epics::pvData::ScalarType scalarType = PyPvDataUtility::getScalarType(ValueFieldKey, pvStructurePtr);
    switch (scalarType) {
        case epics::pvData::pvBoolean: {
            oss << static_cast<bool>(pvStructurePtr->getSubField<epics::pvData::PVBoolean>(ValueFieldKey)->get());
            break;
        }
        case epics::pvData::pvByte: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVByte>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUByte: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVUByte>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvShort: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVShort>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUShort: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVUShort>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvInt: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVInt>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvUInt: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVUInt>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvLong: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVLong>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvULong: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVULong>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvFloat: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVFloat>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvDouble: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVDouble>(ValueFieldKey)->get();
            break;
        }
        case epics::pvData::pvString: {
            oss << pvStructurePtr->getSubField<epics::pvData::PVString>(ValueFieldKey)->get();
            break;
        }
        default: {
            throw PvaException("Unrecognized scalar type: %d", scalarType);
        }
    }
    return oss.str();
}
Пример #4
0
epics::pvData::PVStructure::shared_pointer RpcClient::request(const epics::pvData::PVStructurePtr& arguments, double timeout)
{
    try {
        epics::pvAccess::RPCClient::shared_pointer client = getRpcClient(pvRequest, timeout);

#if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION >= 440
        epics::pvData::PVStructure::shared_pointer response = client->request(arguments, timeout);
#endif // if defined PVA_RPC_API_VERSION && PVA_RPC_API_VERSION >= 440

        return response;
    }
    catch (const epics::pvAccess::RPCRequestException& ex) {
        throw PvaException(ex.what());
    }
    catch (std::exception& ex) {
        throw PvaException(ex.what());
    }
    catch (...) {
        throw PvaException("Unexpected error caught in RpcClient::request().");
    }
}
Пример #5
0
PvObject* Channel::get(const std::string& requestDescriptor) 
{
    epics::pvData::PVStructure::shared_pointer pvRequest = epics::pvData::CreateRequest::create()->createRequest(requestDescriptor);

    std::tr1::shared_ptr<ChannelRequesterImpl> channelRequesterImpl = std::tr1::dynamic_pointer_cast<ChannelRequesterImpl>(channel->getChannelRequester());

    if (channel->getConnectionState() != epics::pvAccess::Channel::CONNECTED) {
        if (!channelRequesterImpl->waitUntilConnected(timeout)) {
            throw ChannelTimeout("Channel %s timed out", channel->getChannelName().c_str());
        }
    }

    std::tr1::shared_ptr<GetFieldRequesterImpl> getFieldRequesterImpl;
    getFieldRequesterImpl.reset(new GetFieldRequesterImpl(channel));
    channel->getField(getFieldRequesterImpl, "");

    if (!getFieldRequesterImpl->waitUntilFieldGet(timeout)) {
        throw ChannelTimeout("Channel %s field get timed out", channel->getChannelName().c_str());
    }
            
    if (!getFieldRequesterImpl.get()) {
        throw PvaException("Failed to get introspection data for channel %s", channel->getChannelName().c_str());
    }

	epics::pvData::Structure::const_shared_pointer structure =
	    std::tr1::dynamic_pointer_cast<const epics::pvData::Structure>(getFieldRequesterImpl->getField());
	if (structure.get() == 0 || structure->getField("value").get() == 0) {
	    // fallback to structure
		pvRequest = epics::pvData::CreateRequest::create()->createRequest("field()");
    }

	std::tr1::shared_ptr<ChannelGetRequesterImpl> getRequesterImpl(new ChannelGetRequesterImpl(channel->getChannelName()));
	epics::pvAccess::ChannelGet::shared_pointer channelGet = channel->createChannelGet(getRequesterImpl, pvRequest);
	if (getRequesterImpl->waitUntilGet(timeout)) {
	    return new PvObject(getRequesterImpl->getPVStructure());
    }
    throw ChannelTimeout("Channel %s get request timed out", channel->getChannelName().c_str());
}
Пример #6
0
PvScalar& PvScalar::add(int i)
{
    epics::pvData::ScalarType scalarType = PyPvDataUtility::getScalarType(ValueFieldKey, pvStructurePtr);
    switch (scalarType) {
        case epics::pvData::pvBoolean: {
            epics::pvData::PVBooleanPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVBoolean>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvByte: {
            epics::pvData::PVBytePtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVByte>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvUByte: {
            epics::pvData::PVUBytePtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVUByte>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvShort: {
            epics::pvData::PVShortPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVShort>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvUShort: {
            epics::pvData::PVUShortPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVUShort>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvInt: {
            epics::pvData::PVIntPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVInt>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvUInt: {
            epics::pvData::PVUIntPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVUInt>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvLong: {
            epics::pvData::PVLongPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVLong>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvULong: {
            epics::pvData::PVULongPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVULong>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvFloat: {
            epics::pvData::PVFloatPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVFloat>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvDouble: {
            epics::pvData::PVDoublePtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVDouble>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+i);
            break;
        }
        case epics::pvData::pvString: {
            epics::pvData::PVStringPtr fieldPtr = pvStructurePtr->getSubField<epics::pvData::PVString>(ValueFieldKey);
            fieldPtr->put(fieldPtr->get()+StringUtility::toString(i));
            break;
        }
        default: {
            throw PvaException("Unrecognized scalar type: %d", scalarType);
        }
    }
    return *this;
}
Пример #7
0
PvObject* Channel::getPut(const std::string& requestDescriptor)
{
    throw PvaException("GetPut() is not supported for 4.4.0 release.");
}
Пример #8
0
PvObject* Channel::getPut()
{
    throw PvaException("GetPut() is not supported for 4.4.0 release.");
}
Пример #9
0
PvObject* Channel::putGet(double value)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #10
0
PvObject* Channel::putGet(double value, const std::string& requestDescriptor)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #11
0
PvObject* Channel::putGet(unsigned long long value)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #12
0
PvObject* Channel::putGet(const boost::python::list& pyList)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #13
0
PvObject* Channel::putGet(const boost::python::list& pyList, const std::string& requestDescriptor) 
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #14
0
PvObject* Channel::putGet(const std::string& value)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}
Пример #15
0
PvObject* Channel::putGet(const PvObject& pvObject)
{
    throw PvaException("PutGet() is not supported for 4.4.0 release.");
}