This is Unofficial EPICS BASE Doxygen Site
gwmain.cpp File Reference
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <map>
#include <signal.h>
#include <epicsStdlib.h>
#include <epicsGetopt.h>
#include <iocsh.h>
#include <epicsTimer.h>
#include <libComRegister.h>
#include <pv/json.h>
#include <pv/pvAccess.h>
#include <pv/clientFactory.h>
#include <pv/configuration.h>
#include <pv/serverContext.h>
#include <pv/reftrack.h>
#include <pv/iocreftrack.h>
#include <pv/iocshelper.h>
#include <pv/logger.h>
#include "server.h"
#include "pva2pva.h"
+ Include dependency graph for gwmain.cpp:

Go to the source code of this file.

Macros

#define USE_SIGNAL
 

Functions

int main (int argc, char *argv[])
 

Variables

int p2pReadOnly
 

Macro Definition Documentation

#define USE_SIGNAL

Definition at line 9 of file gwmain.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 240 of file gwmain.cpp.

241 {
242  try {
244 
245  epics::iocshRegister<const char*, const char*, &iocsh_drop>("drop", "client", "channel");
246  epics::iocshRegister<int, const char*, &gwsr>("gwsr", "level", "channel");
247  epics::iocshRegister<int, const char*, const char*, &gwcr>("gwcr", "level", "client", "channel");
248 
249  libComRegister();
256 
257  ServerConfig arg;
258  theserver = &arg;
259  getargs(arg, argc, argv);
260 
261  if(arg.debug>0)
262  std::cout<<"Notice: This p2p gateway prototype has been superceded by the p4p.gw gateway\n"
263  " which has exciting new features including granular access control,\n"
264  " and status PVs including bandwidth usage reports.\n"
265  " p2p is considered deprecated by its author, and will receive\n"
266  " minimal maintainance effort going forward.\n"
267  " Users are encouraged to migrate to p4p.gw.\n"
268  "\n"
269  " https://mdavidsaver.github.io/p4p/gw.html\n"
270  "\n";
271 
273  if(arg.debug<0)
274  lvl = pva::logLevelError;
275  else if(arg.debug==0)
276  lvl = pva::logLevelWarn;
277  else if(arg.debug==1)
278  lvl = pva::logLevelInfo;
279  else if(arg.debug==2)
280  lvl = pva::logLevelDebug;
281  else if(arg.debug==3)
282  lvl = pva::logLevelTrace;
283  else if(arg.debug>=4)
284  lvl = pva::logLevelAll;
285  SET_LOG_LEVEL(lvl);
286 
288 
290 
291  arr = arg.conf->getSubFieldT<pvd::PVStructureArray>("clients")->view();
292 
293  for(size_t i=0; i<arr.size(); i++) {
294  if(!arr[i]) continue;
295  const pvd::PVStructurePtr& client = arr[i];
296 
297  std::string name(client->getSubFieldT<pvd::PVString>("name")->get());
298  if(name.empty())
299  throw std::runtime_error("Client with empty name not allowed");
300 
301  ServerConfig::clients_t::const_iterator it(arg.clients.find(name));
302  if(it!=arg.clients.end())
303  throw std::runtime_error(std::string("Duplicate client name not allowed : ")+name);
304 
305  arg.clients[name] = configure_client(arg, client);
306  }
307 
308  arr = arg.conf->getSubFieldT<pvd::PVStructureArray>("servers")->view();
309 
310  for(size_t i=0; i<arr.size(); i++) {
311  if(!arr[i]) continue;
312  const pvd::PVStructurePtr& server = arr[i];
313 
314  std::string name(server->getSubFieldT<pvd::PVString>("name")->get());
315  if(name.empty())
316  throw std::runtime_error("Server with empty name not allowed");
317 
318  ServerConfig::servers_t::const_iterator it(arg.servers.find(name));
319  if(it!=arg.servers.end())
320  throw std::runtime_error(std::string("Duplicate server name not allowed : ")+name);
321 
322  arg.servers[name] = configure_server(arg, server);
323  }
324 
325  int ret = 0;
326  if(arg.interactive) {
327  ret = iocsh(NULL);
328  } else {
329 #ifdef USE_SIGNAL
330  signal(SIGINT, sigdone);
331  signal(SIGTERM, sigdone);
332  signal(SIGQUIT, sigdone);
333 #endif
334 
335  while(!quit) {
336  done.wait();
337  }
338  }
339 
340  theserver = 0;
341 
342  return ret;
343  }catch(std::exception& e){
344  std::cerr<<"Fatal Error : "<<e.what()<<"\n";
345  return 1;
346  }
347 }
int i
Definition: scan.c:967
#define SET_LOG_LEVEL(level)
Definition: logger.h:50
::epics::pvData::shared_vector< const PVStructurePtr > const_svector
Definition: pvData.h:1249
#define NULL
Definition: catime.c:38
void registerReadOnly()
Definition: channel.cpp:242
bool interactive
Definition: server.h:42
storage_t::arg_type get() const
Definition: pvData.h:396
epicsShareExtern void refTrackRegistrar()
Definition: reftrackioc.cpp:84
int epicsStdCall iocsh(const char *pathname)
Definition: iocsh.cpp:1011
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
clients_t clients
Definition: server.h:46
epics::pvData::PVStructure::shared_pointer conf
Definition: server.h:43
Definition: server.h:76
servers_t servers
Definition: server.h:49
void registerRefCounter(const char *name, const size_t *counter)
Definition: reftrack.cpp:59
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
Data class for a structureArray.
Definition: pvData.h:1236
void epicsStdCall libComRegister(void)
static size_t num_instances
Definition: chancache.h:27
static size_t num_instances
Definition: chancache.h:108
void done(int k)
Definition: antelope.c:77
int debug
Definition: server.h:41
static size_t num_instances
Definition: chancache.h:70
static size_t num_instances
Definition: channel.h:13

Variable Documentation

int p2pReadOnly

Definition at line 21 of file channel.cpp.