-
Notifications
You must be signed in to change notification settings - Fork 3
/
wireless.html
1954 lines (1886 loc) · 82.2 KB
/
wireless.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
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
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<script type="text/javascript">
RED.nodes.registerType('ncd-gateway-node',{
category: 'NCD',
color: '#a6bbcf',
icon: "serial.png",
paletteLabel: "Wireless Gateway",
outputLabels: ["Parsed","Unknown"],
defaults: {
name: {value: ""},
connection: {value: "", type: "ncd-gateway-config"},
unknown_devices: {value:0},
outputs:{value:1}
},
inputs: 1,
outputs: 1,
label: function() {
return this.name || "Wireless Gateway";
},
oneditsave: function(){
this.outputs = $("#node-input-unknown_devices").is(':checked') ? 2 : 1;
},
button: {
enabled: function() {
return true;
},
onclick: function() {
if (this.changed) {
return RED.notify(RED._("notification.warning", {message:RED._("notification.warnings.undeployedChanges")}),"warning");
}
var label = this.name;
if (label.length > 30) {
label = label.substring(0,50)+"...";
}
label = label.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
if (this.payloadType === "date") { label = this._("inject.timestamp"); }
if (this.payloadType === "none") { label = this._("inject.blank"); }
var node = this;
$.ajax({
url: "ncd/wireless/gateway/config/"+this.id,
type:"POST",
success: function(resp) {
RED.notify(node._("Modem "+resp,{label:label}),"success");
},
error: function(jqXHR,textStatus,errorThrown) {
RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.not-deployed")}),"error");
}
});
}
},
});
</script>
<script type="text/x-red" data-template-name="ncd-gateway-node">
<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">
<label for="node-input-connection"><i class="icon-tag"></i> Serial Device</label>
<select id="node-input-connection"></select>
</div>
<div class="form-row">
<label for="node-input-unknown_devices"><i class="icon-tag"></i> Output data from Unknown Devices</label>
<input type="checkbox" id="node-input-unknown_devices" value="1">
</div>
</script>
<style>
.ncd-active-check strong{
width: 100%;
}
.form-row.ncd-active-check{
margin: 12px 0px;
border: 1px solid #eee;
padding: 12px;
border-radius: 8px;
}
.form-row.ncd-active-check > div{
padding: 4px;
}
.form-row.ncd-active-check > div > input[type='checkbox']{
width: inherit;
}
.form-row .caption{
font-size: .95em;
padding-left: 1em;
margin-top: .25em;
}
</style>
<script type="text/x-red" data-help-name="ncd-gateway-node">
<h3>Gateway Node</h3>
<p>This node is primarily useful for debugging and configuring sensors. This node is equipped with a button on the flow that switches the modem between configuration and listening mode.</p>
<h3>Output</h3>
<p>Any time sensor data is received from any sensor on the network, this node will output a message containing all pertinant information as in the example below.</p>
<h3>Input</h3>
<p>The Input connection to this Gateway node allows for sending data to devices. The input connection expects the payload to be an object containging an address and data variable. Address is a string representation of the destination device. Data is a byte array of data to be transmitted as payload to that device. Example "payload":{"address":"00:13:A2:00:01:02:03:04",data:[254,108,1]}</p>
<pre>
msg = {
topic: "sensor_data",
payload: {
nodeId: 0,
firmware: 3,
battery: 3.2940600000000004,
counter: 37,
sensor_type: 1,
sensor_data: {
humidity: 45.51,
temperature: 23.91,
},
type: "sensor_data",
addr: "00:13:a2:00:41:07:18:81",
original: {
mac: "00:13:a2:00:41:07:18:81",
receive_options: {
ack: 0,
broadcast: 0,
type: ""
}
},
data: [127,0,3,3,255,37,0,1,0,17,199,9,87],
type: "receive_packet"
},
_msgid: "391caba.5a19454"
}
</pre>
</script>
<script type="text/javascript">
NCD_validators = {
number_range: function(l, h, base, property_name = false){
if(!base) base = 10;
if(property_name === 'on_request_timeout_80'){
return function(v){
var int = parseInt(v, base);
if(this.on_request_timeout_80 == 0){
console.log('ERROR: Invalid property detect. Setting on_request_timeout_80 to default value');
$("#node-input-on_request_timeout_80").val(1);
return true;
} else if(v == undefined){
return true;
}
return int >= l && int <= h;
}
}
if(base == 'decimal'){
return function(v){
var n = parseFloat(v);
return n >= l && n <= h;
}
}else{
return function(v){
var int = parseInt(v, base);
// Added to remove new settings from interfering with old nodes
if(v == undefined){
return true;
}
return int >= l && int <= h;
}
}
}
}
RED.nodes.registerType('ncd-wireless-node',{
category: 'NCD',
color: '#a6bbcf',
icon: "serial.png",
paletteLabel: "Wireless Device",
defaults: {
name: {value: ""},
connection: {value: "", type: "ncd-gateway-config"},
config_comm: {value: "", type: "ncd-gateway-config", required: false},
addr: {value: ""},
sensor_type: {value: ""},
auto_config: {value: ""},
on_the_fly_enable: {value: ""},
node_id_delay_active: {value: ""},
node_id: {value: 0, validate: NCD_validators.number_range(0, 255)},//0 - 255
delay: {value: 300, validate: NCD_validators.number_range(0, 16777215)},//1 - 16777215
form_network: {value: ""},
destination_active: {value: ""},
destination: {value: '0000FFFF', validate: NCD_validators.number_range(0, 0xFFFFFFFF, 16)},//(0 - 0xFFFFFFFF)
power_active: {value: ""},
power: {value: 4},//(0 - 4)
retries_active: {value: ""},
retries: {value: 10, validate: NCD_validators.number_range(0, 16)},//(0 - 16)
pan_id_active: {value: ""},
pan_id: {value: '7FFF', validate: NCD_validators.number_range(0, 0x7FFF, 16)},//(0 - 0x7FFF)
change_enabled: {value: ""},
change_pr: {value: "0", validate: NCD_validators.number_range(0, 255)},
change_interval: {value: "0", validate: NCD_validators.number_range(0, 16712198)},
cm_calibration: {value: "60.6", validate: NCD_validators.number_range(0, 655.35, 'decimal')},
bp_altitude: {value: "0", validate: NCD_validators.number_range(0, 65535)},
bp_pressure: {value: "0", validate: NCD_validators.number_range(0, 14000)},
bp_temp_prec: {value: "0"},
bp_press_prec: {value: "0"},
amgt_accel: {value: "0"},
amgt_mag: {value: "0"},
amgt_gyro: {value: "0"},
impact_accel_active: {value: ""},
impact_accel: {value: "0"},
impact_data_rate_active: {value: ""},
impact_data_rate: {value: "4"},
impact_threshold_active: {value: ""},
impact_threshold: {value: 25, validate: NCD_validators.number_range(1, 127)},
impact_duration_active: {value: ""},
impact_duration: {value: 1, validate: NCD_validators.number_range(1, 127)},
activ_interr_x: {value: 1, validate: RED.validators.number()},
activ_interr_y: {value: 2, validate: RED.validators.number()},
activ_interr_z: {value: 4, validate: RED.validators.number()},
activ_interr_op: {value: 8, validate: RED.validators.number()},
force_calibration_co2_auto_config: {value: ""},
force_calibration_co2: {value: 400, validate: NCD_validators.number_range(400, 2000)},
filtering: {value: 0, validate: RED.validators.number()},
data_rate: {value: 5, validate: RED.validators.number()},
time_series: {value: 0, validate: RED.validators.number()},
reading_type: {value: 1, validate: RED.validators.number()},
mode_80_active: {value: ""},
mode_80: {value: 0},
measurement_mode_80_active: {value: ""},
measurement_mode_80: {value: 0},
on_request_timeout_80_active: {value: ""},
on_request_timeout_80: {value: 1, validate: NCD_validators.number_range(1, 10, 10, 'on_request_timeout_80')},
sensor_boot_time_420ma_active: {value: ""},
sensor_boot_time_420ma: {value: 0, validate: NCD_validators.number_range(0, 255)},
sensor_boot_time_78_active: {value: ""},
sensor_boot_time_78: {value: 0, validate: NCD_validators.number_range(0, 255)},
deadband_80_active: {value: ""},
deadband_80: {value: 0, validate: NCD_validators.number_range(0, 255)},
filter_80_active: {value: ""},
filter_80: {value: 0},
output_data_rate_p1_81_active: {value: ""},
output_data_rate_p1_81: {value: 0},
output_data_rate_p2_81_active: {value: ""},
output_data_rate_p2_81: {value: 0},
sampling_duration_p1_81_active: {value: ""},
sampling_duration_p1_81: {value: 0},
sampling_duration_p2_81_active: {value: ""},
sampling_duration_p2_81: {value: 0},
led_alert_mode_84_active: {value: ""},
led_alert_mode_84: {value: 0},
led_accelerometer_threshold_84_active: {value: ""},
led_accelerometer_threshold_84: {},
led_velocity_threshold_84_active: {value: ""},
led_velocity_threshold_84: {},
acceleration_interrupt_threshold_84_active: {value: ""},
acceleration_interrupt_threshold_84: {},
set_rtc_101:{value:0},
current_calibration_82:{Value:0},
current_calibration_82_active:{Value:""},
current_calibration_c1_80:{value:178, validate: NCD_validators.number_range(0, 655)},
current_calibration_c1_80_active:{value:""},
current_calibration_c2_80:{value:178, validate: NCD_validators.number_range(0, 655)},
current_calibration_c2_80_active:{value:""},
current_calibration_c3_80:{value:178, validate: NCD_validators.number_range(0, 655)},
current_calibration_c3_80_active:{value:""},
current_calibration_c2_82:{Value:0, validate: NCD_validators.number_range(0, 655)},
current_calibration_c2_82_active:{Value:""},
current_calibration_c3_82:{Value:0, validate: NCD_validators.number_range(0, 655)},
current_calibration_c3_82_active:{Value:""},
output_data_rate_101_active: {value: ""},
output_data_rate_101: {value: 0},
output_data_rate_101_m2_active: {value: ""},
output_data_rate_101_m2: {value: 0},
sampling_duration_101_active: {value: ""},
sampling_duration_101: {value: 1, validate: NCD_validators.number_range(1, 255)},
sampling_interval_101_active: {value: ""},
sampling_interval_101: {value: 1},
full_scale_range_101_active: {value: ""},
full_scale_range_101: {value: 1},
full_scale_range_101_m2_active: {value: ""},
full_scale_range_101_m2: {value: 1},
x_axis_101: {value: ""},
y_axis_101: {value: ""},
z_axis_101: {value: ""},
low_pass_filter_80_active: {value:""},
low_pass_filter_80: {value:0},
high_pass_filter_80_active: {value:""},
high_pass_filter_80: {value:0},
low_pass_filter_81_p2_active: {value:""},
low_pass_filter_81_p2: {value:0},
high_pass_filter_81_p2_active: {value:""},
high_pass_filter_81_p2: {value:0},
roll_angle_threshold_47:{value:0, validate: NCD_validators.number_range(0, 255)},
roll_angle_threshold_47_active:{value:""},
pitch_angle_threshold_47:{value:0, validate: NCD_validators.number_range(0, 255)},
pitch_angle_threshold_47_active:{value:""},
counter_threshold_35:{value:50, validate: NCD_validators.number_range(0, 65534)},
counter_threshold_35_active:{value:""},
payload_length_80_active:{value:""},
payload_length_80:{value:3, validate: NCD_validators.number_range(0, 3)},
motion_threshold_46_active:{value:""},
motion_threshold_46:{value: 100, validate: NCD_validators.number_range(0, 4294967295)},
low_calibration_420ma_active:{value:""},
low_calibration_420ma:{value: 68805, validate: NCD_validators.number_range(0, 4294967295)},
mid_calibration_420ma_active:{value:""},
mid_calibration_420ma:{value: 68724, validate: NCD_validators.number_range(0, 4294967295)},
high_calibration_420ma_active:{value:""},
high_calibration_420ma:{value: 68714, validate: NCD_validators.number_range(0, 4294967295)},
thermocouple_type_23_active:{value:""},
thermocouple_type_23:{value: 0},
},
inputs: 0,
outputs: 1,
label: function() {
if(this.name) return this.name;
if(this.addr) return this.addr.split(":").slice(4).join(':');
if(this.sensor_type){
var types = {
"1": "1 - Temperature/Humidity",
"2": "2 - 2ch Push Notification/Voltage Detection",
"3": "3 - ADC/4-20 mA/DC Voltage",
"4": "4 - Thermocouple",
"5": "5 - Gyro/Magneto/Temperature",
"6": "6 - Temperature/Barometeric Pressure",
"7": "7 - Impact Detection",
"8": "8 - Vibration",
"9": "9 - Proximity and Light",
"10": "10 - Light",
"12": "12 - 3 Channel Thermocouple",
"13": "13 - Current Monitor",
"14": "14 - 1 Channel 4-20mA Receiver",
"15": "15 - 1 Channel 0-10V Receiver",
"16": "16 - 1 Channel Soil Moisture Sensor",
"17": "17 - 1 Channel AC Voltage Sensor",
"18": "18 - Pulse Frequency",
"19": "19 - 2 Channel Current Sensor",
"20": "20 - High Precision Pressure Sensor",
"21": "21 - Differential Bi directional Pressure Sensor",
"22": "22 - 0-24V AC/DC Optically Isolated Inputs",
"23": "23 - 2 Channel Thermocouple Sensor",
"24": "24 - Activity Detection",
"25": "25 - Asset Monitor",
"26": "26 - Pressure Sensor",
"27": "27 - Environmental Sensor",
"28": "28 - 3 Channel Current Sensor",
"29": "29 - Linear Displacement Sensor",
"30": "30 - Structural Monitoring Sensor",
"31": "31 - Air Quality TVOC eCO2 Temperature and Humidity Sensor",
"32": "32 - Particulate Matter Sensor",
"33": "33 - AC Current Detect Sensor",
"34": "34 - Tank Level Sensor",
"35": "35 - 1 Channel Counter",
"36": "36 - 2 Channel Counter",
"37": "37 - 7 Channel Push Notification",
"39": "39 - 3 Wire RTD Temperature Sensor",
"40": "40 - Enterprise Vibration Sensor",
"41": "41 - RPM Proximity Sensor",
"42": "42 - 0-24VDC Voltage Monitor",
"43": "43 - Dual Temperature Humidity Current Detection Sensor",
"44": "44 - CO2 Gas Sensor",
"45": "45 - 4-20mA 16-Bit Input Transmitter",
"46": "46 - Motion Detection Sensor",
"47": "47 - Wireless Tilt Sensor",
"48": "48 - 4-20mA 16-Bit Input Transmitter",
"49": "49 - 6 Channel Thermocouple Sensor",
"50": "50 - Predictive Maintenance Sensor",
"51": "51 - 6 Channel Current Sensor",
"52": "52 - 2 Channel 4-20mA Receiver",
"53": "53 - Air Quality CO2 and PM Sensor",
"54": "54 - 3 Channel RTD",
"56": "56 - 2 Channel 0-10VDC Receiver",
"60": "60 - Air Velocity, Pressure, & Temperature Sensor",
"61": "61 - pH Temperature Sensor",
"62": "62 - ORP Temperature Sensor",
"63": "63 - pH and ORPTemperature Sensor",
"64": "64 - EC Salinity TDS and Temperature Sensor",
"65": "65 - DO and Temperature Sensor",
"66": "66 - DO EC Salinity TDS and Temperature Sensor",
"67": "67 - PAR Sensor",
"69": "69 - Soil Moisture Temperature and EC Sensor",
// "70": "70 - 2 Channel Soil Moisture Temperature and EC Sensor",
"71": "71 - 3 Channel Soil Moisture Temperature and EC Sensor",
"72": "72 - SDI Soil Moisture Temperature Moisture Probe",
"75": "75 - Siemens Air Velocity Probe",
"76": "76 - Wireless CO Gas Sensor",
"77": "77 - 3 Channel SDI Soil Moisture Temperature Moisture Probe",
"78": "78 - Oil Particulate Counter Sensor",
"79": "79 - Oil Analysis Sensor",
"80": "80 - One Channel Vibration Plus",
"81": "81 - Two Channel Vibration Plus",
"82": "82 - Condition Based/Predictive Maintenance Sensor",
"84": "84 - Standalone Smart Vibration Sensor",
"88": "88 - 1 Channel Ultrasound Vibration Sensor",
"89": "89 - 2 Channel Ultrasound Vibration Sensor",
"91": "91 - Wireless Air Velocity Sensor HVAC",
"92": "92 - Sound Sensor",
"95": "95 - 16-Bit 1-Channel 0-24VDC Receiver",
"96": "96 - 16-Bit 1-Channel 0-48VDC Receiver",
"101": "101 - Pro Vibration",
"102": "102 - Strain Gauge",
"200": "200 - 4-20mA Pass Through",
"202": "202 - Weather Station",
"502": "502 - C_50-27",
"505": "505 - Custom_SAP_Current_1C",
"506": "506 - Custom_SAP_Current_3C",
"507": "507 - Custom_SAP_Current_7C",
"510": "510 - GreenLight",
"515": "515 - Custom_SAP_Current_48C",
"519": "519: Custom Vibration 1",
"520": "520: Custom 6 Channel Current Temperature & Humidity",
"521": "521 - Custom 3 Channel Light Sensor",
"524": "524 - SDI Multi Soil Probe",
"531": "531 - Custom Noise Sensor",
"537": "537 - Custom Standalone Smart Vibration Sensor",
"10000": "10000 - 4-Channel Relay",
"10006": "10006 - 4-Channel 4-20 mA Input",
"10007": "10007 - 4-Channel Current Monitor",
"10012": "10012 - 2-Relay + 2-Input",
}
return types[this.sensor_type];
}
return 'Wireless Device';
},
oneditprepare: function() {
var that = this;
try {
$("#node-config-input-addr").autocomplete( "destroy" );
} catch(err) {}
$('.ncd-dependent[sensor_type]').hide();
// loops through all settings that need validation and sets default values
// Solves library upgrades that add new properties
for(let prop in this._def.defaults){
if(typeof this._def.defaults[prop].validate == 'function'){
if(this[prop] == undefined || this[prop] == ""){
$('#node-input-'+prop).val(this._def.defaults[prop].value);
}
}
}
$('#node-input-connection').change(function(){
$.getJSON('ncd/wireless/needs_input/'+$(this).val(),function(data) {
if(data.is_raw){
that.needs_input = 1;
}
});
});
$('#node-input-sensor_type').change(() => {
var type = $('#node-input-sensor_type').val();
$('.ncd-dependent').hide();
$('.ncd-dependent[data-sensor-'+type+']').show();
if(parseInt(type) >= 10000){
var current = $('#node-input-auto_config').prop('checked');
if(!current) $('#node-input-auto_config').click();
$('#node-input-auto_config').data('_checked', current).closest('.form-row').hide();
this.inputs = 1;
}else{
$("#node-input-auto_config").closest('.form-row').show();
if (typeof $("#node-input-auto_config").data('_checked') !== 'undefined'){
$('#node-input-auto_config').prop('checked', $("#node-input-auto_config").data('_checked')).click().removeData('_checked');
}
}
});
$("#node-lookup-sensors").click(function() {
$("#node-lookup-sensors").addClass('disabled');
var connection = RED.nodes.node($('#node-input-connection').val())
$.getJSON('ncd/wireless/sensors/list/'+$('#node-input-connection').val(),function(data) {
$("#node-lookup-sensors").removeClass('disabled');
var macs = [];
var sensors = {};
$.each(data, function(i, sensor) {
macs.push(sensor.mac);
sensors[sensor.mac] = sensor;
});
$("#node-input-addr").autocomplete({
source:macs,
minLength:0,
close: function( event, ui ) {
$("#node-input-addr").autocomplete( "destroy" );
},
select: function(e, ui){
$('#node-input-sensor_type option[value="'+sensors[ui.item.value].type+'"]').prop('selected', true);
$('#node-input-sensor_type').change();
$('#node-input-node_id').val(sensors[ui.item.value].nodeId);
}
}).autocomplete("search","");
});
});
$('.section .section-control').each(function(){
var handleClick = function(){
$(this).closest('.section').find('input, select').not('.section-control').prop('disabled', !$(this).is(':checked'));
}
$(this).click(handleClick);
handleClick.apply(this);
});
$('#config_sensor').click(function(){
if($(this).prop('disabled')) return;
$(this).prop('disabled', true).text('Configuring...');
$('#config_response').empty();
$.getJSON('ncd/wireless/sensors/configure/'+that.id,function(data) {
var clean = true;
for(var i in data){
if(data[i] !== true){
clean = false;
$('#config_response').append('<div>Problem setting '+i+': '+data[i]);
}
}
if(clean){
$('#config_response').append('<div>All configurations successfully set</div>');;
}
$('#config_sensor').prop('disabled', false).text('Configure Now');
});
});
$('.ncd-config-toggle').each(function(){
var handleClick = function(){
// if($(this).prop('checked') && $(this).data('target-id')) {
// $('#'+$(this).data('target-id')).prop('disabled', false);
// }
// else{
// $('#'+$(this).data('target-id')).prop('disabled', true);
// }
if($(this).prop('checked')){
if($(this).data('target-id')){
$('#'+$(this).data('target-id')).prop('disabled', false);
}
if($(this).data('target-class')){
$('.'+$(this).data('target-class')).prop('disabled', false);
}
}
else{
if($(this).data('target-id')){
$('#'+$(this).data('target-id')).prop('disabled', true);
}
if($(this).data('target-class')){
$('.'+$(this).data('target-class')).prop('disabled', true);
}
// $('#'+$(this).data('target-id')).prop('disabled', true);
}
}
$(this).click(handleClick);
handleClick.apply(this);
});
},
});
</script>
<script type="text/x-red" data-template-name="ncd-wireless-node">
<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">
<label for="node-input-connection"><i class="icon-tag"></i> Serial Device</label>
<select id="node-input-connection"></select>
</div>
<div class="form-row">
<label for="node-input-config_comm"><i class="icon-tag"></i> Serial Device for Config</label>
<select id="node-input-config_comm"></select>
</div>
<div class="form-row">
<label for="node-input-addr"><i class="fa fa-random"></i> Mac Address</label>
<input type="text" id="node-input-addr" style="width:60%;" >
<a id="node-lookup-sensors" class="btn"><i id="node-lookup-sensors-icon" class="fa fa-search"></i></a>
</div>
<div class="form-row">
<label for="node-input-sensor_type"><i class="icon-tag"></i> Sensor Type</label>
<select id="node-input-sensor_type">
<option value="1">1 - Temperature and Humidity</option>
<option value="2">2 - 2ch Push Notification/Voltage Detection</option>
<option value="3">3 - ADC/4-20 mA/DC Voltage</option>
<option value="4">4 - Thermocouple</option>
<option value="5">5 - Accel, Gyro, Magneto and Temperature</option>
<option value="6">6 - Temperature and Barometeric Pressure</option>
<option value="7">7 - Impact Detection</option>
<option value="8">8 - Vibration</option>
<option value="9">9 - Proximity</option>
<option value="10">10 - Light</option>
<option value="12">12 - 3-channel Thermocouple</option>
<option value="13">13 - Current Monitor</option>
<option value="14">14 - 10-Bit 1-Channel 4-20mA</option>
<option value="15">15 - 10-Bit 1-Channel ADC</option>
<option value="16">16 - Soil Moisture Sensor</option>
<option value="17">17 - 24-Bit AC Voltage Monitor</option>
<option value="18">18 - Pulse/Frequency</option>
<option value="19">19 - 2-channel 24-bit Current Monitor</option>
<option value="20">20 - Precision Pressure & Temperature (pA)</option>
<option value="21">21 - AMS Pressure & Temperature</option>
<option value="22">22 - 0-24V AC/DC Optically Isolated Inputs</option>
<option value="23">23 - 2-channel Thermocouple</option>
<option value="24">24 - Activity Detection</option>
<option value="25">25 - Asset Monitor</option>
<option value="26">26 - Pressure & Temperature (PSI)</option>
<option value="27">27 - Environmental</option>
<option value="28">28 - 3-Channel Current Monitor</option>
<option value="29">29 - Linear Displacement Sensor</option>
<option value="30">30 - Structural Monitoring Sensor</option>
<option value="31">31 - Air Quality TVOC eCO2 Temperature and Humidity Sensor</option>
<option value="32">32 - Particulate Matter Sensor</option>
<option value="33">33 - AC Current Detect Sensor</option>
<option value="34">34 - Wireless Tank Level</option>
<option value="35">35 - One Channel Counter</option>
<option value="36">36 - Two Channel Counter</option>
<option value="37">37 - 7 Channel Push Notification</option>
<option value="39">39 - RTD Temperature Sensor</option>
<option value="40">40 - Vibration w/Time Domain (partial support)</option>
<option value="41">41 - RPM Proximity Sensor</option>
<option value="42">42 - 0-24VDC Voltage Monitor</option>
<option value="43">43 - Dual Temperature Humidity Current Detection Sensor</option>
<option value="44">44 - Wireless CO2 Gas Sensor</option>
<option value="45">45 - 4-20mA 16-Bit Input Transmitter</option>
<option value="46">46 - Motion Detection Sensor</option>
<option value="47">47 - Type 47: Tilt Sensor</option>
<option value="48">48 - 4-20mA 16-Bit Input Transmitter</option>
<option value="49">49 - 6 Channel Thermocouple Sensor</option>
<option value="50">50 - Predictive Maintenance Sensor</option>
<option value="51">51 - 6 Channel Current Sensor</option>
<option value="52">52 - 2 Channel 4-20mA Receiver</option>
<option value="53">53 - Air Quality CO2 and PM Sensor</option>
<option value="54">54 - 3 Channel RTD</option>
<option value="56">56 - 2 Channel 0-10VDC Receiver</option>
<option value="60">60 - Air Velocity and Precision Pressure & Temperature Sensor</option>
<option value="61">61 - pH Temperature Sensor</option>
<option value="62">62 - ORP Temperature Sensor</option>
<option value="63">63 - pH and ORPTemperature Sensor</option>
<option value="64">64 - EC Salinity TDS and Temperature Sensor</option>
<option value="65">65 - DO and Temperature Sensor</option>
<option value="66">66 - DO EC Salinity TDS and Temperature Sensor</option>
<option value="67">67 - PAR Sensor</option>
<option value="69">69 - Soil Moisture Temperature and EC Sensor</option>
<!--
<option value="70">70 - 2 Channel Soil Moisture Temperature and EC Sensor</option>
-->
<option value="71">71 - 3 Channel Soil Moisture Temperature and EC Sensor</option>
<option value="72">72 - SDI-12 Wireless</option>
<option value="75">75 - Siemens Air Velocity Probe</option>
<option value="76">76 - Wireless CO Gas Sensor</option>
<option value="77">77 - 3 Channel SDI Soil Moisture Temperature Moisture Probe</option>
<option value="78">78 - Oil Particulate Counter Sensor</option>
<option value="79">79 - Oil Analysis Sensor</option>
<option value="80">80 - One Channel Vibration Plus</option>
<option value="81">81 - Two Channel Vibration Plus</option>
<option value="82">82 - Condition Based/Predictive Maintenance Sensor</option>
<option value="84">84 - Standalone Smart Vibration Sensor</option>
<option value="88">88 - 1 Channel Ultrasound Vibration Sensor</option>
<option value="89">89 - 2 Channel Ultrasound Vibration Sensor</option>
<option value="91">91 - Wireless Air Velocity Sensor HVAC</option>
<option value="92">92 - Sound Sensor</option>
<option value="95">95 - 16-Bit 1-Channel 0-24VDC Receiver</option>
<option value="96">96 - 16-Bit 1-Channel 0-48VDC Receiver</option>
<option value="101">101 - Pro Vibration</option>
<option value="102">102 - Strain Gauge</option>
<option value="200">200 - 4-20mA Pass Through</option>
<option value="202">202 - Weather Station</option>
<option value="502">502 - C_50-27</option>
<option value="505">505 - Custom_SAP_Current_1C</option>
<option value="506">506 - Custom_SAP_Current_3C</option>
<option value="507">507 - Custom_SAP_Current_7C</option>
<option value="510">510 - GreenLight</option>
<option value="515">515 - Custom_SAP_Current_48C</option>
<option value="519">519 - Type 519: Custom Vibration 1</option>
<option value="520">520 - Type 520: Custom 6 Channel Current Temperature & Humidity</option>
<option value="521">521 - Custom 3 Channel Light Sensor</option>
<option value="524">524 - SDI Multi Soil Probe</option>
<option value="531">531 - Custom Noise Sensor</option>
<option value="537">537 - Custom Standalone Smart Vibration Sensor</option>
<option value="10000">10000 - 4-Channel Relay</option>
<option value="10006">10006 - 4-Channel 4-20 mA Input</option>
<option value="10007">10007 - 4-Channel Current Monitor</option>
<option value="10012">10012 - 2-Relay + 2-Input</option>
</select>
</div>
<div class="section">
<h3>Advanced</h3>
<div>
<div class="form-row">
<label for="node-input-auto_config"><i class="icon-tag"></i> Auto Config</label>
<input class="section-control" type="checkbox" id="node-input-auto_config" value="1">
</div>
<div class="form-row ncd-dependent" data-sensor-23 data-sensor-26 data-sensor-45 data-sensor-48 data-sensor-78 data-sensor-79 data-sensor-80 data-sensor-81 data-sensor-82 data-sensor-84 data-sensor-88 data-sensor-89 data-sensor-91 data-sensor-101 data-sensor-102 data-sensor-519 data-sensor-520 data-sensor-521 data-sensor-531 data-sensor-537>
<hr>
<label for="node-input-on_the_fly_enable"><i class="icon-tag"></i> OTF Config*</label>
<input type="checkbox" id="node-input-on_the_fly_enable" value="1">
<p class="caption">
*OTF: On The Fly.<br>This option allows for configuring the sensor without entering configuration mode.<br>
This option is in development and few configuration options are supported.
</p>
<hr>
</div>
<div class="form-row ncd-active-check">
<strong>Wait for Network Formation</strong>
<div>
<label for="node-input-form_network"><i class="icon-tag"></i>Enable</label>
<input type="checkbox" id="node-input-form_network" value="1">
</div>
<p class="caption">
Enabling this adds commands to ensure the mesh network is <br>fully formed before sending configuration<br>
This will increase the reliability of confiugration commands but slow down configuration
</p>
</div>
<div class="form-row ncd-active-check">
<strong>Destination Address</strong>
<div>
<label for="node-input-destination_active">Active:</label>
<input type="checkbox" id="node-input-destination_active" class="ncd-config-toggle" data-target-class="node-input-destination" value="1">
</div>
<div>
<label for="node-input-destination"><i class="icon-tag"></i>Address:</label>
<input type="text" id="node-input-destination" value="0000FFFF">
</div>
<p class="caption">
Default value: 0000FFFF for Broadcast Mode<br>
Example of targeted address: 41D5EC37
</p>
</div>
<div class="form-row ncd-active-check">
<strong>Network ID</strong>
<div>
<label for="node-input-pan_id_active">Active:</label>
<input type="checkbox" id="node-input-pan_id_active" class="ncd-config-toggle" data-target-class="node-input-pan_id" value="1">
</div>
<div>
<label for="node-input-pan_id"><i class="icon-tag"></i>Network ID:</label>
<input type="text" id="node-input-pan_id" value="7FFF">
</div>
<p class="caption">
Network ID Valid Range: 0-0x7FFF. Automatic sensor reboot<br><br>
<strong>WARNING</strong>: Setting this to active while your sensor supports OTF will put sensors into a reboot cycle.<br>
Once all of the sensors have had their Network ID updated you must disable this configuration.
</p>
</div>
<div class="form-row ncd-active-check">
<strong>Node ID and Delay</strong>
<div>
<label for="node-input-node_id_delay_active">Active:</label>
<input type="checkbox" id="node-input-node_id_delay_active" class="ncd-config-toggle" data-target-class="node-input-node_id_delay" value="1">
</div>
<div>
<label for="node-input-node_id"><i class="icon-tag"></i>Node ID:</label>
<input type="text" id="node-input-node_id" class="node-input-node_id_delay">
</div>
<div>
<label for="node-input-delay"><i class="icon-tag"></i>Delay:</label>
<input type="text" id="node-input-delay" class="node-input-node_id_delay">
</div>
</div>
<div class="form-row ncd-active-check">
<strong>Power</strong>
<div>
<label for="node-input-power_active">Active:</label>
<input type="checkbox" id="node-input-power_active" class="ncd-config-toggle" data-target-id="node-input-power" value="1">
</div>
<div>
<label for="node-input-power"><i class="icon-tag"></i>Value:</label>
<select id="node-input-power">
<option value="0">+7 dBm (5 mW)</option>
<option value="1">+15 dBm (32 mW)</option>
<option value="2">+18 dBm (63 mW)</option>
<option value="3">+21 dBm (125 mW)</option>
<option selected="selected" value="4">+24 dBm (250 mW)</option>
</select>
</div>
</div>
<div class="form-row ncd-active-check">
<strong>Retries</strong>
<div>
<label for="node-input-retries_active">Active:</label>
<input type="checkbox" id="node-input-retries_active" class="ncd-config-toggle" data-target-id="node-input-retries" value="1">
</div>
<div>
<label for="node-input-retries"><i class="icon-tag"></i>Value:</label>
<input type="text" id="node-input-retries">
</div>
</div>
<div class="ncd-dependent" data-sensor-13 data-sensor-10 data-sensor-3>
<div class="form-row">
<label for="node-input-change_enabled"><i class="icon-tag"></i> Enable Percentage Change Detection</label>
<input type="checkbox" id="node-input-change_enabled" value="1">
</div>
<div class="form-row">
<label for="node-input-change_pr"><i class="icon-tag"></i> Percentage Change Threshold (0-255)</label>
<input type="text" id="node-input-change_pr">
</div>
<div class="form-row">
<label for="node-input-change_interval"><i class="icon-tag"></i> Percentage Change Interval (seconds)</label>
<input type="text" id="node-input-change_interval">
</div>
</div>
<!-- Current Monitor Options -->
<div class="ncd-dependent" data-sensor-13>
<div class="form-row">
<label for="node-input-cm_calibration"><i class="icon-tag"></i> Calibration Option (0 - 655.35)</label>
<input type="text" id="node-input-cm_calibration">
</div>
</div>
<!-- Barometric Pressure Options -->
<div class="ncd-dependent" data-sensor-6>
<div class="form-row">
<label for="node-input-bp_altitude"><i class="icon-tag"></i> Baseline Altitude (0 - 65535 meters)</label>
<input type="text" id="node-input-bp_altitude">
</div>
<div class="form-row">
<label for="node-input-bp_pressure"><i class="icon-tag"></i> Baseline Pressure (0 - 14000 mbar)</label>
<input type="text" id="node-input-bp_pressure">
</div>
<div class="form-row">
<label for="node-input-bp_temp_prec"><i class="icon-tag"></i> Temperature Precision</label>
<select id="node-input-bp_temp_prec">
<option selected="selected" value="0">0.012</option>
<option value="2">0.008</option>
<option value="4">0.005</option>
<option value="6">0.003</option>
<option value="8">0.002</option>
</select>
</div>
<div class="form-row">
<label for="node-input-bp_press_prec"><i class="icon-tag"></i> Pressure Precision</label>
<select id="node-input-bp_press_prec">
<option selected="selected" value="0">0.065</option>
<option value="2">0.042</option>
<option value="4">0.027</option>
<option value="6">0.018</option>
<option value="8">0.012</option>
</select>
</div>
</div>
<!-- Magneto/Gyro/Accel/Temp Options -->
<div class="ncd-dependent" data-sensor-5>
<div class="form-row">
<label for="node-input-amgt_accel"><i class="icon-tag"></i> Acceleration Range</label>
<select id="node-input-amgt_accel">
<option selected="selected" value="0">±2g</option>
<option value="1">±4g</option>
<option value="3">±8g</option>
<option value="4">±16g</option>
</select>
</div>
<div class="form-row">
<label for="node-input-amgt_mag"><i class="icon-tag"></i> Magnetometer Gain</label>
<select id="node-input-amgt_mag">
<option selected="selected" value="0">±4 gauss</option>
<option value="1">±8 gauss</option>
<option value="2">±12 gauss</option>
<option value="3">±16 gauss</option>
</select>
</div>
<div class="form-row">
<label for="node-input-amgt_gyro"><i class="icon-tag"></i> Gyroscope Scale</label>
<select id="node-input-amgt_gyro">
<option selected="selected" value="0">±245dps</option>
<option value="1">±500dps</option>
<option value="2">±2000dps</option>
</select>
</div>
</div>
<div class="ncd-dependent" data-sensor-7 data-sensor-24>
<hr>
<div class="form-row ncd-active-check">
<div>
<strong>Acceleration Range</strong>
</div>
<div>
<label for="node-input-impact_accel_active">Active:</label>
<input type="checkbox" id="node-input-impact_accel_active" class="ncd-config-toggle" data-target-id="node-input-impact_accel" value="1">
</div>
<div>
<label for="node-input-impact_accel"><i class="icon-tag"></i>Value:</label>
<select id="node-input-impact_accel">
<option selected="selected" value="0">±2g</option>
<option value="1">±4g</option>
<option value="3">±8g</option>
<option value="4">±16g</option>
</select>
</div>
</div>
<div class="form-row ncd-active-check">
<div>
<strong>Data Rate</strong>
</div>
<div>
<label for="node-input-impact_data_rate_active">Active:</label>
<input type="checkbox" id="node-input-impact_data_rate_active" class="ncd-config-toggle" data-target-id="node-input-impact_data_rate" value="1">
</div>
<div>
<label for="node-input-impact_data_rate"><i class="icon-tag"></i> Data Rate</label>
<select id="node-input-impact_data_rate">
<option selected="selected" value="0">Value:</option>
<option value="1">1</option>
<option value="2">10</option>
<option value="3">25</option>
<option value="4">50</option>
<option value="5">100</option>
<option value="6">200</option>
<option value="7">400</option>
<option value="8">1600</option>
<option value="9">5376</option>
</select>
</div>
</div>
<div class="form-row ncd-active-check">
<div>
<strong>Threshold</strong>
<p>Accepted values from 1-127.</p>
</div>
<div>
<label for="node-input-impact_threshold_active">Active:</label>
<input type="checkbox" id="node-input-impact_threshold_active" class="ncd-config-toggle" data-target-id="node-input-impact_threshold" value="1">
</div>
<div>
<label for="node-input-impact_threshold"><i class="icon-tag"></i>Value:</label>
<input id="node-input-impact_threshold">
</div>
</div>
<div class="form-row ncd-active-check">
<div>
<strong>Duration</strong>
<p>Accepted values from 1-127.</p>
</div>
<div>
<label for="node-input-impact_duration_active">Active:</label>
<input type="checkbox" id="node-input-impact_duration_active" class="ncd-config-toggle" data-target-id="node-input-impact_duration" value="1">
</div>
<div>
<label for="node-input-impact_duration"><i class="icon-tag"></i>Value:</label>
<input id="node-input-impact_duration">
</div>
</div>
</div>
<div class="ncd-dependent" data-sensor-24>
<div class="form-row">
<label for="node-input-activ_interr_x"><i class="icon-tag"></i> Interrupt X-Axis</label>
<select id="node-input-activ_interr_x">
<option value="1">High</option>
<option value="0">Low</option>
</select>
</div>
<div class="form-row">
<label for="node-input-activ_interr_y"><i class="icon-tag"></i> Interrupt Y-Axis</label>
<select id="node-input-activ_interr_y">
<option value="2">High</option>
<option value="0">Low</option>
</select>
</div>
<div class="form-row">
<label for="node-input-activ_interr_z"><i class="icon-tag"></i> Interrupt Z-Axis</label>
<select id="node-input-activ_interr_z">
<option value="4">High</option>
<option value="0">Low</option>
</select>
</div>
<div class="form-row">
<label for="node-input-activ_interr_op"><i class="icon-tag"></i> Interrupt Logic</label>
<select id="node-input-activ_interr_op">
<option value="8">And</option>
<option value="0">Or</option>
</select>
</div>
</div>
<div class="ncd-dependent" data-sensor-40>
<div class="form-row">
<label for="node-input-filtering"><i class="icon-tag"></i> Data Filtering</label>
<select id="node-input-filtering">
<option value="1">Enable</option>
<option value="0">Disable</option>
</select>
</div>
<div class="form-row">
<label for="node-input-data_rate"><i class="icon-tag"></i> Data Rate</label>
<select id="node-input-data_rate">
<option value="5">400 Hz</option>