gaps-online-software 0.10
online software for the TOF system for the GAPS experiment
Loading...
Searching...
No Matches
caraspace.hpp
1#ifndef CARASPACE_H_INCLUDED
2#define CARASPACE_H_INCLUDED
3#include <iostream>
4#include <fstream>
5#include <cmath>
6
7#include "tof_typedefs.h"
8#include "packets/tof_packet.h"
9#include "telemetry_dataclasses.hpp"
10#include "calibration.h"
11#include "errors.hpp"
12#include "result/result.h"
13#ifdef BUILD_CXXDB
14#include "database.h"
15#endif
16
17namespace r = result;
18
19namespace Gaps {
22 std::vector<std::string> list_path_contents_sorted(const std::string& input);
23
25 enum class CRFrameObjectType : u8 {
26 Unknown = 0,
27 TofPacket = 10,
28 TelemetryPacket = 20,
29 };
30
32 static constexpr u16 HEAD = 0xAAAA;
33 static constexpr u16 TAIL = 0x5555;
34
35 u8 version;
37 Vec<u8> payload;
38
40 static auto from_bytestream(Vec<u8> stream, usize &pos) -> CRFrameObject;
41
43 auto to_string() -> std::string;
44 };
45
46
47 struct CRFrame {
48 static constexpr u16 HEAD = 0xAAAA;
49 static constexpr u16 TAIL = 0x5555;
50
51 static auto from_bytestream(Vec<u8> stream, usize &pos) -> CRFrame;
52
53 std::map<std::string, std::tuple<u64, CRFrameObjectType>> index;
54 Vec<u8> bytestorage;
55 auto to_string() const -> std::string;
56
57 static auto parse_index(Vec<u8> stream, usize &pos) -> std::map<std::string, std::tuple<u64, CRFrameObjectType>>;
58
60 auto get_tofpacket(std::string name) -> r::Result<TofPacket,Gaps::IOError>;
61 auto get_telemetrypacket(std::string name) -> Gaps::Telemetry::Packet;
62 };
63
64 struct CRReader {
65 CRReader();
66 CRReader(std::string pathname);
67 CRReader(const CRReader&) = delete;
68
69 auto set_path(std:: string pathname) -> void;
78 auto get_filenames() const -> Vec<std::string>;
82 auto is_exhausted() const -> bool;
85 auto n_packets_read() const -> bool;
88 auto get_rbcalibrations(u8 n_rb) -> RBCalibrationMap;
89
90 private:
91 #ifdef BUILD_CXXDB
92 TofPaddleMap paddles_ ;
93 #endif
94 bool exhausted_ ;
95 usize n_packets_read_ ;
96 Vec<std::string> filenames_ ;
97 std::ifstream stream_file_ ;
98 usize fileindex_ ;
99 auto prime_next_file_() -> void;
100 };
101}
102#endif
Definition calibration.h:105
std::map< u8, TofPaddle > TofPaddleMap
A map of paddle id -> TofPaddle.
Definition database.h:62
CRFrameObjectType
These are objects which can be stored in a caraspace frame
Definition caraspace.hpp:25
std::vector< std::string > list_path_contents_sorted(const std::string &input)
Definition caraspace.hpp:31
auto to_string() -> std::string
string representation for printing
static auto from_bytestream(Vec< u8 > stream, usize &pos) -> CRFrameObject
Decode a serializable from a bytestream
Definition caraspace.hpp:47
auto get_tofpacket(std::string name) -> r::Result< TofPacket, Gaps::IOError >
extract a tofpacket if this frame object is of the correct type
Definition caraspace.hpp:64
auto is_exhausted() const -> bool
auto get_next_frame() -> CRFrame
auto get_rbcalibrations(u8 n_rb) -> RBCalibrationMap
auto n_packets_read() const -> bool
Definition telemetry_dataclasses.hpp:72
Definition tof_packet.h:83