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