-
Notifications
You must be signed in to change notification settings - Fork 7
/
thermo.html
136 lines (133 loc) · 5.56 KB
/
thermo.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
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
<script type="text/javascript">
RED.nodes.registerType('ppTHERMO', {
category: 'Pi_Plates',
color: '#87A980',
defaults: {
config_plate: { value: '', type: "pi_plate" },
name: { value: '' },
channel: { value: "1", required: true },
scale: { value: 'c' },
tc_type: { value: 'k' }
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-thermometer",
paletteLabel: 'THERMO',
label: function () {
return (this.name || 'THERMO' + this.channel);
},
outputLabels: function(index) {
let thermo_labels = ['COLD','TC1','TC2','TC3','TC4','TC5','TC6','TC7','TC8','DS9','DS10','DS11','DS12'];
let node = this;
if (node.plate_model && node.channel) {
let input_index = parseInt(node.channel, 10);
if (node.plate_model == "THERMOplate") {
return(thermo_labels[input_index]);
} else {
return('');
}
} else {
return('');
}
},
oneditprepare: function () {
var node = this;
node.prev_config_id = $("#node-input-config_plate").val();
node.plate_model = 'unknown';
function draw_form() {
$("#invalid_plate_section").hide();
$("#channel_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 == "THERMOplate") {
$("#channel_section").show()
$("#tc_type_section").show()
} else {
$("#invalid_plate_section").show();
$("#channel_section").hide();
$("#tc_type_section").hide()
node.input = null;
}
if (node.channel) {
$("#channel_section select").val(node.channel);
if (node.channel > 8) {
$("#tc_type_section").hide()
} else {
$("#tc_type_section").show()
}
}
}
} // draw_form()
$("#node-input-config_plate").on('focus', function() {node.prev_config_id = this.value}).change(function() {
// if config node selection has changed, clear our form selection and redraw the form
if (node.prev_config_id !== this.value) {
node.plate_model = null;
}
draw_form()
});
$("#node-input-channel").change(function () {
// Thermocouple type only applies to TC1 through TC8
let new_channel = $('#node-input-channel').val();
if (new_channel > 8) {
$("#tc_type_section").hide()
} else {
$("#tc_type_section").show()
}
// draw_form()
});
} // oneditprepare()
});
</script>
<script type="text/x-red" data-template-name="ppTHERMO">
<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="channel_section">
<label for="node-input-channel"><i class="icon-tag"></i> Input #</label>
<select id="node-input-channel">
<option value="1">TC1</option>
<option value="2">TC2</option>
<option value="3">TC3</option>
<option value="4">TC4</option>
<option value="5">TC5</option>
<option value="6">TC6</option>
<option value="7">TC7</option>
<option value="8">TC8</option>
<option value="9">DS9</option>
<option value="10">DS10</option>
<option value="11">DS11</option>
<option value="12">DS12</option>
<option value="0">COLD</option>
</select>
</div>
<div class="form-row" id="scale_section">
<label for="node-input-scale"><i class="icon-tag"></i> Temperature Scale</label>
<select id="node-input-scale">
<option value="c">Celcius</option>
<option value="f">Fahrenheit</option>
<option value="k">Kelvin</option>
</select>
</div>
<div class="form-row" id="tc_type_section">
<label for="node-input-tc_type"><i class="icon-tag"></i> Thermocouple Type</label>
<select id="node-input-tc_type">
<option value="k">K-type</option>
<option value="j">J-type</option>
</select>
</div>
<div class="form-row" id="invalid_plate_section">
<h3 style="color: red">Invalid plate selected</h2>
</div>
</script>
<script type="text/x-red" data-help-name="ppTHERMO">
<p>Temperature Input from THERMOplate board. Inputs 1-8 are K-type thermocouple, 9-12 are DS18B20 1-wire devices, COLD is cold junction temperature of board. Returned values are in degrees Celcius.</p>
</script>