Skip to content

Commit

Permalink
Merge pull request #86 from tum-esm/main
Browse files Browse the repository at this point in the history
4.0.4 Release
  • Loading branch information
dostuffthatmatters authored Aug 10, 2022
2 parents 617b6eb + 5fe3e90 commit 0a08b06
Show file tree
Hide file tree
Showing 54 changed files with 1,145 additions and 597 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-on-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'build-on-release'
on:
push:
branches:
- prerelease

defaults:
run:
working-directory: packages/ui

jobs:
publish-tauri:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 16
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install app dependencies and build it
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: v__VERSION__-prerelease
releaseName: 'v__VERSION__-prerelease (generated by CI)'
releaseBody: 'TODO: description'
releaseDraft: true
prerelease: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config/config.json
config/config.original.json
config/*.lock
.env
packages/cli/alias/pyra-cli.bat

# logs
*.log
Expand All @@ -25,12 +26,13 @@ pids
*.pid.lock
.DS_Store
*.dat
Bilder/**/*.JPG
*.txt
runtime-data/
pyra-core-process-state.json
logs/persistent-state.json
logs/activity/*.json
logs/vbdsd/*.jpg
logs/vbdsd-autoexposure/*.jpg

# pyra ui
packages/electron-ui/node_modules/
Expand Down
26 changes: 18 additions & 8 deletions config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
"general": {
"seconds_per_core_interval": 30,
"test_mode": false,
"station_id": "..."
"station_id": "...",
"min_sun_elevation": 11
},
"opus": {
"em27_ip": "10.0.0.1",
"em27_ip": "10.10.0.1",
"executable_path": "C:\\Program Files (x86)\\Bruker\\OPUS_7.8.44\\opus.exe",
"executable_parameter": "/LANGUAGE=ENGLISH /DIRECTLOGINPASSWORD=Default@OPUS",
"experiment_path": "C:\\Users\\Public\\Documents\\Bruker\\OPUS_7.8.44\\XPM\\experiment.xpm",
"macro_path": "C:\\Users\\Public\\Documents\\Bruker\\OPUS_7.8.44\\Macro\\macro.mtx"
"macro_path": "C:\\Users\\Public\\Documents\\Bruker\\OPUS_7.8.44\\Macro\\macro.mtx",
"username": "Default",
"password": "..."
},
"camtracker": {
"config_path": "C:\\Users\\Public\\Documents\\Bruker\\camtracker_3_9_1_0\\CamTrackerConfig.txt",
Expand All @@ -19,7 +21,7 @@
"motor_offset_threshold": 10
},
"error_email": {
"sender_address": "esm-technical-user@gmail.com",
"sender_address": "pyra.technical.user@gmail.com",
"sender_password": "...",
"notify_recipients": true,
"recipients": "your@mail.com"
Expand All @@ -33,9 +35,17 @@
"consider_time": true,
"consider_sun_elevation": true,
"consider_vbdsd": false,
"start_time": { "hour": 7, "minute": 0, "second": 0 },
"stop_time": { "hour": 21, "minute": 0, "second": 0 },
"min_sun_elevation": 0.0
"start_time": {
"hour": 7,
"minute": 0,
"second": 0
},
"stop_time": {
"hour": 21,
"minute": 0,
"second": 0
},
"min_sun_elevation": 0
},
"tum_plc": null,
"vbdsd": null
Expand Down
1 change: 0 additions & 1 deletion config/tum_plc.config.default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"min_power_elevation": 10.0,
"ip": "10.0.0.4",
"version": 1,
"controlled_by_user": false
Expand Down
1 change: 0 additions & 1 deletion config/vbdsd.config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"evaluation_size": 15,
"seconds_per_interval": 6,
"measurement_threshold": 0.6,
"min_sun_elevation": 11.0,
"save_images": false
}
Empty file.
Empty file added logs/vbdsd/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions packages/cli/alias/pyra-cli.example.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
echo.
python C:\Users\...\Documents\pyra-4\packages\cli\main.py %


4 changes: 3 additions & 1 deletion packages/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def _get_config():
content = json.load(f)
except:
raise AssertionError("file not in a valid json format")

ConfigValidation.check_structure(content)
click.echo(json.dumps(content))


Expand All @@ -50,7 +52,7 @@ def _update_config(content: str):

merged_json = update_dict_recursively(current_json, new_partial_json)
with open(CONFIG_FILE_PATH, "w") as f:
json.dump(merged_json, f)
json.dump(merged_json, f, indent=4)

success_handler("Updated config file")

Expand Down
41 changes: 28 additions & 13 deletions packages/cli/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,34 @@ def _stop_pyra_core():
return

config = ConfigInterface().read()
enclosure = EnclosureControl(config)
tracking = SunTracking(config)
opus = OpusMeasurement(config)

enclosure.force_cover_close()
if tracking.ct_application_running():
tracking.stop_sun_tracking_automation()
if opus.opus_application_running():
opus.stop_macro()
time.sleep(2)
opus.close_opus()

success_handler("Stopped the measurement process")

try:
enclosure = EnclosureControl(config)
enclosure.force_cover_close()
enclosure.plc_interface.disconnect()
success_handler("Successfully closed cover")
except Exception as e:
error_handler(f"Failed to close cover: {e}")

try:
tracking = SunTracking(config)
if tracking.ct_application_running():
tracking.stop_sun_tracking_automation()
success_handler("Successfully closed CamTracker")
except Exception as e:
error_handler(f"Failed to close CamTracker: {e}")

try:
processes = [p.name() for p in psutil.process_iter()]
for e in ["opus.exe", "OpusCore.exe"]:
if e in processes:
exit_code = os.system(f"taskkill /f /im {e}")
assert (
exit_code == 0
), f'taskkill of "{e}" ended with an exit_code of {exit_code}'
success_handler("Successfully closed OPUS")
except Exception as e:
error_handler(f"Failed to close OPUS: {e}")


@click.command(help="Checks whether the pyra-core background process is running")
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/commands/plc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_plc_interface():
assert config["tum_plc"] is not None, "PLC not configured"
assert config["tum_plc"]["controlled_by_user"], "PLC is controlled by automation"
plc_interface = PLCInterface(config)
plc_interface.connect()
except (PLCError, AssertionError) as e:
error_handler(f"{e}")

Expand All @@ -38,6 +39,7 @@ def _read(no_indent):
if plc_interface is not None:
plc_readings = plc_interface.read()
success_handler(json.dumps(plc_readings.to_dict(), indent=(None if no_indent else 2)))
plc_interface.disconnect()


@click.command(help="Run plc function 'reset()'")
Expand All @@ -58,6 +60,7 @@ def _reset():
break
assert running_time <= 20, "plc took to long to set reset_needed to false"
success_handler("Ok")
plc_interface.disconnect()


def wait_until_cover_is_at_angle(plc_interface: PLCInterface, new_cover_angle, timeout=15):
Expand Down Expand Up @@ -100,6 +103,7 @@ def _set_cover_angle(angle):
wait_until_cover_is_at_angle(plc_interface, new_cover_angle)

success_handler("Ok")
plc_interface.disconnect()


@with_filelock(CONFIG_LOCK_PATH)
Expand All @@ -108,7 +112,7 @@ def enable_user_control_in_config():
config: dict = json.load(f)
config["tum_plc"]["controlled_by_user"] = True
with open(CONFIG_FILE_PATH, "w") as f:
json.dump(config, f)
json.dump(config, f, indent=4)


@click.command(help="Run plc function 'force_cover_close()'")
Expand All @@ -124,6 +128,7 @@ def _close_cover():
wait_until_cover_is_at_angle(plc_interface, 0)

success_handler("Ok")
plc_interface.disconnect()


def set_boolean_plc_state(
Expand All @@ -134,6 +139,7 @@ def set_boolean_plc_state(
assert state in ["true", "false"], 'state has to be either "true" or "false"'
get_setter_function(plc_interface)(state == "true")
success_handler("Ok")
plc_interface.disconnect()


@click.command(help="Run plc function 'set_sync_to_tracker()'")
Expand Down Expand Up @@ -175,7 +181,7 @@ def _set_spectrometer_power(state):
@click.command(help="Run plc function 'set_power_computer()'")
@click.argument("state")
def _set_computer_power(state):
set_boolean_plc_state(state, lambda p: plc_command_group.set_power_computer)
set_boolean_plc_state(state, lambda p: p.set_power_computer)


@click.group()
Expand Down
1 change: 1 addition & 0 deletions packages/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def run():
_CONFIG = ConfigInterface.read()
break
except AssertionError as e:
logger.error(f"{e}")
logger.error(f"Invalid config, waiting 10 seconds")
time.sleep(10)

Expand Down
Loading

0 comments on commit 0a08b06

Please sign in to comment.