Skip to content

Commit ba1f533

Browse files
committed
Allow passing reference epoch to register reader
1 parent 516ab1a commit ba1f533

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

harp/reader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from math import log2
44
from os import PathLike
55
from pathlib import Path
6+
from datetime import datetime
67
from functools import partial
78
from numpy import dtype
89
from pandas import DataFrame, Series
@@ -17,7 +18,9 @@
1718

1819
class _ReadRegister(Protocol):
1920
def __call__(
20-
self, file: Optional[Union[str, bytes, PathLike[Any], BinaryIO]] = None
21+
self,
22+
file: Optional[Union[str, bytes, PathLike[Any], BinaryIO]] = None,
23+
epoch: Optional[datetime] = None,
2124
) -> DataFrame:
2225
...
2326

@@ -134,6 +137,7 @@ def _create_register_reader(register: Register, base_path: Path):
134137
def reader(
135138
file: Optional[Union[str, bytes, PathLike[Any], BinaryIO]] = None,
136139
columns: Optional[Axes] = None,
140+
epoch: Optional[datetime] = None,
137141
):
138142
if file is None:
139143
file = f"{base_path}_{register.address}.bin"
@@ -144,6 +148,7 @@ def reader(
144148
dtype=dtype(register.type),
145149
length=register.length,
146150
columns=columns,
151+
epoch=epoch,
147152
)
148153
return data
149154

tests/test_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
path="data/device.yml",
1313
expected_whoAmI=0,
1414
expected_registers=["DigitalInputMode"],
15-
)
15+
),
1616
]
1717

1818

0 commit comments

Comments
 (0)