allow setting p2pReadOnly from config file
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
"version":1,
|
"version":1,
|
||||||
|
/* "readOnly":true, */
|
||||||
"clients":[
|
"clients":[
|
||||||
{
|
{
|
||||||
"name":"theclient",
|
"name":"theclient",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <epicsGetopt.h>
|
#include <epicsGetopt.h>
|
||||||
#include <iocsh.h>
|
#include <iocsh.h>
|
||||||
#include <epicsTimer.h>
|
#include <epicsTimer.h>
|
||||||
|
#include <libComRegister.h>
|
||||||
|
|
||||||
#include <pv/json.h>
|
#include <pv/json.h>
|
||||||
|
|
||||||
@ -25,14 +26,18 @@
|
|||||||
#include <pv/iocshelper.h>
|
#include <pv/iocshelper.h>
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "pva2pva.h"
|
||||||
|
|
||||||
namespace pvd = epics::pvData;
|
namespace pvd = epics::pvData;
|
||||||
namespace pva = epics::pvAccess;
|
namespace pva = epics::pvAccess;
|
||||||
|
|
||||||
|
extern int p2pReadOnly;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
pvd::StructureConstPtr schema(pvd::getFieldCreate()->createFieldBuilder()
|
pvd::StructureConstPtr schema(pvd::getFieldCreate()->createFieldBuilder()
|
||||||
->add("version", pvd::pvUInt)
|
->add("version", pvd::pvUInt)
|
||||||
|
->add("readOnly", pvd::pvBoolean)
|
||||||
->addNestedStructureArray("clients")
|
->addNestedStructureArray("clients")
|
||||||
->add("name", pvd::pvString)
|
->add("name", pvd::pvString)
|
||||||
->add("provider", pvd::pvString)
|
->add("provider", pvd::pvString)
|
||||||
@ -95,6 +100,12 @@ void getargs(ServerConfig& arg, int argc, char *argv[])
|
|||||||
std::ifstream strm(argv[optind]);
|
std::ifstream strm(argv[optind]);
|
||||||
pvd::parseJSON(strm, arg.conf);
|
pvd::parseJSON(strm, arg.conf);
|
||||||
|
|
||||||
|
{
|
||||||
|
pvd::PVScalarPtr V(arg.conf->getSubField<pvd::PVScalar>("readOnly"));
|
||||||
|
if(V)
|
||||||
|
p2pReadOnly = V->getAs<pvd::boolean>();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned version = arg.conf->getSubFieldT<pvd::PVUInt>("version")->get();
|
unsigned version = arg.conf->getSubFieldT<pvd::PVUInt>("version")->get();
|
||||||
if(version==0) {
|
if(version==0) {
|
||||||
std::cerr<<"Warning: config file missing \"version\" key. Assuming 1\n";
|
std::cerr<<"Warning: config file missing \"version\" key. Assuming 1\n";
|
||||||
@ -222,6 +233,8 @@ int main(int argc, char *argv[])
|
|||||||
epics::iocshRegister<int, const char*, &gwsr>("gwsr", "level", "channel");
|
epics::iocshRegister<int, const char*, &gwsr>("gwsr", "level", "channel");
|
||||||
epics::iocshRegister<int, const char*, const char*, &gwcr>("gwcr", "level", "client", "channel");
|
epics::iocshRegister<int, const char*, const char*, &gwcr>("gwcr", "level", "client", "channel");
|
||||||
|
|
||||||
|
libComRegister();
|
||||||
|
registerReadOnly();
|
||||||
epics::registerRefCounter("ChannelCacheEntry", &ChannelCacheEntry::num_instances);
|
epics::registerRefCounter("ChannelCacheEntry", &ChannelCacheEntry::num_instances);
|
||||||
epics::registerRefCounter("ChannelCacheEntry::CRequester", &ChannelCacheEntry::CRequester::num_instances);
|
epics::registerRefCounter("ChannelCacheEntry::CRequester", &ChannelCacheEntry::CRequester::num_instances);
|
||||||
epics::registerRefCounter("GWChannel", &GWChannel::num_instances);
|
epics::registerRefCounter("GWChannel", &GWChannel::num_instances);
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
typedef epicsGuard<epicsMutex> Guard;
|
typedef epicsGuard<epicsMutex> Guard;
|
||||||
typedef epicsGuardRelease<epicsMutex> UnGuard;
|
typedef epicsGuardRelease<epicsMutex> UnGuard;
|
||||||
|
|
||||||
epicsShareExtern void registerGWClientIocsh();
|
void registerGWClientIocsh();
|
||||||
epicsShareExtern void gwServerShutdown();
|
void gwServerShutdown();
|
||||||
epicsShareExtern void gwClientShutdown();
|
void gwClientShutdown();
|
||||||
epicsShareExtern void registerReadOnly();
|
void registerReadOnly();
|
||||||
|
|
||||||
#endif // PVA2PVA_H
|
#endif // PVA2PVA_H
|
||||||
|
Reference in New Issue
Block a user