-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2ndGenLocoControlStand.tcl
executable file
·1365 lines (1315 loc) · 60 KB
/
2ndGenLocoControlStand.tcl
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
#*****************************************************************************
#
# System :
# Module :
# Object Name : $RCSfile$
# Revision : $Revision$
# Date : $Date$
# Author : $Author$
# Created By : Robert Heller
# Created : Sun Jul 30 22:21:49 2017
# Last Modified : <191006.0844>
#
# Description
#
# Notes
#
# History
#
#*****************************************************************************
#
# Copyright (C) 2017 Robert Heller D/B/A Deepwoods Software
# 51 Locke Hill Road
# Wendell, MA 01379-9728
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#*****************************************************************************
#lappend auto_path [glob -nocomplain /usr/share/tcl*/tcllib*]
package require snit
package require struct::matrix
## Primitive types:
snit::listtype point -minlen 3 -maxlen 3 -type snit::double
snit::listtype pointlist -minlen 3 -type point
snit::integer cval -min 0 -max 255
snit::listtype color -minlen 3 -maxlen 3 -type cval
snit::enum direction -values {DX DY DZ}
## Generic solid cylinders
snit::type cylinder {
option -bottom -type point -readonly yes -default {0 0 0}
option -radius -type snit::double -readonly yes -default 1
option -height -type snit::double -readonly yes -default 1
option -color -type color -readonly yes -default {0 0 0}
option -direction -type direction -default DZ -readonly yes
variable index
typevariable _index 40
constructor {args} {
$self configurelist $args
set index $_index
incr _index
}
method print {{fp stdout}} {
puts $fp [eval [list format {DEFCOL %d %d %d}] $options(-color)]
puts $fp [format {C%d = P (%f %f %f) VAL (%f) %s} $index \
[lindex $options(-bottom) 0] \
[lindex $options(-bottom) 1] \
[lindex $options(-bottom) 2] \
$options(-radius) $options(-direction)]
puts $fp [format {b%d = PRISM C%d %f} $index $index $options(-height)]
}
typemethod validate {obj} {
if {[catch {$obj info type} thetype]} {
error "Not a $type: $obj"
} elseif {$thetype ne $type} {
error "Not a $type: $obj"
} else {
return $obj
}
}
}
snit::type PolySurface {
typevariable _index 20
option -rectangle -type snit::boolean -readonly yes -default no
option -cornerpoint -type point -readonly yes -default {0 0 0}
option -vec1 -type point -readonly yes -default {0 0 0}
option -vec2 -type point -readonly yes -default {0 0 0}
option -polypoints -type pointlist -readonly yes -default {{0 0 0} {0 0 0} {0 0 0}}
variable index
constructor {args} {
$self configurelist $args
set index $_index
incr _index
}
method print {{fp stdout}} {
if {$options(-rectangle)} {
set cpp [eval [list format {P(%f,%f,%f)}] $options(-cornerpoint)]
set v1 [eval [list format {D(%f,%f,%f)}] $options(-vec1)]
set v2 [eval [list format {D(%f,%f,%f)}] $options(-vec2)]
puts $fp [format {S%d = REC %s %s %s} $index $cpp $v1 $v2]
} else {
puts -nonewline $fp [format {S%d = POL} $index]
foreach p $options(-polypoints) {
puts -nonewline $fp [eval [list format { P(%f,%f,%f)}] $p]
}
puts $fp {}
}
return [format {S%d} $index]
}
typemethod validate {obj} {
if {[catch {$obj info type} thetype]} {
error "Not a $type: $obj"
} elseif {$thetype ne $type} {
error "Not a $type: $obj"
} else {
return $obj
}
}
}
snit::type PrismSurfaceVector {
typevariable _index 20
option -surface -type ::PolySurface -readonly yes -default {}
component surface
option -vector -type point -readonly yes -default {0 0 0}
option -color -type color -readonly yes -default {147 147 173}
variable index
constructor {args} {
$self configurelist $args
set index $_index
incr _index
set surface $options(-surface)
}
method print {{fp stdout}} {
puts $fp [eval [list format {DEFCOL %d %d %d}] $options(-color)]
set s [$surface print $fp]
set pr [format {B%d} $index]
puts $fp [eval [list format {B%d = PRISM %s D(%f,%f,%f)} $index $s] $options(-vector)]
return $pr
}
typemethod validate {obj} {
if {[catch {$obj info type} thetype]} {
error "Not a $type: $obj"
} elseif {$thetype ne $type} {
error "Not a $type: $obj"
} else {
return $obj
}
}
}
snit::type Sphere {
option -center -type point -readonly yes -default [list 0 0 0]
option -radius -type snit::double -default 0.0 -readonly yes
option -color -type color -readonly yes -default {147 147 173}
variable index
typevariable _index 60
constructor {args} {
$self configurelist $args
set index $_index
incr _index
}
method print {{fp stdout}} {
puts $fp [eval [list format {DEFCOL %d %d %d}] $options(-color)]
lassign $options(-center) X Y Z
puts $fp [format {B%d = SPH P (%f %f %f) %f} $index $X $Y $Z $options(-radius)]
}
}
snit::type GeometryFunctions {
pragma -hastypeinfo no -hastypedestroy no -hasinstances no
## Degrees to Radians
typemethod radians {degrees} {
return [expr {($degrees/180.0)*$::PI}]
}
## Compute the 3D point on a circle of a specified radius, at a specificed
## height at a specificed angle.
typemethod pointXdeltaatang {angle {dx 25} {z 0.0}} {
set theta [$type radians $angle]
return [list [expr {sin($theta) * $dx}] [expr {cos($theta) * $dx}] $z]
}
typemethod translate3D {pointsH point3d} {
set result [list]
foreach {dx dy dz} $point3d {break}
foreach p $pointsH {
foreach {x y z w} $p {break}
lappend result [list [expr {$x + $dx}] \
[expr {$y + $dy}] [expr {$z + $dz}] $w]
}
return $result
}
typemethod translate3D_point {originPoint DeltaPoint} {
#puts stderr [list *** $type translate3D_point $originPoint $DeltaPoint]
foreach {dx dy dz} $DeltaPoint {break}
foreach {x y z} $originPoint {break}
set result [list [expr {$x + $dx}] [expr {$y + $dy}] [expr {$z + $dz}]]
#puts stderr [list *** $type translate3D_point result is $result]
return $result
}
typemethod rotateZAxis {pointsH theta_rads} {
#puts stderr [list *** $type rotateZAxis $pointsH $theta_rads]
set p 4
set n [llength $pointsH]
set m 4
#puts stderr "*** $type rotateZAxis: p = $p, n = $n, m = $m"
set rmat [::struct::matrix]
$rmat deserialize [list $m $p [list \
[list \
[expr {cos($theta_rads)}] \
[expr {-sin($theta_rads)}] \
0 0] \
[list \
[expr {sin($theta_rads)}] \
[expr {cos($theta_rads)}] \
0 0] \
{0 0 1 0} {0 0 0 1}]]
#puts stderr [list *** $type rotateZAxis: rmat = [$rmat serialize]]
set pointsMat [::struct::matrix]
$pointsMat deserialize [list $n $m $pointsH]
#puts stderr [list *** $type rotateZAxis: pointsMat = [$pointsMat serialize]]
set resultMat [::struct::matrix]
$resultMat deserialize [list $n $p {}]
#puts stderr [list *** $type rotateZAxis: resultMat = [$resultMat serialize]]
for {set i 0} {$i < $n} {incr i} {
for {set j 0} {$j < $p} {incr j} {
$resultMat set cell $j $i 0.0
#puts stderr [list *** $type rotateZAxis: resultMat = [$resultMat serialize]]
for {set k 0} {$k < $m} {incr k} {
#puts stderr "*** $type rotateZAxis: \[\$resultMat get cell $j $i\] = [$resultMat get cell $j $i]"
#puts stderr "*** $type rotateZAxis: \[\$pointsMat get cell $k $i\] = [$pointsMat get cell $k $i]"
#puts stderr "*** $type rotateZAxis: \[\$rmat get cell $k $j\] = [$rmat get cell $k $j]"
set p1 [expr {[$pointsMat get cell $k $i] * \
[$rmat get cell $k $j]}]
#puts stderr "*** $type rotateZAxis: p1 = $p1"
#snit::double validate $p1
set p2 [$resultMat get cell $j $i]
#snit::double validate $p2
$resultMat set cell $j $i [expr {$p2 + $p1}]
}
}
}
set result [lindex [$resultMat serialize] 2]
#puts stderr [list *** $type rotateZAxis: result is $result]
$rmat destroy
$pointsMat destroy
$resultMat destroy
return $result
}
typemethod rotateZAxis_point {originPoint theta_rads} {
#puts stderr [list *** $type rotateZAxis_point $originPoint $theta_rads]
return [lindex [$type StripHomogenous [$type rotateZAxis \
[list [list \
[lindex $originPoint 0] \
[lindex $originPoint 1] \
[lindex $originPoint 2] 1.0]] \
$theta_rads]] 0]
}
typemethod StripHomogenous {pointsH} {
set result [list]
foreach pH $pointsH {
lappend result [lrange $pH 0 end-1]
}
return $result
}
}
## Compute 3.14259...
global PI
set PI [expr {acos(0)*2}]
snit::type RL6435 {
constructor {args} {
}
method OutsideLength {} {return 150}
method OutsideWidth {} {return 100}
method InsideBoxLength {} {return 146}
method InsideBoxWidth {} {return 96}
method _holeCenterLength {} {return 132}
method _holeCenterWidth {} {return 82}
method _insideLength {} {return 142.73}
method _insideWidth {} {return 92.73}
}
snit::type RL6555 {
constructor {args} {
}
method OutsideLength {} {return 175}
method OutsideWidth {} {return 125}
method InsideBoxLength {} {return 166.79}
method InsideBoxWidth {} {return 116.79}
method _holeCenterLength {} {return 154}
method _holeCenterWidth {} {return 104}
method _insideLength {} {return 166.73}
method _insideWidth {} {return 116.73}
}
snit::type RL6685 {
constructor {args} {
}
method OutsideLength {} {return 200}
method OutsideWidth {} {return 149.93}
method InsideBoxLength {} {return 190.22}
method InsideBoxWidth {} {return 140.22}
method _holeCenterLength {} {return 178}
method _holeCenterWidth {} {return 128}
method _insideLength {} {return 191.73}
method _insideWidth {} {return 141.73}
}
snit::enum BoxType -values {RL6435 RL6555 RL6685}
snit::type OrignalLid {
component _boxtype
delegate method * to _boxtype
component _l1
component _l2
component _h1
component _h2
component _h3
component _h4
option -origin -type point -readonly yes -default [list 0 0 0]
option -boxtype -type BoxType -readonly yes -default RL6435
typevariable _totalLidHeight -7
typevariable _lidThickness -2.50
method LidThickness {} {return $_lidThickness}
typevariable _lidHeight -2.0
typevariable _holeDiameter 3
method TotalLidHeight {} {return $_totalLidHeight}
constructor {args} {
$self configurelist $args
switch $options(-boxtype) {
RL6435 {
install _boxtype using RL6435 ${selfns}_boxtype
}
RL6555 {
install _boxtype using RL6555 ${selfns}_boxtype
}
RL6685 {
install _boxtype using RL6685 ${selfns}_boxtype
}
}
lassign [$self cget -origin] oX oY oZ
install _l1 using PrismSurfaceVector ${selfns}_l1 \
-surface [PolySurface create ${selfns}_l1_surf -rectangle yes \
-cornerpoint [list $oX $oY $oZ] \
-vec1 [list [$_boxtype OutsideWidth] 0 0] \
-vec2 [list 0 [$_boxtype OutsideLength] 0]] \
-vector [list 0 0 [expr {$_totalLidHeight - $_lidHeight}]] \
-color {90 90 90}
set innerX [expr {$oX + (([$_boxtype OutsideWidth] - \
[$_boxtype _insideWidth])/2.0)}]
set innerY [expr {$oY + (([$_boxtype OutsideLength] - \
[$_boxtype _insideLength])/2.0)}]
set innerZ [expr {$oZ + ($_totalLidHeight - $_lidHeight)}]
install _l2 using PrismSurfaceVector ${selfns}_l2 \
-surface [PolySurface create ${selfns}_l2_surf -rectangle yes \
-cornerpoint [list $innerX $innerY $innerZ] \
-vec1 [list [$_boxtype _insideWidth] 0 0] \
-vec2 [list 0 [$_boxtype _insideLength] 0]] \
-vector [list 0 0 $_lidHeight] \
-color {190 190 190}
set h1X [expr {$oX + (([$_boxtype OutsideWidth] - \
[$_boxtype _holeCenterWidth])/2.0)}]
set h1Y [expr {$oY + (([$_boxtype OutsideLength] - \
[$_boxtype _holeCenterLength])/2.0)}]
install _h1 using cylinder ${selfns}_h1 \
-bottom [list $h1X $h1Y $oZ] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $_totalLidHeight \
-color {255 255 255}
set h2X [expr {$h1X + [$_boxtype _holeCenterWidth]}]
set h2Y $h1Y
install _h2 using cylinder ${selfns}_h2 \
-bottom [list $h2X $h2Y $oZ] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $_totalLidHeight \
-color {255 255 255}
set h3X $h2X
set h3Y [expr {$h2Y + [$_boxtype _holeCenterLength]}]
install _h3 using cylinder ${selfns}_h3 \
-bottom [list $h3X $h3Y $oZ] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $_totalLidHeight \
-color {255 255 255}
set h4X [expr {$h3X - [$_boxtype _holeCenterWidth]}]
set h4Y $h3Y
install _h4 using cylinder ${selfns}_h4 \
-bottom [list $h4X $h4Y $oZ] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $_totalLidHeight \
-color {255 255 255}
}
method print {{fp stdout}} {
$_l1 print $fp
$_l2 print $fp
$_h1 print $fp
$_h2 print $fp
$_h3 print $fp
$_h4 print $fp
}
}
snit::enum Orient -values {horizontal vertical}
snit::type Slot {
option -origin -type point -default {0 0 0} -readonly yes
option -width -type snit::double -default 0.0 -readonly yes
option -length -type snit::double -default 0.0 -readonly yes
option -depth -type snit::double -default 0.0 -readonly yes
option -orientation -type Orient -default horizontal -readonly yes
component _object
delegate method print to _object
constructor {args} {
$self configurelist $args
lassign [$self cget -origin] X Y Z
set L [$self cget -length]
set W [$self cget -width]
set D [$self cget -depth]
switch [$self cget -orientation] {
horizontal {
set corner [list [expr {$X - ($L / 2.0)}] [expr {$Y - ($W / 2.0)}] $Z]
set v1 [list $L 0 0]
set v2 [list 0 $W 0]
}
vertical {
set corner [list [expr {$X - ($W / 2.0)}] [expr {$Y - ($L / 2.0)}] $Z]
set v1 [list $W 0 0]
set v2 [list 0 $L 0]
}
}
#puts stderr "*** $type create $self: X: $X, Y: $Y, Z: $Z, L: $L, W: $W, D: $D"
#puts stderr "*** $type create $self: corner: $corner, v1: $v1, v2: $v2"
install _object using PrismSurfaceVector ${selfns}_object \
-surface [PolySurface create ${selfns}_object_surf -rectangle yes \
-cornerpoint $corner -vec1 $v1 -vec2 $v2] \
-vector [list 0 0 $D] -color {255 255 255}
}
}
snit::macro XYHelpers {} {
method _3DPoint {XY {ZZ {}}} {
lassign $XY x y
lassign [$self cget -origin] X Y Z
if {$ZZ ne {}} {set Z $ZZ}
return [list [expr {$X + $x}] [expr {$Y + $y}] $Z]
}
method _3DPoly {XYpoly {ZZ {}}} {
set result [list]
foreach XY $XYpoly {
lappend result [$self _3DPoint $XY $ZZ]
}
return $result
}
}
snit::type ButtonDisplayBoard {
component _board
component _mh1
component _mh2
component _mh3
component _mh4
typemethod Length {} {return 57.15}
typemethod Width {} {return 40.64}
typevariable _boardMHXY {{3.81 53.34} {3.81 3.81} {36.83 3.81} {36.83 53.34}}
typevariable _holeDiameter 2.5
typevariable _displayCutoutCornerXY {6.35 29.845}
typevariable _displayCutoutCornerWidth 29.845
typevariable _displayCutoutCornerLength 11.43
typevariable _displayMountingHolesXY {{6.604 27.305} {6.604 43.815} {36.576 27.305} {36.576 43.815}}
typevariable _displayMountingHoleDiameter 2.3
typevariable _buttonHolesXY {{11.43 52.07} {7.62 19.05} {16.51 19.05}
{25.4 19.05} {34.29 19.05}}
typevariable _buttonHoleDiameter 5.08
typevariable _statusLEDHoleXY {22.86 50.8}
typevariable _statusLEDHoleDiameter 5
option -origin -type point -readonly yes -default [list 0 0 0]
XYHelpers
constructor {args} {
$self configurelist $args
install _board using PrismSurfaceVector ${selfns}_board \
-surface [PolySurface create ${selfns}_board_surf -rectangle yes \
-cornerpoint [$self cget -origin] \
-vec1 [list [$type Width] 0 0] \
-vec2 [list 0 [$type Length] 0]] \
-vector [list 0 0 1.5875] -color {0 255 0}
set Z [lindex [$self cget -origin] 2]
for {set i 1} {$i <= 4} {incr i} {
set _mh$i [$self mountingHole ${selfns}_mh$i $i $Z 1.5875]
}
}
method print {{fp stdout}} {
$_board print $fp
for {set i 1} {$i <= 4} {incr i} {
[set _mh$i] print $fp
}
}
method mountingHole {name i base height} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_boardMHXY [expr {$i - 1}]] $base] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
method standoff {name i base height {diameter 6}} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_boardMHXY [expr {$i - 1}]] $base] \
-radius [expr {$diameter / 2.0}] \
-height $height -color {255 255 255}]
}
method buttonHole {name i base height} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_buttonHolesXY [expr {$i - 1}]] $base] \
-radius [expr {$_buttonHoleDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
method statusLEDHole {name base height} {
return [cylinder $name \
-bottom [$self _3DPoint $_statusLEDHoleXY $base] \
-radius [expr {$_statusLEDHoleDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
method displayCutoutHole {name base height} {
return [PrismSurfaceVector ${name} \
-surface [PolySurface create ${name}_surf -rectangle yes \
-cornerpoint [$self _3DPoint $_displayCutoutCornerXY $base] \
-vec1 [list $_displayCutoutCornerWidth 0 0] \
-vec2 [list 0 $_displayCutoutCornerLength 0]] \
-vector [list 0 0 $height] -color {255 255 255}]
}
method displayMountingHole {name i base height} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_displayMountingHolesXY [expr {$i - 1}]] $base] \
-radius [expr {$_displayMountingHoleDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
}
snit::type ButtonLEDBoard {
component _board
component _mh1
component _mh2
component _mh3
component _mh4
typemethod Length {} {return 67.31}
typemethod Width {} {return 73.660}
typevariable _boardMHXY {{3.175 23.495} {3.175 64.135} {70.485 23.495}
{70.485 64.135}}
typevariable _holeDiameter 2.5
typevariable _buttonHoleX0org 6.35
typevariable _buttonHoleX1org 5.715
typevariable _buttonHoleY 6.985
typevariable _holeDeltaX 8.89
typevariable _buttonHoleDiameter 5.08
typevariable _LEDHoleX0org 5.08
typevariable _LEDHoleX1org 6.985
typevariable _LEDHoleDeltaX
typevariable _LEDHoleY 17.145
typevariable _LEDHoleDiameter 5
typevariable _buttonHoleAndLEDCount 8
option -board0 -type snit::boolean -default yes -readonly yes
option -origin -type point -readonly yes -default [list 0 0 0]
XYHelpers
constructor {args} {
$self configurelist $args
install _board using PrismSurfaceVector ${selfns}_board \
-surface [PolySurface create ${selfns}_board_surf -rectangle yes \
-cornerpoint [$self cget -origin] \
-vec1 [list [$type Width] 0 0] \
-vec2 [list 0 [$type Length] 0]] \
-vector [list 0 0 1.5875] -color {0 255 0}
set Z [lindex [$self cget -origin] 2]
for {set i 1} {$i <= 4} {incr i} {
set _mh$i [$self mountingHole ${selfns}_mh$i $i $Z 1.5875]
}
}
method print {{fp stdout}} {
$_board print $fp
for {set i 1} {$i <= 4} {incr i} {
[set _mh$i] print $fp
}
}
method mountingHole {name i base height} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_boardMHXY [expr {$i - 1}]] $base] \
-radius [expr {$_holeDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
method standoff {name i base height {diameter 6}} {
return [cylinder $name \
-bottom [$self _3DPoint [lindex $_boardMHXY [expr {$i - 1}]] $base] \
-radius [expr {$diameter / 2.0}] \
-height $height -color {255 255 255}]
}
method buttonHole {name i base height} {
lassign [$self cget -origin] X Y Z
if {[$self cget -board0]} {
set Xoff [expr {$_buttonHoleX0org + (($i-1)*$_holeDeltaX)}]
} else {
set Xoff [expr {$_buttonHoleX1org + (($i-1)*$_holeDeltaX)}]
}
return [cylinder $name \
-bottom [list [expr {$X + $Xoff}] [expr {$Y + $_buttonHoleY}] $base] \
-radius [expr {$_buttonHoleDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
method LEDHole {name i base height} {
lassign [$self cget -origin] X Y Z
if {[$self cget -board0]} {
set Xoff [expr {$_LEDHoleX0org + (($i-1)*$_holeDeltaX)}]
} else {
set Xoff [expr {$_LEDHoleX1org + (($i-1)*$_holeDeltaX)}]
}
return [cylinder $name \
-bottom [list [expr {$X + $Xoff}] [expr {$Y + $_LEDHoleY}] $base] \
-radius [expr {$_LEDHoleDiameter / 2.0}] \
-height $height -color {255 255 255}]
}
}
snit::type Mech_Encoder_25L {
option -origin -type point -default {0 0 0} -readonly yes
option -bracketthick -type snit::double -default 0 -readonly yes
component _body
component _bushing
component _shaft
component _noturn
component _circuitBoard
typevariable _bodyWidth 23.5
typevariable _bodyHeight 21.97
typevariable _bodyDepth 8.71
typevariable _bushingDiameter [expr {(3.0/8.0)*25.4}]
typevariable _bushingLength 6.35
typevariable _noTurnXoff 10.16
typevariable _noTurnDia 3.05
typevariable _shaftDiameter 6.35
typevariable _shaftLength 12.7
typevariable _circuitBoardWidth 31.75
typevariable _circuitBoardLength 27.94
typevariable _circuitBoardXoff 16.51
typevariable _circuitBoardZoff 16.51
typevariable _circuitBoardThick [expr {(1.0/16.0)*25.4}]
constructor {args} {
$self configurelist $args
lassign [$self cget -origin] X Y Z
puts stderr "*** $type create $self: -origin is [$self cget -origin]"
set bodyCornerX [expr {$X - ($_bodyWidth / 2.0)}]
set bodyCornerY $Y
set bodyCornerZ [expr {$Z - ($_bodyHeight / 2.0)}]
puts stderr "*** $type create $self: bodyCornerX: $bodyCornerX"
puts stderr "*** $type create $self: bodyCornerY: $bodyCornerY"
puts stderr "*** $type create $self: bodyCornerZ: $bodyCornerZ"
install _body using PrismSurfaceVector ${selfns}_body \
-surface [PolySurface create ${selfns}_body_surf -rectangle yes \
-cornerpoint [list $bodyCornerX $bodyCornerY $bodyCornerZ] \
-vec1 [list $_bodyWidth 0 0] \
-vec2 [list 0 [expr {-1*$_bodyDepth}] 0]] \
-vector [list 0 0 $_bodyHeight] -color {0 0 0}
install _bushing using cylinder ${selfns}_bushing \
-bottom [list $X $Y $Z] \
-radius [expr {$_bushingDiameter / 2.0}] \
-height [expr {$_bushingLength}] \
-direction DY -color {200 200 200}
puts stderr "*** $type create $self: _bushing -bottom is [$_bushing cget -bottom]"
install _shaft using cylinder ${selfns}_shaft \
-bottom [list $X [expr {$Y + $_bushingLength}] $Z] \
-radius [expr {$_shaftDiameter / 2.0}] \
-height [expr {$_shaftLength}] \
-direction DY -color {240 240 240}
install _noturn using cylinder ${selfns}_noturn \
-bottom [list [expr {$X + $_noTurnXoff}] $Y $Z] \
-radius [expr {$_noTurnDia / 2.0}] \
-height [$self cget -bracketthick] \
-direction DY -color {255 255 255}
install _circuitBoard using PrismSurfaceVector ${selfns}_circuitBoard \
-surface [PolySurface create ${selfns}_circuitBoard_surf -rectangle yes \
-cornerpoint [list [expr {$X - $_circuitBoardXoff}] \
[expr {$bodyCornerY - $_bodyDepth}] \
[expr {$Z - $_circuitBoardZoff}]] \
-vec1 [list $_circuitBoardWidth 0 0] \
-vec2 [list 0 0 $_circuitBoardLength]] \
-vector [list 0 [expr {-1*$_circuitBoardThick}] 0] \
-color {0 255 0}
}
method print {{fp stdout}} {
$_body print $fp
$_bushing print $fp
$_shaft print $fp
$_noturn print $fp
$_circuitBoard print $fp
}
}
snit::type PEC12R {
option -origin -type point -default {0 0 0} -readonly yes
option -bracketthick -type snit::double -default 0 -readonly yes
component _body
component _bushing
component _shaft
component _circuitBoard
component _noturnHole
component _noturnStandoff
typevariable _bodyWidth 12.4
typevariable _bodyHeight 13.4
typevariable _bodyDepth 5.6
typevariable _bushingDiameter 9
typevariable _bushingLength 7
typevariable _shaftDiameter 6
typevariable _shaftLength [expr {25-(5.6+7)}]
typevariable _circuitBoardWidth 17.78
typevariable _circuitBoardLength 28.575
typevariable _circuitBoardOffset 8.89
typevariable _circuitBoardThick [expr {(1.0/16.0)*25.4}]
typevariable _circuitBoardNTZoff 10.795
typevariable _circuitBoardNTXoff 5.715
typevariable _circuitBoardNTHoleDiameter 2.5
typevariable _circuitBoardNTStandoffDiameter 5.08
constructor {args} {
$self configurelist $args
lassign [$self cget -origin] X Y Z
puts stderr "*** $type create $self: -origin is [$self cget -origin]"
set bodyCornerX [expr {$X - ($_bodyWidth / 2.0)}]
set bodyCornerY [expr {$Y + [$self cget -bracketthick]}]
set bodyCornerZ [expr {$Z - ($_bodyHeight / 2.0)}]
puts stderr "*** $type create $self: bodyCornerX: $bodyCornerX"
puts stderr "*** $type create $self: bodyCornerY: $bodyCornerY"
puts stderr "*** $type create $self: bodyCornerZ: $bodyCornerZ"
install _body using PrismSurfaceVector ${selfns}_body \
-surface [PolySurface create ${selfns}_body_surf -rectangle yes \
-cornerpoint [list $bodyCornerX $bodyCornerY $bodyCornerZ] \
-vec1 [list $_bodyWidth 0 0] \
-vec2 [list 0 [expr {$_bodyDepth}] 0]] \
-vector [list 0 0 $_bodyHeight] -color {0 0 0}
install _bushing using cylinder ${selfns}_bushing \
-bottom [list $X $bodyCornerY $Z] \
-radius [expr {$_bushingDiameter / 2.0}] \
-height [expr {-1*$_bushingLength}] \
-direction DY -color {200 200 200}
puts stderr "*** $type create $self: _bushing -bottom is [$_bushing cget -bottom]"
install _shaft using cylinder ${selfns}_shaft \
-bottom [list $X [expr {$bodyCornerY - $_bushingLength}] $Z] \
-radius [expr {$_shaftDiameter / 2.0}] \
-height [expr {-1*$_shaftLength}] \
-direction DY -color {240 240 240}
install _circuitBoard using PrismSurfaceVector ${selfns}_circuitBoard \
-surface [PolySurface create ${selfns}_circuitBoard_surf -rectangle yes \
-cornerpoint [list [expr {$X - $_circuitBoardOffset}] \
[expr {$bodyCornerY + $_bodyDepth}] \
[expr {$Z + $_circuitBoardOffset}]] \
-vec1 [list $_circuitBoardWidth 0 0] \
-vec2 [list 0 0 [expr {-1*$_circuitBoardLength}]]] \
-vector [list 0 [expr {$_circuitBoardThick}] 0] \
-color {0 255 0}
install _noturnHole using cylinder ${selfns}_noturnHole \
-bottom [list [expr {$X + $_circuitBoardNTXoff}] \
$bodyCornerY \
[expr {$Z - $_circuitBoardNTZoff}]] \
-radius [expr {$_circuitBoardNTHoleDiameter / 2.0}] \
-height [expr {-1*[$self cget -bracketthick]}] \
-direction DY -color {255 255 255}
install _noturnStandoff using cylinder ${selfns}_noturnStandoff \
-bottom [list [expr {$X + $_circuitBoardNTXoff}] \
$bodyCornerY \
[expr {$Z - $_circuitBoardNTZoff}]] \
-radius [expr {$_circuitBoardNTStandoffDiameter / 2.0}] \
-height $_bodyDepth \
-direction DY -color {255 255 255}
}
method print {{fp stdout}} {
$_body print $fp
$_bushing print $fp
$_shaft print $fp
$_circuitBoard print $fp
$_noturnHole print $fp
$_noturnStandoff print $fp
}
}
snit::enum Pot_450T328_Orientation -values {brake horn}
snit::type Pot_450T328 {
option -origin -type point -default {0 0 0} -readonly yes
option -bracketthick -type snit::double -default 0 -readonly yes
option -orientation -type Pot_450T328_Orientation -default brake -readonly yes
component _body
component _bushing
component _shaft
component _tab1
component _tab2
typevariable _bodyDiameter 23.8
typevariable _bodyDepth 11.3
typevariable _bushingDiameter [expr {(3.0/8.0)*25.4}]
typevariable _bushingLength 9.53
typevariable _shaftDiameter 6.35
typevariable _shaftLength [expr {25.4-9.53}]
typevariable _tabHoleDiameter 4.2
typevariable _tabXoffset 11.1
constructor {args} {
$self configurelist $args
lassign [$self cget -origin] X Y Z
puts stderr "*** $type create $self: -origin is [$self cget -origin]"
switch [$self cget -orientation] {
brake {
set Y [expr {$Y + [$self cget -bracketthick]}]
install _body using cylinder ${selfns}_body \
-bottom [list $X $Y $Z] \
-radius [expr {$_bodyDiameter / 2.0}] \
-height $_bodyDepth \
-direction DY -color {255 255 0}
install _bushing using cylinder ${selfns}_bushing \
-bottom [list $X $Y $Z] \
-radius [expr {$_bushingDiameter / 2.0}] \
-height [expr {-1*$_bushingLength}] \
-direction DY -color {200 200 200}
install _shaft using cylinder ${selfns}_shaft \
-bottom [list $X [expr {$Y - $_bushingLength}] $Z] \
-radius [expr {$_shaftDiameter / 2.0}] \
-height [expr {-1*$_shaftLength}] \
-direction DY -color {240 240 240}
install _tab1 using cylinder ${selfns}_tab1 \
-bottom [list [expr {$X - $_tabXoffset}] $Y $Z] \
-radius [expr {$_tabHoleDiameter / 2.0}] \
-height [expr {-1*[$self cget -bracketthick]}] \
-direction DY -color {255 255 255}
install _tab2 using cylinder ${selfns}_tab2 \
-bottom [list [expr {$X + $_tabXoffset}] $Y $Z] \
-radius [expr {$_tabHoleDiameter / 2.0}] \
-height [expr {-1*[$self cget -bracketthick]}] \
-direction DY -color {255 255 255}
}
horn {
#set X [expr {$X + [$self cget -bracketthick]}]
install _body using cylinder ${selfns}_body \
-bottom [list $X $Y $Z] \
-radius [expr {$_bodyDiameter / 2.0}] \
-height [expr {-1*$_bodyDepth}] \
-direction DX -color {255 255 0}
install _bushing using cylinder ${selfns}_bushing \
-bottom [list $X $Y $Z] \
-radius [expr {$_bushingDiameter / 2.0}] \
-height [expr {1*$_bushingLength}] \
-direction DX -color {200 200 200}
install _shaft using cylinder ${selfns}_shaft \
-bottom [list [expr {$X + $_bushingLength}] $Y $Z] \
-radius [expr {$_shaftDiameter / 2.0}] \
-height [expr {1*$_shaftLength}] \
-direction DX -color {240 240 240}
install _tab1 using cylinder ${selfns}_tab1 \
-bottom [list $X [expr {$Y - $_tabXoffset}] $Z] \
-radius [expr {$_tabHoleDiameter / 2.0}] \
-height [expr {1*[$self cget -bracketthick]}] \
-direction DX -color {255 255 255}
install _tab2 using cylinder ${selfns}_tab2 \
-bottom [list $X [expr {$Y + $_tabXoffset}] $Z] \
-radius [expr {$_tabHoleDiameter / 2.0}] \
-height [expr {1*[$self cget -bracketthick]}] \
-direction DX -color {255 255 255}
}
}
}
method print {{fp stdout}} {
$_body print $fp
$_bushing print $fp
$_shaft print $fp
$_tab1 print $fp
$_tab2 print $fp
}
}
snit::type Bracket {
option -bracketthick -type snit::double -default 0 -readonly yes
option -bracketcenterpoint -type point -default {0 0 0} -readonly yes
option -bracketdepth -type snit::double -default 0 -readonly yes
option -bracketwidth -type snit::double -default 0 -readonly yes
option -bracketcornersize -type snit::double -default 5.0 -readonly yes
option -orientation -type Orient -default horizontal -readonly yes
component _bracket
constructor {args} {
$self configurelist $args
lassign [$self cget -bracketcenterpoint] X Y Z
puts stderr "*** $type create $self -bracketcenterpoint [$self cget -bracketcenterpoint]"
set bw_2 [expr {[$self cget -bracketwidth]/2.0}]
set bd [$self cget -bracketdepth]
set bcs [$self cget -bracketcornersize]
switch [$self cget -orientation] {
horizontal {
set bracketSurfPoly [list [list [expr {$X - $bw_2}] $Y $Z] \
[list [expr {$X + $bw_2}] $Y $Z] \
[list [expr {$X + $bw_2}] $Y [expr {$Z - ($bd-$bcs)}]] \
[list [expr {$X + $bw_2-$bcs}] $Y [expr {$Z - $bd}]] \
[list [expr {$X - $bw_2+$bcs}] $Y [expr {$Z - $bd}]] \
[list [expr {$X - $bw_2}] $Y [expr {$Z - ($bd-$bcs)}]] \
[list [expr {$X - $bw_2}] $Y $Z]]
set brackVector [list 0 [$self cget -bracketthick] 0]
}
vertical {
set bracketSurfPoly [list [list $X [expr {$Y - $bw_2}] $Z] \
[list $X [expr {$Y + $bw_2}] $Z] \
[list $X [expr {$Y + $bw_2}] [expr {$Z - ($bd-$bcs)}]] \
[list $X [expr {$Y + $bw_2-$bcs}] [expr {$Z - $bd}]] \
[list $X [expr {$Y - $bw_2+$bcs}] [expr {$Z - $bd}]] \
[list $X [expr {$Y - $bw_2}] [expr {$Z - ($bd-$bcs)}]] \
[list $X [expr {$Y - $bw_2}] $Z]]
set brackVector [list [$self cget -bracketthick] 0 0]
}
}
install _bracket using PrismSurfaceVector ${selfns}_bracket \
-surface [PolySurface create ${selfns}_bracket_surf -rectangle no \
-polypoints $bracketSurfPoly] \
-vector $brackVector \
-color {200 200 200}
}
method print {{fp stdout}} {
$_bracket print $fp
}
}
snit::type 2ndGenLocoControlStandLid {
component _baseLid
delegate option -origin to _baseLid
component _throttleSlot
component _reverserSlot
component _brakeSlot
component _throttleReverserBrakeBracket
component _throttleEncoder
component _reverserEncoder
component _brakePotentiometer
component _hornSlot
component _hornBracket
component _hornPotentiometer
component _buttonDisplayBoard
component _buttonDisplayBoardMountHole1
component _buttonDisplayBoardMountHole2
component _buttonDisplayBoardMountHole3
component _buttonDisplayBoardMountHole4
component _buttonDisplayBoardStandoff1
component _buttonDisplayBoardStandoff2
component _buttonDisplayBoardStandoff3
component _buttonDisplayBoardStandoff4
component _buttonDisplayBoardButtonHole1
component _buttonDisplayBoardButtonHole2
component _buttonDisplayBoardButtonHole3
component _buttonDisplayBoardButtonHole4
component _buttonDisplayBoardButtonHole5
component _buttonDisplayBoardStatusLEDHole
component _buttonDisplayBoardDisplayCutout
component _buttonDisplayBoardDisplayMH1
component _buttonDisplayBoardDisplayMH2
component _buttonDisplayBoardDisplayMH3
component _buttonDisplayBoardDisplayMH4
component _buttonLEDBoard
component _buttonLEDBoardMH1
component _buttonLEDBoardMH2
component _buttonLEDBoardMH3
component _buttonLEDBoardMH4
component _buttonLEDBoardStandoff1
component _buttonLEDBoardStandoff2
component _buttonLEDBoardStandoff3
component _buttonLEDBoardStandoff4
component _buttonLEDBoardB1
component _buttonLEDBoardB2
component _buttonLEDBoardB3
component _buttonLEDBoardB4
component _buttonLEDBoardB5
component _buttonLEDBoardB6
component _buttonLEDBoardB7
component _buttonLEDBoardB8
component _buttonLEDBoardL1
component _buttonLEDBoardL2
component _buttonLEDBoardL3
component _buttonLEDBoardL4
component _buttonLEDBoardL5
component _buttonLEDBoardL6
component _buttonLEDBoardL7
component _buttonLEDBoardL8
component _lightSwitchMH
typevariable _lightSwitchMHDiameter 9.525
constructor {args} {
install _baseLid using OrignalLid ${selfns}_baseLid \
-origin [from args -origin {0 0 0}] \
-boxtype RL6685