My Project
mrmtimesrc.h
1 /*************************************************************************\
2 * Copyright (c) 2016 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 MRMTIMESRC_H
7 #define MRMTIMESRC_H
8 
9 #include <string>
10 
11 #include <shareLib.h>
12 #include <epicsTypes.h>
13 
14 /* Handles sending shirt 0/1 events after the start of each second.
15  */
16 class epicsShareClass TimeStampSource
17 {
18  struct Impl;
19  Impl * const impl;
20 public:
21  explicit TimeStampSource(double period);
22  virtual ~TimeStampSource();
23 
25  void resyncSecond();
26 
28  void tickSecond();
29 
31  bool validSeconds() const;
32 
34  epicsUInt32 updateSecond(epicsUInt32 ts_in);
35 
37  double deltaSeconds() const;
38 
40  void softSecondsSrc(bool enable);
41  bool isSoftSeconds() const;
42 
43  std::string nextSecond() const;
44  std::string currentSecond() const;
45 
46 protected:
47  virtual void setEvtCode(epicsUInt32 evtCode) =0;
48 
49  virtual void postSoftSecondsSrc() {tickSecond();}
50 
51 private:
52  TimeStampSource(const TimeStampSource&);
53  TimeStampSource& operator=(const TimeStampSource&);
54 };
55 
56 #endif // MRMTIMESRC_H