gaps-online-software 0.10
online software for the TOF system for the GAPS experiment
Loading...
Searching...
No Matches
CommandPacket.h
1#ifndef COMMANDPACKET_H_INCLUDED
2#define COMMANDPACKET_H_INCLUDED
3
4#include "tof_typedefs.h"
5
6
7/*******************************************
8 * These are the commands which can be send
9 * to the Tof in general and/or the
10 * individual RB.
11 *
12 * We set individual command codes
13 *
14 * THE COMMAND CODES MUST BE THE
15 * "OFFICAL" COMMAND CODES!
16 * Please see the documentation!
17 *
18 */
19enum class TofCommand {
20 // power class - 1
21 PowerOn = 11,
22 PowerOff = 10,
23 PowerCycle = 12,
24 // setup class - 2
25 RBSetup = 20,
26 SetThresholds = 21,
27 SetMtConfig = 22,
28 // run class - 3
29 StartValidationRun = 32,
30 DataRunStart = 31,
31 DataRunEnd = 30,
32 // request class -4
33 RequestWaveforms = 41,
34 RequestEvent = 42,
35 RequestMoni = 43,
36 UnspoolEventCache = 44,
37 StreamAnyEvent = 45,
38 // calibration class 5
39 VoltageCalibration = 51,
40 TimingCalibration = 52,
41 CreateCalibrationFile = 53,
42 Unknown
43};
44
45enum class TofResponse {
46 Success = 1,
47 GeneralFailure = 2,
48 EventNotReady = 3,
49 SerializationIssue = 4,
50 Unknown
51};
52
53
54/*********************************************
55 * This packet holds all kinds of commands
56 * which can be sent to the tof computer/RB
57 *
58 * The CommandPacket has the following structur
59 *
60 * The package layout in binary is like this
61 * HEAD : u16 = 0xAAAA
62 * CommnadClas : u8
63 * DATA : u32
64 * TAIL : u16 = 0x5555
65 *
66 *
67 */
68//struct CommandPacket {
69// const u16 head = 0xAAAA;
70// const u16 tail = 0x5555;
71// // every command packet is 9 bytes
72// u16 p_length_fixed = 9;
73// TofCommand command;
74// u32 value;
75//
76// CommandPacket(const TofCommand &cmd, const u32 value);
77// Vec<u8> to_bytestream();
78//
79// usize from_bytestream(Vec<u8>& payload,
80// usize start_pos=0);
81//
82//};
83
84
85/**************************************
86 * Each Command will trigger the system
87 * to send a response
88 *
89 * The response consists of a class
90 * (see the above enum) + a specific,
91 * 32bit response code.
92 *
93 *************************/
94
95//struct ResponsePacket {
96// // these are the specific response code
97// static const u32 RESP_ERR_LEVEL_NOPROBLEM = 4000;
98// static const u32 RESP_ERR_LEVEL_MEDIUM = 4010;
99// static const u32 RESP_ERR_LEVEL_CRITICAL = 4030;
100// static const u32 RESP_ERR_LEVEL_MISSION_CRITICAL = 4040;
101// static const u32 RESP_ERR_LEVEL_RUN_FOOL_RUN = 99999;
102// static const u32 RESP_ERR_LEVEL_SEVERE = 4020;
103// static const u32 RESP_ERR_NORUNACTIVE = 501;
104// static const u32 RESP_ERR_NOTIMPLEMENTED = 404;
105// static const u32 RESP_ERR_RUNACTIVE = 502;
106// static const u32 RESP_ERR_UNEXECUTABLE = 500;
107// static const u32 RESP_SUCC_FINGERS_CROSSED = 200;
108//
109// u16 head = 0xAAAA;
110// u16 tail = 0x5555;
111// // every command packet is 9 bytes
112// u16 p_length_fixed = 9;
113// TofResponse response;
114// u32 value;
115//
116// ResponsePacket(const TofResponse &resp, const u32 value);
117// Vec<u8> to_bytestream() const;
118//
119// usize from_bytestream(Vec<u8>& payload,
120// usize start_pos=0);
121//
122// //! Get a string represntation of the response codes
123// std::string translate_response_code(u32 code) const;
124//};
125
126#endif