Skip to content

Commit 9f15bfb

Browse files
committed
Update package README file
1 parent a616650 commit 9f15bfb

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

README.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,55 @@ A low-level interface to data collected with the [Harp](https://harp-tech.org/)
44

55
## Data model
66

7-
To regenerate Pydantic data models from device schema definitions, activate a virtual environment with `dev` dependencies, and run:
7+
The interface makes use of a Pydantic data model generated from Harp device schema definitions. The schema data classes are used to automatically generate binary readers for each device.
8+
9+
All binary data files from a single device need to be stored in the same folder alongside the device meta-schema, named `device.yml`. Each register file should have the following naming convention `<deviceName>_<registerAddress>.bin`.
10+
11+
For example, for a dataset collected with a `Behavior` device, you might have:
812

913
```
10-
datamodel-codegen --input ./reflex-generator/schema/device.json --output harp/model.py --output-model-type pydantic_v2.BaseModel
14+
📦device.harp
15+
┣ 📜Behavior_0.bin
16+
┣ 📜Behavior_1.bin
17+
...
18+
┗ 📜device.yml
1119
```
1220

13-
> [!IMPORTANT]
14-
> Currently code generation adds an unwanted field at the very end of the data model definition `registers: Optional[Any] = None`. This declaration needs to be removed for serialization to work properly.
15-
1621
## How to use
1722

18-
### Read Harp device schema from YML file
19-
20-
```python
21-
from harp.schema import read_schema
22-
schema = read_schema('device.yml')
23-
```
24-
2523
### Create device reader object from schema
2624

2725
```python
28-
from harp.reader import create_reader
29-
reader = create_reader(schema)
26+
import harp
27+
reader = harp.create_reader("device.harp")
3028
```
3129

3230
### Read data from named register
3331

3432
```python
35-
reader.OperationControl.read("data/Behavior_10.bin")
33+
reader.OperationControl.read()
3634
```
3735

3836
### Access register metadata
3937

4038
```python
4139
reader.OperationControl.register.address
4240
```
41+
42+
### Create device reader object with UTC datetime format
43+
44+
```python
45+
reader = harp.create_reader("device.harp", epoch=harp.REFERENCE_EPOCH)
46+
```
47+
48+
### Read data with message type information
49+
50+
```python
51+
reader.OperationControl.read(keep_type=True)
52+
```
53+
54+
### Read data from a specific file
55+
56+
```python
57+
reader.OperationControl.read("data/Behavior_10.bin")
58+
```

0 commit comments

Comments
 (0)