Skip to content

Commit 091f8f3

Browse files
committed
[gsi,gsidna] changed gsi serialnumber word to store int
1 parent de66194 commit 091f8f3

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1212
- Added testing for Python 3.14
1313
- Added logging of the instrument serial number to GeoCOM connection
1414

15+
### Changed
16+
17+
- Changed `GsiSerialnumberWord` to store value as `int` instead of `str`
18+
- Changed `get_serialnumber` measurement command on `GsiOnlineDNA` to return
19+
`int` instead of `str` in the response object
20+
1521
## v0.14.0 (2025-10-18)
1622

1723
### Added

src/geocompy/gsi/dna/measurements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def get_temperature(self) -> GsiOnlineResponse[float]:
277277
gsi.GsiTemperatureWord
278278
).map_value(_word_value)
279279

280-
def get_serialnumber(self) -> GsiOnlineResponse[str]:
280+
def get_serialnumber(self) -> GsiOnlineResponse[int]:
281281
"""
282282
``GET 12``
283283

src/geocompy/gsi/gsiformat.py

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,16 +520,65 @@ class GsiSerialnumberWord(GsiValueWord):
520520
def WI(cls) -> int:
521521
return 12
522522

523-
def __init__(self, serialnumber: str):
523+
def __init__(self, serialnumber: int):
524524
"""
525525
Parameters
526526
----------
527-
serialnumber : str
528-
Serial number as string (as it might sometimes contain letters).
527+
serialnumber : int
528+
Serial number.
529529
"""
530-
self.value: str
530+
self.value: int
531531
super().__init__(serialnumber)
532532

533+
@classmethod
534+
def parse(cls, value: str) -> Self:
535+
"""
536+
Parses serial number from a serialized GSI word.
537+
538+
Parameters
539+
----------
540+
value : str
541+
Serialized GSI word.
542+
543+
Returns
544+
-------
545+
Self
546+
"""
547+
cls._check_format(value)
548+
549+
return cls(
550+
int(value[7:-1].lstrip("0"))
551+
)
552+
553+
def serialize(
554+
self,
555+
*,
556+
gsi16: bool = False,
557+
angleunit: GsiUnit | None = None,
558+
distunit: GsiUnit | None = None
559+
) -> str:
560+
"""
561+
Serialize data to GSI word text.
562+
563+
Parameters
564+
----------
565+
gsi16 : bool, optional
566+
Create GSI16 word instead of GSI8, by default False
567+
angleunit : GsiUnit | None, optional
568+
Unused, by default None
569+
distunit : GsiUnit | None, optional
570+
Unused, by default None
571+
572+
Returns
573+
-------
574+
str
575+
"""
576+
return format_gsi_word(
577+
self.wi,
578+
str(self.value),
579+
gsi16=gsi16
580+
)
581+
533582

534583
class GsiInstrumentTypeWord(GsiValueWord):
535584
"""``WI13`` Instrument type name."""

0 commit comments

Comments
 (0)