Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions python/src/streaming_data_types/fbschemas/run_stop_6s4t/RunStop.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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)
5 changes: 5 additions & 0 deletions python/src/streaming_data_types/run_stop_6s4t.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -53,6 +55,7 @@ def serialise_6s4t(
("job_id", str),
("service_id", str),
("command_id", str),
("abort", bool),
),
)

Expand All @@ -66,11 +69,13 @@ 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,
run_name=run_name.decode(),
job_id=job_id.decode(),
service_id=service_id.decode(),
command_id=command_id.decode(),
abort=abort,
)
2 changes: 2 additions & 0 deletions python/tests/test_6s4t.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions rust/src/flatbuffers_generated/6s4t_run_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}

Expand Down Expand Up @@ -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::<bool>(RunStop::VT_ABORT, Some(false)).unwrap()}
}
}

impl ::flatbuffers::Verifiable for RunStop<'_> {
Expand All @@ -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::<bool>("abort", Self::VT_ABORT, false)?
.finish();
Ok(())
}
Expand All @@ -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]
Expand All @@ -112,6 +123,7 @@ impl<'a> Default for RunStopArgs<'a> {
job_id: None,
service_id: None,
command_id: None,
abort: false,
}
}
}
Expand Down Expand Up @@ -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::<bool>(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 {
Expand All @@ -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()
}
}
Expand Down
56 changes: 28 additions & 28 deletions rust/src/flatbuffers_generated/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions schemas/6s4t_run_stop.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading