Skip to content

Commit cf16980

Browse files
authored
Merge pull request #35 from MrClock8163/feature/shutdown
Add utility commands to start up and shut down instrument functions
2 parents a7242ff + f8591ec commit cf16980

File tree

11 files changed

+406
-0
lines changed

11 files changed

+406
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
99

10+
### Added
11+
12+
- Added GeoCom shutdown utility (`shutdown geocom`)
13+
- Added GeoCom startup utility (`startup geocom`)
14+
- Added GSI Online DNA shutdown utility (`shutdown gsidna`)
15+
- Added GSI Online DNA startup utility (`startup gsidna`)
16+
1017
### Changed
1118

1219
- All console output was updated to use the `rich` package instead of `click`

docs/commands/control/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:icon: material/toggle-switch
2+
3+
Control
4+
=======
5+
6+
The control commands are a set of simple utilities to activate or deactivate
7+
certain components of an instrument.
8+
9+
.. toctree::
10+
:maxdepth: 1
11+
12+
shutdown_geocom
13+
shutdown_gsidna
14+
startup_geocom
15+
startup_gsidna
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Shutdown - GeoCom
2+
=================
3+
4+
For power management reasons, it might be required to deactivate some aspects
5+
of an instrument to conserve power.
6+
7+
Requirements
8+
------------
9+
10+
- GeoCom capable instrument
11+
12+
Examples
13+
--------
14+
15+
.. code-block:: shell
16+
:caption: Shutting down the instrument
17+
18+
iman shutdown geocom instrument COM1
19+
20+
.. code-block:: shell
21+
:caption: Deactivating GeoCom online mode (only applicable before TPS1200)
22+
23+
iman shutdown geocom protocol COM1
24+
25+
Usage
26+
-----
27+
28+
.. click:: instrumentman.control:cli_shutdown_geocom
29+
:prog: iman shutdown geocom
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Shutdown - GSI Online DNA
2+
=================
3+
4+
Requirements
5+
------------
6+
7+
- GSI Online capable digital level
8+
9+
Examples
10+
--------
11+
12+
.. code-block:: shell
13+
:caption: Shutting down the instrument
14+
15+
iman shutdown gsidna COM1
16+
17+
Usage
18+
-----
19+
20+
.. click:: instrumentman.control:cli_shutdown_gsidna
21+
:prog: iman shutdown gsidna
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Startup - GeoCom
2+
=================
3+
4+
If an instrument system was deactivated, it might be necessary to reactivate it
5+
before using certain capabilities of the instrument.
6+
7+
Requirements
8+
------------
9+
10+
- GeoCom capable instrument
11+
12+
Examples
13+
--------
14+
15+
.. code-block:: shell
16+
:caption: Activating laser pointer
17+
18+
iman startup geocom pointer COM1
19+
20+
Usage
21+
-----
22+
23+
.. click:: instrumentman.control:cli_startup_geocom
24+
:prog: iman startup geocom
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Startup - GSI Online DNA
2+
=================
3+
4+
Requirements
5+
------------
6+
7+
- GSI Online capable digital level
8+
9+
Examples
10+
--------
11+
12+
.. code-block:: shell
13+
:caption: Waking up instrument
14+
15+
iman startup gsidna COM1
16+
17+
Usage
18+
-----
19+
20+
.. click:: instrumentman.control:cli_startup_gsidna
21+
:prog: iman startup gsidna

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Content
4646
commands/data/index
4747
commands/jobs/index
4848
commands/settings/index
49+
commands/control/index
4950
commands/station/index
5051

5152
Indices

docs/latexindex.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ Applications
3131
commands/data/index
3232
commands/jobs/index
3333
commands/settings/index
34+
commands/control/index
3435
commands/station/index

src/instrumentman/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from . import jobs
2727
from . import datatransfer
2828
from . import settings
29+
from . import control
2930

3031

