Commit c6881cf7bd17486761193917881ecf22a941e671
1 parent
2814501f
Exists in
master
Pad device GUI.
Showing
3 changed files
with
113 additions
and
13 deletions
Show diff stats
gui/pad_device/pad_device.py
... | ... | @@ -398,12 +398,39 @@ class Devicepad(): |
398 | 398 | else: |
399 | 399 | self._main.camera_acq_modpoi(exp, binning, side, fitsdark, self._visu1) |
400 | 400 | |
401 | - def pad_cbk_button_pushed(self, key): | |
402 | - print(f"Select command {key=}") | |
401 | + def pad_cbk_button_pushed(self, cmd): | |
402 | + #print(f"Select command {cmd=}") | |
403 | 403 | device = self._device |
404 | - res = device.commandstring(key) | |
404 | + component_name = cmd.split()[0] | |
405 | + #component = device.component(component_name) | |
406 | + res = device.commandstring(cmd) | |
407 | + #print(f"device.commandstring {res=}") | |
405 | 408 | self.pad_var_component[component_name].set(res) |
406 | 409 | |
410 | + def pad_cbk_button_param_pushed(self, cmd, widget, special_case): | |
411 | + #print(f"Select command {cmd=}") | |
412 | + device = self._device | |
413 | + component_name = cmd.split()[0] | |
414 | + component = device.component(component_name) | |
415 | + res = device.commandstring(cmd) | |
416 | + #print(f"device.commandstring {res=}") | |
417 | + if special_case == 1: | |
418 | + # - motion | |
419 | + msg = component.motion2string(res) | |
420 | + res = f"{msg} ({res})" | |
421 | + if special_case == 2: | |
422 | + # - status | |
423 | + msg = component.status2string(res) | |
424 | + res = f"{msg} ({res})" | |
425 | + widget.configure(text = res) | |
426 | + self.tkroot.update() | |
427 | + | |
428 | + def pad_cbk_devstatus(self): | |
429 | + if self._device.real: | |
430 | + msg = "Status mode real" | |
431 | + else: | |
432 | + msg = "Status mode simulation" | |
433 | + return msg | |
407 | 434 | |
408 | 435 | # ========================================== |
409 | 436 | # ========================================== |
... | ... | @@ -433,7 +460,7 @@ class Devicepad(): |
433 | 460 | max_height = 700 |
434 | 461 | if screen_height>max_height: |
435 | 462 | screen_height = max_height |
436 | - self.tkroot.geometry(str(screen_width)+"x"+str(screen_height)+"+0+0") | |
463 | + self.tkroot.geometry(str(int(0.8*screen_width))+"x"+str(int(0.8*screen_height))+"+0+0") | |
437 | 464 | self.tkroot.title("Device pad for "+ device.param['NAME']) |
438 | 465 | self.tkroot.protocol('WM_DELETE_WINDOW', self.pad_cbk_quit) |
439 | 466 | |
... | ... | @@ -462,6 +489,10 @@ class Devicepad(): |
462 | 489 | fontStyle_3 = tkFont.Font(family="Arial", size=10, weight="bold") |
463 | 490 | fontStyle_c3 = tkFont.Font(family="courier", size=10, weight="bold") |
464 | 491 | |
492 | + #s = ttk.Style() | |
493 | + #s.configure('TFrame', background='red') | |
494 | + #s.configure('Frame1.TFrame', background='blue') | |
495 | + | |
465 | 496 | # ===================================================== |
466 | 497 | # === All the tabs are in a X scrollable frame |
467 | 498 | # ===================================================== |
... | ... | @@ -475,6 +506,21 @@ class Devicepad(): |
475 | 506 | |
476 | 507 | # ===================================================== |
477 | 508 | # ===================================================== |
509 | + # Frame of Status | |
510 | + # ===================================================== | |
511 | + # ===================================================== | |
512 | + label = {} | |
513 | + | |
514 | + frame_status = tk.Frame(self.tkroot) | |
515 | + msg = self.pad_cbk_devstatus() | |
516 | + self.pad_var_status = tk.StringVar() | |
517 | + label['dev_status'] = tk.Label(frame_status, textvariable = self.pad_var_status, font=fontStyle_3) | |
518 | + label['dev_status'].pack(side = tk.LEFT) | |
519 | + self.pad_var_status.set(msg) | |
520 | + frame_status.pack(side = tk.TOP, anchor = tk.W) | |
521 | + | |
522 | + # ===================================================== | |
523 | + # ===================================================== | |
478 | 524 | # (100) Frame Pilot |
479 | 525 | # ===================================================== |
480 | 526 | # ===================================================== |
... | ... | @@ -492,11 +538,12 @@ class Devicepad(): |
492 | 538 | # ===================================================== |
493 | 539 | frame = {} |
494 | 540 | button = {} |
495 | - label = {} | |
496 | 541 | entry = {} |
497 | 542 | self.pad_var_component = {} |
543 | + kcol = 0 | |
498 | 544 | for kcomp, component_name in zip(kcomps, device.component_names): |
499 | - tabs[kcomp] = ttk.Frame(notebook) | |
545 | + kcol += 1 | |
546 | + tabs[kcomp] = ttk.Frame(notebook) # , style='Frame1.TFrame' | |
500 | 547 | component = device.component(component_name) |
501 | 548 | # --- |
502 | 549 | frame[kcomp] = tk.Frame(tabs[kcomp]) |
... | ... | @@ -538,7 +585,7 @@ class Devicepad(): |
538 | 585 | frame_tmp = tk.Frame(frame[kcomp]) |
539 | 586 | label[lab_comp_key] = tk.Label(frame_tmp, text = "Result", font=fontStyle_3) |
540 | 587 | label[lab_comp_key].pack(side = tk.LEFT) |
541 | - entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_component[component_name], font=fontStyle_3) | |
588 | + entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_component[component_name], font=fontStyle_3, width = 40) | |
542 | 589 | entry[lab_comp_key].pack(side = tk.LEFT) |
543 | 590 | frame_tmp.pack(side = tk.TOP, anchor = tk.W) |
544 | 591 | |
... | ... | @@ -565,32 +612,73 @@ class Devicepad(): |
565 | 612 | entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_binning, font=fontStyle_3) |
566 | 613 | entry[lab_comp_key].pack(side = tk.LEFT) |
567 | 614 | frame_tmp.pack(side = tk.TOP, anchor = tk.W) |
615 | + # --- | |
616 | + lab_comp_key = str(kcomp) + "_status" | |
617 | + frame_tmp = tk.Frame(frame[kcomp]) | |
618 | + cmd = cmd = f"{component_name} GET status" | |
619 | + button[lab_comp_key] = tk.Button(frame_tmp, text = "status", font=fontStyle_3) | |
620 | + button[lab_comp_key].pack(side = tk.LEFT) | |
621 | + entry[lab_comp_key] = tk.Label(frame_tmp, text = "Unknown", font=fontStyle_3) | |
622 | + entry[lab_comp_key].pack(side = tk.LEFT) | |
623 | + special_case = 2 | |
624 | + button[lab_comp_key].configure(command=functools.partial(self.pad_cbk_button_param_pushed, cmd, entry[lab_comp_key], special_case)) | |
625 | + frame_tmp.pack(side = tk.TOP, anchor = tk.W) | |
626 | + self.pad_cbk_button_param_pushed(cmd, entry[lab_comp_key], special_case) | |
627 | + | |
568 | 628 | if component.category == 'MountPointing': |
569 | 629 | # --- |
570 | 630 | val = component.command("GET", "target") |
571 | 631 | lab_comp_key = str(kcomp) + "_target" |
572 | 632 | self.pad_var_target = tk.StringVar() |
573 | - self.pad_var_target.set("RADEC 6h 30d") | |
633 | + target = "RADEC 6h 30d" | |
634 | + component.command("SET", "target", target) | |
635 | + self.pad_var_target.set(target) | |
574 | 636 | frame_tmp = tk.Frame(frame[kcomp]) |
575 | 637 | label[lab_comp_key] = tk.Label(frame_tmp, text = "Target", font=fontStyle_3) |
576 | 638 | label[lab_comp_key].pack(side = tk.LEFT) |
577 | 639 | entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_target, font=fontStyle_3) |
578 | 640 | entry[lab_comp_key].pack(side = tk.LEFT) |
579 | 641 | frame_tmp.pack(side = tk.TOP, anchor = tk.W) |
642 | + # --- | |
643 | + lab_comp_key = str(kcomp) + "_motion" | |
644 | + frame_tmp = tk.Frame(frame[kcomp]) | |
645 | + cmd = cmd = f"{component_name} GET motion" | |
646 | + button[lab_comp_key] = tk.Button(frame_tmp, text = "motion", font=fontStyle_3) | |
647 | + button[lab_comp_key].pack(side = tk.LEFT) | |
648 | + entry[lab_comp_key] = tk.Label(frame_tmp, text = "Unknown", font=fontStyle_3) | |
649 | + entry[lab_comp_key].pack(side = tk.LEFT) | |
650 | + special_case = 1 | |
651 | + button[lab_comp_key].configure(command=functools.partial(self.pad_cbk_button_param_pushed, cmd, entry[lab_comp_key], special_case)) | |
652 | + frame_tmp.pack(side = tk.TOP, anchor = tk.W) | |
653 | + self.pad_cbk_button_param_pushed(cmd, entry[lab_comp_key], special_case) | |
654 | + | |
580 | 655 | if component.category == 'DetectorFocuser': |
581 | 656 | # --- |
582 | 657 | val = component.command("GET", "target") |
583 | 658 | lab_comp_key = str(kcomp) + "_target" |
584 | 659 | self.pad_var_detectorfocuser_target = tk.DoubleVar() |
585 | - self.pad_var_detectorfocuser_target.set("1000") | |
660 | + target = float(val) | |
661 | + self.pad_var_detectorfocuser_target.set(target) | |
586 | 662 | frame_tmp = tk.Frame(frame[kcomp]) |
587 | 663 | label[lab_comp_key] = tk.Label(frame_tmp, text = "Target", font=fontStyle_3) |
588 | 664 | label[lab_comp_key].pack(side = tk.LEFT) |
589 | 665 | entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_detectorfocuser_target, font=fontStyle_3) |
590 | 666 | entry[lab_comp_key].pack(side = tk.LEFT) |
591 | 667 | frame_tmp.pack(side = tk.TOP, anchor = tk.W) |
668 | + # --- | |
669 | + lab_comp_key = str(kcomp) + "_motion" | |
670 | + frame_tmp = tk.Frame(frame[kcomp]) | |
671 | + cmd = cmd = f"{component_name} GET motion" | |
672 | + button[lab_comp_key] = tk.Button(frame_tmp, text = "motion", font=fontStyle_3) | |
673 | + button[lab_comp_key].pack(side = tk.LEFT) | |
674 | + entry[lab_comp_key] = tk.Label(frame_tmp, text = "Unknown", font=fontStyle_3) | |
675 | + entry[lab_comp_key].pack(side = tk.LEFT) | |
676 | + special_case = 1 | |
677 | + button[lab_comp_key].configure(command=functools.partial(self.pad_cbk_button_param_pushed, cmd, entry[lab_comp_key], special_case)) | |
678 | + frame_tmp.pack(side = tk.TOP, anchor = tk.W) | |
679 | + self.pad_cbk_button_param_pushed(cmd, entry[lab_comp_key], special_case) | |
592 | 680 | |
593 | - frame[kcomp].pack(side = tk.TOP, pady=5) | |
681 | + frame[kcomp].pack(side = tk.TOP, pady=5, anchor = tk.W) | |
594 | 682 | |
595 | 683 | # ===================================================== |
596 | 684 | # Pack frame pilot | ... | ... |
src/guitastro/component_detector_focuser.py
... | ... | @@ -109,7 +109,7 @@ class ComponentDetectorFocuser(ComponentDetectorFocuserException, Component, Gui |
109 | 109 | param["motion_simu"] = self.MOTION_STATE_UNKNOWN |
110 | 110 | param["motion_real"] = self.MOTION_STATE_UNKNOWN |
111 | 111 | param["unit"] = "inc" # inc, rot, lin, phy |
112 | - param["target"] = 0 # unit | |
112 | + param["target"] = (self._focuser_params["LIM_INF"]+self._focuser_params["LIM_SUP"])/2.0 # unit | |
113 | 113 | param["speed_slew"] = 100 # unit/s |
114 | 114 | self._queue.put(param) |
115 | 115 | time.sleep(0.02) # wait to be sure the thread has record the new value |
... | ... | @@ -245,6 +245,10 @@ class ComponentDetectorFocuser(ComponentDetectorFocuserException, Component, Gui |
245 | 245 | raise ComponentException(ComponentException.ERR_OPERATION_NOT_FOUND, msg) |
246 | 246 | # --- |
247 | 247 | if operation == "GOTO": |
248 | + # For real and simu | |
249 | + target = self.database.query('target') | |
250 | + if target == None: | |
251 | + raise ComponentException(ComponentException.ERR_TARGET_NOT_FOUND) | |
248 | 252 | result = self._do_goto(*args, **kwargs) |
249 | 253 | elif operation == "STOP": |
250 | 254 | result = self._do_stop(*args, **kwargs) | ... | ... |
src/guitastro/component_mount_pointing.py
... | ... | @@ -70,8 +70,9 @@ class ComponentMountPointingException(GuitastroException): |
70 | 70 | ERR_AXIS_SYMBOL_NOT_FOUND = 5 |
71 | 71 | ERR_SIMU_KEY_NOT_FOUND = 6 |
72 | 72 | ERR_REAL_READING_COORDINATES = 7 |
73 | + ERR_TARGET_NOT_FOUND = 8 | |
73 | 74 | |
74 | - errors = [""]*8 | |
75 | + errors = [""]*9 | |
75 | 76 | errors[ERR_POINTING_MUST_BE_STOPED] = "The pointing must be stoped before asking a motion" |
76 | 77 | errors[ERR_TARGET_OUTSIDE_LIMITS] = "The asked target is outside the limits" |
77 | 78 | errors[ERR_MOUNT_TYPE_NOT_SUPPORTED] = "The asked mount type is not supported" |
... | ... | @@ -80,6 +81,7 @@ class ComponentMountPointingException(GuitastroException): |
80 | 81 | errors[ERR_AXIS_SYMBOL_NOT_FOUND] = "Axis symbol not found" |
81 | 82 | errors[ERR_SIMU_KEY_NOT_FOUND] = "Key 'simu' not found" |
82 | 83 | errors[ERR_REAL_READING_COORDINATES] = "Problem during reading real coordinates (inc)" |
84 | + errors[ERR_TARGET_NOT_FOUND] = "Target key is not found in parameters" | |
83 | 85 | |
84 | 86 | |
85 | 87 | class ComponentMountPointing(ComponentMountPointingException, Component, GuitastroTools): |
... | ... | @@ -343,7 +345,10 @@ class ComponentMountPointing(ComponentMountPointingException, Component, Guitast |
343 | 345 | """ |
344 | 346 | operation = args[0].upper() |
345 | 347 | param = self.database.query() |
346 | - target = param['target'] | |
348 | + target = param.get('target') | |
349 | + if target == "": | |
350 | + print("*** STEP CMP 2050 ***") | |
351 | + | |
347 | 352 | # --- Read the start position |
348 | 353 | inc_start = self.read_inc() |
349 | 354 | #print(f"inc_start = {inc_start['simu']}") |
... | ... | @@ -534,6 +539,9 @@ class ComponentMountPointing(ComponentMountPointingException, Component, Guitast |
534 | 539 | kwargs['operation'] = operation |
535 | 540 | if operation == "GOTO": |
536 | 541 | # For real and simu |
542 | + target = self.database.query('target') | |
543 | + if target == None: | |
544 | + raise ComponentException(ComponentException.ERR_TARGET_NOT_FOUND) | |
537 | 545 | result = self._do_goto(*args, **kwargs) |
538 | 546 | elif operation == "TRAJECTORY": |
539 | 547 | # For simu only. Real is processed in _my_do | ... | ... |