diff --git a/python/src/streaming_data_types/fbschemas/run_start_pl72/RunStart.py b/python/src/streaming_data_types/fbschemas/run_start_pl72/RunStart.py index d6e86fd..739f8e3 100644 --- a/python/src/streaming_data_types/fbschemas/run_start_pl72/RunStart.py +++ b/python/src/streaming_data_types/fbschemas/run_start_pl72/RunStart.py @@ -1,28 +1,28 @@ # automatically generated by the FlatBuffers compiler, do not modify -# namespace: +# namespace: import flatbuffers from flatbuffers.compat import import_numpy - np = import_numpy() - class RunStart(object): - __slots__ = ["_tab"] + __slots__ = ['_tab'] @classmethod - def GetRootAsRunStart(cls, buf, offset): + def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) x = RunStart() x.Init(buf, n + offset) return x @classmethod + def GetRootAsRunStart(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod def RunStartBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier( - buf, offset, b"\x70\x6C\x37\x32", size_prefixed=size_prefixed - ) + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x70\x6C\x37\x32", size_prefixed=size_prefixed) # RunStart def Init(self, buf, pos): @@ -32,18 +32,14 @@ def Init(self, buf, pos): def StartTime(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) if o != 0: - return self._tab.Get( - flatbuffers.number_types.Uint64Flags, o + self._tab.Pos - ) + return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) return 0 # RunStart def StopTime(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: - return self._tab.Get( - flatbuffers.number_types.Uint64Flags, o + self._tab.Pos - ) + return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) return 0 # RunStart @@ -99,9 +95,7 @@ def Filename(self): def NPeriods(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22)) if o != 0: - return self._tab.Get( - flatbuffers.number_types.Uint32Flags, o + self._tab.Pos - ) + return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) return 1 # RunStart @@ -110,7 +104,6 @@ def DetectorSpectrumMap(self): if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from .SpectraDetectorMapping import SpectraDetectorMapping - obj = SpectraDetectorMapping() obj.Init(self._tab.Bytes, x) return obj @@ -130,82 +123,118 @@ def ControlTopic(self): return self._tab.String(o + self._tab.Pos) return None + # RunStart + def GpsStartTime(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30)) + if o != 0: + return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) + return None + + # RunStart + def GpsStopTime(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32)) + if o != 0: + return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) + return None def RunStartStart(builder): - builder.StartObject(13) + builder.StartObject(15) +def Start(builder): + RunStartStart(builder) def RunStartAddStartTime(builder, startTime): builder.PrependUint64Slot(0, startTime, 0) +def AddStartTime(builder, startTime): + RunStartAddStartTime(builder, startTime) def RunStartAddStopTime(builder, stopTime): builder.PrependUint64Slot(1, stopTime, 0) +def AddStopTime(builder, stopTime): + RunStartAddStopTime(builder, stopTime) def RunStartAddRunName(builder, runName): - builder.PrependUOffsetTRelativeSlot( - 2, flatbuffers.number_types.UOffsetTFlags.py_type(runName), 0 - ) + builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(runName), 0) +def AddRunName(builder, runName): + RunStartAddRunName(builder, runName) def RunStartAddInstrumentName(builder, instrumentName): - builder.PrependUOffsetTRelativeSlot( - 3, flatbuffers.number_types.UOffsetTFlags.py_type(instrumentName), 0 - ) + builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(instrumentName), 0) +def AddInstrumentName(builder, instrumentName): + RunStartAddInstrumentName(builder, instrumentName) def RunStartAddNexusStructure(builder, nexusStructure): - builder.PrependUOffsetTRelativeSlot( - 4, flatbuffers.number_types.UOffsetTFlags.py_type(nexusStructure), 0 - ) + builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(nexusStructure), 0) +def AddNexusStructure(builder, nexusStructure): + RunStartAddNexusStructure(builder, nexusStructure) def RunStartAddJobId(builder, jobId): - builder.PrependUOffsetTRelativeSlot( - 5, flatbuffers.number_types.UOffsetTFlags.py_type(jobId), 0 - ) + builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(jobId), 0) +def AddJobId(builder, jobId): + RunStartAddJobId(builder, jobId) def RunStartAddBroker(builder, broker): - builder.PrependUOffsetTRelativeSlot( - 6, flatbuffers.number_types.UOffsetTFlags.py_type(broker), 0 - ) + builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(broker), 0) +def AddBroker(builder, broker): + RunStartAddBroker(builder, broker) def RunStartAddServiceId(builder, serviceId): - builder.PrependUOffsetTRelativeSlot( - 7, flatbuffers.number_types.UOffsetTFlags.py_type(serviceId), 0 - ) + builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(serviceId), 0) +def AddServiceId(builder, serviceId): + RunStartAddServiceId(builder, serviceId) def RunStartAddFilename(builder, filename): - builder.PrependUOffsetTRelativeSlot( - 8, flatbuffers.number_types.UOffsetTFlags.py_type(filename), 0 - ) + builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(filename), 0) +def AddFilename(builder, filename): + RunStartAddFilename(builder, filename) def RunStartAddNPeriods(builder, nPeriods): builder.PrependUint32Slot(9, nPeriods, 1) +def AddNPeriods(builder, nPeriods): + RunStartAddNPeriods(builder, nPeriods) def RunStartAddDetectorSpectrumMap(builder, detectorSpectrumMap): - builder.PrependUOffsetTRelativeSlot( - 10, flatbuffers.number_types.UOffsetTFlags.py_type(detectorSpectrumMap), 0 - ) + builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(detectorSpectrumMap), 0) +def AddDetectorSpectrumMap(builder, detectorSpectrumMap): + RunStartAddDetectorSpectrumMap(builder, detectorSpectrumMap) def RunStartAddMetadata(builder, metadata): - builder.PrependUOffsetTRelativeSlot( - 11, flatbuffers.number_types.UOffsetTFlags.py_type(metadata), 0 - ) + builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(metadata), 0) +def AddMetadata(builder, metadata): + RunStartAddMetadata(builder, metadata) def RunStartAddControlTopic(builder, controlTopic): - builder.PrependUOffsetTRelativeSlot( - 12, flatbuffers.number_types.UOffsetTFlags.py_type(controlTopic), 0 - ) + builder.PrependUOffsetTRelativeSlot(12, flatbuffers.number_types.UOffsetTFlags.py_type(controlTopic), 0) + +def AddControlTopic(builder, controlTopic): + RunStartAddControlTopic(builder, controlTopic) +def RunStartAddGpsStartTime(builder, gpsStartTime): + builder.PrependUint64Slot(13, gpsStartTime, None) + +def AddGpsStartTime(builder, gpsStartTime): + RunStartAddGpsStartTime(builder, gpsStartTime) + +def RunStartAddGpsStopTime(builder, gpsStopTime): + builder.PrependUint64Slot(14, gpsStopTime, None) + +def AddGpsStopTime(builder, gpsStopTime): + RunStartAddGpsStopTime(builder, gpsStopTime) def RunStartEnd(builder): return builder.EndObject() + +def End(builder): + return RunStartEnd(builder) diff --git a/python/src/streaming_data_types/fbschemas/run_stop_6s4t/RunStop.py b/python/src/streaming_data_types/fbschemas/run_stop_6s4t/RunStop.py index 183a6d6..4e29a30 100644 --- a/python/src/streaming_data_types/fbschemas/run_stop_6s4t/RunStop.py +++ b/python/src/streaming_data_types/fbschemas/run_stop_6s4t/RunStop.py @@ -70,8 +70,15 @@ def Abort(self): return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) return False + # RunStop + def GpsStopTime(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) + if o != 0: + return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos) + return None + def RunStopStart(builder): - builder.StartObject(6) + builder.StartObject(7) def Start(builder): RunStopStart(builder) @@ -112,6 +119,12 @@ def RunStopAddAbort(builder, abort): def AddAbort(builder, abort): RunStopAddAbort(builder, abort) +def RunStopAddGpsStopTime(builder, gpsStopTime): + builder.PrependUint64Slot(6, gpsStopTime, None) + +def AddGpsStopTime(builder, gpsStopTime): + RunStopAddGpsStopTime(builder, gpsStopTime) + def RunStopEnd(builder): return builder.EndObject() diff --git a/python/src/streaming_data_types/run_start_pl72.py b/python/src/streaming_data_types/run_start_pl72.py index ac01024..6400e5a 100644 --- a/python/src/streaming_data_types/run_start_pl72.py +++ b/python/src/streaming_data_types/run_start_pl72.py @@ -39,6 +39,8 @@ def serialise_pl72( detector_spectrum_map: Optional[DetectorSpectrumMap] = None, control_topic: str = "", n_periods: int = 1, + gps_start_time: Union[int, datetime, None] = None, + gps_stop_time: Union[int, datetime, None] = None, ) -> bytes: builder = flatbuffers.Builder(512) builder.ForceDefaults(True) @@ -103,6 +105,16 @@ def serialise_pl72( RunStart.RunStartAddDetectorSpectrumMap(builder, detector_spectrum_map_offset) RunStart.RunStartAddControlTopic(builder, control_topic_offset) + if gps_start_time is not None: + if type(gps_start_time) is datetime: + gps_start_time = int(gps_start_time.timestamp() * 1_000_000_000) + RunStart.RunStartAddGpsStartTime(builder, gps_start_time) + + if gps_stop_time is not None: + if type(gps_stop_time) is datetime: + gps_stop_time = int(gps_stop_time.timestamp() * 1_000_000_000) + RunStart.RunStartAddGpsStopTime(builder, gps_stop_time) + run_start_message = RunStart.RunStartEnd(builder) builder.Finish(run_start_message, file_identifier=FILE_IDENTIFIER) @@ -123,6 +135,8 @@ class RunStartInfo(NamedTuple): metadata: str = "" detector_spectrum_map: Optional[DetectorSpectrumMap] = None control_topic: str = "" + gps_start_time: Union[int, None] = None + gps_stop_time: Union[int, None] = None def deserialise_pl72(buffer: Union[bytearray, bytes]) -> RunStartInfo: @@ -138,6 +152,8 @@ def deserialise_pl72(buffer: Union[bytearray, bytes]) -> RunStartInfo: run_name = run_start.RunName() if run_start.RunName() else b"" metadata = run_start.Metadata() if run_start.Metadata() else b"" control_topic = run_start.ControlTopic() if run_start.ControlTopic() else b"" + gps_start_time = run_start.GpsStartTime() + gps_stop_time = run_start.GpsStopTime() detector_spectrum_map = None det_spec_map_buf = run_start.DetectorSpectrumMap() @@ -162,4 +178,6 @@ def deserialise_pl72(buffer: Union[bytearray, bytes]) -> RunStartInfo: detector_spectrum_map=detector_spectrum_map, control_topic=control_topic.decode(), n_periods=run_start.NPeriods(), + gps_start_time=gps_start_time, + gps_stop_time=gps_stop_time, ) diff --git a/python/src/streaming_data_types/run_stop_6s4t.py b/python/src/streaming_data_types/run_stop_6s4t.py index ba6cfc1..9dddd12 100644 --- a/python/src/streaming_data_types/run_stop_6s4t.py +++ b/python/src/streaming_data_types/run_stop_6s4t.py @@ -16,6 +16,7 @@ def serialise_6s4t( command_id: str = "", stop_time: Union[int, datetime, None] = None, abort: bool = False, + gps_stop_time: Union[int, datetime, None] = None, ) -> bytes: builder = flatbuffers.Builder(500) builder.ForceDefaults(True) @@ -41,23 +42,25 @@ def serialise_6s4t( RunStop.RunStopAddCommandId(builder, command_id_offset) RunStop.RunStopAddAbort(builder, abort) + if gps_stop_time is not None: + if type(gps_stop_time) is datetime: + gps_stop_time = int(gps_stop_time.timestamp() * 1_000_000_000) + RunStop.RunStopAddGpsStopTime(builder, gps_stop_time) + run_stop_message = RunStop.RunStopEnd(builder) builder.Finish(run_stop_message, file_identifier=FILE_IDENTIFIER) return bytes(builder.Output()) -RunStopInfo = NamedTuple( - "RunStopInfo", - ( - ("stop_time", int), - ("run_name", str), - ("job_id", str), - ("service_id", str), - ("command_id", str), - ("abort", bool), - ), -) +class RunStopInfo(NamedTuple): + stop_time: int + run_name: str + job_id: str + service_id: str + command_id: str + abort: bool + gps_stop_time: int | None def deserialise_6s4t(buffer: Union[bytearray, bytes]) -> RunStopInfo: @@ -70,6 +73,7 @@ def deserialise_6s4t(buffer: Union[bytearray, bytes]) -> RunStopInfo: stop_time = run_stop.StopTime() command_id = run_stop.CommandId() abort = run_stop.Abort() + gps_stop_time = run_stop.GpsStopTime() return RunStopInfo( stop_time=stop_time, @@ -78,4 +82,5 @@ def deserialise_6s4t(buffer: Union[bytearray, bytes]) -> RunStopInfo: service_id=service_id.decode(), command_id=command_id.decode(), abort=abort, + gps_stop_time=gps_stop_time, ) diff --git a/python/tests/test_6s4t.py b/python/tests/test_6s4t.py index ff055b0..3093443 100644 --- a/python/tests/test_6s4t.py +++ b/python/tests/test_6s4t.py @@ -13,6 +13,7 @@ class TestSerialisation6s4t: "service_id": "filewriter1", "command_id": "some command id", "abort": True, + "gps_stop_time": 123456789, } def test_serialises_and_deserialises_6s4t_message_correctly(self): @@ -25,6 +26,7 @@ def test_serialises_and_deserialises_6s4t_message_correctly(self): assert deserialised_tuple.service_id == self.original_entry["service_id"] assert deserialised_tuple.command_id == self.original_entry["command_id"] assert deserialised_tuple.abort == self.original_entry["abort"] + assert deserialised_tuple.gps_stop_time == self.original_entry["gps_stop_time"] def test_if_buffer_has_wrong_id_then_throws(self): buf = serialise_6s4t(**self.original_entry) diff --git a/python/tests/test_pl72.py b/python/tests/test_pl72.py index 65517ac..3771b7d 100644 --- a/python/tests/test_pl72.py +++ b/python/tests/test_pl72.py @@ -27,6 +27,8 @@ class TestSerialisationPl72: ), "control_topic": "some_topic_name", "n_periods": 69420, + "gps_start_time": 123456789, + "gps_stop_time": 9876543210, } def test_serialises_and_deserialises_pl72_message_correctly(self): @@ -62,6 +64,8 @@ def test_serialises_and_deserialises_pl72_message_correctly(self): ) assert deserialised_tuple.control_topic == self.original_entry["control_topic"] assert deserialised_tuple.n_periods == self.original_entry["n_periods"] + assert deserialised_tuple.gps_start_time == self.original_entry["gps_start_time"] + assert deserialised_tuple.gps_stop_time == self.original_entry["gps_stop_time"] def test_if_buffer_has_wrong_id_then_throws(self): buf = serialise_pl72(**self.original_entry) diff --git a/rust/src/flatbuffers_generated/6s4t_run_stop.rs b/rust/src/flatbuffers_generated/6s4t_run_stop.rs index 44c58e0..b18755e 100644 --- a/rust/src/flatbuffers_generated/6s4t_run_stop.rs +++ b/rust/src/flatbuffers_generated/6s4t_run_stop.rs @@ -25,6 +25,7 @@ impl<'a> RunStop<'a> { pub const VT_SERVICE_ID: ::flatbuffers::VOffsetT = 10; pub const VT_COMMAND_ID: ::flatbuffers::VOffsetT = 12; pub const VT_ABORT: ::flatbuffers::VOffsetT = 14; + pub const VT_GPS_STOP_TIME: ::flatbuffers::VOffsetT = 16; #[inline] pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { @@ -36,6 +37,7 @@ impl<'a> RunStop<'a> { args: &'args RunStopArgs<'args> ) -> ::flatbuffers::WIPOffset> { let mut builder = RunStopBuilder::new(_fbb); + if let Some(x) = args.gps_stop_time { builder.add_gps_stop_time(x); } builder.add_stop_time(args.stop_time); if let Some(x) = args.command_id { builder.add_command_id(x); } if let Some(x) = args.service_id { builder.add_service_id(x); } @@ -88,6 +90,13 @@ impl<'a> RunStop<'a> { // which contains a valid value in this slot unsafe { self._tab.get::(RunStop::VT_ABORT, Some(false)).unwrap()} } + #[inline] + pub fn gps_stop_time(&self) -> Option { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RunStop::VT_GPS_STOP_TIME, None)} + } } impl ::flatbuffers::Verifiable for RunStop<'_> { @@ -102,6 +111,7 @@ impl ::flatbuffers::Verifiable for RunStop<'_> { .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("service_id", Self::VT_SERVICE_ID, false)? .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("command_id", Self::VT_COMMAND_ID, false)? .visit_field::("abort", Self::VT_ABORT, false)? + .visit_field::("gps_stop_time", Self::VT_GPS_STOP_TIME, false)? .finish(); Ok(()) } @@ -113,6 +123,7 @@ pub struct RunStopArgs<'a> { pub service_id: Option<::flatbuffers::WIPOffset<&'a str>>, pub command_id: Option<::flatbuffers::WIPOffset<&'a str>>, pub abort: bool, + pub gps_stop_time: Option, } impl<'a> Default for RunStopArgs<'a> { #[inline] @@ -124,6 +135,7 @@ impl<'a> Default for RunStopArgs<'a> { service_id: None, command_id: None, abort: false, + gps_stop_time: None, } } } @@ -158,6 +170,10 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RunStopBuilder<'a, 'b, A> { self.fbb_.push_slot::(RunStop::VT_ABORT, abort, false); } #[inline] + pub fn add_gps_stop_time(&mut self, gps_stop_time: u64) { + self.fbb_.push_slot_always::(RunStop::VT_GPS_STOP_TIME, gps_stop_time); + } + #[inline] pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> RunStopBuilder<'a, 'b, A> { let start = _fbb.start_table(); RunStopBuilder { @@ -181,6 +197,7 @@ impl ::core::fmt::Debug for RunStop<'_> { ds.field("service_id", &self.service_id()); ds.field("command_id", &self.command_id()); ds.field("abort", &self.abort()); + ds.field("gps_stop_time", &self.gps_stop_time()); ds.finish() } } diff --git a/rust/src/flatbuffers_generated/mod.rs b/rust/src/flatbuffers_generated/mod.rs index 9614fc8..cd2f0f6 100644 --- a/rust/src/flatbuffers_generated/mod.rs +++ b/rust/src/flatbuffers_generated/mod.rs @@ -1,38 +1,38 @@ -#[path = "fc00_forwarder_config.rs"] -pub mod forwarder_config_fc00; -#[path = "vc00_veto_configuration.rs"] -pub mod veto_configuration_vc00; -#[path = "al00_alarm.rs"] -pub mod alarm_al00; #[path = "6s4t_run_stop.rs"] pub mod run_stop_6s4t; -#[path = "hs01_event_histogram.rs"] -pub mod event_histogram_hs01; -#[path = "ep01_epics_connection.rs"] -pub mod epics_connection_ep01; -#[path = "wrdn_finished_writing.rs"] -pub mod finished_writing_wrdn; -#[path = "pl72_run_start.rs"] -pub mod run_start_pl72; -#[path = "f144_logdata.rs"] -pub mod logdata_f144; -#[path = "da00_dataarray.rs"] -pub mod dataarray_da00; -#[path = "un00_units.rs"] -pub mod units_un00; #[path = "ad00_area_detector_array.rs"] pub mod area_detector_array_ad00; -#[path = "se00_data.rs"] -pub mod data_se00; -#[path = "ev44_events.rs"] -pub mod events_ev44; +#[path = "al00_alarm.rs"] +pub mod alarm_al00; #[path = "answ_action_response.rs"] pub mod action_response_answ; -#[path = "pu00_pulse_metadata.rs"] -pub mod pulse_metadata_pu00; -#[path = "x5f2_status.rs"] -pub mod status_x5f2; +#[path = "da00_dataarray.rs"] +pub mod dataarray_da00; #[path = "df12_det_spec_map.rs"] pub mod det_spec_map_df12; +#[path = "ep01_epics_connection.rs"] +pub mod epics_connection_ep01; +#[path = "ev44_events.rs"] +pub mod events_ev44; +#[path = "f144_logdata.rs"] +pub mod logdata_f144; +#[path = "fc00_forwarder_config.rs"] +pub mod forwarder_config_fc00; +#[path = "hs01_event_histogram.rs"] +pub mod event_histogram_hs01; #[path = "json_json.rs"] pub mod json_json; +#[path = "pl72_run_start.rs"] +pub mod run_start_pl72; +#[path = "pu00_pulse_metadata.rs"] +pub mod pulse_metadata_pu00; +#[path = "se00_data.rs"] +pub mod data_se00; +#[path = "un00_units.rs"] +pub mod units_un00; +#[path = "vc00_veto_configuration.rs"] +pub mod veto_configuration_vc00; +#[path = "wrdn_finished_writing.rs"] +pub mod finished_writing_wrdn; +#[path = "x5f2_status.rs"] +pub mod status_x5f2; diff --git a/rust/src/flatbuffers_generated/pl72_run_start.rs b/rust/src/flatbuffers_generated/pl72_run_start.rs index 412df29..be4f82d 100644 --- a/rust/src/flatbuffers_generated/pl72_run_start.rs +++ b/rust/src/flatbuffers_generated/pl72_run_start.rs @@ -162,6 +162,8 @@ impl<'a> RunStart<'a> { pub const VT_DETECTOR_SPECTRUM_MAP: ::flatbuffers::VOffsetT = 24; pub const VT_METADATA: ::flatbuffers::VOffsetT = 26; pub const VT_CONTROL_TOPIC: ::flatbuffers::VOffsetT = 28; + pub const VT_GPS_START_TIME: ::flatbuffers::VOffsetT = 30; + pub const VT_GPS_STOP_TIME: ::flatbuffers::VOffsetT = 32; #[inline] pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { @@ -173,6 +175,8 @@ impl<'a> RunStart<'a> { args: &'args RunStartArgs<'args> ) -> ::flatbuffers::WIPOffset> { let mut builder = RunStartBuilder::new(_fbb); + if let Some(x) = args.gps_stop_time { builder.add_gps_stop_time(x); } + if let Some(x) = args.gps_start_time { builder.add_gps_start_time(x); } builder.add_stop_time(args.stop_time); builder.add_start_time(args.start_time); if let Some(x) = args.control_topic { builder.add_control_topic(x); } @@ -281,6 +285,20 @@ impl<'a> RunStart<'a> { // which contains a valid value in this slot unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(RunStart::VT_CONTROL_TOPIC, None)} } + #[inline] + pub fn gps_start_time(&self) -> Option { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RunStart::VT_GPS_START_TIME, None)} + } + #[inline] + pub fn gps_stop_time(&self) -> Option { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RunStart::VT_GPS_STOP_TIME, None)} + } } impl ::flatbuffers::Verifiable for RunStart<'_> { @@ -302,6 +320,8 @@ impl ::flatbuffers::Verifiable for RunStart<'_> { .visit_field::<::flatbuffers::ForwardsUOffset>("detector_spectrum_map", Self::VT_DETECTOR_SPECTRUM_MAP, false)? .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("metadata", Self::VT_METADATA, false)? .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("control_topic", Self::VT_CONTROL_TOPIC, false)? + .visit_field::("gps_start_time", Self::VT_GPS_START_TIME, false)? + .visit_field::("gps_stop_time", Self::VT_GPS_STOP_TIME, false)? .finish(); Ok(()) } @@ -320,6 +340,8 @@ pub struct RunStartArgs<'a> { pub detector_spectrum_map: Option<::flatbuffers::WIPOffset>>, pub metadata: Option<::flatbuffers::WIPOffset<&'a str>>, pub control_topic: Option<::flatbuffers::WIPOffset<&'a str>>, + pub gps_start_time: Option, + pub gps_stop_time: Option, } impl<'a> Default for RunStartArgs<'a> { #[inline] @@ -338,6 +360,8 @@ impl<'a> Default for RunStartArgs<'a> { detector_spectrum_map: None, metadata: None, control_topic: None, + gps_start_time: None, + gps_stop_time: None, } } } @@ -400,6 +424,14 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RunStartBuilder<'a, 'b, A> { self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(RunStart::VT_CONTROL_TOPIC, control_topic); } #[inline] + pub fn add_gps_start_time(&mut self, gps_start_time: u64) { + self.fbb_.push_slot_always::(RunStart::VT_GPS_START_TIME, gps_start_time); + } + #[inline] + pub fn add_gps_stop_time(&mut self, gps_stop_time: u64) { + self.fbb_.push_slot_always::(RunStart::VT_GPS_STOP_TIME, gps_stop_time); + } + #[inline] pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> RunStartBuilder<'a, 'b, A> { let start = _fbb.start_table(); RunStartBuilder { @@ -430,6 +462,8 @@ impl ::core::fmt::Debug for RunStart<'_> { ds.field("detector_spectrum_map", &self.detector_spectrum_map()); ds.field("metadata", &self.metadata()); ds.field("control_topic", &self.control_topic()); + ds.field("gps_start_time", &self.gps_start_time()); + ds.field("gps_stop_time", &self.gps_stop_time()); ds.finish() } } diff --git a/schemas/6s4t_run_stop.fbs b/schemas/6s4t_run_stop.fbs index 133f10f..3ad761f 100644 --- a/schemas/6s4t_run_stop.fbs +++ b/schemas/6s4t_run_stop.fbs @@ -10,12 +10,13 @@ file_identifier "6s4t"; table RunStop { // *Mantid* // *File Writer* // *Description* - stop_time : uint64; // Required // Required // milliseconds since Unix epoch (1 Jan 1970). When set to 0, will trigger a "stop NOW" code path in the file writer. + stop_time : uint64; // Required // Required // milliseconds since Unix epoch (1 Jan 1970), according to an NTP-synchronised computer clock. When set to 0, will trigger a "stop NOW" code path in the file writer. run_name : string; // Required // Unused // Name for the run, must match corresponding field in RunStart job_id : string; // Unused // Required // Uuid of the job that is to get a new stop time. service_id : string; // Unused // Optional // The identifier for the instance of the file-writer that should handle this command command_id : string; // Unused // Required // Command uuid for uniquely identifying the stop command. abort : bool = false; // Required // Required // Whether to abort this run and stop writing files. + gps_stop_time : uint64 = null; // Unused // Required // nanoseconds since Unix epoch (1 Jan 1970), according to the GPS clock used to timestamp events. } root_type RunStop; diff --git a/schemas/pl72_run_start.fbs b/schemas/pl72_run_start.fbs index 42e22b9..c8f6e20 100644 --- a/schemas/pl72_run_start.fbs +++ b/schemas/pl72_run_start.fbs @@ -12,8 +12,8 @@ include "df12_det_spec_map.fbs"; file_identifier "pl72"; table RunStart { // *Mantid* // *File Writer* // *Description* - start_time : uint64; // Required // Required // milliseconds since Unix epoch (1 Jan 1970) - stop_time : uint64; // Unused // Optional // milliseconds since Unix epoch (1 Jan 1970), optional, can send a RunStop instead + start_time : uint64; // Required // Required // milliseconds since Unix epoch (1 Jan 1970), according to an NTP-synchronised computer clock + stop_time : uint64; // Unused // Optional // milliseconds since Unix epoch (1 Jan 1970), according to an NTP-synchronised computer clock. Optional, can send a RunStop instead run_name : string; // Required // Unused // Name for the run, used as workspace name by Mantid instrument_name : string; // Required // Unused // Name of the instrument, only required by Mantid nexus_structure : string; // Optional // Required // JSON description of NeXus file (See https://github.com/ess-dmsc/kafka-to-nexus/ for detail) @@ -28,6 +28,8 @@ table RunStart { // *Mantid* // *File Wr detector_spectrum_map: SpectraDetectorMapping; // Optional // Unused // Map spectrum numbers in the event messages to detector IDs in the instrument definition (optional, for ISIS only) metadata : string; // Unused // Optional // Holds a JSON string with (static) metadata about the measurement. E.g. proposal id. control_topic : string; // Unused // Optional // Topic on which the File Writer will listen for further commands and publish status messages when started from a pool + gps_start_time : uint64 = null; // Unused // Required // nanoseconds since Unix epoch (1 Jan 1970), according to the GPS clock used to timestamp events. + gps_stop_time : uint64 = null; // Unused // Required // nanoseconds since Unix epoch (1 Jan 1970), according to the GPS clock used to timestamp events. } root_type RunStart;