3132
@extra_group(
@@ -151,6 +152,22 @@ def cli_upload() -> None:
151152
"""Upload data to the instrument."""
152153

153154

155+
@cli.group(
156+
"shutdown",
157+
aliases=["sh", "exit", "deactivate", "turnoff", "switchoff"]
158+
) # type: ignore[misc]
159+
def cli_shutdown() -> None:
160+
"""Deactivate various instrument functions."""
161+
162+
163+
@cli.group(
164+
"startup",
165+
aliases=["st", "enter", "activate", "turnon", "switchon"]
166+
) # type: ignore[misc]
167+
def cli_startup() -> None:
168+
"""Activate various instrument functions."""
169+
170+
154171
cli.add_command(morse.cli)
155172
cli.add_command(terminal.cli)
156173
cli_measure.add_command(setmeasurement.cli_measure)
@@ -178,3 +195,7 @@ def cli_upload() -> None:
178195
cli_convert.add_command(setup.cli_convert_gsi_to_targets)
179196
cli_convert.add_command(setup.cli_convert_targets_to_gsi)
180197
cli_convert.add_command(setmeasurement.cli_convert_set_to_gsi)
198+
cli_shutdown.add_command(control.cli_shutdown_geocom)
199+
cli_shutdown.add_command(control.cli_shutdown_gsidna)
200+
cli_startup.add_command(control.cli_startup_geocom)
201+
cli_startup.add_command(control.cli_startup_gsidna)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
from typing import Any
2+
3+
from click_extra import (
4+
extra_command,
5+
argument,
6+
Choice
7+
)
8+
9+
from ..utils import (
10+
com_port_argument,
11+
com_option_group
12+
)
13+
14+
15+
@extra_command(
16+
"gsidna",
17+
params=None,
18+
context_settings={"auto_envvar_prefix": None}
19+
) # type: ignore[misc]
20+
@com_port_argument()
21+
@com_option_group()
22+
def cli_shutdown_gsidna(**kwargs: Any) -> None:
23+
"""
24+
Deactivate a GSI Online capable digital level.
25+
"""
26+
from .app import main_shutdown_gsidna
27+
28+
main_shutdown_gsidna(**kwargs)
29+
30+
31+
@extra_command(
32+
"geocom",
33+
params=None,
34+
context_settings={"auto_envvar_prefix": None}
35+
) # type: ignore[misc]
36+
@argument(
37+
"component",
38+
help="Instrument component to shut down",
39+
type=Choice(
40+
(
41+
"protocol",
42+
"instrument",
43+
"edm",
44+
"pointer",
45+
"telescopic-camera",
46+
"overview-camera"
47+
),
48+
case_sensitive=False
49+
)
50+
)
51+
@com_port_argument()
52+
@com_option_group()
53+
def cli_shutdown_geocom(**kwargs: Any) -> None:
54+
"""
55+
Deactivate components of a GeoCom capable instrument.
56+
57+
To reduce power consumption, in certain scenarios it can be beneficial to
58+
power off some components of an instrument. Or shut down the entire machine
59+
completely.
60+
61+
Instruments before the TPS1200 series cannot be remotely reactivated after
62+
a complete shutdown (the GeoCom online mode has to be manually switched
63+
on). Similarly, instruments that are not connected by physical cable (but
64+
by Bluetooth for example) cannot be reactivated as the wireless connection
65+
can only be esatblished with an active instrument. Only shut down these
66+
instruments remotely if no further operation is needed until the next
67+
manual access.
68+
"""
69+
from .app import main_shutdown_geocom
70+
71+
main_shutdown_geocom(**kwargs)
72+
73+
74+
@extra_command(
75+
"gsidna",
76+
params=None,
77+
context_settings={"auto_envvar_prefix": None}
78+
) # type: ignore[misc]
79+
@com_port_argument()
80+
@com_option_group()
81+
def cli_startup_gsidna(**kwargs: Any) -> None:
82+
"""
83+
Activate/reactivate a GSI Online capable digital level.
84+
"""
85+
from .app import main_startup_gsidna
86+
87+
main_startup_gsidna(**kwargs)
88+
89+
90+
@extra_command(
91+
"geocom",
92+
params=None,
93+
context_settings={"auto_envvar_prefix": None}
94+
) # type: ignore[misc]
95+
@argument(
96+
"component",
97+
help="Instrument component to start up",
98+
type=Choice(
99+
(
100+
"instrument",
101+
"edm",
102+
"pointer",
103+
"telescopic-camera",
104+
"overview-camera"
105+
),
106+
case_sensitive=False
107+
)
108+
)
109+
@com_port_argument()
110+
@com_option_group()
111+
def cli_startup_geocom(**kwargs: Any) -> None:
112+
"""
113+
Activate/reactivate components of a GeoCom capable instrument.
114+
115+
Instruments can be reactivated remotely after a complete shutdown only if
116+
they are TPS1200 or newer series and connected by a physical cable.
117+
"""
118+
from .app import main_startup_geocom
119+
120+
main_startup_geocom(**kwargs)

0 commit comments

Comments
 (0)