ICP  1
dae_events.h
Go to the documentation of this file.
1 #ifndef DAE_EVENTS_H
2 #define DAE_EVENTS_H
3 
6 
9 {
10  unsigned header_type : 4;
11  unsigned header_length : 5;
12  unsigned unused1 : 2;
13  unsigned bad_frame : 1;
14  unsigned unused2 : 1;
15  unsigned fifo_read_late : 1;
16  unsigned memory_wrap : 1;
17  unsigned frame_overflow : 1;
18  unsigned fifo_overflows : 16;
19 };
20 
21 
22 struct DAEEventHeaderVetos // 32bits
23 {
24  unsigned fifo : 1;
25  unsigned smp : 1;
26  unsigned unused4 : 2;
27  unsigned ts2_pulse : 1;
28  unsigned wrong_pulse : 1;
29  unsigned isis_slow : 1;
30  unsigned unused3 : 5;
31  unsigned external : 4;
32  unsigned unused2 : 8;
33  unsigned fast_chopper : 4;
34  unsigned unused1 : 4;
35 };
36 
37 
39 
40 static const int DAEEventHeaderFixedMarker = 0xffffffff;
41 
45 {
46  uint32_t marker0;
47  uint32_t marker1;
49  uint32_t frame_number;
50  struct DAETime
51  {
52  uint32_t low;
53  uint32_t high;
54  } time;
55  struct
56  {
57  unsigned period : 23;
58  unsigned unused1 : 9;
59  };
60  uint32_t num_events;
61  struct
62  {
63  unsigned protons : 10;
64  unsigned unused : 22;
65  };
67 };
68 
69 inline std::ostream& operator<<(std::ostream& os, const DAEEventHeader::DAETime& t)
70 {
71  os << (((uint64_t)t.high) << 32) + t.low;
72  return os;
73 }
74 
75 // POSLUT spectrum number and time channels from card. Should not see time_channel=0, first time_channel=1
77 {
78  unsigned time_channel : 16;
79  unsigned spectrum : 16;
80 };
81 
82 
83 // for 32MHz timing, time is after frame sync in 31.25 ns steps
85 {
86  unsigned position : 12;
87  unsigned dim : 4;
88  unsigned unused1 : 16;
89  unsigned time : 31;
90  unsigned unused2 : 1;
91 };
92 
93 namespace dae_events_conditions {
96  BOOST_STATIC_ASSERT(sizeof(DAEEventHeader) == 40);
97  BOOST_STATIC_ASSERT( (sizeof(DAEEventHeader) % 8) == 0 ); // Must always be an even number of 32bit words (i.e. a multiple of 8 bytes) - see above
100 }
101 
102 static const unsigned DAE_EVENT_HEADER_WORDS = (sizeof(DAEEventHeader) / 4);
103 
105 {
106 private:
107  static uint32_t checkEventsFrame(const isisU32_t* buffer, uint32_t maxlen, DAEstatus& status);
108  static uint32_t getCompleteFramesLen(const isisU32_t* buffer, uint32_t len, DAEstatus& status);
109  static void getEventHeaderErrorMessage(const DAEEventHeader* head, unsigned code, std::string& error_message);
110  static int checkEventHeaderImpl(const DAEEventHeader* head);
111 public:
112  static void checkEventHeader(const DAEEventHeader* head);
113  static int checkEventHeader(const DAEEventHeader* head, std::string& error_message);
114  static void checkEvents(const isisU32_t* buffer, uint32_t maxlen, DAEstatus& status);
115  static bool isEndRunHeader(const DAEEventHeader* head, DAEstatus& status);
116  static int findValidEventHeaderOffset(const isisU32_t* buffer, uint32_t len, DAEstatus& status);
117  static void printEventHeader(const DAEEventHeader* head, std::ostream& os);
118  static void printDetectorEvents(const DetectorEvent32* events, int n, std::ostream& os);
119  static void DAETimeToSystemTime(const DAEEventHeader::DAETime& daetime, SYSTEMTIME& systime);
120  static void SystemTimeToDAETime(const SYSTEMTIME& systime, DAEEventHeader::DAETime& daetime);
121  static void DAETimeToFILETIME(const DAEEventHeader::DAETime& daetime, FILETIME& filetime);
122  template<typename T> static void DAETimeToOffset(const DAEEventHeader::DAETime& daetime, time_t base, T& offset);
123  static void OffsetToDAETime(time_t base, double offset, DAEEventHeader::DAETime& daetime);
124  static void FILETIMEToDAETime(const FILETIME& filetime, DAEEventHeader::DAETime& daetime);
125  static std::string DAETimeAsString(const DAEEventHeader::DAETime& daetime);
126 };
127 
128 #endif /* DAE_EVENTS_H */
static int checkEventHeaderImpl(const DAEEventHeader *head)
return 0x20 if dummy header present
Definition: dae_events.cpp:44
unsigned header_type
Definition: dae_events.h:10
static void printEventHeader(const DAEEventHeader *head, std::ostream &os)
Definition: dae_events.cpp:279
uint32_t num_events
Definition: dae_events.h:60
Sutucture of an Event in DAE memory (32bits)
Definition: dae_events.h:8
uint32_t marker1
should always be DAEEventHeaderFixedMarker
Definition: dae_events.h:47
unsigned unused1
Definition: dae_events.h:88
unsigned dim
Definition: dae_events.h:87
unsigned unused
Definition: dae_events.h:64
fixed header marker for DAEEventHeader
Definition: dae_events.h:44
unsigned long isisU32_t
Definition: isisvme_types.h:8
unsigned ts2_pulse
Definition: dae_events.h:27
DAEEventHeaderVetos vetos
Definition: dae_events.h:66
unsigned wrong_pulse
Definition: dae_events.h:28
unsigned memory_wrap
Definition: dae_events.h:16
unsigned period
Definition: dae_events.h:57
static const int DAEEventHeaderFixedMarker
Definition: dae_events.h:40
static void OffsetToDAETime(time_t base, double offset, DAEEventHeader::DAETime &daetime)
Definition: dae_events.cpp:238
static void getEventHeaderErrorMessage(const DAEEventHeader *head, unsigned code, std::string &error_message)
Definition: dae_events.cpp:77
unsigned header_length
Definition: dae_events.h:11
unsigned unused2
Definition: dae_events.h:90
unsigned fast_chopper
Definition: dae_events.h:33
unsigned isis_slow
Definition: dae_events.h:29
unsigned frame_overflow
Definition: dae_events.h:17
static void DAETimeToFILETIME(const DAEEventHeader::DAETime &daetime, FILETIME &filetime)
Definition: dae_events.cpp:215
static void DAETimeToSystemTime(const DAEEventHeader::DAETime &daetime, SYSTEMTIME &systime)
Definition: dae_events.cpp:192
unsigned time
Definition: dae_events.h:89
unsigned protons
Definition: dae_events.h:63
unsigned fifo_overflows
Definition: dae_events.h:18
static uint32_t getCompleteFramesLen(const isisU32_t *buffer, uint32_t len, DAEstatus &status)
Definition: dae_events.cpp:135
static void SystemTimeToDAETime(const SYSTEMTIME &systime, DAEEventHeader::DAETime &daetime)
Definition: dae_events.cpp:202
DAEEventHeaderInfo info
should be DAEEventHeaderMarker
Definition: dae_events.h:48
static int findValidEventHeaderOffset(const isisU32_t *buffer, uint32_t len, DAEstatus &status)
returns index of start of a valid event header, -1 on error
Definition: dae_events.cpp:111
BOOST_STATIC_ASSERT(sizeof(DAEEventHeaderInfo)==4)
uint32_t marker0
Definition: dae_events.h:46
struct DAEEventHeader::DAETime time
static void printDetectorEvents(const DetectorEvent32 *events, int n, std::ostream &os)
Definition: dae_events.cpp:291
static void DAETimeToOffset(const DAEEventHeader::DAETime &daetime, time_t base, T &offset)
Definition: dae_events.cpp:226
static std::string DAETimeAsString(const DAEEventHeader::DAETime &daetime)
return as ISO8601 format string
Definition: dae_events.cpp:266
unsigned unused1
Definition: dae_events.h:12
unsigned bad_frame
Definition: dae_events.h:13
unsigned time_channel
Definition: dae_events.h:78
uint32_t frame_number
Definition: dae_events.h:49
static const unsigned DAE_EVENT_HEADER_WORDS
Definition: dae_events.h:102
unsigned spectrum
Definition: dae_events.h:79
static void FILETIMEToDAETime(const FILETIME &filetime, DAEEventHeader::DAETime &daetime)
Definition: dae_events.cpp:255
unsigned fifo_read_late
Definition: dae_events.h:15
static bool isEndRunHeader(const DAEEventHeader *head, DAEstatus &status)
check whether an event frame header is a special enf of frame header
Definition: dae_events.cpp:179
static void checkEvents(const isisU32_t *buffer, uint32_t maxlen, DAEstatus &status)
checks that buffer corresponds to a copmplete set of event frames
Definition: dae_events.cpp:6
DAEEventHeaderMarker
Definition: dae_events.h:38
static uint32_t checkEventsFrame(const isisU32_t *buffer, uint32_t maxlen, DAEstatus &status)
Definition: dae_events.cpp:155
std::ostream & operator<<(std::ostream &os, const DAEEventHeader::DAETime &t)
Definition: dae_events.h:69
unsigned position
Definition: dae_events.h:86
unsigned unused2
Definition: dae_events.h:14
static void checkEventHeader(const DAEEventHeader *head)
Definition: dae_events.cpp:22
unsigned unused1
Definition: dae_events.h:58