ariel-tcu 0.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ariel_tcu/__init__.py ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ __all__ = [
2
+ "show_processes",
3
+ ]
4
+
5
+ import re
6
+
7
+ from egse.process import ProcessInfo, get_processes
8
+
9
+
10
+ def show_processes():
11
+ def filter_procs(pi: ProcessInfo):
12
+ pattern = r"tcu_(ui|cs)"
13
+
14
+ return re.search(pattern, pi.command)
15
+
16
+ return get_processes(filter_procs)
@@ -0,0 +1,57 @@
1
+ import subprocess
2
+ from pathlib import Path
3
+ from typing import TextIO, Annotated
4
+
5
+ import sys
6
+ import rich
7
+ import typer
8
+
9
+ from egse.system import all_logging_disabled, redirect_output_to_log
10
+
11
+ tcu = typer.Typer(name="tcu", help="Ariel Telescope Control Unit (TCU)", no_args_is_help=True)
12
+
13
+
14
+ @tcu.command(name="start")
15
+ def start_tcu(
16
+ simulator: Annotated[
17
+ bool, typer.Option("--simulator", "--sim", help="use a device simulator as the backend")
18
+ ] = False,
19
+ ):
20
+ """Start the Ariel TCU Control Server.
21
+
22
+ The Control Server is always started in the background.
23
+ """
24
+
25
+ rich.print(f"Starting the Ariel TCU Control Server - {simulator = }")
26
+ out = redirect_output_to_log("tcu_cs.start.log")
27
+
28
+ cmd = [sys.executable, "-m", "egse.ariel.tcu.tcu_cs", "start"]
29
+ if simulator:
30
+ cmd.append("--simulator")
31
+
32
+ subprocess.Popen(cmd, stdout=out, stderr=out, stdin=subprocess.DEVNULL, close_fds=True)
33
+
34
+
35
+ @tcu.command(name="stop")
36
+ def stop_tcu():
37
+ """Stops the Ariel TCU Control Server."""
38
+
39
+ rich.print("Stopping the Ariel TCU Control Server")
40
+ out = redirect_output_to_log("tcu_cs.stop.log")
41
+
42
+ cmd = [sys.executable, "-m", "egse.ariel.tcu.tcu_cs", "stop"]
43
+ subprocess.Popen(cmd, stdout=out, stderr=out, stdin=subprocess.DEVNULL, close_fds=True)
44
+
45
+
46
+ @tcu.command(name="status")
47
+ def status_tcu():
48
+ """Prints the status information about the Ariel TCU Control Server."""
49
+
50
+ with all_logging_disabled():
51
+ from egse.ariel.tcu import tcu_cs
52
+
53
+ tcu_cs.status()
54
+
55
+
56
+ if __name__ == "__main__":
57
+ tcu()
@@ -0,0 +1,20 @@
1
+ PACKAGES:
2
+ ARIEL_TCU: Telescope Control Unit for Ariel
3
+
4
+ Ariel TCU Controller:
5
+ # HOSTNAME: localhost
6
+ COM_PORT: COM1
7
+ BAUD_RATE: 9600
8
+ NUM_DATA_BITS: 8
9
+ NUM_STOP_BITS: 1
10
+ PARITY: N
11
+
12
+ Ariel TCU Control Server:
13
+ PROTOCOL: tcp
14
+ HOSTNAME: localhost # Hostname that the client shall connect to, e.g. on the same machine
15
+ COMMANDING_PORT: 0 # Port on which the controller listens to commands (REQ-REP)
16
+ MONITORING_PORT: 0 # Port on which the controller sends periodic status information about the device (PUB-SUB)
17
+ SERVICE_PORT: 0 # Port on which the controller listens for configuration and administration (REQ-REP)
18
+ METRICS_PORT: 0
19
+ STORAGE_MNEMONIC: TCU
20
+ SERVICE_TYPE: TCU_CS
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: ariel-tcu
3
+ Version: 0.17.0
4
+ Summary: Telescope Control Unit (TCU) for Ariel
5
+ Author: IVS KU Leuven
6
+ Maintainer-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
7
+ License-Expression: MIT
8
+ Keywords: Ariel,hardware testing,software framework,telescope control
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: cgse-common
11
+ Requires-Dist: cgse-core
12
+ Requires-Dist: cgse-gui
13
+ Requires-Dist: crcmod>=1.7
14
+ Requires-Dist: pyserial>=3.5
@@ -0,0 +1,15 @@
1
+ ariel_tcu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ariel_tcu/cgse_explore.py,sha256=vyplUdKvizZeuaChU-Y-sje1Pwz72gFH_fUptp_-8Iw,283
3
+ ariel_tcu/cgse_services.py,sha256=c04Xd75QyZ_rfRnAZgPq-HChjAg7HJJISEcHOWCeycI,1543
4
+ ariel_tcu/settings.yaml,sha256=Czc58_bK3sEozVkTnAPSXGiE6v-9meS2ay9tBCMkAMI,1000
5
+ egse/ariel/tcu/__init__.py,sha256=S8TZxQ39g0-PEQsUAyQ3fovHEGlsJpbf9Kd1N2Hr2FA,3127
6
+ egse/ariel/tcu/tcu.py,sha256=etu-iTW4DBYpdzuDv75x_o4vp-ODvLGKKT1U5awMENE,35147
7
+ egse/ariel/tcu/tcu.yaml,sha256=hzhsa6XkWB0fX8R-2eryxcfBtP3r2spLFv6cu_tY-V4,1287
8
+ egse/ariel/tcu/tcu_cmd_utils.py,sha256=xp2znLbC20sYA4T1dP0mG2MNI9QC7r37U8Wo5HxnXZk,46061
9
+ egse/ariel/tcu/tcu_cs.py,sha256=KwjeADMQavLF3zDr4TnGEcgfQjBPqaKmLkxiUvQurBo,7901
10
+ egse/ariel/tcu/tcu_devif.py,sha256=5A60IKyh9ej6IwosjPFxWAE2lCDZjp5tqfIIutN9F6c,3088
11
+ egse/ariel/tcu/tcu_protocol.py,sha256=ie_ivSkG5Tx0lP2AKvqlN1JyemOA5g-_tVpk7m-45Ho,5394
12
+ ariel_tcu-0.17.0.dist-info/METADATA,sha256=jgtT_mJWykSBpN10gQZemcnKJoe3l5KMXcXbofrCLhw,467
13
+ ariel_tcu-0.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ ariel_tcu-0.17.0.dist-info/entry_points.txt,sha256=eijgIMSb0EWjBjIRxhPJd2ltwoOo3qTbyDySEccIjQ4,283
15
+ ariel_tcu-0.17.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,14 @@
1
+ [console_scripts]
2
+ tcu_cs = egse.ariel.tcu.tcu_cs:app
3
+
4
+ [cgse.explore]
5
+ explore = ariel_tcu.cgse_explore
6
+
7
+ [cgse.service.device_command]
8
+ tcu = ariel_tcu.cgse_services:tcu
9
+
10
+ [cgse.settings]
11
+ ariel-tcu = ariel_tcu:settings.yaml
12
+
13
+ [cgse.version]
14
+ ariel-tcu = egse.version:get_version_installed
@@ -0,0 +1,105 @@
1
+ """General information for the Ariel Telescope Control Unit (TCU).
2
+
3
+ Reference documents:
4
+ - RD01: TCU User Manual (ARIEL-IEEC-PL-TN-002), v1.2
5
+ - RD02: ARIEL TCU Data Handling (ARIEL-IEEC-PL-TN-007), v1.0
6
+ - RD02: TCU code provided by Vladimiro Noce (priv. comm.)
7
+ """
8
+
9
+ from enum import IntEnum
10
+ from pathlib import Path
11
+
12
+ from egse.settings import Settings
13
+
14
+ HERE = Path(__file__).parent
15
+ settings = Settings.load("Ariel TCU Control Server")
16
+
17
+ # General information about the TCU Control Server
18
+
19
+ PROCESS_NAME = settings.get("PROCESS_NAME", "tcu_cs") # Name under which it is registered in the service registry
20
+ SERVICE_TYPE = settings.get(
21
+ "SERVICE_TYPE", "tcu_cs"
22
+ ) # Service type under which it is registered in the service registry
23
+ PROTOCOL = settings.get("PROTOCOL", "tcp") # Communication protocol
24
+ HOSTNAME = settings.get("HOSTNAME", "localhost") # Hostname
25
+ COMMANDING_PORT = settings.get("COMMANDING_PORT", 0) # Commanding port (as per settings or dynamically assigned)
26
+ SERVICE_PORT = settings.get("SERVICE_PORT", 0) # Service port (as per settings or dynamically assigned)
27
+ MONITORING_PORT = settings.get("MONITORING_PORT", 0) # Monitoring port (as per settings or dynamically assigned)
28
+ STORAGE_MNEMONIC = settings.get("STORAGE_MNEMONIC", "TCU") # Storage mnemonic (used in the HK filenames)
29
+
30
+ PROXY_TIMEOUT = 10
31
+
32
+ NUM_TSM_FRAMES = 2
33
+ NUM_TSM_PROBES_PER_FRAME = 22
34
+ NUM_M2MD_POSITIONS = 18
35
+
36
+ NUM_M2MD_AXES = 3
37
+
38
+
39
+ class TcuMode(IntEnum):
40
+ """Ariel TCU operating modes.
41
+
42
+ The different TCU modes are:
43
+ - IDLE: Waiting for commands, minimum power consumption,
44
+ - BASE: HK + TSM circuitry on,
45
+ - CALIBRATION: HK + TSM + M2MD circuitry on.
46
+ """
47
+
48
+ # Adopted from Vladimiro's code
49
+
50
+ IDLE = 0x0000 # Waiting for commands, minimum power consumption
51
+ BASE = 0x0001 # HK + TSM circuitry on
52
+ CALIBRATION = 0x0003 # HK + TSM + M2MD circuitry on
53
+
54
+
55
+ class MotorState(IntEnum):
56
+ """State of the M2MD motors.
57
+
58
+ The different motor states are:
59
+ - STANDBY: No motion,
60
+ - OPERATION: Motor moving.
61
+ """
62
+
63
+ # Adopted from Vladimiro's code
64
+ # RD01 -> Sect. 5.1
65
+
66
+ STANDBY = 0x0001 # No motion
67
+ OPERATION = 0x0010 # Motor moving
68
+
69
+
70
+ AXIS_VELOCITY = {
71
+ 1: 0x5DC0, # Writing @ 1Hz
72
+ 2: 0x2EE0, # Writing @ 2Hz
73
+ 4: 0x1770, # Writing @ 4Hz
74
+ 8: 0x0BB8, # Writing @ 8Hz
75
+ 16: 0x05DC, # Writing @ 16Hz
76
+ 32: 0x02EE, # Writing @ 32Hz
77
+ 64: 0x0177, # Writing @ 64Hz
78
+ # For testing purposes
79
+ 75: 0x0140, # Writing @ 75Hz
80
+ 80: 0x012C, # Writing @ 80Hz
81
+ 96: 0x00FA, # Writing @ 96Hz
82
+ }
83
+
84
+
85
+ # To interpret the error code values
86
+ # Taken from RD02 -> Table 3
87
+
88
+ ERROR_CODES = {
89
+ 0x00: "No errors",
90
+ 0x01: "Command not executed",
91
+ 0x02: "Command error",
92
+ 0x03: "Command not allowed",
93
+ 0x04: "Destination address error",
94
+ 0x05: "Protocol ID error",
95
+ 0x06: "Source address error",
96
+ 0x07: "Unexpected sequence error",
97
+ 0x08: "Address error",
98
+ 0x09: "Data length error",
99
+ 0x0A: "CRC error",
100
+ 0x0B: "Parameter values error",
101
+ 0x0C: "Bad mode",
102
+ 0x0D: "Timeout",
103
+ 0x0E: "Unknown",
104
+ 0x0F: "Extended error, see cargo",
105
+ }