7
7
direct download without them needing to be committed to the repository
8
8
"""
9
9
import os
10
+ import json
10
11
11
12
from cadorchestrator .generate import generate_components
12
- from cadorchestrator .components import GeneratedMechanicalComponent
13
- from nimble_build_system .orchestration .paths import BUILD_DIR , REL_MECH_DIR
13
+
14
+ from nimble_build_system .orchestration .paths import BUILD_DIR
15
+
16
+ from nimble_build_system .cad .shelf import create_shelf_for
14
17
15
18
def generate ():
16
19
"""
@@ -28,100 +31,20 @@ def get_component_list():
28
31
shelves
29
32
"""
30
33
31
- components = []
32
-
33
- components .append (
34
- generate_leg (
35
- length = 294 ,
36
- mounting_holes_dia = 3.6 ,
37
- name = "Rack leg with 21 holes" ,
38
- out_file = "./printed_components/beam-21holes.stl"
39
- )
40
- )
41
- components .append (
42
- generate_leg (
43
- length = 168 ,
44
- mounting_holes_dia = 3.6 ,
45
- name = "Rack leg with 12 holes" ,
46
- out_file = "./printed_components/beam-12holes.stl"
47
- )
48
- )
49
-
50
- components .append (
51
- generate_leg (
52
- length = 294 ,
53
- mounting_holes_dia = 5.8 ,
54
- name = "Rack leg with 21 M6 holes" ,
55
- out_file = "./printed_components/beam-M6-21holes.stl"
56
- )
57
- )
58
-
59
- components .append (
60
- generate_leg (
61
- length = 168 ,
62
- mounting_holes_dia = 5.8 ,
63
- name = "Rack leg with 12 M6 holes" ,
64
- out_file = "./printed_components/beam-M6-12holes.stl"
65
- )
66
- )
67
-
68
- for (shelf_type , height_in_u ) in [
69
- ("stuff" , 3 ),
70
- ("stuff-thin" , 3 ),
71
- ("nuc" , 3 ),
72
- ("nuc" , 4 ),
73
- ("usw-flex" , 3 ),
74
- ("usw-flex-mini" , 2 ),
75
- ("anker-powerport5" , 2 ),
76
- ("anker-a2123" , 2 ),
77
- ("anker-atom3slim" , 2 ),
78
- ("hdd35" , 2 ),
79
- ("dual-ssd" , 2 ),
80
- ("raspi" , 2 )]:
81
-
82
- components .append (generate_shelf (shelf_type , height_in_u ))
83
-
84
- return components
85
-
86
-
87
- def generate_leg (length , mounting_holes_dia , name , out_file ):
88
- """
89
- Helper function to generate a leg. Returns a GeneratedMechanicalComponent
90
- object which contains the data for the leg.
91
- """
92
- source = os .path .join (REL_MECH_DIR , "components/cadquery/rack_leg.py" )
93
- key = name .lower ().replace (' ' , '_' )
94
- return GeneratedMechanicalComponent (
95
- key = key ,
96
- name = name ,
97
- description = 'A leg for a nimble rack' ,
98
- output_files = [out_file ],
99
- source_files = [source ],
100
- parameters = {
101
- "length" : length ,
102
- "mounting_holes_dia" : mounting_holes_dia
103
- },
104
- application = "cadquery"
105
- )
106
-
107
-
108
- def generate_shelf (shelf_type , height_in_u ):
109
- """
110
- Helper function to generate a shelf/tray. Returns a GeneratedMechanicalComponent
111
- object which contains the data for the shelf.
112
- """
113
- out_file = f"./printed_components/shelf_6in_{ shelf_type } u_{ height_in_u } .stl"
114
- source = os .path .join (REL_MECH_DIR , "components/cadquery/tray_6in.py" )
115
- device_name = shelf_type .replace ('-' , ' ' )
116
- return GeneratedMechanicalComponent (
117
- key = f"{ shelf_type } _{ height_in_u } u" ,
118
- name = f"Tray for { device_name } " ,
119
- description = f"Tray for { device_name } , height = { height_in_u } u" ,
120
- output_files = [out_file ],
121
- source_files = [source ],
122
- parameters = {'shelf_type' : shelf_type , 'height_in_u' : height_in_u },
123
- application = "cadquery"
124
- )
34
+ component_list = []
35
+
36
+ #Loop through the options dictionary that the web ui uses for config options
37
+ with open ('OrchestratorConfigOptions.json' , encoding = "utf-8" ) as config_options_file :
38
+ conf_options = json .load (config_options_file )
39
+
40
+ for device_category_dict in conf_options ['options' ][0 ]['add-options' ]:
41
+ for device in device_category_dict ['items' ]:
42
+ device_id = device ['value' ]
43
+ shelf = create_shelf_for (device_id )
44
+ component_list .append (shelf .shelf_component )
45
+ #return a list of GeneratedMechanicalComponent objects
46
+ return component_list
47
+
125
48
126
49
def output_static_site (components ):
127
50
"""
@@ -139,37 +62,30 @@ def output_static_site(components):
139
62
</style>
140
63
</head>
141
64
<body>
142
-
65
+
143
66
<h1>
144
- Nimble STL files
67
+ Nimble downloads
145
68
</h1>
146
69
70
+ <h2>Auto-generated documentation:</h3>
147
71
<p>
148
- Nimble is going through a transition towards live generation of all files and documentation
149
- for hardware configuration. We call this "Smart Doc". For more details on Nimble see
150
- <a href="https://github.com/Wakoma/nimble">https://github.com/Wakoma/nimble </a>
72
+ We are working on a system to automatically generate documentation for any
73
+ nimble configuration. This is an example of the <a href="assembly-docs">
74
+ automatically generated documentation </a> for a specific configuration.
151
75
</p>
152
76
77
+ <h2>Shelf STL files:</h3>
153
78
<p>
154
- Smart Doc" is not yet finished, but the code already generates a number of nimble components
155
- that may be useful to you. You can find them below.
79
+ While we work on builing the nimble configurator you can download all
80
+ nimble shelves from the list below
156
81
</p>
157
-
158
82
""" )
159
83
160
- f .write ("<h3>Generated files:</h3> " )
84
+ f .write ("" )
161
85
f .write ("<ul>" )
162
86
for component in components :
163
- f .write (f"<li><a href='{ component .output_files [ 0 ] } '>{ component .name } </a></li>" )
87
+ f .write (f"<li><a href='{ component .stl_representation } '>{ component .name } </a></li>" )
164
88
f .write ("</ul>" )
165
- f .write (
166
- """
167
- <h3>Example documentation:</h3>
168
- <p>
169
- Partially complete automatically generated documentation
170
- <a href="assembly-docs">is also available</a>.
171
- </p>
172
- """ )
173
89
174
90
f .write ("</body></html>" )
175
91
0 commit comments