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 55faf97..183a6d6 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 @@ -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 RunStop(object): - __slots__ = ["_tab"] + __slots__ = ['_tab'] @classmethod - def GetRootAsRunStop(cls, buf, offset): + def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) x = RunStop() x.Init(buf, n + offset) return x @classmethod + def GetRootAsRunStop(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod def RunStopBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier( - buf, offset, b"\x36\x73\x34\x74", size_prefixed=size_prefixed - ) + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x36\x73\x34\x74", size_prefixed=size_prefixed) # RunStop def Init(self, buf, pos): @@ -32,9 +32,7 @@ def Init(self, buf, pos): def StopTime(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 # RunStop @@ -65,38 +63,57 @@ def CommandId(self): return self._tab.String(o + self._tab.Pos) return None + # RunStop + def Abort(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) + if o != 0: + return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) + return False def RunStopStart(builder): - builder.StartObject(5) + builder.StartObject(6) +def Start(builder): + RunStopStart(builder) def RunStopAddStopTime(builder, stopTime): builder.PrependUint64Slot(0, stopTime, 0) +def AddStopTime(builder, stopTime): + RunStopAddStopTime(builder, stopTime) def RunStopAddRunName(builder, runName): - builder.PrependUOffsetTRelativeSlot( - 1, flatbuffers.number_types.UOffsetTFlags.py_type(runName), 0 - ) + builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(runName), 0) +def AddRunName(builder, runName): + RunStopAddRunName(builder, runName) def RunStopAddJobId(builder, jobId): - builder.PrependUOffsetTRelativeSlot( - 2, flatbuffers.number_types.UOffsetTFlags.py_type(jobId), 0 - ) + builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(jobId), 0) +def AddJobId(builder, jobId): + RunStopAddJobId(builder, jobId) def RunStopAddServiceId(builder, serviceId): - builder.PrependUOffsetTRelativeSlot( - 3, flatbuffers.number_types.UOffsetTFlags.py_type(serviceId), 0 - ) + builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(serviceId), 0) +def AddServiceId(builder, serviceId): + RunStopAddServiceId(builder, serviceId) def RunStopAddCommandId(builder, commandId): - builder.PrependUOffsetTRelativeSlot( - 4, flatbuffers.number_types.UOffsetTFlags.py_type(commandId), 0 - ) + builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(commandId), 0) + +def AddCommandId(builder, commandId): + RunStopAddCommandId(builder, commandId) +def RunStopAddAbort(builder, abort): + builder.PrependBoolSlot(5, abort, 0) + +def AddAbort(builder, abort): + RunStopAddAbort(builder, abort) def RunStopEnd(builder): return builder.EndObject() + +def End(builder): + return RunStopEnd(builder) diff --git a/python/src/streaming_data_types/run_stop_6s4t.py b/python/src/streaming_data_types/run_stop_6s4t.py index fadf4ef..ba6cfc1 100644 --- a/python/src/streaming_data_types/run_stop_6s4t.py +++ b/python/src/streaming_data_types/run_stop_6s4t.py @@ -15,6 +15,7 @@ def serialise_6s4t( service_id: str = "", command_id: str = "", stop_time: Union[int, datetime, None] = None, + abort: bool = False, ) -> bytes: builder = flatbuffers.Builder(500) builder.ForceDefaults(True) @@ -38,6 +39,7 @@ def serialise_6s4t( RunStop.RunStopAddRunName(builder, run_name_offset) RunStop.RunStopAddStopTime(builder, stop_time) RunStop.RunStopAddCommandId(builder, command_id_offset) + RunStop.RunStopAddAbort(builder, abort) run_stop_message = RunStop.RunStopEnd(builder) builder.Finish(run_stop_message, file_identifier=FILE_IDENTIFIER) @@ -53,6 +55,7 @@ def serialise_6s4t( ("job_id", str), ("service_id", str), ("command_id", str), + ("abort", bool), ), ) @@ -66,6 +69,7 @@ def deserialise_6s4t(buffer: Union[bytearray, bytes]) -> RunStopInfo: run_name = run_stop.RunName() if run_stop.RunName() else b"" stop_time = run_stop.StopTime() command_id = run_stop.CommandId() + abort = run_stop.Abort() return RunStopInfo( stop_time=stop_time, @@ -73,4 +77,5 @@ def deserialise_6s4t(buffer: Union[bytearray, bytes]) -> RunStopInfo: job_id=job_id.decode(), service_id=service_id.decode(), command_id=command_id.decode(), + abort=abort, ) diff --git a/python/tests/test_6s4t.py b/python/tests/test_6s4t.py index 772bb61..ff055b0 100644 --- a/python/tests/test_6s4t.py +++ b/python/tests/test_6s4t.py @@ -12,6 +12,7 @@ class TestSerialisation6s4t: "run_name": "test_run", "service_id": "filewriter1", "command_id": "some command id", + "abort": True, } def test_serialises_and_deserialises_6s4t_message_correctly(self): @@ -23,6 +24,7 @@ def test_serialises_and_deserialises_6s4t_message_correctly(self): assert deserialised_tuple.run_name == self.original_entry["run_name"] 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"] def test_if_buffer_has_wrong_id_then_throws(self): buf = serialise_6s4t(**self.original_entry) diff --git a/rust/src/flatbuffers_generated/6s4t_run_stop.rs b/rust/src/flatbuffers_generated/6s4t_run_stop.rs index 506c531..44c58e0 100644 --- a/rust/src/flatbuffers_generated/6s4t_run_stop.rs +++ b/rust/src/flatbuffers_generated/6s4t_run_stop.rs @@ -24,6 +24,7 @@ impl<'a> RunStop<'a> { pub const VT_JOB_ID: ::flatbuffers::VOffsetT = 8; pub const VT_SERVICE_ID: ::flatbuffers::VOffsetT = 10; pub const VT_COMMAND_ID: ::flatbuffers::VOffsetT = 12; + pub const VT_ABORT: ::flatbuffers::VOffsetT = 14; #[inline] pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { @@ -40,6 +41,7 @@ impl<'a> RunStop<'a> { if let Some(x) = args.service_id { builder.add_service_id(x); } if let Some(x) = args.job_id { builder.add_job_id(x); } if let Some(x) = args.run_name { builder.add_run_name(x); } + builder.add_abort(args.abort); builder.finish() } @@ -79,6 +81,13 @@ impl<'a> RunStop<'a> { // which contains a valid value in this slot unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(RunStop::VT_COMMAND_ID, None)} } + #[inline] + pub fn abort(&self) -> bool { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(RunStop::VT_ABORT, Some(false)).unwrap()} + } } impl ::flatbuffers::Verifiable for RunStop<'_> { @@ -92,6 +101,7 @@ impl ::flatbuffers::Verifiable for RunStop<'_> { .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("job_id", Self::VT_JOB_ID, false)? .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)? .finish(); Ok(()) } @@ -102,6 +112,7 @@ pub struct RunStopArgs<'a> { pub job_id: Option<::flatbuffers::WIPOffset<&'a str>>, pub service_id: Option<::flatbuffers::WIPOffset<&'a str>>, pub command_id: Option<::flatbuffers::WIPOffset<&'a str>>, + pub abort: bool, } impl<'a> Default for RunStopArgs<'a> { #[inline] @@ -112,6 +123,7 @@ impl<'a> Default for RunStopArgs<'a> { job_id: None, service_id: None, command_id: None, + abort: false, } } } @@ -142,6 +154,10 @@ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RunStopBuilder<'a, 'b, A> { self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(RunStop::VT_COMMAND_ID, command_id); } #[inline] + pub fn add_abort(&mut self, abort: bool) { + self.fbb_.push_slot::(RunStop::VT_ABORT, abort, false); + } + #[inline] pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> RunStopBuilder<'a, 'b, A> { let start = _fbb.start_table(); RunStopBuilder { @@ -164,6 +180,7 @@ impl ::core::fmt::Debug for RunStop<'_> { ds.field("job_id", &self.job_id()); ds.field("service_id", &self.service_id()); ds.field("command_id", &self.command_id()); + ds.field("abort", &self.abort()); ds.finish() } } diff --git a/rust/src/flatbuffers_generated/mod.rs b/rust/src/flatbuffers_generated/mod.rs index cd2f0f6..9614fc8 100644 --- a/rust/src/flatbuffers_generated/mod.rs +++ b/rust/src/flatbuffers_generated/mod.rs @@ -1,38 +1,38 @@ -#[path = "6s4t_run_stop.rs"] -pub mod run_stop_6s4t; -#[path = "ad00_area_detector_array.rs"] -pub mod area_detector_array_ad00; -#[path = "al00_alarm.rs"] -pub mod alarm_al00; -#[path = "answ_action_response.rs"] -pub mod action_response_answ; -#[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 = "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 = "json_json.rs"] -pub mod json_json; +#[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 = "pu00_pulse_metadata.rs"] -pub mod pulse_metadata_pu00; -#[path = "se00_data.rs"] -pub mod data_se00; +#[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 = "vc00_veto_configuration.rs"] -pub mod veto_configuration_vc00; -#[path = "wrdn_finished_writing.rs"] -pub mod finished_writing_wrdn; +#[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 = "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 = "df12_det_spec_map.rs"] +pub mod det_spec_map_df12; +#[path = "json_json.rs"] +pub mod json_json; diff --git a/schemas/6s4t_run_stop.fbs b/schemas/6s4t_run_stop.fbs index a87012d..133f10f 100644 --- a/schemas/6s4t_run_stop.fbs +++ b/schemas/6s4t_run_stop.fbs @@ -15,6 +15,7 @@ table RunStop { // *Mantid* // *File Writer* // *Description* 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. } root_type RunStop;