areaDetector  3-5-0
EPICS areaDetector framework
NDPluginAttrPlot.h
Go to the documentation of this file.
1 #ifndef NDATTRPLOT_H_
2 #define NDATTRPLOT_H_
3 
18 #include "CircularBuffer.h"
19 
20 #include <NDPluginDriver.h>
21 #include <epicsThread.h>
22 
23 #include <string>
24 #include <vector>
25 
26 #define NDAttrPlotDataString "AP_Data"
27 #define NDAttrPlotDataLabelString "AP_DataLabel"
28 #define NDAttrPlotDataSelectString "AP_DataSelect"
29 #define NDAttrPlotAttributeString "AP_Attribute"
30 #define NDAttrPlotResetString "AP_Reset"
31 #define NDAttrPlotNPtsString "AP_NPts"
32 
33 #define ND_ATTRPLOT_UID_INDEX -1
34 #define ND_ATTRPLOT_UID_LABEL "UID"
35 #define ND_ATTRPLOT_NONE_INDEX -2
36 #define ND_ATTRPLOT_NONE_LABEL "None"
37 
38 #define ND_ATTRPLOT_DATA_EXPOSURE_PERIOD 1. // Data callback period in seconds
39 
40 class NDPluginAttrPlot;
41 
45 class ExposeDataTask : public epicsThreadRunable
46 {
47 public:
54 
58  void run();
59 
63  void start();
64 
68  void stop();
69 
70 private:
72  NDPluginAttrPlot& plugin_;
73 
75  bool stop_;
76 
78  epicsThread thread_;
79 };
80 
94 {
95  typedef CircularBuffer<double> CB;
96 
97 public:
112  NDPluginAttrPlot(const char * port, int max_attributes, int cache_size,
113  int max_selected, const char * in_port, int in_addr, int queue_size,
114  int blocking_callbacks, int priority, int stackSize);
115 
119  void start_expose();
120 
121  friend class ExposeDataTask;
122 
123 public:
132  void processCallbacks(NDArray * pArray);
133 
140  asynStatus writeInt32(asynUser * pasynUser, epicsInt32 value);
141 
142 protected:
144 #define NDATTRPLOT_FIRST_PARAM NDAttrPlotData
150 #define NDATTRPLOT_LAST_PARAM NDAttrPlotNPts
151 #define NUM_NDATTRPLOT_PARAMS (&NDATTRPLOT_LAST_PARAM - \
152  &NDATTRPLOT_FIRST_PARAM + 1)
153 
154 private:
158  enum NDAttrPlotState {
159  NDAttrPlot_InitState,
160  NDAttrPlot_ActiveState
161  };
162 
175  void rebuild_attributes(NDAttributeList& attr_list);
176 
180  void reset_data();
181 
187  asynStatus push_data(epicsInt32 uid, NDAttributeList& attr_list);
188 
192  void callback_data();
193 
197  void callback_attributes();
198 
202  void callback_selected();
203 
204 private:
206  NDAttrPlotState state_;
207 
209  std::vector<CB> data_;
210 
212  CB uids_;
213 
215  const size_t n_attributes_;
216 
218  std::vector<std::string> attributes_;
219 
220  const unsigned n_data_blocks_;
221  std::vector<int> data_selections_;
222 
224  ExposeDataTask expose_task_;
225 };
226 
227 #endif // NDATTRPLOT_H_
228 
Class from which actual plugin drivers are derived; derived from asynNDArrayDriver.
Definition: NDPluginDriver.h:56
void start()
Start the internal thread of the task.
Definition: NDPluginAttrPlot.cpp:22
int NDAttrPlotDataSelect
Definition: NDPluginAttrPlot.h:146
void run()
Periodically runs the data exposure on the plugin.
Definition: NDPluginAttrPlot.cpp:26
A task that periodically executes the data exposure method of the plugin.
Definition: NDPluginAttrPlot.h:45
NDPluginAttrPlot * plugin
Definition: NDPluginAttrPlot.cpp:299
list value
Definition: makeDbAndEdl.py:234
void start_expose()
Starts the data exposure task.
Definition: NDPluginAttrPlot.cpp:93
int NDAttrPlotDataLabel
Definition: NDPluginAttrPlot.h:145
ExposeDataTask(NDPluginAttrPlot &plugin)
Constructor.
Definition: NDPluginAttrPlot.cpp:15
NDAttributeList.h.
Definition: NDAttributeList.h:21
NDPluginAttrPlot(const char *port, int max_attributes, int cache_size, int max_selected, const char *in_port, int in_addr, int queue_size, int blocking_callbacks, int priority, int stackSize)
Constructor.
Definition: NDPluginAttrPlot.cpp:39
int NDAttrPlotNPts
Definition: NDPluginAttrPlot.h:149
asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Called when an OUT record with asynInt32 interface is processed.
Definition: NDPluginAttrPlot.cpp:269
void processCallbacks(NDArray *pArray)
Caches the values of attributes in the array.
Definition: NDPluginAttrPlot.cpp:127
AD plugin that saves attribute values from recieved NDArrays.
Definition: NDPluginAttrPlot.h:93
int NDAttrPlotAttribute
Definition: NDPluginAttrPlot.h:147
int NDAttrPlotData
Definition: NDPluginAttrPlot.h:143
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:92
int NDAttrPlotReset
Definition: NDPluginAttrPlot.h:148
void stop()
Stop the internal thread of the task.
Definition: NDPluginAttrPlot.cpp:35