mrfioc2  2.3.0
drvemTSBuffer.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2020 Michael Davidsaver
3 * mrfioc2 is distributed subject to a Software License Agreement found
4 * in file LICENSE that is included with this distribution.
5 \*************************************************************************/
6 #ifndef DRVEMTSBUFFER_H
7 #define DRVEMTSBUFFER_H
8 
9 #include <vector>
10 #include <utility> // std::pair
11 
12 #include <dbScan.h>
13 
14 #include "mrf/object.h"
15 
16 class EVRMRM;
17 
18 struct EVRMRMTSBuffer : public mrf::ObjectInst<EVRMRMTSBuffer>
19 {
21 
22  explicit EVRMRMTSBuffer(const std::string& n, EVRMRM* evr);
23  virtual ~EVRMRMTSBuffer();
24 
25  virtual void lock() const OVERRIDE FINAL;
26  virtual void unlock() const OVERRIDE FINAL;
27 
28  epicsUInt32 dropCount() const { return dropped; }
29 
30  epicsUInt16 timeEvent() const { return timeEvt; }
31  void flushTimeSet(epicsUInt16 v);
32 
33  epicsUInt16 flushEvent() const { return flushEvt; }
34  void flushEventSet(epicsUInt16 v);
35 
36  void flushNow();
37  void doFlush();
38 
39  epicsUInt32 getTimesRelFirst(epicsInt32 *arr, epicsUInt32 count) const;
40  epicsUInt32 getTimesRelFlush(epicsInt32 *arr, epicsUInt32 count) const;
41  epicsUInt32 getTimesRelPrevFlush(epicsInt32 *arr, epicsUInt32 count) const;
42 
43  IOSCANPVT flushed() const { return scan; }
44 
45  EVRMRM* const evr;
46 
47  epicsUInt32 dropped;
48 
49  IOSCANPVT scan;
50 
51  epicsUInt8 timeEvt;
52  epicsUInt8 flushEvt;
53 
54  struct ebuf_t {
55  size_t pos;
56  std::vector<epicsTimeStamp> buf;
57  epicsTimeStamp flushtime, prevflushtime;
58  bool ok, prevok;
59  bool drop;
60  ebuf_t() :pos(0u), ok(false), prevok(false), drop(false) {
61  flushtime.secPastEpoch = 0u;
62  flushtime.nsec = 0u;
63  prevflushtime = flushtime;
64  }
65  private:
66  ebuf_t(const ebuf_t&);
67  } ebufs[2];
68  // active buffer being filled. Other is for readout.
69  // must lock both evr and this mutex to change.
70  unsigned char active; // either 0 or 1
71 };
72 
73 #endif // DRVEMTSBUFFER_H
epicsUInt8 flushEvt
Definition: drvemTSBuffer.h:52
epicsUInt32 dropped
Definition: drvemTSBuffer.h:47
epicsUInt32 getTimesRelFirst(epicsInt32 *arr, epicsUInt32 count) const
mrf::ObjectInst< EVRMRMTSBuffer > base_t
Definition: drvemTSBuffer.h:20
epicsTimeStamp flushtime
Definition: drvemTSBuffer.h:57
std::vector< epicsTimeStamp > buf
Definition: drvemTSBuffer.h:56
Modular Register Map Event Receivers.
Definition: drvem.h:86
virtual ~EVRMRMTSBuffer()
epicsUInt32 getTimesRelFlush(epicsInt32 *arr, epicsUInt32 count) const
void flushTimeSet(epicsUInt16 v)
EVRMRMTSBuffer(const std::string &n, EVRMRM *evr)
EVRMRM *const evr
Definition: drvemTSBuffer.h:45
epicsUInt32 getTimesRelPrevFlush(epicsInt32 *arr, epicsUInt32 count) const
User implementation hook.
Definition: object.h:459
void flushEventSet(epicsUInt16 v)
epicsUInt8 timeEvt
Definition: drvemTSBuffer.h:51
epicsUInt16 flushEvent() const
Definition: drvemTSBuffer.h:33
epicsTimeStamp prevflushtime
Definition: drvemTSBuffer.h:57
unsigned char active
Definition: drvemTSBuffer.h:70
IOSCANPVT flushed() const
Definition: drvemTSBuffer.h:43
virtual void lock() const OVERRIDE FINAL
epicsUInt32 dropCount() const
Definition: drvemTSBuffer.h:28
IOSCANPVT scan
Definition: drvemTSBuffer.h:49
epicsUInt16 timeEvent() const
Definition: drvemTSBuffer.h:30
struct EVRMRMTSBuffer::ebuf_t ebufs[2]
virtual void unlock() const OVERRIDE FINAL