-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-ng.tcl
More file actions
executable file
·4084 lines (3149 loc) · 118 KB
/
css-ng.tcl
File metadata and controls
executable file
·4084 lines (3149 loc) · 118 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/wish
################################################################################
proc HelpExit {} {
puts "\n Usage: css-ng.tcl \[LOCATION\] \[-sim\] \[-eng\] \[Hz\]\n"
puts " Optional args: \[LOCATION\] can be 703, G96, I52, V06, E12 or 21-IN"
puts " \[-sim\] turns simulation mode ON"
puts " \[-eng\] turns engineering mode ON"
puts " \[-ver\] turns verbose output ON"
puts " \[Hz\] is the refresh rate, cycles per second (max. 5)\n"
puts " If a LOCATION is not defined, 703 is assumed.\n"
exit
}
################################################################################
proc NullRoutine {} {
global verbose
if {$verbose} {
puts "GUI: NullRoutine"
}
}
################################################################################
proc Time {} {
return [ clock clicks -milliseconds ]
}
################################################################################
proc ReportTime { t1 t2 str } {
puts "$str : [ expr {$t2 - $t1} ]"
}
################################################################################
proc ExitTCS {} {
global SIMULATION simpid gTCSConnected
set result [ MessBox "Exiting" "Note that closing the TCS GUI will NOT shut down the TCS.\n\nMake sure the telescope is properly stowed and shut down before leaving it unattended.\n\nContinue exiting the GUI?" yesno ]
if {$result == "NO"} {
return
}
# if we launched a simulator, then kill it:
if {$SIMULATION} {
set result [ MessBox "Simulation mode" "Also stop the TCS simulator?" yesno ]
if {$result == "YES"} {
catch { exec kill -9 $simpid }
catch { exec ./killsim.tcl }
}
}
# disconnect nicely from TCS before exiting:
if {$gTCSConnected} {
ToggleTelemetryGUI
after 100
}
exit
}
################################################################################
proc Deg2Rad { deg } {
global pi
set rad [ expr {($deg * $pi) / 180.0} ]
return $rad
}
################################################################################
proc Rad2Deg { rad } {
global pi
set deg [ expr {($rad/$pi) * 180.0} ]
return $deg
}
################################################################################
proc ConvertToTelem { sex } {
set telem [ string map { : "" } $sex ]
return $telem
}
################################################################################
proc sex2dec { sexvalue } {
scan $sexvalue {%3d:%2d:%4f} place1 place2 place3
set decval [expr {abs($place1) + $place2 / 60.0 + $place3 / 3600.0}]
if {[string index $sexvalue 0] == "-"} {
set decval [ expr {$decval * -1.0} ]
}
return $decval
}
################################################################################
proc ValidateCoords { inputRA inputDEC inputEpoch } {
# masterfully-crafted proc by E. Beshore, from aqutility.tcl
# would be even more masterful to allow integer seconds, instead of requiring sub-seconds...
# check out the RA syntax by matching it with a masterfully-crafted regular expression ;-)
set regexppat {[ ]*([0-1][0-9]|2[0-3])[ :;.\-*/+hH][0-5][0-9][ :;.\-*/+mM][0-5][0-9].[0-9][ sS]?[ ]*}
if {$inputRA == "" || ![regexp $regexppat $inputRA]} {
set message "Right Ascension must be specified and be of the form XX:XX:XX.X and must include leading zeros. Separators may include a single space, a character from the following: \":;.-*/+\", or H,M, or S as appropriate."
MessBox "Error" $message ok
return "ERR"
}
# now the DEC
set regexppat {[ ]*(\+|-)(90[ :;.\-*/+dD]00[ :;.\-*/+mM]00.0|[0-8][0-9][ :;.\-*/+dD][0-5][0-9][ :;.\-*/+mM][0-5][0-9].[0-9])[ sS]?[ ]*}
if {$inputDEC == "" || ![regexp $regexppat $inputDEC]} {
set message "Declination must be specified and be of the form \[+ or -\]XX:XX:XX.X and must include leading zeros. Separators may include a single space, a character from the following: \":;.-*/+\", or D,M, or S as appropriate."
MessBox "Error" $message ok
return "ERR"
}
# clean up epoch
set inputEpoch [string trim $inputEpoch " "]
# Match xxxx., xxxx.x or xxxx.xx
set regexppat {[0-9]{4}.[0-9]{0,2}}
if {$inputEpoch == "" || ![regexp $regexppat $inputEpoch]} {
set message "Epoch must be specified and be of the form XXXX.XX (e.g. 2000.00)."
MessBox "Error" $message ok
return "ERR"
}
# if user did not supply one or two trailing zeros, add them
if {[string length $inputEpoch] == 5} {
append inputEpoch "00"
} elseif {[string length $inputEpoch] == 6} {
append inputEpoch "0"
}
return "OK"
}
################################################################################
proc dec2sex { decvalue { decimalplaces 1 } } {
set isneg 0
if {$decvalue < 0.0 } {
set isneg 1
set decvalue [expr {$decvalue * -1}]
}
set place1 [expr {int($decvalue)}]
set decvalue [expr {$decvalue - $place1}]
set decvalue [expr {$decvalue * 60.0}]
set place2 [expr {int($decvalue)}]
set decvalue [expr {$decvalue - $place2}]
set place3 [expr {$decvalue * 60.0}]
set place1 [expr {$place1}]
# now build up the value
if {$isneg} {
set result [format {-%2.2d:%2.2d:%07.4f} $place1 $place2 $place3]
} else {
set result [format {%2.2d:%2.2d:%07.4f} $place1 $place2 $place3]
}
# we formatted to avoid round off, now trim to one decimal place
set len [string length $result]
set result [string range $result 0 [expr {$len - 5 + $decimalplaces}]]
return $result
}
################################################################################
proc DrawCircle { x y size color type width { tag "" } } {
global top
set r [ expr {$size / 2} ]
set x1 [ expr {$x - $r} ]
set y1 [ expr {$y - $r} ]
set x2 [ expr {$x + $r} ]
set y2 [ expr {$y + $r} ]
if {$type == "fill"} {
$top.radar create oval "$x1 $y1 $x2 $y2" -outline $color -fill $color -width $width -tags "$tag"
} elseif {$type == "dash"} {
$top.radar create oval "$x1 $y1 $x2 $y2" -outline $color -dash {.} -width $width -tags "$tag"
} else {
$top.radar create oval "$x1 $y1 $x2 $y2" -outline $color -width $width -tags "$tag"
}
}
################################################################################
proc GetRadarXY { az el { dome 0 } } {
# dome and telescope are on two different coordinate systems - telescope az, el
# is aligned with the radar, but the dome is offset to properly display relative
# offset between tel + dome due to rho/nu/phi values
global rcentx rcenty rwidth rheight rscale rborder dcentx dcenty
set r [ expr {(90 - $el) / $rscale} ]
set radaz [ Deg2Rad $az ]
set xoff [ expr {$r * sin($radaz)} ]
set yoff [ expr {$r * cos($radaz)} ]
if {!$dome} {
# to display E on left, use $rcentx - $xoff. E on right, $rcentx + $xoff
set x [ expr {$rcentx - $xoff} ]
set y [ expr {$rcenty - $yoff} ]
} else {
# to display E on left, use $dcentx - $xoff. E on right, $dcentx + $xoff
set x [ expr {$dcentx - $xoff} ]
set y [ expr {$dcenty - $yoff} ]
}
return "$x $y"
}
################################################################################
proc ShowRadar {} {
global rscale relevcolor rcentx rcenty top gTCSConnected rbackcolor rtextcolor
set radar $top.radar
$top.radar delete "elevation"
$top.radar delete "azimuth"
$top.radar delete "tick"
set color $relevcolor
set textcolor $rtextcolor
if {!$gTCSConnected} {
set color grey25
set textcolor $color
}
# draw elevation lines:
set elevations "90 60 50 40 30 20 0"
foreach r $elevations {
set size [ expr {int(2 * (90 - $r) / $rscale)} ]
set type "normal"
DrawCircle $rcentx $rcenty $size $color $type 1 "elevation"
}
# draw azimuth tick marks
for {set i 0} {$i < 360} {incr i 5} {
set tick 3
if {[ expr {$i % 30} ] == 0} {
set tick 10
}
set p1 [ GetRadarXY $i 0.5 ]
set p2 [ GetRadarXY $i $tick ]
$radar create line "$p1 $p2" -width 1 -fill $color -tags "tick"
}
# draw cardinal direction lines
set p1 [ GetRadarXY 0 0 ]
set p2 [ GetRadarXY 180 0 ]
$radar create line "$p1 $p2" -width 1 -fill $color -dash 5 -tags "azimuth"
set p1 [ GetRadarXY 90 0 ]
set p2 [ GetRadarXY 270 0 ]
$radar create line "$p1 $p2" -width 1 -fill $color -dash 5 -tags "azimuth"
# draw directional boxes w/ text:
set directions "{0 N} {90 E} {180 S} {270 W}"
set h [ expr {int(5 * (1/$rscale))} ]
set w [ expr {int(5 * (1/$rscale))} ]
foreach pair $directions {
set d [ lindex $pair 0 ]
set char [ lindex $pair 1 ]
set p1 [ GetRadarXY $d 0 ]
set p2 [ GetRadarXY $d 10 ]
set p2x [ lindex $p2 0 ]
set p2y [ lindex $p2 1 ]
set p2x1 [ expr {$p2x + $w} ]
set p2x2 [ expr {$p2x - $w} ]
set p2y1 [ expr {$p2y + $h} ]
set p2y2 [ expr {$p2y - $h} ]
$radar create rectangle "$p2x1 $p2y1 $p2x2 $p2y2" -width 1 -outline $color -fill $rbackcolor -tags "azimuth"
$radar create text $p2 -text $char -fill $textcolor -tags "azimuth"
}
}
################################################################################
proc FixRadar {} {
set radar [ BuildRadar ]
pack $radar
ShowDome current
ShowTel current
update idletasks
}
################################################################################
proc BuildRadar {} {
global top
global rwidth rheight rcentx rcenty rbackcolor rtextcolor relevcolor rscale
global rlimitcolor radarDisplayed
set radarDisplayed 1
set showlimits 0
set limitfile "ObsHorizon.tcl"
if {![ file isfile $limitfile ]} {
puts "GUI: Cannot find limits file '$limitfile'"
set showlimits 0
}
set showlimits 0
set radar $top.radar
if {[ winfo exists $radar ]} {
destroy $top.radar
}
canvas $radar -width $rwidth -height $rheight -background $rbackcolor
ShowRadar
# draw limits:
if {$showlimits} {
# we assume that LOCATION has already been set
source $limitfile
set entry [ lindex $HorizonList 0 ]
# "step" degree intervals to mark limits - must be between 1 and 15:
set step 3
set az1 [ lindex $entry 0 ]
set el1 [ lindex $entry 1 ]
foreach entry $HorizonList {
set az2 [ lindex $entry 0 ]
set el2 [ lindex $entry 1 ]
for {set i $az1} {$i <= $az2} {set i [ expr {$i + $step} ]} {
# first special case:
if {$az1 == $az2} {
continue
}
# i is az
set thisaz $i
# find interpolated elevation:
set thisel [ expr {($thisaz - $az1) * (($el2 - $el1)/($az2 - $az1)) + $el1} ]
set limxy [ GetRadarXY $thisaz $thisel ]
set limx [ lindex $limxy 0 ]
set limy [ lindex $limxy 1 ]
DrawCircle $limx $limy 2 $rlimitcolor "fill" 1 "limit"
}
set az1 $az2
set el1 $el2
}
}
# give the user a way to force a re-draw of the radar if things get messed up:
bind $radar <Button-1> { FixRadar }
return $radar
}
################################################################################
proc Refresh {} {
global refreshrate tcswait gTCSConnected verbose radarDisplayed gLatency refreshHertz
update idletasks
if {$radarDisplayed} {
UpdateRadar
}
if {!$gTCSConnected} {
if {$verbose} {
puts "GUI: called Refresh but leaving - no TCS connection"
}
return
}
if {[ info exists tcswait ]} {
after cancel $tcswait
}
UpdateStatus
if {$gTCSConnected} {
after $refreshrate [ set tcswait Refresh ]
} else {
after $refreshrate [ set tcswait NullRoutine ]
}
# periodically re-calibrate the latency:
if {$gLatency(count) == $gLatency(repeat)} {
set gLatency(calibrated) 0
set gLatency(count) 0
}
if {!$gLatency(calibrated)} {
set skipcount 5
set maxcount 10
# skip the first couple of calls:
if {$gLatency(count) == $skipcount} {
set gLatency(baseline) [ Time ]
}
if {$gLatency(count) == $maxcount} {
# ready to calibrate latency:
set gLatency(baseline2) [ Time ]
set targetrate [ expr {1000 / $refreshHertz * 1.0} ]
set requested [ expr {$targetrate * ($maxcount - $skipcount)} ]
set actual [ expr {$gLatency(baseline2) - $gLatency(baseline)} ]
set totalwait [ expr {$refreshrate * ($maxcount - $skipcount)} ]
set totalwork [ expr {$actual - $totalwait} ]
# set cyclework [ expr {$totalwork / ($maxcount - $skipcount)*1.0} ]
# puts $cyclework
set refreshrate [ expr {int(($requested - $totalwork)/(($maxcount - $skipcount)*1.0))} ]
# don't let refreshrate drop to zero
if {$refreshrate < 10} {
set refreshrate 10
}
set gLatency(count) 0
set gLatency(calibrated) 1
}
}
incr gLatency(count)
}
################################################################################
proc UpdateRadar {} {
ShowRadar
ShowDome "current"
ShowTel "current"
update idletasks
}
################################################################################
proc DumpTCS {} {
global gTCSFocus currentFocus
GetTelemetry
# limits?
set currentFocus $gTCSFocus
update idletasks
}
################################################################################
proc GetDome {} {
# DOME call returns 2 element list: autodome status and dome position
set pos [ SendCommand "DOME" ]
return $pos
}
################################################################################
proc GetDomePos {} {
# DOME call returns 2 element list: autodome status and dome position
set pos [ lindex [ SendCommand "DOME" ] 1 ]
return $pos
}
################################################################################
proc GetDomeParam {} {
# populate global variables that tracks telescope position within the dome
global domeConst dcentx dcenty rcentx rcenty dscale
set domestring [ SendCommand "DOME" "PARAM" ]
set domeConst(nu) [ lindex $domestring 4 ]
set domeConst(rho) [ lindex $domestring 5 ]
set domeConst(phi) [ lindex $domestring 6 ]
# calculate the center of the dome relative to telescope:
set elx [ expr {90 - abs(90 * $domeConst(rho))} ]
if {$domeConst(rho) < 0} {
set azx 270
} else {
set azx 90
}
set dcentx [ lindex [ GetRadarXY $azx $elx ] 0 ]
set ely [ expr {90 - abs(90 * $domeConst(phi))} ]
if {$domeConst(phi) < 0} {
set azy 0
} else {
set azy 180
}
set dcenty [ lindex [ GetRadarXY $azy $ely ] 1 ]
}
################################################################################
proc GetAutoDome {} {
# DOME call returns 2 element list: autodome status and dome position
# dome status: 0=autodome off, 1= autodome on, 2=user domegoto move
return [ lindex [ SendCommand "DOME" ] 0 ]
}
################################################################################
proc GetCorrection { corr { corrstring "" } } {
# returns 1 if requested correction is active, 0 if inactive. requesting "all"
# returns the full correction string from the TCS
# if corrstring is supplied, check the string, otherwise, ask the TCS
switch $corr {
"M" { set i 0 }
"P" { set i 1 }
"N" { set i 2 }
"A" { set i 3 }
"R" { set i 4 }
"F" { set i 5 }
"p" { set i 6 }
"+" { set i 7 }
"t" { set i 8 }
"o" { set i 9 }
"b" { set i 10 }
"all" {}
default { return "ERROR" }
}
if {$corrstring == ""} {
set corrstring [ SendCommand "CORRECTIONS" ]
}
if {$corr == "all"} {
return $corrstring
}
set trackbit [ string range $corrstring $i $i ]
if {$trackbit == $corr} {
return 1
}
return 0
}
################################################################################
proc DisEnableGUI { state } {
global top ebackcolor engineering gPaddleState
set lbg $ebackcolor
if {$state != "normal" && $state != "disabled"} {
puts "GUI: DisEnableGUI: invalid state '$state'"
return
}
set tel $top.telescope
set eng $top.engineering
set lbox $tel.list
set pad $top.pad
set buttons "bslew bstop bdome bfoc bdis btrack bpec bauto bdini bstow bload btelem binit bdstop bcat"
set entries "era edec eaz eel edome efoc"
set radios "rradec razel"
set labels "ldate lut lcut lloc llst lcdate lclst lha lcha lra lcra ldec lcdec lepo lcepo laz lcaz lel lcel lam lcam ldome lcdome lfoc lcfoc ldis ltrack lpec lauto ltelem lcat"
set listbox "list.head list.text"
if {$engineering} {
set engstring "lcom ecom lfeed"
foreach thing $engstring {
$eng.$thing config -state $state
}
}
set everything "$buttons $entries $radios $labels $listbox"
foreach thing $everything {
$tel.$thing config -state $state
}
if {$state == "disabled"} {
$tel.list.scroll config -command { NullRoutine }
} else {
$tel.list.scroll config -command "$tel.list.text yview"
}
update idletasks
# re-define the keyboard bindings:
KeyboardTraversal
}
################################################################################
proc ReturnMoveStatus {} {
# motion status is carried in gTCSmovestatus from aqtelemetry. It is an 8-bit int
# 64 = ??
# 32 = ??
# 16 = Derotator?
# 8 = Dome
# 4 = Focus
# 2 = Dec
# 1 = RA
global gTCSmovestatus
set ra 0
set dec 0
set focus 0
set dome 0
set int $gTCSmovestatus
if {$int >= 64} {
incr int -64
}
if {$int >= 32} {
incr int -32
}
if {$int >= 16} {
incr int -16
}
if {$int >= 8} {
set dome 1
incr int -8
}
if {$int >= 4} {
set focus 1
incr int -4
}
if {$int >= 2} {
set dec 1
incr int -2
}
if {$int >= 1} {
set ra 1
incr int -1
}
if {$int != 0} {
puts "GUI: problem parsing motion bits ('$int' != 0)"
}
return "$ra $dec $focus $dome"
}
################################################################################
proc UpdateStatus {} {
# global variables may automatically update status in labels - check acquisition code for examples
global gAutoDome top offcolor oncolor gMovemode
global currentFocus currentDome currentDate currentAirmass currentCorrections
global gTCSmovestatus gTCSConnected
global gTCSRAlimit gTCSDEClimit gTCSHorzlimit gTCSFocUplimit gTCSFocDnlimit gTCSSoftlimit gTCSDRlimit
global gTCSfocusstatus gTCSdomestatus gTCSRAstatus gTCSDECstatus gPaddleState gTCSDisabled
global motionRA motionDEC motionDome motionFoc currentGuide currentDrift currentBiasRA currentBiasDEC
set tel $top.telescope
set pad $top.pad
# parse "ALL" return from TCS: this handles RA, Dec, LST, LHA, UT time, move status, limits,
# disabled status and possibly focus?
DumpTCS
set currentDate [ SendCommand "DATE" ]
set corrstring [ GetCorrection "all" ]
set currentCorrections $corrstring
set biascheck [ GetCorrection "b" $corrstring ]
if {$biascheck} {
$pad.bbias config -state normal -text "STOP BIAS"
$pad.lcbira config -state active
$pad.lcbidec config -state active
} else {
$pad.bbias config -text "Apply Bias"
ColorButton $pad.bbias
if {$gPaddleState} {
$pad.lcbira config -state normal
$pad.lcbidec config -state normal
}
}
set currentDrift [ expr {int([ GetRate "drift" ])} ]
set currentGuide [ expr {int([ GetRate "guide" ])} ]
set currentBiasRA [ GetRate "biasra" ]
set currentBiasDEC [ GetRate "biasdec" ]
# colors of toggle buttons/labels:
# Enable/Disable:
# DISABSTAT is a made-up call to the TCS: we intercept it in aqtelemetry and turn it into a
# DISABLE request (not to be confused with a DISABLE command)
set gTCSDisabled [ SendCommand "DISABSTAT" ]
if {$gTCSDisabled == 1} {
set state active
set text "ENABLE"
set text2 "DISABLED"
} else {
set state normal
set text "DISABLE"
set text2 "ENABLED"
}
$tel.ldis config -state $state -text $text2
$tel.bdis config -text $text
# tracking:
set trackcheck [ GetCorrection "t" $corrstring ]
if {$trackcheck == 0} {
set text "OFF"
set state active
} else {
set state normal
set text "ON"
}
$tel.ltrack config -state $state -text $text
# PEC:
set peccheck [ SendCommand "PECSTAT" ]
if {$peccheck == 0} {
set state active
set text "OFF"
} elseif {$peccheck == 1} {
set state normal
set text "ON"
} elseif {$peccheck == 2} {
set state active
set text "TRAINING"
} elseif {$peccheck == 3} {
set state active
set text "INDEXING"
}
$tel.lpec config -state $state -text $text
# autodome:
set domestatus [ GetDome ]
set autocheck [ lindex $domestatus 0 ]
set currentDome [ format "%0.1f" [ lindex $domestatus 1 ] ]
if {$autocheck != 1} {
set state active
set text "OFF"
} else {
set state normal
set text "ON"
}
$tel.lauto config -state $state -text $text
# Autodome - disable dome rotation control if autodome is active (only if drives are enabled):
if {!$gTCSDisabled} {
if {$autocheck == 1} {
set state disabled
} else {
set state normal
}
} else {
set state disabled
}
$tel.bdome config -state $state
$tel.edome config -state $state
# in-position flags:
set motionstatus [ ReturnMoveStatus ]
set motionRA [ lindex $motionstatus 0 ]
set motionDEC [ lindex $motionstatus 1 ]
set motionFoc [ lindex $motionstatus 2 ]
set motionDome [ lindex $motionstatus 3 ]
# telescope:
if {$motionRA} {
set state active
} else {
set state normal
}
$tel.lcra config -state $state
if {$motionDEC} {
set state active
} else {
set state normal
}
$tel.lcdec config -state $state
# kind of redundant, but if ra or dec are moving, then by definition az and el are moving:
if {$motionDEC || $motionRA} {
$tel.lcaz config -state active
$tel.lcel config -state active
} else {
$tel.lcaz config -state normal
$tel.lcel config -state normal
}
# dome in-position
if {$motionDome} {
set state active
} else {
set state normal
}
$tel.lcdome config -state $state
# focus in-position
if {$motionFoc} {
set state active
} else {
set state normal
}
$tel.lcfoc config -state $state
# airmass warning:
if {$currentAirmass >= 2} {
set state active
} else {
set state normal
}
$tel.lcam config -state $state
# aqtelemetry updated limit bits, but we still need to check the limit override bit
set gTCSlimoverride [ SendCommand "LIMITINHIBIT" ]
# limit indicators:
if {$gTCSRAlimit || $gTCSDEClimit || $gTCSHorzlimit || $gTCSFocDnlimit || $gTCSFocUplimit || $gTCSSoftlimit || $gTCSDRlimit || $gTCSlimoverride} {
set text ""
set state active
append text "*** "
if {$gTCSRAlimit} {
append text "RA "
}
if {$gTCSDEClimit} {
append text "DEC "
}
if {$gTCSHorzlimit} {
append text "HORIZON "
}
if {$gTCSFocDnlimit} {
append text "FOC(-) "
}
if {$gTCSFocUplimit} {
append text "FOC(+) "
}
if {$gTCSSoftlimit} {
append text "SOFT "
}
if {$gTCSDRlimit} {
append text "ROT "
}
append text "LIMIT "
if {$gTCSlimoverride} {
append text "OVERRIDE "
}
append text " ***"
} else {
set state disabled
set text "TELESCOPE WITHIN LIMITS"
}
set width [ string length $text ]
$tel.llim config -state $state -text $text -width $width
# if telescope is disabled, disable other buttons too
if {$gTCSDisabled} {
set state disabled
set state2 active
} else {
set state normal
set state2 normal
}
set widgetlist "bslew bstop bstow era edec eaz eel rradec razel bdstop bfoc binit bdini efoc"
foreach w $widgetlist {
$tel.$w config -state $state
}
# move mode:
if {!$gTCSDisabled} {
if {$gMovemode == "azel"} {
set state1 "disabled"
set state2 "normal"
} else {
set state1 "normal"
set state2 "disabled"
}
$tel.era config -state $state1
$tel.edec config -state $state1
$tel.eaz config -state $state2
$tel.eel config -state $state2
}
# paddle availability depends on telescope being enabled and connected to TCS...will be checked in SetPaddle proc:
SetPaddle
update idletasks
}
################################################################################
proc ShowPaddle {} {
global paddleDisplayed
if {$paddleDisplayed} {
set paddleDisplayed 0
} else {
set paddleDisplayed 1
}
}
################################################################################
proc ShowDome { which } {
global rcentx rcenty top currentDome autoDomeTol movecolor rdomecolor
global motionDome gTCSConnected domeConst
global domewidth halfwidth
# this is expensive to draw...should only do it if we need to. add yet another global variable
# to indicate if we need to or not (check current=target?)
set currentlinewidth 1
set currcolor $rdomecolor
set dashwidth 5
# site-specific dome parameters like domewidth and halfwidth are calculated in the init proc
if {$which == "current"} {
if {![ info exists currentDome ] || $currentDome == ""} {
return
}
set pos $currentDome
set tags "currentdome"
if {$motionDome} {
set color $movecolor
set width 3
} else {
set color $currcolor
set width 2
}
} else {
puts "GUI: proc ShowDome bad arg '$which'"
return
}
# get points at horizon:
# get points beyond the radar screen:
set currxy1 [ GetRadarXY [ expr {$pos + $halfwidth} ] -90 1 ]
set currxy2 [ GetRadarXY [ expr {$pos - $halfwidth} ] -90 1 ]
# get points near (but not at) zenith:
set dome1 [ expr {$pos + 128} ]
set dome2 [ expr {$pos - 128} ]
if {$dome1 >= 360} { set dome1 [ expr {$dome1 - 360} ] } elseif {$dome1 < 0} { set dome1 [ expr {$dome1 + 360} ] }
if {$dome2 >= 360} { set dome2 [ expr {$dome2 - 360} ] } elseif {$dome2 < 0} { set dome2 [ expr {$dome2 + 360} ] }
set zdist [ expr {90 - $domewidth} ]
set currxy3 [ GetRadarXY $dome1 $zdist 1 ]
set currxy4 [ GetRadarXY $dome2 $zdist 1 ]
if {!$gTCSConnected} {
set color grey25
}
$top.radar delete $tags
$top.radar create line "$currxy1 $currxy3" -width $width -fill $color -tags $tags
$top.radar create line "$currxy3 $currxy4" -width $width -fill $color -tags $tags
$top.radar create line "$currxy4 $currxy2" -width $width -fill $color -tags $tags
}
################################################################################
proc ShowTel { which } {