-
Notifications
You must be signed in to change notification settings - Fork 531
Expand file tree
/
Copy pathprocess_processlist.php
More file actions
2017 lines (1820 loc) · 78.4 KB
/
process_processlist.php
File metadata and controls
2017 lines (1820 loc) · 78.4 KB
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
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Emoncms - open source energy visualisation
Part of the OpenEnergyMonitor project: http://openenergymonitor.org
*/
// no direct access
use Mosquitto\Client;
defined('EMONCMS_EXEC') or die('Restricted access');
// This is core Process list module
class Process_ProcessList
{
private $mysqli;
private $input;
private $feed;
private $timezone;
private $proc_initialvalue; // save the input value at beginning of the processes list execution
private $proc_skip_next; // skip execution of next process in process list
private $proc_goto; // goto step in process list
private $log;
private $mqtt = false;
private $data_cache = array();
// Module required constructor, receives parent as reference
public function __construct($parent)
{
$this->mysqli = &$parent->mysqli;
$this->input = &$parent->input;
$this->feed = &$parent->feed;
$this->timezone = &$parent->timezone;
$this->proc_initialvalue = &$parent->proc_initialvalue;
$this->proc_skip_next = &$parent->proc_skip_next;
$this->proc_goto = &$parent->proc_goto;
$this->log = new EmonLogger(__FILE__);
// Load MQTT if enabled
// Publish value to MQTT topic, see: http://openenergymonitor.org/emon/node/5943
global $settings, $log;
if ($settings['mqtt']['enabled'] && !$this->mqtt) {
// @see: https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
if (class_exists(Client::class)) {
/*
new Mosquitto\Client($id,$cleanSession)
$id (string) – The client ID. If omitted or null, one will be generated at random.
$cleanSession (boolean) – Set to true to instruct the broker to clean all messages and subscriptions on disconnect. Must be true if the $id parameter is null.
*/
$mqtt_client = new Mosquitto\Client(null, true);
$mqtt_client->onDisconnect(function ($responseCode) use ($log) {
if ($responseCode > 0) {
$log->info('unexpected disconnect from mqtt server');
}
});
$this->mqtt = $mqtt_client;
}
}
}
public function process_list()
{
textdomain("process_messages");
return array(
array(
"id_num" => 1,
"name" => tr("Log to feed"),
"short" => "log",
"function" => "log_to_feed",
"args" => array(
array(
"type" => ProcessArg::FEEDID,
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY, Engine::CASSANDRA)
),
),
"group" => tr("Main"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>This processor logs to a timeseries feed which can then be used to explore historic data. This is recommended for logging power, temperature, humidity, voltage and current data.</p><p><b>Feed engine:</b><ul><li><b>Emoncms Fixed Interval TimeSeries (PHPFina)</b> is the recommended feed engine, it is a fixed interval timeseries engine.</li><li><b>Emoncms Variable Interval TimeSeries (PHPTimeseries)</b> is for data posted at a non regular interval.</li></ul></p><p><b>Feed interval:</b> When selecting the feed interval select an interval that is the same as, or longer than the update rate that is set in your monitoring equipment. Setting the interval rate to be shorter than the update rate of the equipment causes un-needed disk space to be used up.</p>")
),
array(
"id_num" => 2,
"name" => tr("x"),
"short" => "x",
"function" => "scale",
"args" => array(
array(
"type" => ProcessArg::VALUE,
"default" => 1
),
),
"group" => tr("Calibration"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Multiplies current value by given constant. This can be useful for calibrating a particular variable on the web rather than by reprogramming hardware.</p>")
),
array(
"id_num" => 3,
"name" => tr("+"),
"short" => "+",
"function" => "offset",
"args" => array(
array(
"type" => ProcessArg::VALUE,
"default" => 0
),
),
"group" => tr("Calibration"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Offset current value by given value. This can again be useful for calibrating a particular variable on the web rather than by reprogramming hardware.</p>")
),
array(
"id_num" => 4,
"name" => tr("Power to kWh"),
"short" => "kwh",
"function" => "power_to_kwh",
"args" => array(
array(
"type" => ProcessArg::FEEDID,
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY)
),
),
"unit" => "kWh",
"group" => tr("Main"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Convert a power value in Watts to a cumulative kWh feed.<br><br><b>Visualisation tip:</b> Feeds created with this input processor can be used to generate daily kWh data using the BarGraph visualisation with the delta property set to 1. See <a href='https://guide.openenergymonitor.org/setup/daily-kwh/' target='_blank' rel='noopener'>Guide: Daily kWh</a><br><br>")
),
array(
"id_num" => 5,
"name" => tr("Power to kWh/d"),
"short" => "kwhd",
"argtype" => ProcessArg::FEEDID,
"function" => "power_to_kwhd",
"unit" => "kWhd",
"group" => tr("Power & Energy"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Convert a power value in Watts to a feed that contains an entry for the total energy used each day (kWh/d)</p>")
),
array(
"id_num" => 6,
"name" => tr("x input"),
"short" => "x inp",
"argtype" => ProcessArg::INPUTID,
"function" => "times_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Multiplies the current value with the last value from other input as selected from the input list.</p>")
),
array(
"id_num" => 7,
"name" => tr("Input on-time"),
"short" => "ontime",
"argtype" => ProcessArg::FEEDID,
"function" => "input_ontime",
"group" => tr("Input"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Counts the amount of time that an input is high in each day and logs the result to a feed. Created for counting the number of hours a solar hot water pump is on each day</p>")
),
array(
"id_num" => 8,
"name" => tr("Wh increments to kWh/d"),
"short" => "whinckwhd",
"argtype" => ProcessArg::FEEDID,
"function" => "whinc_to_kwhd",
"unit" => "kWhd",
"group" => tr("Power & Energy"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Accumulate Wh measurements into kWh/d.<p><b>Input</b>: energy increments in Wh.</p>")
),
array(
"deleted" => true,
"id_num" => 9,
"name" => tr("kWh to kWh/d (OLD)"),
"short" => "kwhkwhdold",
"argtype" => ProcessArg::FEEDID,
"function" => "kwh_to_kwhd_old",
"unit" => "kWhd",
"group" => tr("Deleted"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"input_context" => true,
"virtual_feed_context" => false,
"description" => ""
),
array(
"id_num" => 10,
"name" => tr("Update feed at day"),
"short" => "update",
"argtype" => ProcessArg::FEEDID,
"function" => "update_feed_data",
"group" => tr("Input"),
"engines" => array(Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Updates or inserts daily value on the specified time (given by the JSON time parameter from the API) of the specified feed</p>")
),
array(
"id_num" => 11,
"name" => tr("+ input"),
"short" => "+ inp",
"argtype" => ProcessArg::INPUTID,
"function" => "add_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Adds the current value with the last value from other input as selected from the input list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 12,
"name" => tr("/ input"),
"short" => "/ inp",
"argtype" => ProcessArg::INPUTID,
"function" => "divide_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Divides the current value with the last value from other input as selected from the input list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 13,
"name" => tr("Phaseshift"),
"short" => "phaseshift",
"argtype" => ProcessArg::VALUE,
"function" => "phaseshift",
"group" => tr("Deleted"),
"deleted" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => ""
),
array(
"id_num" => 14,
"name" => tr("Accumulator"),
"short" => "accumulate",
"argtype" => ProcessArg::FEEDID,
"function" => "accumulator",
"group" => tr("Misc"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Output feed accumulates by input value</p>")
),
array(
"id_num" => 15,
"name" => tr("Rate of change"),
"short" => "rate",
"argtype" => ProcessArg::FEEDID,
"function" => "ratechange",
"group" => tr("Misc"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"requireredis" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Output feed is the difference between the current value and the last</p>")
),
array(
"id_num" => 16,
"name" => tr("Histogram"),
"short" => "hist",
"argtype" => ProcessArg::FEEDID,
"function" => "histogram",
"group" => tr("Deleted"),
"deleted" => true,
"engines" => array(Engine::MYSQL, Engine::MYSQLMEMORY),
"input_context" => true,
"virtual_feed_context" => false,
"description" => ""
),
array(
"id_num" => 17,
"name" => tr("Daily Average"),
"short" => "mean",
"argtype" => ProcessArg::FEEDID,
"function" => "average",
"group" => tr("Deleted"),
"deleted" => true,
"engines" => array(Engine::PHPTIMESERIES),
"input_context" => true,
"virtual_feed_context" => false,
"description" => ""
),
array(
"id_num" => 18,
"name" => tr("Heat flux"),
"short" => "flux",
"argtype" => ProcessArg::FEEDID,
"function" => "heat_flux",
"group" => tr("Deleted"),
"deleted" => true,
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"input_context" => true,
"virtual_feed_context" => false,
"description" => ""
),
array(
"id_num" => 19,
"name" => tr("Power gained to kWh/d"),
"short" => "pwrgain",
"argtype" => ProcessArg::FEEDID,
"function" => "power_acc_to_kwhd",
"unit" => "kWhd",
"group" => tr("Deleted"),
"deleted" => true,
"engines" => array(Engine::PHPTIMESERIES),
"input_context" => true,
"virtual_feed_context" => false,
"description" => ""
),
array(
"id_num" => 20,
"name" => tr("Total pulse count to pulse increment"),
"short" => "pulsdiff",
"argtype" => ProcessArg::FEEDID,
"function" => "pulse_diff",
"group" => tr("Pulse"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Returns the number of pulses incremented since the last update for a input that is a cumulative pulse count. i.e If the input updates from 23400 to 23410 the result will be an incremenet of 10.</p>")
),
array(
"id_num" => 21,
"name" => tr("kWh to Power"),
"short" => "kwhpwr",
"argtype" => ProcessArg::FEEDID,
"function" => "kwh_to_power",
"unit" => "W",
"group" => tr("Power & Energy"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"requireredis" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Convert accumulating kWh to instantaneous power</p>")
),
array(
"id_num" => 22,
"name" => tr("- input"),
"short" => "- inp",
"argtype" => ProcessArg::INPUTID,
"function" => "subtract_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Subtracts from the current value the last value from other input as selected from the input list.</p>")
),
array(
"id_num" => 23,
"name" => tr("kWh to kWh/d"),
"short" => "kwhkwhd",
"argtype" => ProcessArg::FEEDID,
"function" => "kwh_to_kwhd",
"unit" => "kWhd",
"group" => tr("Power & Energy"),
"engines" => array(Engine::PHPTIMESERIES),
"requireredis" => true,
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Upsert kWh to a daily value.</p>")
),
array(
"id_num" => 24,
"name" => tr("Allow positive"),
"short" => "> 0",
"argtype" => ProcessArg::NONE,
"function" => "allowpositive",
"group" => tr("Limits"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Negative values are zeroed for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 25,
"name" => tr("Allow negative"),
"short" => "< 0",
"argtype" => ProcessArg::NONE,
"function" => "allownegative",
"group" => tr("Limits"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Positive values are zeroed for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 26,
"name" => tr("Signed to unsigned"),
"short" => "unsign",
"argtype" => ProcessArg::NONE,
"function" => "signed2unsigned",
"unit" => "unsign",
"group" => tr("Misc"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Convert a number that was interpreted as a 16 bit signed number to an unsigned number.</p>")
),
array(
"id_num" => 27,
"name" => tr("Max daily value"),
"short" => "max",
"argtype" => ProcessArg::FEEDID,
"function" => "max_value",
"group" => tr("Misc"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Maximal daily value. Upserts on the selected daily feed the highest value reached each day.</p>")
),
array(
"id_num" => 28,
"name" => tr("Min daily value"),
"short" => "min",
"argtype" => ProcessArg::FEEDID,
"function" => "min_value",
"group" => tr("Misc"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Minimal daily value. Upserts on the selected daily feed the lowest value reached each day.</p>")
),
array(
"id_num" => 29,
"name" => tr("+ feed"),
"short" => "+ feed",
"argtype" => ProcessArg::FEEDID,
"function" => "add_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Adds the current value with the last value from a feed as selected from the feed list.</p>")
),
array(
"id_num" => 30,
"name" => tr("- feed"),
"short" => "- feed",
"argtype" => ProcessArg::FEEDID,
"function" => "sub_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Subtracts from the current value the last value from a feed as selected from the feed list.</p>")
),
array(
"id_num" => 31,
"name" => tr("* feed"),
"short" => "x feed",
"argtype" => ProcessArg::FEEDID,
"function" => "multiply_by_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Multiplies the current value with the last value from a feed as selected from the feed list.</p>")
),
array(
"id_num" => 32,
"name" => tr("/ feed"),
"short" => "/ feed",
"argtype" => ProcessArg::FEEDID,
"function" => "divide_by_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Divides the current value by the last value from a feed as selected from the feed list.</p>")
),
array(
"id_num" => 33,
"name" => tr("Reset to ZERO"),
"short" => "0",
"argtype" => ProcessArg::NONE,
"function" => "reset2zero",
"group" => tr("Misc"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>The value \"0\" is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 34,
"name" => tr("Wh Accumulator"),
"short" => "whacc",
"argtype" => ProcessArg::FEEDID,
"function" => "wh_accumulator",
"unit" => "Wh",
"group" => tr("Main"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"requireredis" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("Use with emontx, emonth or emonpi pulsecount or an emontx running firmware <i>emonTxV3_4_continuous_kwhtotals</i> sending cumulative watt hours.<br><br>This processor ensures that when the emontx is reset the watt hour count in emoncms does not reset, it also checks filter's out spikes in energy use that are larger than a max power threshold set in the processor, assuming these are error's, the max power threshold is set to 60 kW. <br><br><b>Visualisation tip:</b> Feeds created with this input processor can be used to generate daily kWh data using the BarGraph visualisation with the delta property set to 1 and scale set to 0.001. See: <a href='https://guide.openenergymonitor.org/setup/daily-kwh/' target='_blank' rel='noopener'>Guide: Daily kWh</a><br><br>")
),
array(
"id_num" => 35,
"name" => tr("Publish to MQTT via Redis"),
"short" => "mqtt",
"argtype" => ProcessArg::TEXT,
"function" => "publish_to_mqtt",
"group" => tr("Misc"),
"nochange" => true,
"requireredis" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Publishes value to REDIS for phpmqtt_input.php to publish the values to MQTT topic e.g. 'home/power/kitchen'</p>")
),
array(
"id_num" => 36,
"name" => tr("Reset to NULL"),
"short" => "null",
"argtype" => ProcessArg::NONE,
"function" => "reset2null",
"group" => tr("Misc"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Value is set to NULL.</p><p>Useful for conditional process to work on.</p>")
),
array(
"id_num" => 37,
"name" => tr("Reset to Original"),
"short" => "ori",
"argtype" => ProcessArg::NONE,
"function" => "reset2original",
"group" => tr("Misc"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>The value is set to the original value at the start of the process list.</p>")
),
array(
"id_num" => 42,
"name" => tr("If ZERO, skip next"),
"short" => "0? skip",
"argtype" => ProcessArg::NONE,
"function" => "if_zero_skip",
"group" => tr("Conditional"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is ZERO, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 43,
"name" => tr("If !ZERO, skip next"),
"short" => "!0? skip",
"argtype" => ProcessArg::NONE,
"function" => "if_not_zero_skip",
"group" => tr("Conditional"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is NOT ZERO, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 44,
"name" => tr("If NULL, skip next"),
"short" => "N? skip",
"argtype" => ProcessArg::NONE,
"function" => "if_null_skip",
"group" => tr("Conditional"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is NULL, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 45,
"name" => tr("If !NULL, skip next"),
"short" => "!N? skip",
"argtype" => ProcessArg::NONE,
"function" => "if_not_null_skip",
"group" => tr("Conditional"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is NOT NULL, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 46,
"name" => tr("If >, skip next"),
"short" => ">? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_gt_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is greater than the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 47,
"name" => tr("If >=, skip next"),
"short" => ">=? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_gt_equal_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is greater or equal to the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 48,
"name" => tr("If <, skip next"),
"short" => "<? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_lt_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is lower than the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 49,
"name" => tr("If <=, skip next"),
"short" => "<=? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_lt_equal_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is lower or equal to the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 50,
"name" => tr("If =, skip next"),
"short" => "=? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_equal_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is equal to the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 51,
"name" => tr("If !=, skip next"),
"short" => "!=? skip",
"argtype" => ProcessArg::VALUE,
"function" => "if_not_equal_skip",
"group" => tr("Conditional - User value"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value from last process is NOT equal to the specified value, process execution will skip execution of next process in list.</p>")
),
array(
"id_num" => 52,
"name" => tr("GOTO"),
"short" => "GOTO",
"argtype" => ProcessArg::VALUE,
"function" => "goto_process",
"default" => 1,
"group" => tr("Misc"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Jumps the process execution to the specified position.</p><p><b>Warning</b><br>If you're not careful you can create a goto loop on the process list.<br>When a loop occurs, the API will appear to lock until the server php times out with an error.</p>")
),
array(
"id_num" => 53,
"name" => tr("Source Feed"),
"short" => "sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "source_feed_data_time",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p><b>Source Feed:</b><br>Virtual feeds should use this processor as the first one in the process list. It sources data from the selected feed.<br>The sourced value is passed back for further processing by the next processor in the processing list.<br>You can then add other processors to apply logic on the passed value for post-processing calculations in realtime.</p><p>Note: This virtual feed process list is executed on visualizations requests that use this virtual feed.</p>")
),
array(
"id_num" => 55,
"name" => tr("+ source feed"),
"short" => "+ sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "add_source_feed",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p>Add the specified feed.</p>")
),
array(
"id_num" => 56,
"name" => tr("- source feed"),
"short" => "- sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "sub_source_feed",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p>Subtract the specified feed.</p>")
),
array(
"id_num" => 57,
"name" => tr("* source feed"),
"short" => "x sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "multiply_by_source_feed",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p>Multiply by specified feed.</p>")
),
array(
"id_num" => 58,
"name" => tr("/ source feed"),
"short" => "/ sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "divide_by_source_feed",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p>Divide by specified feed. Returns NULL for zero values.</p>")
),
array(
"id_num" => 59,
"name" => tr("/ source feed"),
"short" => "/ sfeed",
"argtype" => ProcessArg::FEEDID,
"function" => "reciprocal_by_source_feed",
"group" => tr("Virtual"),
"input_context" => false,
"virtual_feed_context" => true,
"description" => tr("<p>Return the reciprical of the specified feed. Returns NULL for zero values.</p>")
),
array(
// "id_num" => 60,
"name" => tr("EXIT"),
"short" => "EXIT",
"argtype" => ProcessArg::NONE,
"function" => "error_found",
"group" => tr("Hidden"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>This was automaticaly added when a loop error was discovered on the processList or execution took too many steps to process. Review the usage of GOTOs or decrease the number of items and delete this entry to resume execution.</p>"),
"internalerror" => true,
"internalerror_reason" => "HAS ERRORS",
"internalerror_desc" => "Processlist disabled due to errors found during execution."
),
array(
"id_num" => 61,
"name" => tr("Max value allowed"),
"short" => "<max",
"argtype" => ProcessArg::VALUE,
"function" => "max_value_allowed",
"group" => tr("Limits"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value is greater than <i>max value allowed</i> then the value passed to following process will be the <i>max value allowed</i></p>"),
"requireredis" => false,
"nochange" => false
),
array(
"id_num" => 62,
"name" => tr("Min value allowed"),
"short" => ">min",
"argtype" => ProcessArg::VALUE,
"function" => "min_value_allowed",
"group" => tr("Limits"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>If value is lower than <i>min value allowed</i> then the value passed to following process will be the <i>min value allowed</i></p>"),
"requireredis" => false,
"nochange" => false
),
array(
"id_num" => 63,
"name" => tr("Absolute value"),
"short" => "abs",
"argtype" => ProcessArg::VALUE,
"function" => "abs_value",
"group" => tr("Calibration"),
"input_context" => true,
"virtual_feed_context" => true,
"description" => tr("<p>Return the absolute value of the current value. This can be useful for calibrating a particular variable on the web rather than by reprogramming hardware.</p>")
),
array(
"id_num" => 64,
"name" => tr("kWh Accumulator"),
"short" => "kwhacc",
"argtype" => ProcessArg::FEEDID,
"function" => "kwh_accumulator",
"unit" => "kWh",
"group" => tr("Main"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES),
"requireredis" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("This processor removes resets from a cumulative kWh input, it also filter's out spikes in energy use that are larger than a max power threshold set in the processor, assuming these are error's, the max power threshold is set to 60 kW. <br><br><b>Visualisation tip:</b> Feeds created with this input processor can be used to generate daily kWh data using the BarGraph visualisation with the delta property set to 1 and scale set to 0.001. See: <a href='https://guide.openenergymonitor.org/setup/daily-kwh/' target='_blank' rel='noopener'>Guide: Daily kWh</a><br><br>")
),
array(
"id_num" => 65,
"name" => tr("Log to feed (Join)"),
"short" => "log_join",
"argtype" => ProcessArg::FEEDID,
"function" => "log_to_feed_join",
"group" => tr("Main"),
"engines" => array(Engine::PHPFINA, Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY, Engine::CASSANDRA),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>In addition to the standard log to feed process, this process links missing data points with a straight line between the newest value and the previous value. It is designed for use with total cumulative kWh meter reading inputs, producing a feed that can be used with the delta property when creating bar graphs. See: <a href='https://guide.openenergymonitor.org/setup/daily-kwh/' target='_blank' rel='noopener'>Guide: Daily kWh</a><br><br>")
),
array(
"id_num" => 66,
"name" => tr("max by input"),
"short" => "max_inp",
"argtype" => ProcessArg::INPUTID,
"function" => "max_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Limits the current value by the last value from an input as selected from the input list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 67,
"name" => tr("min by input"),
"short" => "min_inp",
"argtype" => ProcessArg::INPUTID,
"function" => "min_input",
"group" => tr("Input"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Limits the current value by the last value from an input as selected from the input list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 68,
"name" => tr("max by feed"),
"short" => "max_feed",
"argtype" => ProcessArg::FEEDID,
"function" => "max_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Limits the current value by the last value from an feed as selected from the feed list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
array(
"id_num" => 69,
"name" => tr("min by feed"),
"short" => "min_feed",
"argtype" => ProcessArg::FEEDID,
"function" => "min_feed",
"group" => tr("Feed"),
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Limits the current value by the last value from an feed as selected from the feed list. The result is passed back for further processing by the next processor in the processing list.</p>")
),
/*
array(
"id_num" => 70,
"name" => tr("Power to kWh/15min"),
"short" => "kwh15m",
"argtype" => ProcessArg::FEEDID,
"function" => "power_to_kwh_15m",
"unit" => "kWh/15m",
"group" => tr("Power & Energy"),
"engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Convert a power value in Watts to a feed that contains an entry for the total energy used every 15 min (starting mid night) (kWh/15min)</p>")
),
*/
array(
"id_num" => 71,
"name" => tr("Power to kWh / custom minutes"),
"short" => "kwhslot",
"args" => array(
array("key" => "interval", "type" => ProcessArg::VALUE, "name" => "Minutes", "desc" => tr("Slot in minutes slot to accumulate"), "default" => "15"),
array("key" => "feed", "type" => ProcessArg::FEEDID, "name" => "Feed", "desc" => tr("Output feed"), "engines" => array(Engine::PHPTIMESERIES, Engine::MYSQL, Engine::MYSQLMEMORY))
),
"function" => "power_to_kwh_custom",
"unit" => "kWh/slot",
"group" => tr("Power & Energy"),
"nochange" => true,
"input_context" => true,
"virtual_feed_context" => false,
"description" => tr("<p>Convert a power value in Watts to a feed that contains an entry for the total energy used every selected minutes (starting mid night) (kWh/x min)</p>")
)
);
}
// / Below are functions of this module processlist
public function scale($arg, $time, $value)
{
if ($value === null) {
return $value;
}
return $value * $arg;
}
public function divide($arg, $time, $value)
{
if ($arg != 0) {
return $value / $arg;
} else {
return null;
}
}
public function offset($arg, $time, $value)
{
if ($value === null) {
return $value;
}
return $value + $arg;
}
public function allowpositive($arg, $time, $value)
{
if ($value < 0) {
$value = 0;
}
return $value;
}
public function allownegative($arg, $time, $value)
{
if ($value > 0) {
$value = 0;
}
return $value;
}
public function max_value_allowed($arg, $time, $value)
{
if ($value > $arg) {
$value = $arg;
}
return $value;
}
public function min_value_allowed($arg, $time, $value)
{
if ($value < $arg) {
$value = $arg;
}
return $value;
}
public function reset2zero($arg, $time, $value)
{
$value = 0;
return $value;
}
public function reset2original($arg, $time, $value)
{
return $this->proc_initialvalue;
}
public function reset2null($arg, $time, $value)
{
return null;
}
public function signed2unsigned($arg, $time, $value)
{
if ($value < 0) {
$value += 65536;
}
return $value;
}
public function log_to_feed($id, $time, $value)
{
$this->feed->post($id, $time, $time, $value);
return $value;
}
public function log_to_feed_join($id, $time, $value)
{
$padding_mode = "join";
$this->feed->post($id, $time, $time, $value, $padding_mode);
return $value;