@ncd-io/node-red-enterprise-sensors 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ module.exports = (globalDevices, emitter) => {
30
30
  emitter.emit('sensor_data', parsed);
31
31
  emitter.emit('sensor_data-114', parsed);
32
32
  emitter.emit('sensor_data' + '-' + deviceAddr, parsed);
33
- }, 6000);
33
+ }, 60000);
34
34
  };
35
35
 
36
36
  const concat_fft_data = (deviceAddr, mode, msg_type) => {
@@ -123,7 +123,8 @@ module.exports = (globalDevices, emitter) => {
123
123
  },
124
124
  "tags": [
125
125
  "system"
126
- ]
126
+ ],
127
+ "old_fly_id": "firmware"
127
128
  },
128
129
  "sensor_type": {
129
130
  "read_index": 5,
@@ -227,7 +228,7 @@ module.exports = (globalDevices, emitter) => {
227
228
  "read_index": 21,
228
229
  "write_index": 10,
229
230
  "descriptions": {
230
- "title": "Probe 1: Output Data Rate",
231
+ "title": "Output Data Rate",
231
232
  "main_caption": "<p>This would determine how many samples the output data has...</p>"
232
233
  },
233
234
  "default_value": 0,
@@ -267,6 +268,10 @@ module.exports = (globalDevices, emitter) => {
267
268
  "max": 100,
268
269
  "generated": true
269
270
  },
271
+ "converter": {
272
+ 'multiplier': 50,
273
+ 'units': 'ms'
274
+ },
270
275
  "tags": [
271
276
  "Vibration Sampling"
272
277
  ],
@@ -287,6 +292,7 @@ module.exports = (globalDevices, emitter) => {
287
292
  "generated": true
288
293
  },
289
294
  "options": {
295
+ "10": "2",
290
296
  "0": "4",
291
297
  "1": "8",
292
298
  "2": "16",
@@ -298,7 +304,8 @@ module.exports = (globalDevices, emitter) => {
298
304
  "8": "1024",
299
305
  "9": "2048"
300
306
  },
301
- "html_id": "low_pass_filter_p1_110"
307
+ "html_id": "low_pass_filter_p1_110",
308
+ "old_fly_id": "lpf_coeff"
302
309
  },
303
310
  "hpf_coefficient": {
304
311
  "read_index": 24,
@@ -326,7 +333,8 @@ module.exports = (globalDevices, emitter) => {
326
333
  "8": "1024",
327
334
  "9": "2048"
328
335
  },
329
- "html_id": "high_pass_filter_p1_110"
336
+ "html_id": "high_pass_filter_p1_110",
337
+ "old_fly_id": "hpf_coeff"
330
338
  },
331
339
  "full_scale_range": {
332
340
  "read_index": 25,
@@ -353,7 +361,8 @@ module.exports = (globalDevices, emitter) => {
353
361
  "tags": [
354
362
  "Vibration Sampling"
355
363
  ],
356
- "html_id": "full_scale_range_101"
364
+ "html_id": "full_scale_range_101",
365
+ "old_fly_id": "fsr"
357
366
  },
358
367
  "axes_enabled": {
359
368
  "read_index": 26,
@@ -412,8 +421,8 @@ module.exports = (globalDevices, emitter) => {
412
421
  "generated": true
413
422
  },
414
423
  "options": {
415
- "0": "Enabled",
416
- "1": "Disabled"
424
+ "0": "Disabled",
425
+ "1": "Enabled"
417
426
  },
418
427
  "html_id": "enable_filtering_110"
419
428
  },
@@ -437,7 +446,8 @@ module.exports = (globalDevices, emitter) => {
437
446
  "2": "Processed + Raw on demand",
438
447
  "3": "Smart"
439
448
  },
440
- "html_id": "mode_110"
449
+ "html_id": "mode_110",
450
+ "old_fly_id": "mode"
441
451
  },
442
452
  "measurement_mode": {
443
453
  "read_index": 30,
@@ -465,6 +475,9 @@ module.exports = (globalDevices, emitter) => {
465
475
  "max": 10,
466
476
  "generated": true
467
477
  },
478
+ "converter": {
479
+ "units": " Seconds"
480
+ },
468
481
  "depends_on": {
469
482
  "operation_mode": [
470
483
  2,
@@ -487,6 +500,9 @@ module.exports = (globalDevices, emitter) => {
487
500
  "max": 255,
488
501
  "generated": true
489
502
  },
503
+ "converter": {
504
+ "units": "mg"
505
+ },
490
506
  "html_id": "deadband_80"
491
507
  },
492
508
  "motion_detection_threshold": {
@@ -556,10 +572,15 @@ module.exports = (globalDevices, emitter) => {
556
572
  "min": 1,
557
573
  "max": 40
558
574
  },
575
+ "converter": {
576
+ "multiplier": 50,
577
+ "units": "mg"
578
+ },
559
579
  "depends_on": {
560
580
  "operation_mode": 3
561
581
  },
562
- "html_id": "smart_threshold_110"
582
+ "html_id": "smart_threshold_110",
583
+ "old_fly_id": "smart_mode_acc_threshold"
563
584
  },
564
585
  "led_alert_mode": {
565
586
  "read_index": 37,
@@ -605,7 +626,8 @@ module.exports = (globalDevices, emitter) => {
605
626
  "tags": [
606
627
  "Communications"
607
628
  ],
608
- "html_id": "payload_length_80"
629
+ "html_id": "payload_length_80",
630
+ "old_fly_id": "payload_length"
609
631
  },
610
632
  "auto_raw_interval": {
611
633
  "read_index": 39,
@@ -730,6 +752,9 @@ module.exports = (globalDevices, emitter) => {
730
752
  "min": 1024,
731
753
  "max": 8100
732
754
  },
755
+ "converter": {
756
+ "units": " Samples"
757
+ },
733
758
  "options": {
734
759
  "1024": "1024 Samples",
735
760
  "2048": "2048 Samples",
@@ -737,7 +762,8 @@ module.exports = (globalDevices, emitter) => {
737
762
  "6400": "6400 Samples",
738
763
  "8100": "8100 Samples"
739
764
  },
740
- "html_id": "max_raw_sample_110"
765
+ "html_id": "max_raw_sample_110",
766
+ "old_fly_id": "max_tx_raw_samples"
741
767
  },
742
768
  "motion_to_sampling_delay": {
743
769
  "read_index": 50,
@@ -753,6 +779,10 @@ module.exports = (globalDevices, emitter) => {
753
779
  "max": 255,
754
780
  "generated": true
755
781
  },
782
+ "converter": {
783
+ "multiplier": 50,
784
+ "units": "msec",
785
+ },
756
786
  "html_id": "motion_to_sampling_delay_110"
757
787
  },
758
788
  "max_motion_tx_per_interval": {
@@ -769,46 +799,62 @@ module.exports = (globalDevices, emitter) => {
769
799
  "max": 255,
770
800
  "generated": true
771
801
  },
772
- "html_id": "max_num_motion_tx_delay_110"
802
+ "html_id": "max_num_motion_tx_delay_110",
803
+ "old_fly_id": "max_num_of_motion_tx_per_interval"
773
804
  }
774
805
  };
775
806
  };
776
807
 
777
808
  const sync_parse = (rep_buffer) => {
778
- let response = {};
809
+ let response = {
810
+ 'human_readable': {},
811
+ 'machine_values': {}
812
+ };
779
813
 
780
814
  // Get the map based on the sensor type byte
781
815
  const sync_map = get_config_map(rep_buffer[4]);
782
816
 
783
817
  for (const [key, config] of Object.entries(sync_map)) {
784
818
  // Destructure 'type' from inside 'validator' and rename 'read_index' to 'idx'
785
- const { read_index: idx, length, validator: { type } = {} } = config;
819
+ const { read_index: idx, length, validator: { type } = {}, converter, options } = config;
786
820
 
787
821
  // If for some reason a config doesn't have a validator/type, skip it
788
822
  if (!type) continue;
789
823
 
790
824
  switch (type) {
791
825
  case 'uint8':
792
- response[key] = rep_buffer[idx];
826
+ response.machine_values[key] = rep_buffer[idx];
793
827
  break;
794
828
  case 'uint16be':
795
- response[key] = rep_buffer.readUInt16BE(idx);
829
+ response.machine_values[key] = rep_buffer.readUInt16BE(idx);
796
830
  break;
797
831
  case 'uint32be':
798
- response[key] = rep_buffer.readUInt32BE(idx);
832
+ response.machine_values[key] = rep_buffer.readUInt32BE(idx);
799
833
  break;
800
834
  case 'buffer':
801
- response[key] = rep_buffer.subarray(idx, idx + length);
835
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length);
802
836
  break;
803
837
  case 'hex':
804
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
838
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
805
839
  break;
806
840
  case 'mac':
807
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
841
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
808
842
  break;
809
843
  }
844
+ let human_value = response.machine_values[key];
845
+ if(options && options[response.machine_values[key]]){
846
+ human_value = options[response.machine_values[key]];
847
+ }else{
848
+ if(converter && converter.multiplier){
849
+ human_value = human_value * converter.multiplier;
850
+ }
851
+ if(converter && converter.units){
852
+ human_value = human_value + converter.units;
853
+ }
854
+ }
855
+ response.human_readable[key] = human_value;
810
856
  }
811
- if (Object.hasOwn(response, 'destination_address') && response.destination_address.toLowerCase() === '00000000') {
857
+ if (Object.hasOwn(response.machine_values, 'destination_address') && response.machine_values.destination_address.toLowerCase() === '00000000') {
812
858
  console.log('##############################');
813
859
  console.log('#########Dest Override########');
814
860
  console.log('##############################');
@@ -217,18 +217,15 @@ module.exports = (globalDevices) => {
217
217
  "validator": {
218
218
  "type": "uint8",
219
219
  "min": 0,
220
- "max": 7,
220
+ "max": 4,
221
221
  "generated": true
222
222
  },
223
223
  "options": {
224
224
  "0": "Disabled",
225
225
  "1": "Enable on IO1",
226
226
  "2": "Enable on IO2",
227
- "3": "Enable on IO3",
228
- "4": "Enable on IO1 and IO2",
229
- "5": "Enable on IO1 and IO3",
230
- "6": "Enable on IO2 and IO3",
231
- "7": "Enable All"
227
+ "3": "Enable on IO1 and IO2",
228
+ "4": "Enable All"
232
229
  },
233
230
  "html_id": "push_notification_123"
234
231
  },
@@ -532,46 +529,61 @@ module.exports = (globalDevices) => {
532
529
  };
533
530
 
534
531
  const sync_parse = (rep_buffer) => {
535
- let response = {};
536
-
532
+ let response = {
533
+ 'human_readable': {},
534
+ 'machine_values': {}
535
+ };
536
+
537
537
  // Get the map based on the sensor type byte
538
538
  const sync_map = get_config_map(rep_buffer[4]);
539
539
 
540
540
  for (const [key, config] of Object.entries(sync_map)) {
541
541
  // Destructure 'type' from inside 'validator' and rename 'read_index' to 'idx'
542
- const { read_index: idx, length, validator: { type } = {} } = config;
542
+ const { read_index: idx, length, validator: { type } = {}, converter, options } = config;
543
543
 
544
544
  // If for some reason a config doesn't have a validator/type, skip it
545
545
  if (!type) continue;
546
546
 
547
547
  switch (type) {
548
- case 'uint8':
549
- response[key] = rep_buffer[idx];
548
+ case 'uint8':
549
+ response.machine_values[key] = rep_buffer[idx];
550
550
  break;
551
- case 'uint16be':
552
- response[key] = rep_buffer.readUInt16BE(idx);
551
+ case 'uint16be':
552
+ response.machine_values[key] = rep_buffer.readUInt16BE(idx);
553
553
  break;
554
- case 'uint32be':
555
- response[key] = rep_buffer.readUInt32BE(idx);
554
+ case 'uint32be':
555
+ response.machine_values[key] = rep_buffer.readUInt32BE(idx);
556
556
  break;
557
- case 'buffer':
558
- response[key] = rep_buffer.subarray(idx, idx + length);
557
+ case 'buffer':
558
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length);
559
559
  break;
560
- case 'hex':
561
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
560
+ case 'hex':
561
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
562
562
  break;
563
- case 'mac':
564
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
563
+ case 'mac':
564
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
565
565
  break;
566
566
  }
567
+ let human_value = response.machine_values[key];
568
+ if(options && options[response.machine_values[key]]){
569
+ human_value = options[response.machine_values[key]];
570
+ }else{
571
+ if(converter && converter.multiplier){
572
+ human_value = human_value * converter.multiplier;
573
+ }
574
+ if(converter && converter.units){
575
+ human_value = human_value + converter.units;
576
+ }
577
+ }
578
+ response.human_readable[key] = human_value;
567
579
  }
568
- // if(Object.hasOwn(response, 'destination_address') && response.destination_address.toLowerCase() === '00000000') {
569
- // console.log('##############################');
570
- // console.log('#########Dest Override########');
571
- // console.log('##############################');
572
- // response.destination_address = "0000ffff";
573
- // response.auto_raw_destination_address = "0000ffff";
574
- // };
580
+ if (Object.hasOwn(response.machine_values, 'destination_address') && response.machine_values.destination_address.toLowerCase() === '00000000') {
581
+ console.log('##############################');
582
+ console.log('#########Dest Override########');
583
+ console.log('##############################');
584
+ response.destination_address = "0000ffff";
585
+ response.auto_raw_destination_address = "0000ffff";
586
+ };
575
587
  return response;
576
588
  };
577
589
 
@@ -590,46 +590,61 @@ module.exports = (globalDevices) => {
590
590
  };
591
591
 
592
592
  const sync_parse = (rep_buffer) => {
593
- let response = {};
594
-
593
+ let response = {
594
+ 'human_readable': {},
595
+ 'machine_values': {}
596
+ };
597
+
595
598
  // Get the map based on the sensor type byte
596
599
  const sync_map = get_config_map(rep_buffer[4]);
597
600
 
598
601
  for (const [key, config] of Object.entries(sync_map)) {
599
602
  // Destructure 'type' from inside 'validator' and rename 'read_index' to 'idx'
600
- const { read_index: idx, length, validator: { type } = {} } = config;
603
+ const { read_index: idx, length, validator: { type } = {}, converter, options } = config;
601
604
 
602
605
  // If for some reason a config doesn't have a validator/type, skip it
603
606
  if (!type) continue;
604
607
 
605
608
  switch (type) {
606
- case 'uint8':
607
- response[key] = rep_buffer[idx];
609
+ case 'uint8':
610
+ response.machine_values[key] = rep_buffer[idx];
608
611
  break;
609
- case 'uint16be':
610
- response[key] = rep_buffer.readUInt16BE(idx);
612
+ case 'uint16be':
613
+ response.machine_values[key] = rep_buffer.readUInt16BE(idx);
611
614
  break;
612
- case 'uint32be':
613
- response[key] = rep_buffer.readUInt32BE(idx);
615
+ case 'uint32be':
616
+ response.machine_values[key] = rep_buffer.readUInt32BE(idx);
614
617
  break;
615
- case 'buffer':
616
- response[key] = rep_buffer.subarray(idx, idx + length);
618
+ case 'buffer':
619
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length);
617
620
  break;
618
- case 'hex':
619
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
621
+ case 'hex':
622
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
620
623
  break;
621
- case 'mac':
622
- response[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
624
+ case 'mac':
625
+ response.machine_values[key] = rep_buffer.subarray(idx, idx + length).toString('hex');
623
626
  break;
624
627
  }
628
+ let human_value = response.machine_values[key];
629
+ if(options && options[response.machine_values[key]]){
630
+ human_value = options[response.machine_values[key]];
631
+ }else{
632
+ if(converter && converter.multiplier){
633
+ human_value = human_value * converter.multiplier;
634
+ }
635
+ if(converter && converter.units){
636
+ human_value = human_value + converter.units;
637
+ }
638
+ }
639
+ response.human_readable[key] = human_value;
625
640
  }
626
- // if(Object.hasOwn(response, 'destination_address') && response.destination_address.toLowerCase() === '00000000') {
627
- // console.log('##############################');
628
- // console.log('#########Dest Override########');
629
- // console.log('##############################');
630
- // response.destination_address = "0000ffff";
631
- // response.auto_raw_destination_address = "0000ffff";
632
- // };
641
+ if (Object.hasOwn(response.machine_values, 'destination_address') && response.machine_values.destination_address.toLowerCase() === '00000000') {
642
+ console.log('##############################');
643
+ console.log('#########Dest Override########');
644
+ console.log('##############################');
645
+ response.destination_address = "0000ffff";
646
+ response.auto_raw_destination_address = "0000ffff";
647
+ };
633
648
  return response;
634
649
  };
635
650