-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodules.js
606 lines (537 loc) · 15 KB
/
modules.js
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
function Category(name, moduleList) {
this.name = name;
this.modules = moduleList;
}
function NavCategory(name, base, items) {
this.name = name;
this.base = base;
this.modules = items;
}
function SidebarLink(name, url) {
this.name = name;
this.url = url;
}
// To add configuration data to a module's page, you simply define its config property with an array
// of Property objects.
// Config declarations begin below the modules array.
// The links array contains a "Link" object with a title and URL for every
// link that will be generated on the top segment of the sidebar.
// Unlike other auto-generated links, local paths are not adjusted
// based on the page. Ensure you use absolute paths to avoid causing
// issues.
let sidebarLinks = [
new SidebarLink("Getting Started", "/"),
new SidebarLink("FAQs", "/faqs.html"),
new SidebarLink("API Reference", "/api_reference.html"),
new SidebarLink("Module Configuration Tool", "/config.html")
];
// The modules array is filled with a category object for each category on the sidebar
// Each category object requires a name, and an array of module objects.
// Each module object consists of a module name and a imageWidth property
// for its page. Ensure all names of each module, its page, its containing folder,
// and its image all match. Images should be named "MODULENAME_STRAIGHTON.png"
// Example: P1-08NA_STRAIGHTON.png
let modules = [
// new NavCategory("FAQ", "/faqs.html", [{
// name: "CPUs",
// link: "#cpus"
// }, {
// name: "Arduino",
// link: "#arduino"
// }, {
// name: "CircuitPython",
// link: "#circuitPy"
// }]),
new Category("CPUs and Shields", [{
name: "P1AM-100",
imageWidth: "150px"
}, {
name: "P1AM-200",
imageWidth: "150px"
}, {
name: "P1AM-ETH",
imageWidth: "180px"
}, {
name: "P1AM-GPIO",
imageWidth: "180px"
}, {
name: "P1AM-PROTO",
imageWidth: "160px"
}, {
name: "P1AM-SERIAL",
imageWidth: "160px"
}]),
new Category("Discrete Input Modules", [{
name: "P1-08NA",
imageWidth: "300px"
}, {
name: "P1-08ND3",
imageWidth: "180px"
}, {
name: "P1-16ND3",
imageWidth: "300px"
}, {
name: "P1-08NE3",
imageWidth: "300px"
}, {
name: "P1-16NE3",
imageWidth: "300px"
}, {
name: "P1-08ND-TTL",
imageWidth: "130px"
}, {
name: "P1-08SIM",
imageWidth: "180px"
}]),
new Category("Discrete Output Modules", [{
name: "P1-08TA",
imageWidth: "300px"
}, {
name: "P1-08TD1",
imageWidth: "180px"
}, {
name: "P1-15TD1",
imageWidth: "300px"
}, {
name: "P1-08TD2",
imageWidth: "180px"
}, {
name: "P1-15TD2",
imageWidth: "300px"
}, {
name: "P1-08TD-TTL",
imageWidth: "130px"
}, {
name: "P1-08TRS",
imageWidth: "200px"
}, {
name: "P1-16TR",
imageWidth: "200px"
}]),
new Category("Discrete Combo Modules", [{
name: "P1-15CDD1",
imageWidth: "150px"
}, {
name: "P1-15CDD2",
imageWidth: "150px"
}, {
name: "P1-16CDR",
imageWidth: "150px"
}]),
new Category("Analog Input Modules", [{
name: "P1-04AD",
imageWidth: "130px"
}, {
name: "P1-04AD-1",
imageWidth: "130px"
}, {
name: "P1-04ADL-1",
imageWidth: "180px"
}, {
name: "P1-08ADL-1",
imageWidth: "150px"
}, {
name: "P1-04AD-2",
imageWidth: "130px"
}, {
name: "P1-04ADL-2",
imageWidth: "180px"
}, {
name: "P1-08ADL-2",
imageWidth: "150px"
}, {
name: "P1-04NTC",
imageWidth: "180px"
}, {
name: "P1-04RTD",
imageWidth: "180px"
}, {
name: "P1-04THM",
imageWidth: "180px"
}]),
new Category("Analog Output Modules", [{
name: "P1-04DAL-1",
imageWidth: "180px"
}, {
name: "P1-08DAL-1",
imageWidth: "140px"
}, {
name: "P1-04DAL-2",
imageWidth: "180px"
}, {
name: "P1-08DAL-2",
imageWidth: "130px"
}]),
new Category("Analog Combo Modules", [{
name: "P1-4ADL2DAL-1",
imageWidth: "180px"
}, {
name: "P1-4ADL2DAL-2",
imageWidth: "180px"
}]),
new Category("Specialty Modules", [{
name: "P1-04PWM",
imageWidth: "300px"
}, {
name: "P1-02HSC",
imageWidth: "150px"
}])
];
function getPageByName(name) {
for (let i = 0; i < modules.length; i++) {
for (let j = 0; j < modules[i].modules.length; j++) {
if (modules[i].modules[j].name === name) {
return modules[i].modules[j];
}
}
}
}
const globalProperty = 0; // property affects entire module
const channelProperty = 1; // property specific to each individual channel
const channelEnable = 2; // property controls which channels are enabled
const reservedField = 3; // property consists of reserved bytes
// Each property on a module needs a type (above), a name (for its label)
// an options array/object (varies depending on type), and the amount
// of bytes the property takes up (almost always 1 or 2).
function Property(type, name, options, bytes) {
this.type = type;
this.name = name;
this.options = options;
this.bytes = bytes;
}
// A config is just an array of Property objects, so first you should create
// array to populate. In this case, P104NTC.
// the push array method adds the argument to the end of the array it is used on.
// we continue pushing Property objects into the array until we are done.
// The order you do this in only matters on a per-property basis.
// ie. globalProperties in order, channelProperties in order.
/******************************* THE OPTIONS PARAMETER *******************************/
// The options array/option is the most important part of the tool.
// It is different for each Property type.
/***** channelEnable *****/
// For channelEnable Properties the "options" parameter is an object with two properties.
// "start" and "delimeter". "start" is the beginning value of the
// property. "delimeter" is the increment for every extra channel
// enabled past the start.
/***** globalProperty *****/
// For globalProperty Properties, the "options" parameter is an array filled with
// objects similar to the modules array.
// Each object in this array has a "name" property, which is the name
// of the option in the dropdown, and a "value" property, which is the
// value associated with that property.
// To specify a property as the default state, add "!!!" to the beginning of
// its name.
/***** channelProperty *****/
// For channelProperty Properties, the "options" parameter is an object
// with two properties. The "values" property is an array filled with
// objects. This is the same as the globalProperty array where each
// object in the array has a "name" property and a "value" property.
// HOWEVER, the "value" property should only include what changes consistently
// across every channel.
// Example: if an option has a value of 0x2105 on channel 1 and 2205 on channel
// 2, you would put 5 as the value.
// The channels property is just an array of Strings. Each array value should be
// the channel value before its option has been added.
// In the above example, this means you would put 2100 on channel 1 and 2200
// on channel 2.
/***** reservedField *****/
// For reservedField Properties, the "options" parameter is just the byte in
// the config array where the field starts.
/******************************* THE OPTIONS PARAMETER *******************************/
// After the Property array has been fully populated, you just need to add
// it to its respective module object and ensure its defined with the correct
// number of channels.
// To access the module, use getPageByName() with its name as the parameter.
// Let's use the P1-04NTC as an example:
// Let's say the array we pushed all of our Properties into is called P104NTC.
// getPageByName("P1-04NTC").config = P104NTC;
// getPageByName("P1-04NTC").channels = 4;
// And we're done. The tool will do the rest.
// Use the modules below as examples (or just copy and paste from) if you are confused.
//ENSURE EVERY MODULE'S CONFIG ARRAY HAS A DIFFERENT NAME.
let P104NTC = new Array();
P104NTC.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
P104NTC.push(new Property(globalProperty, "Burnout and Units", [{
name: "Low Side Burnout (min scale)/Temp in °C",
value: "6001"
}, {
name: "High Side Burnout (max scale)/Temp in °C",
value: "6003"
}, {
name: "!!!Low Side Burnout (min scale)/Temp in °F",
value: "6005"
}, {
name: "High Side Burnout (max scale)/Temp in °F",
value: "6007"
}], 2));
P104NTC.push(new Property(globalProperty, "Range", [{
name: "!!!2252",
value: "2000"
}, {
name: "10K-AN",
value: "2001"
}, {
name: "10K-CP",
value: "2002"
}, {
name: "5K",
value: "2003"
}, {
name: "3K",
value: "2004"
}, {
name: "1.8K",
value: "2005"
}], 2));
P104NTC.push(new Property(globalProperty, "Digital Filter", [{
name: "!!!33Hz/16bit/61ms",
value: "8000"
}, {
name: "470Hz/14bit/4ms",
value: "8001"
}], 2));
getPageByName("P1-04NTC").config = P104NTC;
getPageByName("P1-04NTC").channels = 4;
let P104RTD = new Array();
P104RTD.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
P104RTD.push(new Property(globalProperty, "Burnout and Units", [{
name: "Low Side Burnout (min scale)/Temp in °C",
value: "6001"
}, {
name: "High Side Burnout (max scale)/Temp in °C",
value: "6003"
}, {
name: "!!!Low Side Burnout (min scale)/Temp in °F",
value: "6005"
}, {
name: "High Side Burnout (max scale)/Temp in °F",
value: "6007"
}], 2));
P104RTD.push(new Property(globalProperty, "Range", [{
name: "jPt100",
value: "2000"
}, {
name: "!!!Pt100",
value: "2001"
}, {
name: "Pt1000",
value: "2002"
}, {
name: "10Ω Cu",
value: "2003"
}, {
name: "25Ω Cu",
value: "2004"
}, {
name: "120Ω Ni",
value: "2005"
}, {
name: "0-193.3125Ω",
value: "2006"
}, {
name: "0-10KΩ",
value: "2007"
}, {
name: "0-6.25KΩ",
value: "2008"
}, {
name: "0-3.125KΩ",
value: "2009"
}, {
name: "0-1.563KΩ",
value: "200A"
}, {
name: "0-781.25Ω",
value: "200B"
}, {
name: "0-390.625Ω",
value: "200C"
}], 2));
P104RTD.push(new Property(globalProperty, "Digital Filter", [{
name: "!!!33Hz/16bit/61ms",
value: "8000"
}, {
name: "470Hz/14bit/4ms",
value: "8001"
}], 2));
getPageByName("P1-04RTD").config = P104RTD;
getPageByName("P1-04RTD").channels = 4;
let P104THM = new Array();
P104THM.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
P104THM.push(new Property(globalProperty, "Burnout and Units", [{
name: "Low Side Burnout (min scale)/Temp in °C",
value: "6001"
}, {
name: "High Side Burnout (max scale)/Temp in °C",
value: "6003"
}, {
name: "!!!Low Side Burnout (min scale)/Temp in °F",
value: "6005"
}, {
name: "High Side Burnout (max scale)/Temp in °F",
value: "6007"
}], 2));
P104THM.push(new Property(channelProperty, "Range", {
values: [{
name: "!!!J",
value: "0",
}, {
name: "K",
value: "1"
}, {
name: "E",
value: "2"
}, {
name: "R",
value: "3"
}, {
name: "S",
value: "4"
}, {
name: "T",
value: "5"
}, {
name: "B",
value: "6"
}, {
name: "N",
value: "7"
}, {
name: "C",
value: "8"
}, {
name: "0-39mV",
value: "9"
}, {
name: "+/-39mV",
value: "A"
}, {
name: "+/-78mV",
value: "B"
}, {
name: "0-156mV",
value: "C"
}, {
name: "+/-156mV",
value: "D"
}, {
name: "0-1.25V",
value: "E"
}],
channels: [
"2100",
"2200",
"2300",
"2400"
]
}, 2));
P104THM.push(new Property(reservedField, "Reserved", 12, 2));
P104THM.push(new Property(reservedField, "Reserved", 14, 2));
P104THM.push(new Property(reservedField, "Reserved", 16, 2));
P104THM.push(new Property(reservedField, "Reserved", 18, 2));
getPageByName("P1-04THM").config = P104THM;
getPageByName("P1-04THM").channels = 4;
let P104AD = new Array();
P104AD.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
P104AD.push(new Property(channelProperty, "Range", {
values: [{
name: "± 10V",
value: "0",
}, {
name: "0-10V",
value: "1"
}, {
name: "0-5V",
value: "2"
}, {
name: "!!!0-20mA",
value: "3"
}, {
name: "± 5V",
value: "4"
}],
channels: [
"2000",
"2100",
"2200",
"2300"
]
}, 2));
P104AD.push(new Property(reservedField, "Reserved", 2, 2));
P104AD.push(new Property(reservedField, "Reserved", 6, 2));
P104AD.push(new Property(reservedField, "Reserved", 10, 2));
P104AD.push(new Property(reservedField, "Reserved", 14, 2));
getPageByName("P1-04AD").config = P104AD;
getPageByName("P1-04AD").channels = 4;
let P104PWM = new Array();
P104PWM.push(new Property(channelProperty, "Range", {
values: [{
name: "!!!PWM",
value: "0",
}, {
name: "DIR",
value: "4"
}],
channels: [
"02",
"02",
"02",
"02"
]
}, 1));
getPageByName("P1-04PWM").config = P104PWM;
getPageByName("P1-04PWM").channels = 4;
let P104AD1 = new Array();
P104AD1.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-04AD-1").config = P104AD1;
getPageByName("P1-04AD-1").channels = 4;
let P104ADL1 = new Array();
P104ADL1.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-04ADL-1").config = P104ADL1;
getPageByName("P1-04ADL-1").channels = 4;
let P104AD2 = new Array();
P104AD2.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-04AD-2").config = P104AD2;
getPageByName("P1-04AD-2").channels = 4;
let P104ADL2 = new Array();
P104ADL2.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-04ADL-2").config = P104ADL2;
getPageByName("P1-04ADL-2").channels = 4;
let P108ADL1 = new Array();
P108ADL1.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-08ADL-1").config = P108ADL1;
getPageByName("P1-08ADL-1").channels = 8;
let P108ADL2 = new Array();
P108ADL2.push(new Property(channelEnable, "Enabled", {
start: "4000",
delimeter: 1
}, 2));
getPageByName("P1-08ADL-2").config = P108ADL2;
getPageByName("P1-08ADL-2").channels = 8;