gondola_core/
packets.rs

1// This file is part of gaps-online-software and published 
2// under the GPLv3 license
3
4pub mod tof_packet_type;
5pub mod tof_packet;
6pub mod telemetry_packet_type;
7pub mod telemetry_packet_header; 
8pub mod telemetry_packet;
9pub mod tracker_header;
10pub use tracker_header::TrackerHeader;
11pub mod bfsw_ack_packet;
12pub use bfsw_ack_packet::AckBfsw;
13pub mod gps_packet;
14pub use gps_packet::GPSPacket;
15pub mod tracker;
16pub use tracker::{
17  TrackerEventIDEchoPacket,
18  TrackerTempLeakPacket,
19  TrackerDAQTempPacket,
20  TrackerDAQHSKPacket
21};
22pub mod magnetometer;
23pub use magnetometer::MagnetoMeter;
24
25
26// public exports to reduce the Matroshka effect a little
27pub use telemetry_packet_type::TelemetryPacketType;
28pub use telemetry_packet::TelemetryPacket;
29pub use telemetry_packet_header::TelemetryPacketHeader;
30pub use tof_packet_type::TofPacketType;
31pub use tof_packet::TofPacket;
32
33use crate::io::serialization::Serialization;
34
35#[cfg(feature="pybindings")]
36use pyo3::prelude::*;
37
38/// Recreate 48bit timestamp from u32 and u16
39#[cfg_attr(feature="pybindings", pyfunction)]
40pub fn make_systime(lower : u32, upper : u16) -> u64 {
41  (upper as u64) << 32 | lower as u64
42}
43
44
45/// Can be wrapped within a TofPacket. To do, we just have
46/// to define a packet type
47pub trait TofPackable {
48  const TOF_PACKET_TYPE     : TofPacketType;
49  // provide an alternative TofPacketType to retrieve the 
50  // packet from without failing
51  const TOF_PACKET_TYPE_ALT : TofPacketType = TofPacketType::Unknown;
52
53  /// Wrap myself in a TofPacket
54  fn pack(&self) -> TofPacket 
55    where Self: Serialization {
56    let mut tp     = TofPacket::new();
57    tp.payload     = self.to_bytestream();
58    tp.packet_type = Self::TOF_PACKET_TYPE;
59    tp
60  }
61}
62
63/// Can be wrapped within a TofPacket. To do, we just have
64/// to define a packet type
65pub trait TelemetryPackable {
66  /// packet type for any kind of telemetry packet which is NOT an 
67  /// event
68  const TEL_PACKET_TYPE : TelemetryPacketType = TelemetryPacketType::Unknown;
69  /// TelemetryEvents can "occupy" several packet types, e.g. GapsTrigger, Boring, etc
70  const TEL_PACKET_TYPES_EVENT : [TelemetryPacketType;4] = [
71    TelemetryPacketType::NoGapsTriggerEvent,
72    TelemetryPacketType::BoringEvent,
73    TelemetryPacketType::InterestingEvent,
74    TelemetryPacketType::NoTofDataEvent];
75}
76