Skip to content

Commit

Permalink
Add missing SHF result field
Browse files Browse the repository at this point in the history
  • Loading branch information
zi-2k committed Jun 13, 2024
1 parent f452a3e commit 07377d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/labone/core/shf_vector_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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())

Expand All @@ -138,7 +141,7 @@ def to_binary(self) -> tuple[bytes, _HeaderVersion]:
this encoding.
"""
return struct.pack(
"qIIddIIIIIHHHH",
"qIIddIIIIIHHHHq",
self.timestamp,
self.job_id,
self.repetition_id,
Expand All @@ -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)
Expand Down

0 comments on commit 07377d8

Please sign in to comment.