This is Unofficial EPICS BASE Doxygen Site
reftrackioc.cpp
Go to the documentation of this file.
1 
7 #include <exception>
8 
9 #include <iocsh.h>
10 
11 #include <pv/reftrack.h>
12 #include <pv/iocshelper.h>
13 
14 #include <epicsExport.h>
15 
16 #include <pv/iocreftrack.h>
17 
18 namespace {
19 
20 void showRefs(const epics::RefSnapshot& snap, int lvl, bool delta)
21 {
22  for(epics::RefSnapshot::const_iterator it = snap.begin(), end = snap.end();
23  it != end; ++it)
24  {
25  if(it->second.current==0 && it->second.delta==0 && lvl<=0) continue;
26  if(delta && it->second.delta==0 && lvl<=0) continue;
27  if(delta) {
28  printf(" %s : %zu (delta %zd)\n",
29  it->first.c_str(), it->second.current, it->second.delta);
30  } else {
31  printf(" %s : %zu\n", it->first.c_str(), it->second.current);
32  }
33  }
34 }
35 
36 #define CATCH() catch(std::exception& e){printf("Error %s\n", e.what());}
37 
38 void refshow(int lvl)
39 {
40  try {
41  epics::RefSnapshot snap;
42  snap.update();
43 
44  showRefs(snap, lvl, false);
45  }CATCH()
46 }
47 
48 // No locking. assume only interactive iocsh use
49 static epics::RefSnapshot savedSnap;
50 
51 void refsave()
52 {
53  try {
54  epics::RefSnapshot snap;
55  snap.update();
56 
57  savedSnap.swap(snap);
58  }CATCH()
59 }
60 
61 void refdiff(int lvl)
62 {
63  epics::RefSnapshot snap;
64  snap.update();
65 
66  showRefs(snap-savedSnap, lvl, true);
67 }
68 
69 static epics::RefMonitor gblmon;
70 
71 void refmon(double period, int lvl)
72 {
73  if(period==0) {
74  gblmon.stop();
75  } else if(period>0) {
76  gblmon.start(period);
77  }
78 }
79 
80 } // namespace
81 
82 namespace epics {namespace pvAccess {
83 
85 {
86  epics::iocshRegister<int, &refshow>("refshow", "detail level");
87  epics::iocshRegister<&refsave>("refsave");
88  epics::iocshRegister<int, &refdiff>("refdiff", "detail level");
89  epics::iocshRegister<double, int, &refmon>("refmon", "update period", "detail level");
90 }
91 
92 }}
93 
94 extern "C" {
95  using namespace epics::pvAccess;
97 }
#define CATCH()
Definition: reftrackioc.cpp:36
#define printf
Definition: epicsStdio.h:41
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
epicsShareExtern void refTrackRegistrar()
Definition: reftrackioc.cpp:84
Holds all PVA related.
Definition: pvif.h:34
epicsExportRegistrar(refTrackRegistrar)
Exporting IOC objects.