ACQ400_XRM (xrmIoc)
Loading...
Searching...
No Matches
acq400_PM.h
Go to the documentation of this file.
1/** @file acq400_PM.h : acq400_PM : Post Mortem class.
2 * @brief handles Post Mortem, one ADDRESS per PMBUF
3 *
4 - ACQ400 has supplied PM data from the start "TRANSIENT".
5 - however, TRANSIENT is a one shot, start, stop, off-load
6 - XRM calls for a "live PM" that allows the capture to continue.
7 - We do this by copying EVERY capture buffer, maintaining a ring-buffer of the previous second.
8 - The previous second is presented as :PM:00 latest .. PM:19: oldest
9 - acq400_PM has a RUNSTOP paramter. On run, the ring-buffer is maintained as normal
10 - on STOP, the PM buffers are published for external client use.
11 *
12 * Created on: 6 Mar 2026
13 * Author: pgm
14 */
15
16#ifndef XRMIOCAPP_SRC_ACQ400_PM_H_
17#define XRMIOCAPP_SRC_ACQ400_PM_H_
18
19#include "acq400_asyn_common.h"
20#include "SamplePrams.h"
21#include "epicsRingBytes.h"
22
23#include <algorithm>
24#include <iostream>
25#include <numeric>
26#include <string>
27#include <deque>
28
29struct BufferPair {
30 short ib_live; // index of live buffer
31 short ib_store; // index of buffer in store
32};
33
34#define MAX_PM_BUFFERS 32
35
36#define PS_NBUF "NBUF" /* asynInt32, r, number of buffers */
37
38#define PS_PM_COL_ROWNUM "PM_COL_ROWNUM"
39#define PS_PM_COL_IBLIVE "PM_COL_IBLIVE"
40#define PS_PM_COL_IBSTORE "PM_COL_IBSTORE"
41#define PS_PM_COL_TS "PM_COL_TS"
42
43#define PS_PM_COL_SP0 "PM_COL_SP0"
44#define PS_PM_COL_SP1 "PM_COL_SP1"
45#define PS_PM_COL_SP2 "PM_COL_SP2" // WRV
46#define PS_PM_COL_SP3 "PM_COL_SP3" // WRS Seconds Since EPOCH, SP3
47#define PS_PM_COL_WRVS "PM_COL_WRVS" // WR Vernier, seconds
48#define PS_PM_COL_WRVT "PM_COL_WRVT" // WR Vernier, ticks
49#define PS_PM_COL_WRUS "PM_COL_WRUS" // WR time, usec since epoch
50
51
52
53#define PS_RAWBUF "RAWBUF" /* addr 0..32 */
54
56
57protected:
58 std::deque<BufferPair> empties;
59 std::deque<BufferPair> filled;
60
61 void init_buffers(const unsigned nbuf);
62 void stash_buffer(int ib_live, const unsigned nbuf);
63
64 struct PM_COLS {
65 epicsInt8 c_rownum[MAX_PM_BUFFERS];
66 epicsInt16 c_ib_live[MAX_PM_BUFFERS];
67 epicsInt16 c_ib_store[MAX_PM_BUFFERS];
68 epicsInt64 c_timestamp[MAX_PM_BUFFERS]; // really U64 but..
69 epicsInt32 c_SP0[MAX_PM_BUFFERS];
70 epicsInt32 c_SP1[MAX_PM_BUFFERS];
71 epicsInt32 c_SP2[MAX_PM_BUFFERS];
72 epicsInt32 c_SP3[MAX_PM_BUFFERS];
73 epicsInt8 c_WRVS[MAX_PM_BUFFERS];
74 epicsInt32 c_WRVT[MAX_PM_BUFFERS];
75 epicsInt64 c_WRUS[MAX_PM_BUFFERS];
76 } pm_cols;
77
78 SamplePrams samplePrams;
79 void get_sample_dimensions();
80
81 virtual void update_pm_tab_row(int row, int ib);
82 virtual void update_pm_callbacks(bool call_array_callbacks);
83
84 virtual void task();
85
86 static void task_runner(void *drvPvt);
87 static int nice;
88 static int verbose;
89 static int spX_from_live;
90 static int buffer_throttle_modulo;
91
92 int P_NBUF;
93 int P_RING;
94 int P_RAWBUF;
95
96 int P_COL_ROWNUM;
97 int P_COL_IBLIVE;
98 int P_COL_IBSTORE;
99 int P_COL_TS;
100
101 int P_COL_SP0;
102 int P_COL_SP1;
103 int P_COL_SP2;
104 int P_COL_SP3;
105 int P_COL_WRVS;
106 int P_COL_WRVT;
107 int P_COL_WRUS;
108
109 int ib; /** ib is physical buffer contains bpb vpb's */
110
111public:
112 acq400_PM(const char *portName);
113 virtual ~acq400_PM() {}
114
115 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
116};
117#endif /* XRMIOCAPP_SRC_ACQ400_PM_H_ */
defines SamplePrams, sample geometry definition struct.
acq400_PM(const char *portName)
Definition acq400_PM.cpp:36
acq400_asynPortDriver(const char *portName, int maxAddr, int interfaceMask, int interruptMask, int asynFlags, int autoConnect, int priority, int stackSize)
Definition acq400_asynPortDriver.cpp:16
Definition acq400_PM.h:29
Definition SamplePrams.h:11
Definition acq400_PM.h:64