Skip to content

Commit da6a36e

Browse files
authored
Merge pull request #16 from MrClock8163/feature/settings
Settings download and upload commands
2 parents c52ffe0 + 10c5673 commit da6a36e

File tree

16 files changed

+850
-2
lines changed

16 files changed

+850
-2
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Downloading
2+
===========
3+
4+
The settings are saved by iterating over a set collection of parameter names.
5+
Any particular instrument might not respond to the query of any of the
6+
parameters (e.g. a total station will not respond to queries regarding the
7+
digital level settings). These settings are marked empty, and later cleaned up
8+
before the config file is saved to disk.
9+
10+
It is possible to save the default values for the parameters, that the
11+
instrument did not respond to. In this case, the config file might need to be
12+
manually cleaned of the irrelevant or unwanted settings.
13+
14+
Examples
15+
--------
16+
17+
.. code-block:: shell
18+
:caption: Saving only applicable GeoCom settings
19+
20+
iman download settings COM1 geocom tps_settings.json
21+
22+
.. code-block:: shell
23+
:caption: Saving to YAML format in a file without extension
24+
25+
iman download settings -f yaml COM1 geocom tps_settings
26+
27+
.. code-block:: shell
28+
:caption: Saving all settings including defaults of not applicable ones
29+
30+
iman download settings --defaults COM1 geocom tps_settings.json
31+
32+
Usage
33+
-----
34+
35+
.. click:: instrumentman.settings:cli_download
36+
:prog: iman download settings

docs/commands/settings/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:icon: material/cog
2+
3+
Settings
4+
========
5+
6+
For different measurements, different instrument settings might be required.
7+
The settings commands can be used to save the settings to the config file,
8+
and later load them back as necessary.
9+
10+
.. toctree::
11+
:maxdepth: 1
12+
13+
download
14+
validate
15+
upload

docs/commands/settings/upload.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Uploading
2+
=========
3+
4+
Once a config file is created (either manually, or saved from the instrument),
5+
the parameters can be uploaded back to the instrument. The config file must
6+
have a valid structure, or the upload will be refused.
7+
8+
The config file can either be in JSON, YAML or TOML format, but regardless,
9+
the structure must follow the required schema.
10+
11+
.. note::
12+
13+
Configs can be validated before upload with the validation command.
14+
15+
Examples
16+
--------
17+
18+
.. code-block:: json
19+
:caption: Total station ATR and target setting
20+
21+
{
22+
"protocol": "geocom",
23+
"settings": [
24+
{
25+
"subsystem": "aut",
26+
"options": {
27+
"atr": true
28+
}
29+
},
30+
{
31+
"subsystem": "bap",
32+
"options": {
33+
"target_type": "REFLECTOR",
34+
"prizm_type": "MINI"
35+
}
36+
}
37+
]
38+
}
39+
40+
41+
.. code-block:: json
42+
:caption: DNA normal staff direction with meter units
43+
44+
{
45+
"protocol": "gsidna",
46+
"settings": [
47+
{
48+
"subsystem": "settings",
49+
"options": {
50+
"distance_unit": "METER",
51+
"staff_mode": false
52+
}
53+
}
54+
]
55+
}
56+
57+
Usage
58+
-----
59+
60+
.. click:: instrumentman.settings:cli_upload
61+
:prog: iman upload settings
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Validation
2+
==========
3+
4+
An instrument settings file must have a valid structure, or the upload will be
5+
refused. The schema file is available in the
6+
`GitHub repository <https://github.com/MrClock8163/Instrumentman/blob/main/src/instrumentman/settings/schema_settings.json>`_.
7+
8+
Usage
9+
-----
10+
11+
.. click:: instrumentman.settings:cli_validate
12+
:prog: iman validate settings
13+

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Content
4444
commands/protocoltest/index
4545
commands/files/index
4646
commands/jobs/index
47+
commands/settings/index
4748

4849
Indices
4950

docs/latexindex.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Applications
2929
commands/protocoltest/index
3030
commands/files/index
3131
commands/jobs/index
32+
commands/settings/index

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ dependencies = [
1717
"rapidfuzz",
1818
"jsonschema",
1919
"jmespath",
20+
"toml",
21+
"PyYAML",
2022
"click-extra"
2123
]
2224
classifiers = [
@@ -62,6 +64,8 @@ linting = [
6264
"types-pyserial",
6365
"types-jsonschema",
6466
"types-jmespath",
67+
"types-toml",
68+
"types-PyYAML",
6569
"mypy",
6670
"flake8"
6771
]

src/instrumentman/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from . import inclination
1414
from . import filetransfer
1515
from . import jobs
16+
from . import settings
1617

1718

1819
@extra_group("iman", params=None) # type: ignore[misc]
@@ -63,6 +64,11 @@ def cli_download() -> None:
6364
"""Download data from the instrument."""
6465

6566

67+
@cli.group("upload") # type: ignore[misc]
68+
def cli_upload() -> None:
69+
"""Upload data to the instrument."""
70+
71+
6672
cli.add_command(morse.cli)
6773
cli.add_command(terminal.cli)
6874
cli_measure.add_command(setmeasurement.cli_measure)
@@ -75,7 +81,10 @@ def cli_download() -> None:
7581
cli_merge.add_command(setmeasurement.cli_merge)
7682
cli_merge.add_command(inclination.cli_merge)
7783
cli_validate.add_command(setmeasurement.cli_validate)
84+
cli_validate.add_command(settings.cli_validate)
7885
cli_import.add_command(setup.cli_import)
7986
cli_list.add_command(filetransfer.cli_list)
8087
cli_list.add_command(jobs.cli_list)
8188
cli_download.add_command(filetransfer.cli_download)
89+
cli_download.add_command(settings.cli_download)
90+
cli_upload.add_command(settings.cli_upload)

src/instrumentman/schema_targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "GeoComPy set measurement targets schema",
2+
"title": "Instrumentman set measurement targets schema",
33
"description": "Target point records for set measurements",
44
"tpye": "object",
55
"additionalProperties": false,

src/instrumentman/setmeasurement/schema_session.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "GeoComPy set measurement session schema",
2+
"title": "Instrumentman set measurement session schema",
33
"description": "Data recorded during a set measurement session",
44
"type": "object",
55
"additionalProperties": false,

0 commit comments

Comments
 (0)