diff --git a/src/labone/core/shf_vector_data.py b/src/labone/core/shf_vector_data.py index d8f763f..d49316c 100644 --- a/src/labone/core/shf_vector_data.py +++ b/src/labone/core/shf_vector_data.py @@ -75,6 +75,7 @@ class ShfResultLoggerVectorExtraHeader: holdoff_errors_reslog: Number of hold-off errors in the result logger holdoff_errors_readout: Number of hold-off errors in the readout holdoff_errors_spectr: Number of hold-off errors in the spectrum + first_sample_timestamp: Timestamp of the first sample """ timestamp: int @@ -90,6 +91,7 @@ class ShfResultLoggerVectorExtraHeader: holdoff_errors_reslog: int holdoff_errors_readout: int holdoff_errors_spectr: int + first_sample_timestamp: int @staticmethod def from_binary( @@ -126,6 +128,7 @@ def from_binary( holdoff_errors_reslog=struct.unpack("H", binary[52:54])[0], holdoff_errors_readout=struct.unpack("H", binary[54:56])[0], holdoff_errors_spectr=struct.unpack("H", binary[56:58])[0], + first_sample_timestamp=struct.unpack("q", binary[58:66])[0], ) raise SHFHeaderVersionNotSupportedError(version=version.as_tuple()) @@ -138,7 +141,7 @@ def to_binary(self) -> tuple[bytes, _HeaderVersion]: this encoding. """ return struct.pack( - "qIIddIIIIIHHHH", + "=qIIddIIIIIHHHqH", self.timestamp, self.job_id, self.repetition_id, @@ -152,6 +155,7 @@ def to_binary(self) -> tuple[bytes, _HeaderVersion]: self.holdoff_errors_reslog, self.holdoff_errors_readout, self.holdoff_errors_spectr, + self.first_sample_timestamp, 0, # padding to make the number of bytes divisible by 4 # this is necessary because the length of the header is encoded # in multiples of 4 bytes (32 bit words) diff --git a/tests/core/test_shf_vector_data.py b/tests/core/test_shf_vector_data.py index 0c4fbc6..39760a2 100644 --- a/tests/core/test_shf_vector_data.py +++ b/tests/core/test_shf_vector_data.py @@ -232,7 +232,7 @@ def test_shf_demodulator_vector( # noqa: PLR0913 @pytest.mark.parametrize("header_version", [1]) @pytest.mark.parametrize("x", range(0, 30, 7)) def test_shf_result_logger_vector(vector_length, header_version, x): - header_length = 64 + header_length = 72 input_vector = VectorData( valueType=VectorValueType.SHF_RESULT_LOGGER_VECTOR_DATA.value, vectorElementType=2, @@ -317,6 +317,7 @@ def test_shf_waveform_logger_vector(vector_length, x, y): holdoff_errors_reslog=10, holdoff_errors_readout=11, holdoff_errors_spectr=12, + first_sample_timestamp=13, ), ShfDemodulatorVectorExtraHeader( timestamp=0, @@ -385,6 +386,7 @@ def __getattr__(self, item): holdoff_errors_reslog=10, holdoff_errors_readout=11, holdoff_errors_spectr=12, + first_sample_timestamp=13, ), np.array([50 + 100j, 100 + 150j], dtype=np.complex64), ), @@ -490,7 +492,7 @@ def test_encoding_decoding_are_invers_shf_demod_sample(header, data): ), ), ( - ShfResultLoggerVectorExtraHeader(0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0), + ShfResultLoggerVectorExtraHeader(0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), SHFDemodSample( np.array([6, 3], dtype=np.int64), np.array([7, 2], dtype=np.int64), diff --git a/tests/mock/module_test.py b/tests/mock/module_test.py index 1836146..08666eb 100644 --- a/tests/mock/module_test.py +++ b/tests/mock/module_test.py @@ -129,6 +129,7 @@ async def test_shf_result_logger_vector_handled_correctly_in_set_and_subscribe() 10, 11, 12, + 13, ) session = await AutomaticLabOneServer({"/a/b": {}}).start_pipe()