4 #include <epicsThread.h>
5 #include <epicsString.h>
6 #include <epicsStdio.h>
10 #include <dbStaticLib.h>
13 #include <epicsVersion.h>
16 #include <pv/reftrack.h>
17 #include <pv/pvAccess.h>
18 #include <pv/serverContext.h>
19 #include <pv/iocshelper.h>
22 #include "pvahelper.h"
25 #include "pdbsingle.h"
27 # include "pdbgroup.h"
30 #include <epicsExport.h>
32 namespace pva = epics::pvAccess;
34 void QSRVRegistrar_counters()
36 epics::registerRefCounter(
"PDBSinglePV", &PDBSinglePV::num_instances);
37 epics::registerRefCounter(
"PDBSingleChannel", &PDBSingleChannel::num_instances);
38 epics::registerRefCounter(
"PDBSinglePut", &PDBSinglePut::num_instances);
39 epics::registerRefCounter(
"PDBSingleMonitor", &PDBSingleMonitor::num_instances);
41 epics::registerRefCounter(
"PDBGroupPV", &PDBGroupPV::num_instances);
42 epics::registerRefCounter(
"PDBGroupChannel", &PDBGroupChannel::num_instances);
43 epics::registerRefCounter(
"PDBGroupPut", &PDBGroupPut::num_instances);
44 epics::registerRefCounter(
"PDBGroupMonitor", &PDBGroupMonitor::num_instances);
45 #endif // USE_MULTILOCK
46 epics::registerRefCounter(
"PDBProvider", &PDBProvider::num_instances);
49 long dbLoadGroup(
const char* fname)
53 printf(
"dbLoadGroup(\"file.json\")\n"
55 "Load additional DB group definitions from file.\n");
62 fprintf(stderr,
"ignoring %s\n", fname);
68 if(fname[0]==
'*' && fname[1]==
'\0') {
69 PDBProvider::group_files.clear();
71 PDBProvider::group_files.remove(fname);
74 PDBProvider::group_files.remove(fname);
75 PDBProvider::group_files.push_back(fname);
79 }
catch(std::exception& e){
80 fprintf(stderr,
"Error: %s\n", e.what());
87 void dbLoadGroupWrap(
const char* fname)
89 (void)dbLoadGroup(fname);
92 void dbgl(
int lvl,
const char *pattern)
98 PDBProvider::shared_pointer prov(
99 std::tr1::dynamic_pointer_cast<PDBProvider>(
100 pva::ChannelProviderRegistry::servers()->getProvider(
"QSRV")));
102 throw std::runtime_error(
"No Provider (PVA server not running?)");
104 PDBProvider::persist_pv_map_t pvs;
106 epicsGuard<epicsMutex> G(prov->transient_pv_map.mutex());
107 pvs = prov->persist_pv_map;
110 for(PDBProvider::persist_pv_map_t::const_iterator it(pvs.begin()), end(pvs.end());
113 if(pattern[0] && epicsStrGlobMatch(it->first.c_str(), pattern)==0)
116 printf(
"%s\n", it->first.c_str());
119 it->second->show(lvl);
122 }
catch(std::exception& e){
123 fprintf(stderr,
"Error: %s\n", e.what());
129 QSRVRegistrar_counters();
130 pva::ChannelProviderRegistry::servers()->addSingleton<
PDBProvider>(
"QSRV");
131 epics::iocshRegister<int, const char*, &dbgl>(
"dbgl",
"level",
"pattern");
132 epics::iocshRegister<const char*, &dbLoadGroupWrap>(
"dbLoadGroup",
"jsonfile");
137 unsigned qsrvVersion(
void)
139 return QSRV_VERSION_INT;
142 unsigned qsrvABIVersion(
void)
144 return QSRV_ABI_VERSION_INT;
148 epicsExportRegistrar(QSRVRegistrar);