wild services support

This commit is contained in:
Matej Sekoranja
2014-09-12 09:27:10 +02:00
parent e2facc2eac
commit 282b8fe11c
7 changed files with 668 additions and 5 deletions

View File

@@ -0,0 +1,48 @@
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* pvAccessCPP is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
#include <pv/pvData.h>
#include <pv/rpcServer.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
static Structure::const_shared_pointer resultStructure =
getFieldCreate()->createFieldBuilder()->
add("channelName", pvString)->
createStructure();
class WildServiceImpl :
public RPCService
{
PVStructure::shared_pointer request(PVStructure::shared_pointer const & pvArguments)
throw (RPCRequestException)
{
// requires NTURI as argument
if (pvArguments->getStructure()->getID() != "uri:ev4:nt/2012/pwd:NTURI")
throw RPCRequestException(Status::STATUSTYPE_ERROR, "RPC argument must be a NTURI normative type");
std::string channelName = pvArguments->getSubField<PVString>("path")->get();
// create return structure and set data
PVStructure::shared_pointer result = getPVDataCreate()->createPVStructure(resultStructure);
result->getSubField<PVString>("channelName")->put(channelName);
return result;
}
};
int main()
{
RPCServer server;
server.registerService("wild*", RPCService::shared_pointer(new WildServiceImpl()));
// you can register as many services as you want here ...
server.printInfo();
server.run();
return 0;
}