Skip to content

Commit bdd4bab

Browse files
authored
Merge branch 'main' into feature/converter-commands
2 parents fdfc8f6 + c2ebb1b commit bdd4bab

File tree

5 files changed

+57
-30
lines changed

5 files changed

+57
-30
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,25 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

1010
### Added
1111

12+
- Added aliases to multiple commands and command groups
1213
- Added resection calculation logic
1314
- Added station calculation (`calc station`) using resection from set
1415
measurements
1516
- Added station uploading (`upload station`) to set station coordinates and
1617
orientation
17-
- Added logging options to `iman` root command
18-
- Added logging to instrument connected commands
1918
- Added CSV to targets JSON conversion (`convert csv-targets`)
2019
- Added targets JSON to CSV conversion (`convert targets-csv`)
2120
- Added GSI to targets JSON conversion (`convert gsi-targets`)
2221
- Added targets JSON to GSI conversion (`convert targets-gsi`)
22+
- Added logging options to `iman` root command
23+
- Added logging to instrument connected commands
24+
- Added `dateformat` option to set measurement
25+
- Added `timeformat` option to set measurement
2326

2427
### Changed
2528

2629
- `geocompy` dependency minimum version was bumped to `v0.11.0`
30+
- Updated descriptions in command helps
2731
- Updated file listing to display results in a tree view
2832
- Reworked file listing to be able to run recursively to build full tree view
2933
- Protocol tests now display results in a table
@@ -34,6 +38,8 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3438
option, instead of a comma separated string list
3539
- `chunk` option of file download now expects size in bytes, instead of
3640
encoded hex characters
41+
- Second argument (`output`) of set measurement now expects a file path or file
42+
path template instead of a directory
3743

3844
### Fixed
3945

@@ -44,8 +50,9 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4450

4551
### Removed
4652

47-
- Removed logging options from set measurement
4853
- Removed importer command group and subcommands (`import`)
54+
- Removed logging options from set measurement
55+
- Removed `format` option from set measurement
4956

5057
## v0.3.0 (2025-08-01)
5158

docs/commands/sets/measure.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,25 @@ Examples
5353
.. code-block:: shell
5454
:caption: Enabling connection retries and timeout recovery attempts (might be useful with bluetooth connections)
5555
56-
iman measure sets -r 3 --sync-after-timeout COM3 targets.json results
56+
iman measure set -r 3 --sync-after-timeout COM3 targets.json set.json
5757
5858
.. code-block:: shell
5959
:caption: Measuring to just a subset of the targets
6060
61-
iman measure sets -p P1 -p P2 -p P8 COM3 targets.json results
61+
iman measure set -p P1 -p P2 -p P8 COM3 targets.json set.json
6262
6363
.. code-block:: shell
6464
:caption: Measuring in face 1 only
6565
66-
iman measure sets -o ABCD COM3 targets.json results
66+
iman measure set -o ABCD COM3 targets.json set.json
67+
68+
.. code-block:: shell
69+
:caption: Saving results with file name template (useful for scheduled measurements)
70+
71+
iman measure set COM3 targets.json "set_{date}_{time}.json"
6772
6873
Usage
6974
-----
7075

7176
.. click:: instrumentman.setmeasurement:cli_measure
72-
:prog: iman measure sets
77+
:prog: iman measure set

