ADARA.h 2.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef __ADARA_H
#define __ADARA_H

#include <string>
#include <stdexcept>

namespace ADARA {

#define ADARA_PKT_TYPE(type, ver)  ((((uint32_t) type) << 8) | (ver))
namespace PacketType {
	enum Enum {
		RAW_EVENT_V0		= ADARA_PKT_TYPE(0x0000, 0),
		RTDL_V0			= ADARA_PKT_TYPE(0x0001, 0),
		BANKED_EVENT_V0		= ADARA_PKT_TYPE(0x4000, 0),
		BEAM_MONITOR_EVENT_V0	= ADARA_PKT_TYPE(0x4001, 0),
		PIXEL_MAPPING_V0	= ADARA_PKT_TYPE(0x4002, 0),
		RUN_STATUS_V0		= ADARA_PKT_TYPE(0x4003, 0),
		RUN_INFO_V0		= ADARA_PKT_TYPE(0x4004, 0),
		TRANS_COMPLETE_V0	= ADARA_PKT_TYPE(0x4005, 0),
		CLIENT_HELLO_V0		= ADARA_PKT_TYPE(0x4006, 0),
		STATS_RESET_V0		= ADARA_PKT_TYPE(0x4007, 0),
		SYNC_V0			= ADARA_PKT_TYPE(0x4008, 0),
		HEARTBEAT_V0		= ADARA_PKT_TYPE(0x4009, 0),
24
		GEOMETRY_V0		= ADARA_PKT_TYPE(0x400A, 0),
25
		BEAMLINE_INFO_V0	= ADARA_PKT_TYPE(0x400B, 0),
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
		DEVICE_DESC_V0		= ADARA_PKT_TYPE(0x8000, 0),
		VAR_VALUE_U32_V0	= ADARA_PKT_TYPE(0x8001, 0),
		VAR_VALUE_DOUBLE_V0	= ADARA_PKT_TYPE(0x8002, 0),
		VAR_VALUE_STRING_V0	= ADARA_PKT_TYPE(0x8003, 0),
	};
}

/* These are defined in the SNS Timing Master Functional System Description,
 * section 1.3.4.
 */
namespace PulseFlavor {
	enum Enum {
		NO_BEAM		  = 0,
		NORMAL		  = 1,
		NORMAL_TGT_1	  = 1,
		NORMAL_TGT_2	  = 2,
		DIAG_10us	  = 3,
		DIAG_50us	  = 4,
		DIAG_100us	  = 5,
		SPECIAL_PHYSICS_1 = 6,
		SPECIAL_PHYSICS_2 = 7
	};
}

namespace RunStatus {
	enum Enum {
		NO_RUN	= 0,
		NEW_RUN	= 1,
		RUN_EOF	= 2,
		RUN_BOF	= 3,
		END_RUN	= 4,
57
		STATE	= 5,
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	};
}

namespace VariableStatus {
	enum Enum {
		OK			= 0,	// EPICS: NO_ALARM
		READ_ERROR		= 1,
		WRITE_ERROR		= 2,
		HIHI_LIMIT		= 3,
		HIGH_LIMIT		= 4,
		LOLO_LIMIT		= 5,
		LOW_LIMIT		= 6,
		BAD_STATE		= 7,
		CHANGED_STATE		= 8,
		NO_COMMUNICATION	= 9,
		COMMUNICATION_TIMEOUT	= 10,
		HARDWARE_LIMIT		= 11,
		BAD_CALCULATION		= 12,
		INVALID_SCAN		= 13,
		LINK_FAILED		= 14,
		INVALID_STATE		= 15,
		BAD_SUBROUTINE		= 16,
		UNDEFINED_ALARM		= 17,
		DISABLED		= 18,
		SIMULATED		= 19,
		READ_PERMISSION		= 20,
		WRITE_PERMISSION	= 21,
		NOT_REPORTED		= 0xffff,
	};
}

namespace VariableSeverity {
	enum Enum {
		OK			= 0,	// EPICS: NO_ALARM
		MINOR_ALARM		= 1,
		MAJOR_ALARM		= 2,
		INVALID			= 3,
		NOT_REPORTED		= 0xffff,
	};
}

99
100
struct Event {
	uint32_t tof;
Miller, Ross's avatar
Miller, Ross committed
101
	uint32_t pixel;
102
103
};

104
105
typedef uint32_t EventBank;

106
107
108
109
110
111
112
struct Header {
	uint32_t payload_len;
	uint32_t pkt_format;
	uint32_t ts_sec;
	uint32_t ts_nsec;
};

113
114
115
116
117
118
119
120
121
122
123
124
class invalid_packet : public std::runtime_error {
public:
	explicit invalid_packet(const std::string &msg) : runtime_error(msg) {}
};

enum {
	EPICS_EPOCH_OFFSET = 631152000
};

} /* namespace ADARA */

#endif /* __ADARA_H */