-
Notifications
You must be signed in to change notification settings - Fork 7
/
alladc.html
93 lines (87 loc) · 3.71 KB
/
alladc.html
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
<script type="text/javascript">
RED.nodes.registerType('ppAllADC', {
category: 'Pi_Plates',
color: '#87A980',
defaults: {
config_plate: { value: '', type: "pi_plate"},
name: { value: ''},
outputs: { value: 0 } // to be set dynamically by adapt_node()
},
inputs: 1,
icon: 'analog.png',
paletteLabel: 'allADC',
label: function () {
return (this.name || 'ADC');
},
outputLabels: function(index) {
let tinker_labels = ['AIN1', 'AIN2', 'AIN3', 'AIN4'];
let daqc_labels = ['AIN0', 'AIN1', 'AIN2', 'AIN3', 'AIN4', 'AIN5', 'AIN6', 'AIN7'];
let adc_labels = ['S0','S1','S2','S3','S4','S5','S6','S7','D0','D1','D2','D3','I0','I1','I2','I3'];
let node = this;
if (node.plate_model) {
if (node.plate_model == "TINKERplate") {
return(tinker_labels[index]);
} else if (node.plate_model == "DAQCplate" || node.plate_model == "DAQC2plate") {
return(daqc_labels[index]);
} else if (node.plate_model == "ADCplate") {
return(adc_labels[index]);
} else {
return('');
}
} else {
return('');
}
},
oneditprepare: function() {
var node = this;
node.prev_config_id = $("#node-input-config_plate").val();
node.plate_model = 'unknown';
function adapt_node() {
$("#invalid_plate_section").hide()
var config_id = $("#node-input-config_plate").val()
if (config_id == "_ADD_") {
// no config node yet
} else {
node.config_node = RED.nodes.node(config_id)
node.plate_model = node.config_node.model;
if (node.plate_model == "DAQCplate" || node.plate_model == "DAQC2plate") {
node.outputs = 8;
} else if (node.plate_model == "TINKERplate") {
node.outputs = 4;
} else if (node.plate_model == "ADCplate") {
node.outputs = 16;
} else {
$("#invalid_plate_section").show();
}
// search for current setting (if it exists) and select
if (node.channel) {
$("#channel_section select").val(node.channel)
}
}
} //adapt_node()
$("#node-input-config_plate").on('focus', function() {node.prev_config_id = this.value}).change(function() {
// if config node selection has changed, reset # of outputs based on plate model
if (node.prev_config_id !== this.value) {
node.plate_model = null;
}
adapt_node()
});
} //oneditprepare()
});
</script>
<script type="text/x-red" data-template-name="ppAllADC">
<div class="form-row">
<label for="node-input-config_plate"><i class="icon-tag"></i> Plate</label>
<input type="text" id="node-input-config_plate">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" id="invalid_plate_section">
<h2 color="red">Invalid plate selected</h2>
</div>
</script>
<script type="text/x-red" data-help-name="ppADC">
<p>retrieve all ADC input channels at once. DAQC/DAQC2 have 8, TINKER has 4</p>
</script>