src/instrumentman/setmeasurement/__init__.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
@extra_command(
2424
"sets",
2525
params=None,
26-
context_settings={"auto_envvar_prefix": None}
26+
context_settings={"auto_envvar_prefix": None},
27+
aliases=["set"]
2728
) # type: ignore[misc]
2829
@com_port_argument()
2930
@argument(
@@ -32,20 +33,25 @@
3233
help="JSON file containing target definitions"
3334
)
3435
@argument(
35-
"directory",
36-
type=dir_path(),
37-
help="Directory to save measurement output to"
36+
"output",
37+
type=str,
38+
help=(
39+
"Output file path or path template with placeholders "
40+
"('{date}', '{time}', '{order}', '{cycles}')"
41+
)
3842
)
3943
@com_option_group()
4044
@option(
41-
"-f",
42-
"--format",
45+
"--dateformat",
4346
type=str,
44-
default="setmeasurement_{time}.json",
45-
help=(
46-
"Session output file name format with placeholders "
47-
"(`{time}`: timestamp, `{order}`: order, `{cycle}`: cycles)"
48-
)
47+
default="%Y%m%d",
48+
help="Date format as accepted by strftime"
49+
)
50+
@option(
51+
"--timeformat",
52+
type=str,
53+
default="%H%M%S",
54+
help="Time format as accepted by strftime"
4955
)
5056
@option(
5157
"-c",
@@ -76,7 +82,8 @@
7682
help=(
7783
"Target to use from loaded target definition "
7884
"(set multiple times to use specific points, leave unset to use all)"
79-
)
85+
),
86+
default=()
8087
)
8188
def cli_measure(**kwargs: Any) -> None:
8289
"""
@@ -99,7 +106,8 @@ def cli_measure(**kwargs: Any) -> None:
99106
@extra_command(
100107
"sets",
101108
params=None,
102-
context_settings={"auto_envvar_prefix": None}
109+
context_settings={"auto_envvar_prefix": None},
110+
aliases=["set"]
103111
) # type: ignore[misc]
104112
@argument(
105113
"output",
@@ -137,7 +145,8 @@ def cli_merge(**kwargs: Any) -> None:
137145
@extra_command(
138146
"sets",
139147
params=None,
140-
context_settings={"auto_envvar_prefix": None}
148+
context_settings={"auto_envvar_prefix": None},
149+
aliases=["set"]
141150
) # type: ignore[misc]
142151
@argument(
143152
"inputs",
@@ -172,7 +181,8 @@ def cli_validate(**kwargs: Any) -> None:
172181
@extra_command(
173182
"sets",
174183
params=None,
175-
context_settings={"auto_envvar_prefix": None}
184+
context_settings={"auto_envvar_prefix": None},
185+
aliases=["set"]
176186
) # type: ignore[misc]
177187
@argument(
178188
"input",

src/instrumentman/setmeasurement/measure.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from datetime import datetime
32
from logging import Logger, getLogger
43
from typing import Iterator, Literal
@@ -177,12 +176,13 @@ def measure_set(
177176
def main(
178177
port: str,
179178
targets: pathlib.Path,
180-
directory: pathlib.Path,
179+
output: str,
181180
baud: int = 9600,
182181
timeout: int = 15,
183182
retry: int = 1,
184183
sync_after_timeout: bool = False,
185-
format: str = "setmeasurement_{time}.json",
184+
dateformat: str = "%Y%m%d",
185+
timeformat: str = "%H%M%S",
186186
cycles: int = 1,
187187
order: Literal['AaBb', 'AabB', 'ABab', 'ABba', 'ABCD'] = "ABba",
188188
sync_time: bool = True,
@@ -211,10 +211,14 @@ def main(
211211
points
212212
)
213213

214-
timestamp = session.cycles[0].time.strftime("%Y%m%d_%H%M%S")
215-
filename = os.path.join(
216-
directory,
217-
format.format(time=timestamp, order=order, cycle=cycles)
214+
epoch = session.cycles[0].time
215+
date = epoch.strftime(dateformat)
216+
time = epoch.strftime(timeformat)
217+
filename = output.format(
218+
date=date,
219+
time=time,
220+
order=order,
221+
cycles=cycles
218222
)
219223
session.export_to_json(filename)
220224
logger.info(f"Saved measurement results to '{filename}'")

src/instrumentman/station/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"(set multiple times to use specific points, leave unset to use all)"
4949
),
5050
type=str,
51-
multiple=True
51+
multiple=True,
52+
default=()
5253
)
5354
@option(
5455
"--height",

0 commit comments

Comments
 (0)