How to Start and Stop Measurements via CLI and UI
Measurement Modes and Triggers
The measurement decision (whether measurements should run or not) depends on the measurement mode:
- Automatic mode: Measurement decision is made based on defined triggers (see below)
- Manual mode: A start/stop button for manual control
- CLI mode: The config contains a field where the CLI can add a decision result
CLI mode can be used when you have already built a system that evaluates measurement conditions and want to use Pyra for the rest of the operation. Respective CLI commands are in the next section.
In the automation tab, Pyra's measurement mode can be selected.
In the configuration tab, you can select measurement triggers that should be considered in automatic mode. When multiple triggers are set, all triggers must be positive to start measurements (e.g. "above a certain sun angle AND between start and end time").
Helios is our module to determine whether direct sunlight (required by the EM27/SUN) is present. Please read about it here.
CLI (Command Line Interface)
Everything seen/clicked in the GUI can also be read/written via the CLI.
The usage of any command is explained in its help menu (available in the terminal).
CLI: Help Menu Examples
Top-level menu:
pyra-cli --help
# Usage: pyra-cli [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# config
# core
# logs
# plc
# remove-filelocks Remove all filelocks.
# state
Command group menu:
pyra-cli config --help
# Usage: pyra-cli config [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# get Read the current config.json file.
# update Set the config.json file.
# validate Validate the current config.json file.
Individual command menus:
pyra-cli config update --help
# Usage: pyra-cli config update [OPTIONS] [CONTENT]
#
# Set config. Pass the JSON directly or via a file path. Only a subset of the
# required config variables has to be passed. The non-occurring values will be
# reused from the current config.
#
# The required schema can be found in the documentation.
#
# Options:
# --help Show this message and exit.
CLI: Config Update
Running the following command will update the number of seconds Pyra spends in one loop:
pyra-cli config update "{\"general\":{\"seconds_per_core_interval\":20}}\"
The same command can be achieved in Python without all the escaping done manually:
import json
import os
import subprocess
def run_pyra_cli_config_update(update: dict) -> str:
p = subprocess.run(
args=["pyra-cli.bat", "config", "update", json.dumps(update)],
cwd=os.path.join(os.environ["USERPROFILE"], "Documents","pyra"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stderr, stdout = p.stderr.decode().strip(), p.stdout.decode().strip()
assert p.returncode == 0, f"pyra-cli config update failed: {stderr}"
return stdout
update = {"general": {"seconds_per_core_interval": 20}}
print(run_pyra_cli_config_update(update))
Pyra will validate the structure of the update and enforce some rules on the parameter values (value range, file existence, etc.)
The developer docs contain a full list of schema and value requirements for the config file.
Starting and Stopping Measurements via CLI
- Set Pyra's measurement mode to "CLI mode" using the UI, or the CLI:
pyra-cli config update "{\"measurement_decision\": {\"mode\": \"cli\"}}"
update = {"measurement_decision": {"mode": "cli"}}
run_pyra_cli_config_update(update)
- Update the CLI's decision on whether or not to measure using the CLI:
pyra-cli config update "{\"measurement_decision\": {\"cli_decision_result\": true}}"
pyra-cli config update "{\"measurement_decision\": {\"cli_decision_result\": false}}"
update = {"measurement_decision": {"cli_decision_result": True}}
run_pyra_cli_config_update(update)
update = {"measurement_decision": {"cli_decision_result": False}}
run_pyra_cli_config_update(update)
The CLI does not offer commands for starting and stopping CamTracker or OPUS directly because this conflicts with PYRA Core's management of these applications.