Commit | Line | Data |
---|---|---|
1ecdb44a MS |
1 | /** |
2 | * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND | |
3 | * | |
4 | * //\\ //\\ //\\ //\\ | |
5 | * ///\\\ ///\\\ ///\\\ ///\\\ | |
6 | * \\\/// \\\/// \\\/// \\\/// | |
7 | * \\// \\// \\// \\// | |
8 | * | |
9 | * EXPERTS ONLY!! EXPERTS ONLY!! | |
10 | * | |
186bc4d3 | 11 | * This file implements the mapping functions needed to lay out the physical |
1ecdb44a MS |
12 | * cubes and the output ports on the panda board. It should only be modified |
13 | * when physical changes or tuning is being done to the structure. | |
14 | */ | |
45f43cc2 | 15 | |
46fc29d4 MS |
16 | class TowerMapping { |
17 | public final float x, y, z; | |
18 | public final float[][] cubePositions; | |
19 | ||
20 | TowerMapping(float x, float y, float z, float[][] cubePositions) { | |
21 | this.x = x; | |
22 | this.y = y; | |
23 | this.z = z; | |
24 | this.cubePositions = cubePositions; | |
25 | } | |
26 | } | |
27 | ||
186bc4d3 | 28 | public Model buildModel() { |
46fc29d4 MS |
29 | // The model is represented as an array of towers. The cubes in the tower |
30 | // are represenented relatively. Each tower has an x, y, z reference position, | |
31 | // which is typically the base cube's bottom left corner. | |
32 | // | |
33 | // Following that is an array of floats. A 2-d array contains an x-offset | |
34 | // and a z-offset from the reference position. Typically the first cube | |
35 | // will just be {0, 0}. | |
36 | // | |
37 | // A 3-d array contains an x-offset, a z-offset, and a rotation about the | |
38 | // y-axis. | |
39 | // | |
40 | // The cubes automatically increment their y-position by Cube.EDGE_HEIGHT. | |
03c7b35a MS |
41 | |
42 | final float STACKED_RELATIVE = 1; | |
43 | final float STACKED_REL_SPIN = 2; | |
92c06c97 | 44 | final float BASS_DEPTH = BassBox.EDGE_DEPTH + 4; |
03c7b35a | 45 | |
46fc29d4 | 46 | TowerMapping[] mapping = new TowerMapping[] { |
92c06c97 | 47 | |
46fc29d4 | 48 | new TowerMapping(0, 0, 0, new float[][] { |
03c7b35a MS |
49 | {STACKED_RELATIVE, 0, 0}, |
50 | {STACKED_RELATIVE, 5, -10, 20}, | |
51 | {STACKED_RELATIVE, 0, -6}, | |
52 | {STACKED_RELATIVE, -5, -2, -20}, | |
46fc29d4 | 53 | }), |
a797d019 | 54 | |
46fc29d4 | 55 | new TowerMapping(Cube.EDGE_WIDTH + 2, 0, 0, new float[][] { |
03c7b35a MS |
56 | {STACKED_RELATIVE, 0, 0}, |
57 | {STACKED_RELATIVE, 0, 5, 10}, | |
58 | {STACKED_RELATIVE, 0, 2, 20}, | |
59 | {STACKED_RELATIVE, 0, 0, 30}, | |
46fc29d4 MS |
60 | }), |
61 | ||
62 | // Back Cubes behind DJ platform (in order of increasing x) | |
63 | new TowerMapping(50, 5, BASS_DEPTH, new float[][] { | |
03c7b35a MS |
64 | {STACKED_RELATIVE, 0, 0}, |
65 | {STACKED_RELATIVE, 2, 0, 20}, | |
66 | {STACKED_RELATIVE, -2, 10}, | |
67 | {STACKED_RELATIVE, -5, 15, -20}, | |
68 | {STACKED_RELATIVE, -2, 13}, | |
46fc29d4 MS |
69 | }), |
70 | ||
71 | new TowerMapping(79, 5, BASS_DEPTH, new float[][] { | |
03c7b35a MS |
72 | {STACKED_RELATIVE, 0, 0}, |
73 | {STACKED_RELATIVE, 2, 0, 20}, | |
74 | {STACKED_RELATIVE, 4, 10}, | |
75 | {STACKED_RELATIVE, 2, 15, -20}, | |
76 | {STACKED_RELATIVE, 0, 13}, | |
46fc29d4 MS |
77 | }), |
78 | ||
79 | new TowerMapping(107, 5, BASS_DEPTH, new float[][] { | |
03c7b35a MS |
80 | {STACKED_RELATIVE, 0, 0}, |
81 | {STACKED_RELATIVE, 4, 0, 20}, | |
82 | {STACKED_RELATIVE, 6, 10}, | |
83 | {STACKED_RELATIVE, 3, 15, -20}, | |
84 | // {STACKED_RELATIVE, 8, 13}, | |
46fc29d4 MS |
85 | }), |
86 | ||
87 | new TowerMapping(133, 5, BASS_DEPTH, new float[][] { | |
03c7b35a MS |
88 | {STACKED_RELATIVE, 0, 0}, |
89 | {STACKED_RELATIVE, -2, 0, 20}, | |
90 | {STACKED_RELATIVE, 0, 10}, | |
91 | {STACKED_RELATIVE, 2, 15, -20}, | |
92 | // {STACKED_RELATIVE, 4, 13} | |
46fc29d4 MS |
93 | }), |
94 | ||
95 | new TowerMapping(165, 5, BASS_DEPTH, new float[][] { | |
03c7b35a MS |
96 | {STACKED_RELATIVE, 0, 0}, |
97 | {STACKED_RELATIVE, -1, 20}, | |
98 | {STACKED_RELATIVE, 2, 10}, | |
99 | {STACKED_RELATIVE, -2, 15, -20}, | |
100 | {STACKED_RELATIVE, 3, 13}, | |
46fc29d4 MS |
101 | }), |
102 | ||
103 | // front DJ cubes | |
92c06c97 | 104 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2, BassBox.EDGE_HEIGHT, 10, new float[][] { |
03c7b35a MS |
105 | {STACKED_RELATIVE, 0, 0}, |
106 | {STACKED_RELATIVE, 0, -10, 20}, | |
46fc29d4 MS |
107 | }), |
108 | ||
92c06c97 | 109 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + Cube.EDGE_HEIGHT, BassBox.EDGE_HEIGHT, 10, new float[][] { |
03c7b35a MS |
110 | {STACKED_RELATIVE, 3, 0}, |
111 | {STACKED_RELATIVE, 2, -10, 20}, | |
46fc29d4 MS |
112 | }), |
113 | ||
92c06c97 | 114 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + 2*Cube.EDGE_HEIGHT + 5, BassBox.EDGE_HEIGHT, 10, new float[][] { |
03c7b35a MS |
115 | {STACKED_RELATIVE, 0, 0}, |
116 | {STACKED_RELATIVE, 1, 0, 10}, | |
46fc29d4 MS |
117 | }), |
118 | ||
92c06c97 | 119 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + 3*Cube.EDGE_HEIGHT + 9, BassBox.EDGE_HEIGHT, 10, new float[][] { |
03c7b35a MS |
120 | {STACKED_RELATIVE, 0, 0}, |
121 | {STACKED_RELATIVE, -1, 0}, | |
46fc29d4 MS |
122 | }), |
123 | ||
92c06c97 | 124 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BassBox.EDGE_HEIGHT, 10, new float[][] { |
03c7b35a MS |
125 | {STACKED_RELATIVE, 0, 0}, |
126 | {STACKED_RELATIVE, -1, 0}, | |
46fc29d4 MS |
127 | }), |
128 | ||
129 | // left dj cubes | |
92c06c97 | 130 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2, BassBox.EDGE_HEIGHT, Cube.EDGE_HEIGHT + 2, new float[][] { |
03c7b35a MS |
131 | {STACKED_RELATIVE, 0, 0}, |
132 | {STACKED_RELATIVE, 0, 2, 20}, | |
46fc29d4 MS |
133 | }), |
134 | ||
92c06c97 | 135 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2, BassBox.EDGE_HEIGHT, 2*Cube.EDGE_HEIGHT + 4, new float[][] { |
03c7b35a MS |
136 | {STACKED_RELATIVE, 0, 0}, |
137 | {STACKED_RELATIVE, 0, 2, 20}, | |
46fc29d4 MS |
138 | }), |
139 | ||
140 | // right dj cubes | |
92c06c97 | 141 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BassBox.EDGE_HEIGHT, Cube.EDGE_HEIGHT + 2, new float[][] { |
03c7b35a MS |
142 | {STACKED_RELATIVE, 0, 0}, |
143 | {STACKED_RELATIVE, 0, 2, 20}, | |
46fc29d4 MS |
144 | }), |
145 | ||
92c06c97 | 146 | new TowerMapping((TRAILER_WIDTH - BassBox.EDGE_WIDTH)/2 + 4*Cube.EDGE_HEIGHT + 15, BassBox.EDGE_HEIGHT, 2*Cube.EDGE_HEIGHT + 4, new float[][] { |
03c7b35a MS |
147 | {STACKED_RELATIVE, 0, 0}, |
148 | {STACKED_RELATIVE, 0, 2, 20}, | |
46fc29d4 | 149 | }), |
186bc4d3 | 150 | |
46fc29d4 | 151 | new TowerMapping(200, 0, 0, new float[][] { |
03c7b35a MS |
152 | {STACKED_RELATIVE, 0, 10}, |
153 | {STACKED_RELATIVE, 5, 0, 20}, | |
154 | {STACKED_RELATIVE, 0, 4}, | |
155 | {STACKED_RELATIVE, -5, 8, -20}, | |
156 | {STACKED_RELATIVE, 0, 3}, | |
46fc29d4 MS |
157 | }), |
158 | ||
159 | new TowerMapping(0, 0, Cube.EDGE_HEIGHT + 10, new float[][] { | |
03c7b35a MS |
160 | {STACKED_RELATIVE, 10, 0, 40}, |
161 | {STACKED_RELATIVE, 3, -2, 20}, | |
162 | {STACKED_RELATIVE, 0, 0, 40}, | |
163 | {STACKED_RELATIVE, 0, 0, 60}, | |
164 | {STACKED_RELATIVE, 0, 0, 40}, | |
46fc29d4 MS |
165 | }), |
166 | ||
167 | new TowerMapping(20, 0, 2*Cube.EDGE_HEIGHT + 18, new float[][] { | |
03c7b35a MS |
168 | {STACKED_RELATIVE, 0, 0, 40}, |
169 | {STACKED_RELATIVE, 10, 0, 20}, | |
170 | {STACKED_RELATIVE, 5, 0, 40}, | |
171 | {STACKED_RELATIVE, 10, 0, 60}, | |
172 | {STACKED_RELATIVE, 12, 0, 40}, | |
46fc29d4 MS |
173 | }), |
174 | ||
175 | new TowerMapping(210, 0, Cube.EDGE_HEIGHT + 15, new float[][] { | |
03c7b35a MS |
176 | {STACKED_RELATIVE, 0, 0, 40}, |
177 | {STACKED_RELATIVE, 5, 0, 20}, | |
178 | {STACKED_RELATIVE, 8, 0, 40}, | |
179 | {STACKED_RELATIVE, 3, 0, 60}, | |
180 | {STACKED_RELATIVE, 0, 0, 40}, | |
46fc29d4 MS |
181 | }), |
182 | ||
183 | new TowerMapping(210, 0, 2*Cube.EDGE_HEIGHT + 25, new float[][] { | |
03c7b35a MS |
184 | {STACKED_RELATIVE, 0, 0, 40}, |
185 | {STACKED_RELATIVE, 5, 0, 20}, | |
186 | {STACKED_RELATIVE, 2, 0, 40}, | |
187 | {STACKED_RELATIVE, 5, 0, 60}, | |
188 | {STACKED_RELATIVE, 0, 0, 40}, | |
46fc29d4 MS |
189 | }), |
190 | ||
191 | }; | |
51d0d59a | 192 | |
46fc29d4 MS |
193 | ArrayList<Tower> towerList = new ArrayList<Tower>(); |
194 | ArrayList<Cube> tower; | |
195 | Cube[] cubes = new Cube[79]; | |
196 | int cubeIndex = 1; | |
03c7b35a | 197 | float tx, ty, tz, px, pz, ny, dx, dz, ry; |
46fc29d4 MS |
198 | for (TowerMapping tm : mapping) { |
199 | tower = new ArrayList<Cube>(); | |
03c7b35a MS |
200 | px = tx = tm.x; |
201 | ny = ty = tm.y; | |
202 | pz = tz = tm.z; | |
203 | int ti = 0; | |
46fc29d4 | 204 | for (float[] cp : tm.cubePositions) { |
03c7b35a MS |
205 | float mode = cp[0]; |
206 | if (mode == STACKED_RELATIVE) { | |
207 | dx = cp[1]; | |
208 | dz = cp[2]; | |
209 | ry = (cp.length >= 4) ? cp[3] : 0; | |
210 | tower.add(cubes[cubeIndex++] = new Cube(px = tx + dx, ny, pz = tz + dz, 0, ry, 0)); | |
211 | ny += Cube.EDGE_HEIGHT; | |
212 | } else if (mode == STACKED_REL_SPIN) { | |
213 | // Same as above but the front left of this cube is actually its back right for wiring | |
214 | // TODO(mcslee): implement this | |
215 | } | |
46fc29d4 MS |
216 | } |
217 | towerList.add(new Tower(tower)); | |
218 | } | |
92c06c97 MS |
219 | |
220 | BassBox bassBox = new BassBox(56, 0, 2); | |
186bc4d3 | 221 | |
92c06c97 | 222 | return new Model(towerList, cubes, bassBox); |
186bc4d3 | 223 | } |
e73ef85d | 224 | |
186bc4d3 MS |
225 | public PandaMapping[] buildPandaList() { |
226 | return new PandaMapping[] { | |
227 | new PandaMapping( | |
228 | "10.200.1.28", new int[][] { | |
229 | { 1, 2, 3, 4 }, // ch1 | |
230 | { 5, 6, 7, 8 }, // ch2 | |
231 | { 9, 10, 11, 12 }, // ch3 | |
232 | { 13, 14, 15, 16 }, // ch4 | |
233 | { 17, 18, 19, 20 }, // ch5 | |
234 | { 21, 22, 23, 24 }, // ch6 | |
235 | { 25, 26, 27, 28 }, // ch7 | |
236 | { 29, 30, 31, 32 }, // ch8 | |
237 | }), | |
45f43cc2 | 238 | |
186bc4d3 MS |
239 | new PandaMapping( |
240 | "10.200.1.29", new int[][] { | |
241 | { 33, 34, 35, 36 }, // ch9 | |
242 | { 37, 38, 39, 40 }, // ch10 | |
243 | { 41, 42, 43, 44 }, // ch11 | |
244 | { 45, 46, 47, 48 }, // ch12 | |
245 | { 49, 50, 51, 52 }, // ch13 | |
246 | { 53, 54, 55, 56 }, // ch14 | |
247 | { 57, 58, 59, 60 }, // ch15 | |
248 | { 61, 62, 63, 64 }, // ch16 | |
249 | }), | |
250 | ||
251 | }; | |
45f43cc2 | 252 | } |
e73ef85d | 253 | |
45f43cc2 MS |
254 | class PandaMapping { |
255 | ||
045b432d MS |
256 | // How many channels are on the panda board |
257 | public final static int CHANNELS_PER_BOARD = 8; | |
258 | ||
259 | // How many cubes per channel xc_PB is configured for | |
260 | public final static int CUBES_PER_CHANNEL = 4; | |
261 | ||
44b8de9c MS |
262 | // How many total pixels on each channel |
263 | public final static int PIXELS_PER_CHANNEL = Cube.POINTS_PER_CUBE * CUBES_PER_CHANNEL; | |
264 | ||
265 | // How many total pixels on the whole board | |
266 | public final static int PIXELS_PER_BOARD = PIXELS_PER_CHANNEL * CHANNELS_PER_BOARD; | |
267 | ||
45f43cc2 | 268 | final String ip; |
045b432d | 269 | final int[][] channelList = new int[CHANNELS_PER_BOARD][CUBES_PER_CHANNEL]; |
45f43cc2 | 270 | |
045b432d | 271 | PandaMapping(String ip, int[][] rawChannelList) { |
45f43cc2 | 272 | this.ip = ip; |
045b432d MS |
273 | for (int chi = 0; chi < CHANNELS_PER_BOARD; ++chi) { |
274 | int[] cubes = (chi < rawChannelList.length) ? rawChannelList[chi] : new int[]{}; | |
275 | for (int cui = 0; cui < CUBES_PER_CHANNEL; ++cui) { | |
276 | channelList[chi][cui] = (cui < cubes.length) ? cubes[cui] : 0; | |
277 | } | |
278 | } | |
e73ef85d | 279 | } |
1ecdb44a MS |
280 | } |
281 | ||
45f43cc2 | 282 |