p2p: read-only switch

This commit is contained in:
Michael Davidsaver
2016-03-28 08:20:34 +09:00
parent f4d1d5f458
commit 16ab57e1f3
3 changed files with 27 additions and 4 deletions

View File

@ -3,12 +3,15 @@
#define epicsExportSharedSymbols
#include "helper.h"
#include "iocshelper.h"
#include "pva2pva.h"
#include "channel.h"
namespace pva = epics::pvAccess;
namespace pvd = epics::pvData;
int p2pReadOnly = 0;
size_t GWChannel::num_instances;
GWChannel::GWChannel(const ChannelCacheEntry::shared_pointer& e,
@ -108,7 +111,10 @@ GWChannel::createChannelProcess(
pva::ChannelProcessRequester::shared_pointer const & channelProcessRequester,
pvd::PVStructure::shared_pointer const & pvRequest)
{
return entry->channel->createChannelProcess(channelProcessRequester, pvRequest);
if(!p2pReadOnly)
return entry->channel->createChannelProcess(channelProcessRequester, pvRequest);
else
return Channel::createChannelProcess(channelProcessRequester, pvRequest);
}
pva::ChannelGet::shared_pointer
@ -124,7 +130,10 @@ GWChannel::createChannelPut(
pva::ChannelPutRequester::shared_pointer const & channelPutRequester,
pvd::PVStructure::shared_pointer const & pvRequest)
{
return entry->channel->createChannelPut(channelPutRequester, pvRequest);
if(!p2pReadOnly)
return entry->channel->createChannelPut(channelPutRequester, pvRequest);
else
return Channel::createChannelPut(channelPutRequester, pvRequest);
}
pva::ChannelPutGet::shared_pointer
@ -132,7 +141,10 @@ GWChannel::createChannelPutGet(
pva::ChannelPutGetRequester::shared_pointer const & channelPutGetRequester,
pvd::PVStructure::shared_pointer const & pvRequest)
{
return entry->channel->createChannelPutGet(channelPutGetRequester, pvRequest);
if(!p2pReadOnly)
return entry->channel->createChannelPutGet(channelPutGetRequester, pvRequest);
else
return Channel::createChannelPutGet(channelPutGetRequester, pvRequest);
}
pva::ChannelRPC::shared_pointer
@ -140,7 +152,10 @@ GWChannel::createChannelRPC(
pva::ChannelRPCRequester::shared_pointer const & channelRPCRequester,
pvd::PVStructure::shared_pointer const & pvRequest)
{
return entry->channel->createChannelRPC(channelRPCRequester, pvRequest);
if(!p2pReadOnly)
return entry->channel->createChannelRPC(channelRPCRequester, pvRequest);
else
return Channel::createChannelRPC(channelRPCRequester, pvRequest);
}
namespace {
@ -246,3 +261,9 @@ GWChannel::printInfo(std::ostream& out)
{
out<<"GWChannel for "<<entry->channelName<<"\n";
}
void registerReadOnly()
{
iocshVariable<int, &p2pReadOnly>("p2pReadOnly");
}

View File

@ -11,6 +11,7 @@ int main(int argc, char *argv[])
libComRegister(); // non-IOC related iocsh functions
registerGWClientIocsh();
registerGWServerIocsh();
registerReadOnly();
if(argc>1)
iocsh(argv[1]);
int ret = iocsh(NULL);

View File

@ -14,5 +14,6 @@ epicsShareExtern void registerGWServerIocsh();
epicsShareExtern void registerGWClientIocsh();
epicsShareExtern void gwServerShutdown();
epicsShareExtern void gwClientShutdown();
epicsShareExtern void registerReadOnly();
#endif // PVA2PVA_H