symetrie-hexapod 2023.1.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.
@@ -0,0 +1,448 @@
1
+ """
2
+ A Graphical User Interface for monitoring and commanding the Symétrie ZONDA Hexapod.
3
+
4
+ Start the GUI from your terminal as follows:
5
+
6
+ zonda_ui [--type proxy|direct|simulator]
7
+
8
+ This GUI is based on the SYM_positioning application from Symétrie. The intent
9
+ is to provide operators a user interface which is platform independent, but
10
+ familiar.
11
+
12
+ The application is completely written in Python/Qt5 and can therefore run on any
13
+ platform that supports Python and Qt5.
14
+
15
+ """
16
+ import argparse
17
+ import logging
18
+ import multiprocessing
19
+ from pathlib import Path
20
+
21
+ import sys
22
+ import threading
23
+ from typing import List
24
+
25
+ multiprocessing.current_process().name = "zonda_ui"
26
+
27
+ import pyqtgraph as pg
28
+ from PyQt5.QtCore import QDateTime, QLockFile
29
+ from PyQt5.QtCore import Qt
30
+ from PyQt5.QtGui import QIcon
31
+ from PyQt5.QtWidgets import QApplication, QMessageBox
32
+ from PyQt5.QtWidgets import QFrame
33
+ from PyQt5.QtWidgets import QGroupBox
34
+ from PyQt5.QtWidgets import QHBoxLayout
35
+ from PyQt5.QtWidgets import QLabel
36
+ from PyQt5.QtWidgets import QLineEdit
37
+ from PyQt5.QtWidgets import QVBoxLayout
38
+ from PyQt5.QtWidgets import QWidget
39
+ from prometheus_client import start_http_server
40
+
41
+ from egse.gui import show_warning_message
42
+ from egse.gui.led import Indic
43
+ from egse.gui.states import States
44
+ from egse.gui.stripchart import StripChart
45
+ from egse.hexapod.symetrie.hexapod_ui import ActuatorStates
46
+ from egse.hexapod.symetrie.hexapod_ui import HexapodUIController
47
+ from egse.hexapod.symetrie.hexapod_ui import HexapodUIModel
48
+ from egse.hexapod.symetrie.hexapod_ui import HexapodUIView
49
+ from egse.hexapod.symetrie.zonda import ZondaController
50
+ from egse.hexapod.symetrie.zonda import ZondaProxy
51
+ from egse.hexapod.symetrie.zonda import ZondaSimulator
52
+ from egse.process import ProcessStatus
53
+ from egse.resource import get_resource
54
+ from egse.settings import Settings
55
+ from egse.system import do_every
56
+
57
+ MODULE_LOGGER = logging.getLogger(__name__)
58
+
59
+ # Status LEDs define the number of status leds (length of the list), the description and the
60
+ # default color when the LED is on.
61
+
62
+ STATUS_LEDS = [
63
+ ["Error", Indic.RED], # bit 0
64
+ ["System Initialized", Indic.GREEN], # bit 1
65
+ ["Control On", Indic.GREEN], # bit 2
66
+ ["In Position", Indic.GREEN], # bit 3
67
+ ["Motion Task Running", Indic.GREEN], # bit 4
68
+ ["Home Task Running", Indic.GREEN], # bit 5
69
+ ["Home Complete", Indic.GREEN], # bit 6
70
+ ["Home Virtual", Indic.GREEN], # bit 7
71
+ ["Phase Found", Indic.GREEN], # bit 8
72
+ ["Brake on", Indic.GREEN], # bit 9
73
+ ["Motion Restricted", Indic.RED], # bit 10
74
+ ["Power on Encoders", Indic.GREEN], # bit 11
75
+ ["Power on Limit switches", Indic.GREEN], # bit 12
76
+ ["Power on Drives", Indic.GREEN], # bit 13
77
+ ["Emergency Stop", Indic.RED], # bit 14
78
+ ]
79
+
80
+ # The index of the Control LED
81
+
82
+ CONTROL_ONOFF = 2
83
+
84
+ ACTUATOR_STATE_LABELS = [
85
+ "Error: ",
86
+ "Control On: ",
87
+ "In Position: ",
88
+ "Motion Task Running: ",
89
+ "Home task running: ",
90
+ "Home complete: ",
91
+ "Phase found: ",
92
+ "Brake on: ",
93
+ "Home HW input: ",
94
+ "Negative HW limit switch: ",
95
+ "Positive HW limit switch: ",
96
+ "SW limit reached: ",
97
+ "Following Error: ",
98
+ "Drive fault: ",
99
+ "Encoder error: ",
100
+ ]
101
+
102
+ SPECIFIC_POSITIONS = ["Position ZERO", "Position RETRACTED"]
103
+
104
+ GUI_SETTINGS = Settings.load("ZONDA GUI")
105
+
106
+ class TemperatureLog(QWidget):
107
+ """This Widget allows to view the temperature value of all six actuators."""
108
+ def __init__(self, temp: List[str] = None):
109
+ super().__init__()
110
+
111
+ self.stripchart = None
112
+
113
+ self.temperatures = temp
114
+
115
+ # Switch to using white background and black foreground for pyqtgraph stripcharts
116
+
117
+ pg.setConfigOption("background", "w")
118
+ pg.setConfigOption("foreground", "k")
119
+
120
+ vbox = QVBoxLayout()
121
+ vbox.addWidget(QLabel("Temperature values in C"))
122
+ vbox.setAlignment(Qt.AlignTop | Qt.AlignLeft)
123
+
124
+ self.create_temperature_stripchart_widget = self.create_temperature_stripchart()
125
+ vbox.addWidget(self.create_temperature_stripchart_widget)
126
+
127
+ self.create_temperature_box_widget = self.create_temperature_box()
128
+ vbox.addWidget(self.create_temperature_box_widget)
129
+
130
+ self.setLayout(vbox)
131
+
132
+ def create_temperature_box(self):
133
+ vbox = QVBoxLayout()
134
+ vbox.setSpacing(0)
135
+
136
+ for box in range(6):
137
+ wbox = QHBoxLayout()
138
+ wbox.setSpacing(0)
139
+ wbox.addWidget(QLabel(f"Temp.{box + 1}: "))
140
+ wbox.setSpacing(0)
141
+ editbox = QLineEdit()
142
+ editbox.setReadOnly(True)
143
+ editbox.setFixedSize(80, 20)
144
+ wbox.setSpacing(0)
145
+ wbox.addWidget(editbox)
146
+ wbox.setSpacing(0)
147
+ vbox.addLayout(wbox)
148
+ vbox.setSpacing(0)
149
+
150
+ create_temperature_box = QGroupBox()
151
+ create_temperature_box.setLayout(vbox)
152
+
153
+ return create_temperature_box
154
+
155
+ def create_temperature_stripchart(self):
156
+ self.stripchart = StripChart(
157
+ labels={"left": ("measure", "C"), "bottom": ("Time", "d hh:mm:ss")}
158
+ )
159
+ self.stripchart.setInterval(60 * 60 * 12) # 12h of data
160
+ self.stripchart.set_yrange(0, 40)
161
+
162
+ vbox = QVBoxLayout()
163
+ vbox.addStretch(1)
164
+ vbox.addWidget(self.stripchart)
165
+
166
+ create_temperature_stripchart = QGroupBox()
167
+ create_temperature_stripchart.setLayout(vbox)
168
+
169
+ return create_temperature_stripchart
170
+
171
+ class ZondaUIView(HexapodUIView):
172
+ def __init__(self):
173
+ super().__init__()
174
+
175
+ self.setWindowTitle("Hexapod ZONDA Controller")
176
+
177
+ self.actuator_states = ActuatorStates(labels=ACTUATOR_STATE_LABELS)
178
+
179
+ self.temperature_log = TemperatureLog()
180
+
181
+ self.temperature_values = self.temperature_log.create_temperature_box_widget
182
+ self.temperature_values = self.temperature_values.findChildren(QLineEdit)
183
+ for temp in range(len(self.temperature_values)):
184
+ self.temperature_values[temp].setText("0.00")
185
+
186
+ self.temperature_stripchart = self.temperature_log.create_temperature_stripchart_widget
187
+ self.temperature_stripchart = self.temperature_stripchart.findChildren(StripChart)
188
+ self.temperature_stripchart = self.temperature_stripchart[0]
189
+
190
+ self.init_gui()
191
+
192
+ def init_gui(self):
193
+
194
+ # The main frame in which all the other frames are located, the outer Application frame
195
+
196
+ app_frame = QFrame()
197
+ app_frame.setObjectName("AppFrame")
198
+
199
+ # The left part which shows the states and positions
200
+
201
+ status_frame = QFrame()
202
+ status_frame.setObjectName("StatusFrame")
203
+
204
+ # The right part which has tabs that allow settings, movements, maintenance etc.
205
+
206
+ tabs_frame = QFrame()
207
+ tabs_frame.setObjectName("TabsFrame")
208
+
209
+ # The states of the Hexapod (contains all the leds)
210
+
211
+ states_frame = QFrame()
212
+ states_frame.setObjectName("StatesFrame")
213
+
214
+ # The user, machine positions and actuator lengths
215
+
216
+ positions_frame = QFrame()
217
+ positions_frame.setObjectName("PositionsFrame")
218
+
219
+ hbox = QHBoxLayout()
220
+ vbox_left = QVBoxLayout()
221
+ vbox_right = QVBoxLayout()
222
+
223
+ self.createToolbar()
224
+ self.createStatusBar()
225
+
226
+ self.states = States(STATUS_LEDS)
227
+
228
+ user_positions_widget = self.createUserPositionWidget()
229
+ mach_positions_widget = self.createMachinePositionWidget()
230
+ actuator_length_widget = self.createActuatorLengthWidget()
231
+
232
+ vbox_right.addWidget(user_positions_widget)
233
+ vbox_right.addWidget(mach_positions_widget)
234
+ vbox_right.addWidget(actuator_length_widget)
235
+
236
+ positions_frame.setLayout(vbox_right)
237
+
238
+ vbox_left.addWidget(self.states)
239
+
240
+ states_frame.setLayout(vbox_left)
241
+
242
+ hbox.addWidget(states_frame)
243
+ hbox.addWidget(positions_frame)
244
+
245
+ status_frame.setLayout(hbox)
246
+
247
+ tabbed_widget = self.create_tabbed_widget()
248
+
249
+ hbox = QHBoxLayout()
250
+ hbox.addWidget(tabbed_widget)
251
+ tabs_frame.setLayout(hbox)
252
+
253
+ hbox = QHBoxLayout()
254
+ hbox.addWidget(status_frame)
255
+ hbox.addWidget(tabs_frame)
256
+
257
+ app_frame.setLayout(hbox)
258
+
259
+ self.setCentralWidget(app_frame)
260
+
261
+ def update_status_bar(self, message=None, mode=None, timeout=2000):
262
+ if message:
263
+ self.statusBar().showMessage(message, msecs=timeout)
264
+ if mode:
265
+ self.mode_label.setStyleSheet(
266
+ f"border: 0; " f"color: {'red' if 'Simulator' in mode else 'black'};"
267
+ )
268
+
269
+ self.mode_label.setText(f"mode: {mode}")
270
+ self.statusBar().repaint()
271
+
272
+ def updatePositions(self, userPositions, machinePositions, actuatorLengths):
273
+
274
+ if userPositions is None:
275
+ MODULE_LOGGER.warning("no userPositions passed into updatePositions(), returning.")
276
+ return
277
+
278
+ for upos in range(len(self.user_positions)):
279
+ try:
280
+ self.user_positions[upos][1].setText(f"{userPositions[upos]:10.4f}")
281
+ except IndexError:
282
+ MODULE_LOGGER.error(f"IndexError in user_positions, upos = {upos}")
283
+
284
+ if machinePositions is None:
285
+ MODULE_LOGGER.warning("no machinePositions passed into updatePositions(), returning.")
286
+ return
287
+
288
+ for mpos in range(len(self.mach_positions)):
289
+ self.mach_positions[mpos][1].setText(f"{machinePositions[mpos]:10.4f}")
290
+
291
+ if actuatorLengths is None:
292
+ MODULE_LOGGER.warning("no actuatorLengths passed into updatePositions(), returning.")
293
+ return
294
+
295
+ for idx, alen in enumerate(self.actuator_lengths):
296
+ alen[1].setText(f"{actuatorLengths[idx]:10.4f}")
297
+
298
+ def updateStates(self, states):
299
+
300
+ if states is None:
301
+ return
302
+
303
+ self.updateControlButton(states[CONTROL_ONOFF])
304
+ self.states.set_states(states)
305
+
306
+ def updateControlButton(self, flag):
307
+
308
+ self.control.set_selected(on=flag)
309
+
310
+ def updateTemperature(self, temp):
311
+ if temp is None:
312
+ MODULE_LOGGER.warning("no temperature passed into updateTemperature(), returning.")
313
+ return
314
+ else:
315
+ #TODO: How to add the 6 temperature values to the stripchart?
316
+ value = temp[0]
317
+ self.temperature_stripchart.update(QDateTime.currentMSecsSinceEpoch(), value)
318
+ for t in range(len(self.temperature_values)):
319
+ self.temperature_values[t].setText(f"{temp[t]:10.4f}")
320
+
321
+
322
+ class ZondaUIModel(HexapodUIModel):
323
+ def __init__(self, connection_type):
324
+
325
+ if connection_type == "proxy":
326
+ device = ZondaProxy()
327
+ elif connection_type == "direct":
328
+ device = ZondaController()
329
+ device.connect()
330
+ elif connection_type == "simulator":
331
+ device = ZondaSimulator()
332
+ else:
333
+ raise ValueError(
334
+ f"Unknown type of Hexapod implementation passed into the model: {connection_type}"
335
+ )
336
+
337
+ super().__init__(connection_type, device)
338
+
339
+ if device is not None:
340
+ MODULE_LOGGER.debug(f"Hexapod initialized as {device.__class__.__name__}")
341
+
342
+ def get_speed(self):
343
+ speed_settings = self.device.get_speed()
344
+ return speed_settings["vt"], speed_settings["vr"]
345
+
346
+ def get_temperature(self):
347
+ temp = self.device.get_temperature()
348
+ return temp
349
+
350
+
351
+ class ZondaUIController(HexapodUIController):
352
+ def __init__(self, model: ZondaUIModel, view: ZondaUIView):
353
+ super().__init__(model, view)
354
+
355
+ def update_values(self):
356
+
357
+ super().update_values()
358
+
359
+ # Add here any updates to ZONDA specific widgets
360
+
361
+ temp = self.model.get_temperature()
362
+ self.view.updateTemperature(temp)
363
+
364
+
365
+ def parse_arguments():
366
+ """
367
+ Prepare the arguments that are specific for this application.
368
+ """
369
+ parser = argparse.ArgumentParser()
370
+ parser.add_argument(
371
+ "--type",
372
+ dest="type",
373
+ action="store",
374
+ choices={"proxy", "simulator", "direct"},
375
+ help="Specify Hexapod implementation you want to connect to.",
376
+ default="proxy",
377
+ )
378
+ parser.add_argument(
379
+ "--profile",
380
+ default=False,
381
+ action="store_true",
382
+ help="Enable info logging messages with method profile information.",
383
+ )
384
+ return parser.parse_args()
385
+
386
+
387
+ def main():
388
+ lock_file = QLockFile(str(Path("~/zonda_ui.app.lock").expanduser()))
389
+
390
+ styles_location = get_resource(":/styles/default.qss")
391
+ app_logo = get_resource(":/icons/logo-zonda.svg")
392
+
393
+ args = list(sys.argv)
394
+ args[1:1] = ["-stylesheet", str(styles_location)]
395
+ app = QApplication(args)
396
+ app.setWindowIcon(QIcon(str(app_logo)))
397
+
398
+ if lock_file.tryLock(100):
399
+
400
+ process_status = ProcessStatus()
401
+
402
+ timer_thread = threading.Thread(target=do_every, args=(10, process_status.update))
403
+ timer_thread.daemon = True
404
+ timer_thread.start()
405
+
406
+ start_http_server(GUI_SETTINGS.METRICS_PORT)
407
+
408
+ args = parse_arguments()
409
+
410
+ if args.profile:
411
+ Settings.set_profiling(True)
412
+
413
+ if args.type == "proxy":
414
+ proxy = ZondaProxy()
415
+ if not proxy.ping():
416
+ description = "Could not connect to Hexapod Control Server"
417
+ info_text = (
418
+ "The GUI will start, but the connection button will show a disconnected state. "
419
+ "Please check if the Control Server is running and start the server if needed. "
420
+ "Otherwise, check if the correct HOSTNAME for the control server is set in the "
421
+ "Settings.yaml "
422
+ "configuration file."
423
+ )
424
+
425
+ show_warning_message(description, info_text)
426
+
427
+ view = ZondaUIView()
428
+ model = ZondaUIModel(args.type)
429
+ ZondaUIController(model, view)
430
+
431
+ view.show()
432
+
433
+ return app.exec_()
434
+ else:
435
+ error_message = QMessageBox()
436
+ error_message.setIcon(QMessageBox.Warning)
437
+ error_message.setWindowTitle("Error")
438
+ error_message.setText("The Zonda GUI application is already running!")
439
+ error_message.setStandardButtons(QMessageBox.Ok)
440
+
441
+ return error_message.exec()
442
+
443
+
444
+ if __name__ == "__main__":
445
+
446
+ logging.basicConfig(level=logging.DEBUG, format=Settings.LOG_FORMAT_FULL)
447
+
448
+ sys.exit(main())
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: symetrie-hexapod
3
+ Version: 2023.1.0
4
+ Summary: Symetrie Hexapod implementation for CGSE
5
+ License: Common-EGSE Software License Agreement
6
+ Requires-Dist: cgse-common
7
+ Requires-Dist: cgse-core
8
+ Requires-Dist: cgse-gui
9
+ Requires-Dist: cgse-coordinates
10
+ Requires-Dist: PyQt5
11
+
@@ -0,0 +1,24 @@
1
+ egse/hexapod/__init__.py,sha256=RY5DGMvjmnwUjHbwBqpQpTJlKDzCpevVS-wE3XjQIAE,917
2
+ egse/hexapod/symetrie/__init__.py,sha256=tBvWayu0AjipMlda-2mjs3Bi1U8tO8Xt0EVCPkX4y0g,5735
3
+ egse/hexapod/symetrie/alpha.py,sha256=d6D7mmApbW4sNKml4_KXH1kqWlGJT75Hywvbf0xwD5g,33739
4
+ egse/hexapod/symetrie/dynalpha.py,sha256=-_J1sC42Kn7dcW7vRdACLGjeZwbCOkNOzn3vystwDaM,55037
5
+ egse/hexapod/symetrie/hexapod_ui.py,sha256=JLUHYar7UwncmH7t-o6uTSLYNsMxOULmO9Q5CYgliLI,52532
6
+ egse/hexapod/symetrie/pmac.py,sha256=tvbLiFAwYrGieOmSx4kiXpEZnCkNXVeYJjo5pLz2nW0,30244
7
+ egse/hexapod/symetrie/pmac_regex.py,sha256=JdBrqhVrC4WngFx8gvuehCV8no7I2mpTwQhHVV3nVDE,2511
8
+ egse/hexapod/symetrie/puna.py,sha256=m30adbOCJylXsO8Iyk0y16R_jqcL71AyJey9JOtxVGM,40486
9
+ egse/hexapod/symetrie/puna.yaml,sha256=PECDOxzeQMsAgeYCR81dkY-R8x_d5lLqXjhLoEv2iag,8538
10
+ egse/hexapod/symetrie/puna_cs.py,sha256=SsW2lly1aJjz9ElIvC3WADbMZPLOjihfmZWXRQRRDEQ,5796
11
+ egse/hexapod/symetrie/puna_protocol.py,sha256=VfNvtS1BXq91LHiKDkCqhT2M9HIO9zg6bOdTzJAC23s,5082
12
+ egse/hexapod/symetrie/puna_ui.py,sha256=xxsYOkNyrb48J7cb9n2A-C8jy3aa3A_gxlwyhzYELK4,13579
13
+ egse/hexapod/symetrie/punaplus.py,sha256=H9hOF91RPjb4T1n7P7ucFiazYcfD7KaaxZzgvOKJrwg,3192
14
+ egse/hexapod/symetrie/zonda.py,sha256=3BXE_61bIXfUm_uVFAKXtXy7c4qBY_CyP5SuoUYz3PA,30161
15
+ egse/hexapod/symetrie/zonda.yaml,sha256=5dhW3mJAQBVcUzAcSwLN53YbpT1ItEpLLU95741psPc,18740
16
+ egse/hexapod/symetrie/zonda_cs.py,sha256=0aXfegg3m09od0vmgT7rpjbQ7ojz8KeH1xWbJl9-BcE,4753
17
+ egse/hexapod/symetrie/zonda_devif.py,sha256=hgrICQmZhAzkLCnDY-yahLo6N9Z-cZCc0CEgAwYN790,14765
18
+ egse/hexapod/symetrie/zonda_protocol.py,sha256=Dr8-J8_wzqP2MkJmnzACz3RVLJIJRTXtW_f17jwII68,4316
19
+ egse/hexapod/symetrie/zonda_ui.py,sha256=0x0K9GHwGDuDVFWsJr1-z2oJFlzQ1eBPHFHjjBOyVrA,14314
20
+ symetrie_hexapod-2023.1.0.dist-info/METADATA,sha256=NN1SFCyESbLhPNE9Wrf9S70gUTgOwvRM3VMy281HOcg,291
21
+ symetrie_hexapod-2023.1.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
22
+ symetrie_hexapod-2023.1.0.dist-info/entry_points.txt,sha256=Aj3G_yRA7QFeegaH7Vmjv6h7uyRwkllAtGVoyxQNnSw,241
23
+ symetrie_hexapod-2023.1.0.dist-info/top_level.txt,sha256=kKai1l5ns8L0l5J5wU01VKrxo3iW-Ck7TFq3ZJ96dOc,5
24
+ symetrie_hexapod-2023.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.3.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,11 @@
1
+ [cgse.service.plugins]
2
+ puna_cs = scripts.cgse_service_plugins:puna_cs
3
+
4
+ [cgse.version]
5
+ symetrie-hexapod = egse.plugins
6
+
7
+ [console_scripts]
8
+ puna_cs = egse.hexapod.symetrie.puna_cs:cli
9
+
10
+ [gui_scripts]
11
+ puna_ui = egse.hexapod.symetrie.puna_ui:main
@@ -0,0 +1 @@
1
+ egse