-
Notifications
You must be signed in to change notification settings - Fork 27
/
process.h
1882 lines (1726 loc) · 75.7 KB
/
process.h
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
/*----------------------------------------------------------------------------+
| |
| Enhanced HEYU Functionality for Uploaded Timers and Macros |
| Copyright 2002,2003,2004,2005,2006 Charles W. Sullivan |
| |
| |
| As used herein, HEYU is a trademark of Daniel B. Suthers. |
| X10, CM11A, and ActiveHome are trademarks of X-10 (USA) Inc. |
| The author is not affiliated with either entity. |
| |
| Charles W. Sullivan |
| Co-author and Maintainer |
| Greensboro, North Carolina |
| Email ID: cwsulliv01 |
| Email domain: -at- heyu -dot- org |
| |
+----------------------------------------------------------------------------*/
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <time.h>
/* Some array length limits */
#define NAME_LEN 32 /* Alias label length */
#define MACRO_LEN 32 /* Macro label length */
#define SCENE_LEN 32 /* Scene label length */
#define PATH_LEN 127 /* File paths */
#define LINE_LEN 4096 /* Line length in input files */
#ifndef NUM_FLAG_BANKS
#define NUM_FLAG_BANKS 1 /* 32 flags per bank, maximum 32 banks (1024 flags) */
#endif
#ifndef NUM_COUNTER_BANKS
#define NUM_COUNTER_BANKS 1 /* 32 counters per bank, maximum 32 banks (1024 counters) */
#endif
#ifndef NUM_TIMER_BANKS
#define NUM_TIMER_BANKS 1 /* 32 user timers per bank, maximum 32 banks (1024 timers) */
#endif
#define NUM_USER_TIMERS (32 * NUM_TIMER_BANKS)
/* Maximum number of unsigned long data storage locations */
/* in x10global state tables. */
#define MAXDATASTORAGE 128
/* Values for x10config variables DAWN_OPTION and DUSK_OPTION */
#define FIRST 1
#define EARLIEST 2
#define LATEST 3
#define AVERAGE 4
#define MEDIAN 5
/* Values for LAUNCH_SCRIPTS */
#define FIRST_MATCH 0
#define ALL_MATCH 1
/* Values for Launcher flow mode */
#define FM_CONTINUE 1
#define FM_BREAK 2
/* Bitmaps for x10config variables LAUNCH_SOURCE */
#define SNDC 1
#define SNDM 2
#define SNDP 4
#define SNDS 8
#define SNDT 16
#define RCVI 32
#define RCVT 64
#define SNDA 128
#define RCVA 256
#define XMTF 512
#define LSNONE 1024
#define LSALL (SNDC | SNDM | SNDT | RCVI | RCVT | SNDA | RCVA | XMTF)
enum {SndC, SndM, SndP, SndS, SndT, RcvI, RcvT, SndA, RcvA, Xmtf};
/* Bitmaps for script options */
#define SCRIPT_HEYU 0 /* Generate heyu environment for scripts */
#define SCRIPT_XTEND 1 /* Generate xtend environment for scripts */
#define SCRIPT_RAWLEVEL 2 /* Heyu environ variables use raw levels */
#define SCRIPT_NOENV 4 /* Create no new environment variables */
#define SCRIPT_QUIET 8 /* Suppress display of command line in log file */
#define SCRIPT_QQUIET 16 /* Suppress display of launcher in log file */
/* Values for script_mode */
#define HEYU_SCRIPT 0 /* Use general heyu scripting */
#define HEYU_HELPER 1 /* Use heyuhelper */
/* Function Modes */
#define FUNC_ACTUAL 0
#define FUNC_GENERIC 1
/* Flags for alias options (Preset modules only) */
#define ALFLAG_RESUME 1 /* 'resume level' has been set */
#define ALFLAG_FIXED 2 /* 'fixed on level' has been set */
/* Values for x10config variabe RESOLVE_OVERLAP */
#define RES_OVLAP_SEPARATE 0
#define RES_OVLAP_COMBINED 1
/* Yes/No */
#define NO 0
#define YES 1
#define VERBOSE 3
#define IGNORE 4
#define NO_ANSWER 0xff
/* Check lockup */
#define CHECK_PORT 1
#define CHECK_CM11 2
#define DISABLE 0
#define ENABLE 1
#define NATIVE 0
#define SCALED 1
#define SC_SINGLE 0
#define SC_BITMAP 1
#define PCTMODE 0
#define RAWMODE 1
/* Module Option flags (alias[].optflags) */
#define MOPT_RESUME 0x00000001
#define MOPT_ONFULL 0x00000002
#define MOPT_SENSOR 0x00000004
#define MOPT_SECURITY 0x00000008
#define MOPT_ENTERTAIN 0x00000010
#define MOPT_NOPLC 0x00000020
#define MOPT_RFIGNORE 0x00000040
#define MOPT_TRANSCEIVE 0x00000080
#define MOPT_RFFORWARD 0x00000100
#define MOPT_REVERSE 0x00000200
#define MOPT_MAIN 0x00000400
#define MOPT_AUX 0x00000800
#define MOPT_RFXSENSOR 0x00001000
#define MOPT_RFXT2 0x00002000
#define MOPT_RFXVS 0x00004000
#define MOPT_RFXVAD 0x00008000
#define MOPT_RFXRH 0x00010000
#define MOPT_RFXBP 0x00020000
#define MOPT_RFXPOT 0x00040000
#define MOPT_RFXPULSE 0x00080000
#define MOPT_RFXPOWER 0x00100000
#define MOPT_RFXWATER 0x00200000
#define MOPT_RFXGAS 0x00400000
#define MOPT_RFXCOUNT 0x00800000
#define MOPT_HEARTBEAT 0x01000000
#define MOPT_PLCSENSOR 0x02000000
#define MOPT_LOBAT 0x04000000
#define MOPT_LOBATUNKN 0x08000000
#define MOPT_KAKU 0x10000000
#define MOPT_RFXMETER (MOPT_RFXPULSE | MOPT_RFXPOWER | MOPT_RFXWATER | MOPT_RFXGAS | MOPT_RFXCOUNT)
/* More Module Option flags (alias[].optflags2) */
#define MOPT2_TMIN 0x00000001
#define MOPT2_TMAX 0x00000002
#define MOPT2_RHMIN 0x00000004
#define MOPT2_RHMAX 0x00000008
#define MOPT2_BPMIN 0x00000010
#define MOPT2_BPMAX 0x00000020
#define MOPT2_DUMMY 0x00000040
#define MOPT2_SWMAX 0x00000080
#define MOPT2_SWHOME 0x00000100
#define MOPT2_IATO 0x00000200 /* Inactive timeout */
#define MOPT2_AUF 0x00000400 /* ACT AllUnitsOff option */
#define MOPT2_ALO 0x00000800 /* ACT AllLightsOn option */
#define MOPT2_ALF 0x00001000 /* ACT AllLightsOff option */
#define MOPT2_DEFER 0x00002000 /* Defer update until StatusOn/Off */
/* Maximum number of security and RFXMeter sensors */
/* (door/window, motion sensor) */
#define MAX_SEC_SENSORS 256
#define MAX_RFX_SENSORS 256
/* Old/New */
#define OLD 0
#define NEW 1
/* High/Low */
#define HIGH_STATE 1
#define LOW_STATE 0
/* Config option */
#define CONFIG_INIT 0
#define CONFIG_RESTART 1
/* Start/Restart */
#define E_START 0
#define E_RESTART 1
/* Manual or Automatic */
#define MANUAL 0
#define AUTOMATIC 1
/* For MIN/MAX DAWN/DUSK */
#define OFF -1
/* Bitmaps for mode variables */
#define UNSPECIFIED 0
#define COMPATIBLE 1
#define HEYU_MODE 2
#define HAS_TIMERS 16
/* Values for variable CM11A_DAY_ZERO */
#define ZERO 0
#define TODAY 1
#define MIXED 2
/* Values involving the X10 Record File */
#define VALID_RECORD_FILE 0
#define SCHEDULE_EXPIRED -1
#define NO_EXPIRATION -2
#define NO_RECORD_FILE -3
#define BAD_RECORD_FILE -4
/* Prefixes for combined and delay-modified macro names */
#define COMB_MAC_PREFIX "_co"
#define DELAY_MAC_PREFIX "_de"
#define SECUR_MAC_PREFIX "_se"
/* Prefix for subdirectories under xxxBASEDIR */
/* (For optional use with command line parameters */
/* -0 ... -9 when there is a CM11A interface on */
/* more than one serial port.) */
#define HEYUSUB_PREFIX ""
/* Files which must have a fixed name and be */
/* in a fixed location. */
#define CONFIG_FILE "x10config"
#define CONFIG_FILE_ETC "x10.conf"
#define RECORD_FILE "x10record"
#define MACROXREF_FILE "x10macroxref"
#define IMAGE_FILE "x10image"
#define STATE_FILE "x10state"
#define RESTART_RELAY_FILE "__restart_relay"
#define RESTART_AUX_FILE "__restart_aux"
/* Device types */
#define DEV_CM11A 0
#define DEV_CM10A 1
#define DEV_CM17A 2
#define DEV_W800RF32 4
#define DEV_MR26A 8
#define DEV_RFXCOM32 16
#define DEV_RFXCOMVL 32
#define DEV_DUMMY 256
/* TTY */
#define TTY_CLOSED -1
#define TTY_DUMMY -2
/* Date Formats */
#define YMD_ORDER 1
#define DMY_ORDER 2
#define MDY_ORDER 4
/* Aux daemon transceive/transcode defaults */
#define TR_NONE 0
#define TR_ALL 0xffff
/* X10 RF code types */
#define RF_STD 0 /* Standard X10 RF */
#define RF_ENT 1 /* Entertainment X10 RF */
#define RF_SEC 2 /* Security X10 RF */
#define RF_XSENSOR 3 /* RFXSensor data */
#define RF_XMETER 4 /* RFXMeter data */
#define RF_DUSK 5 /* Security Dusk RF */
#define RF_VISONIC 6 /* Visonic sensors and remotes */
#define RF_XJAM 7 /* RFXCOMVL jamming signal */
#define RF_XJAM32 8 /* RFXCOM32 jamming signal */
#define RF_SEC16 9 /* Security X10 RF 16-bit ID */
#define RF_DIGIMAX 10 /* Digimax */
#define RF_OREGON 11 /* Oregon sensors */
#define RF_ELECSAVE 12 /* Electrisave sensor */
#define RF_SECX 13 /* DM10 Alert */
#define RF_KAKU 14 /* KAKU/HomeEasy */
#define RF_OWL 15 /* OWL CM119 */
#define RF_VDATAM 16 /* VDATA for memory byte */
#define RF_XSENSORHDR 0x77 /* RFXSensor Initialization */
#define RF_RAWW800 0x78 /* Raw data from W800RF32A */
#define RF_RAWMR26 0x79 /* Raw data from MR26A */
#define RF_RAWVL 0x7a /* Raw variable length */
#define RF_FLOOD 0x7b /* Unceasing RF signals */
#define RF_TEST 0x7c
#define RF_NOISEW800 0x7d /* Noise from W800RF32A */
#define RF_NOISEMR26 0x7e /* Noise from MR26A */
#define RF_NOISEVL 0x7f /* Variable length noise */
/* RF Raw display modes */
#define DISPMODE_RF_NONE 0
#define DISPMODE_RF_NORMAL 1
#define DISPMODE_RF_NOISE 2
/* Treatment of RF codes */
#define RF_IGNORE 0
#define RF_FORWARD 1
#define RF_TRANSCEIVE 2
/* RFXSensor ID offsets */
#define RFX_T 0 /* Temperature */
#define RFX_H 1 /* Humidity or Pressure A/D */
#define RFX_S 2 /* Supply Voltage A/D */
/* RFXSensor output bitmap */
#define RFXO_T 0x0001 /* Temperature */
#define RFXO_H 0x0002 /* Humidity */
#define RFXO_S 0x0004 /* Supply Voltage */
#define RFXO_V 0x0008 /* A/D Voltage */
#define RFXO_B 0x0010 /* Barometric Pressure */
#define RFXO_P 0x0020 /* Potentiometer */
#define RFXO_T2 0x0040 /* Second Temperature */
#define RFXO_LO 0x0080 /* Low battery */
#define RFXO_VI 0x0100 /* Internal A/D Voltage */
#define RFXO_ALL 0xffff
#define RAISE_DTR 1
#define RAISE_RTS 2
#define ADDR_STD 0x40 /* Includes a HU address */
#define ADDR_EXT 0x80 /* Virtual extended housecode Q-Z */
/* Wind Direction bitmap */
#define COMPASS_POINTS 1
#define COMPASS_ANGLE 2
/* Wind speed bitmap */
#define WINDSPEED 1
#define BEAUFORT 2
/* RFXCOM Receiver types and positions */
#define RFXX10 0
#define VISONIC 1
#define RFXMASTER 0
#define RFXSLAVE 1
/* The state engine lockfile */
#define STATE_LOCKFILE "heyu.engine"
/* These files are written for 'heyu upload' or */
/* 'heyu upload check' if the WRITE_CHECK_FILES */
/* directive in the x10config file is YES. */
#define RECORD_FILE_CHECK "x10record.check"
#define MACROXREF_FILE_CHECK "x10macroxref.check"
#define IMAGE_BIN_FILE "x10image.bin"
#define IMAGE_FILE_CHECK "x10image.check"
#define IMAGE_HEX_FILE "x10image.hex"
/* Other files */
#define REPORT_FILE "report.txt"
#define CRON_REPORT_FILE "cronreport.txt"
#define SUN_TABLE_FILE "sun_%d.txt"
enum {RiseSet, CivilTwi, NautTwi, AstroTwi, AngleOffset, };
enum {ArmLogicStrict, ArmLogicMedium, ArmLogicLoose};
#define RFXCOM_ARCTECH 0x00000001
#define RFXCOM_OREGON 0x00000002
#define RFXCOM_ATIWONDER 0x00000004
#define RFXCOM_X10 0x00000008
#define RFXCOM_VISONIC 0x00000010
#define RFXCOM_KOPPLA 0x00000020
#define RFXCOM_HE_UK 0x00000040
#define RFXCOM_HE_EU 0x00000080
/* Default values for X10 configuration file */
#define DEF_MODE COMPATIBLE
#define DEF_SCHEDFILE "x10.sched"
#define DEF_PROGRAM_DAYS 366
#define DEF_COMBINE_EVENTS YES
#define DEF_COMPRESS_MACROS NO
#define DEF_FEB_KLUGE YES
#define DEF_HOUSECODE 'A'
#define DEF_DAWN_OPTION FIRST
#define DEF_DUSK_OPTION FIRST
#define DEF_DAWN_SUBSTITUTE (6*60)
#define DEF_DUSK_SUBSTITUTE (18*60)
#define DEF_MIN_DAWN OFF
#define DEF_MAX_DAWN OFF
#define DEF_MIN_DUSK OFF
#define DEF_MAX_DUSK OFF
#define DEF_CHECK_FILES NO
#define DEF_TTY "/dev/ttyS0"
#define DEF_REPL_DELAYED_MACROS YES
#define DEF_FORCE_ADDR NO
#define DEF_ACK_HAILS NO
#define DEF_TRIGGER_TAG YES
#define DEF_XREF_APPEND NO
#define DEF_RCS_TEMPERATURE NO
#define DEF_MACTERM YES
#define DEF_MAX_PPARMS 8
#define DEF_STATUS_TIMEOUT 2
#define DEF_SPF_TIMEOUT 3
#define DEF_DISPLAY_OFFSET YES
#define DEF_RESERVED_TIMERS 0
#define DEF_DISPLAY_EXP_MACROS YES
#define DEF_AUTO_CHAIN NO
#define DEF_MODULE_TYPES YES
#define DEF_LAUNCH_MODE TMODE_SIGNAL
#define DEF_LAUNCH_SOURCE RCVI
#define DEF_RES_OVERLAP RES_OVLAP_SEPARATE
#define DEF_DEFAULT_MODULE "LM"
#define DEF_SCRIPT_OPTION SCRIPT_HEYU
#define DEF_SCRIPT_MODE HEYU_SCRIPT
#define DEF_FUNCTION_MODE FUNC_ACTUAL
#define DEF_LOGFILE "/dev/null"
#define DEF_ISDARK_OFFSET 30
#define DEF_ENV_ALIAS_PREFIX "x10"
#define DEF_DEVICE_TYPE DEV_CM11A
#define DEF_SUNMODE RiseSet
#define DEF_FIX_5A YES
#define DEF_AUTOFETCH YES
#define DEF_PFAIL_UPDATE YES
#define DEF_CM17A_BIT_DELAY 500
#define DEF_RF_BURST_SPACING 110
#define DEF_RF_TIMER_TWEAK 20
#define DEF_RF_POST_DELAY 850
#define DEF_RF_FARB_DELAY 850
#define DEF_RF_FARW_DELAY 850
#define DEF_DISP_RF_XMIT YES
#define DEF_RF_BURSTS 5
#define DEF_RESTRICT_DIMS YES
#define DEF_STATE_FORMAT NEW
#define DEF_CM11_POST_DELAY 80 /* 4 cycles @ 50 Hz */
#define DEF_START_ENGINE MANUAL
#define DEF_RF_NOSWITCH NO
#define DEF_RESPOOL_PERMS 01777
#define DEF_SPOOLFILE_MAX 1000000
#define DEF_CHECK_RI_LINE YES
#define DEF_RING_CTRL ENABLE
#define DEF_SEND_RETRIES 3
#define DEF_SCRIPT_CTRL ENABLE
#define DEF_TRANSCEIVE TR_ALL
#define DEF_RFFORWARD TR_NONE
#define DEF_TRANS_DIMLEVEL 2
#define DEF_STATE_CTRL SC_SINGLE
#define DEF_RF_FUNCMASK 0x7f
#define DEF_DISP_RF_NOISE NO
#define DEF_AUX_MINCOUNT_W800 1
#define DEF_AUX_MINCOUNT_MR26 2
#define DEF_AUX_MINCOUNT_RFXCOM 1
#define DEF_AUX_MINCOUNT_RFX 1 /* RFXSensor data */
#define DEF_AUX_REPCOUNT 8
#define DEF_AUX_MAXCOUNT 200
#define DEF_AUX_FLOODREP 0
#define DEF_HIDE_UNCHANGED NO
#define DEF_HIDE_UNCHANGED_INACTIVE NO
#define DEF_SHOW_CHANGE NO
#define DEF_ARM_MAX_DELAY 0
#define DEF_DISP_RAW_RF DISPMODE_RF_NONE
#define DEF_ARM_LOGIC ArmLogicMedium
#define DEF_INACTIVE_TIMEOUT 14400 /* 4 hours */
#define DEF_HEYU_UMASK 0000
#define DEF_LOG_UMASK -1
#define DEF_AUTO_WAIT 0
#define DEF_FULL_BRIGHT 22
#define DEF_ENGINE_POLL 10000 /* microsends */
#define DEF_RFX_TSCALE 'C'
#define DEF_RFX_TOFFSET 0.0
#define DEF_RFX_VADSCALE 1.0
#define DEF_RFX_VADOFFSET 0.0
#define DEF_RFX_VADUNITS "Volts"
#define DEF_RFX_BPSCALE 1.0
#define DEF_RFX_BPOFFSET 0.0
#define DEF_RFX_BPUNITS "hPa"
#define DEF_RFXCOM_DTR_RTS (RAISE_DTR | RAISE_RTS)
#define DEF_DEV_RFXCOM DEV_RFXCOMVL
#define DEF_RFXCOM_HIBAUD NO
#define DEF_RFX_POWERSCALE 0.001
#define DEF_RFX_POWERUNITS "kWh"
#define DEF_RFX_WATERSCALE 1.0
#define DEF_RFX_WATERUNITS ""
#define DEF_RFX_GASSCALE 1.0
#define DEF_RFX_GASUNITS ""
#define DEF_RFX_PULSESCALE 1.0
#define DEF_RFX_PULSEUNITS ""
#define DEF_RFXCOM_ENABLE 0
#define DEF_RFXCOM_DISABLE 0
#define DEF_LOCKUP_CHECK 0
#define DEF_TAILPATH ""
#define DEF_SUPPRESS_RFXJAM NO
#define DEF_DISPLAY_DMXTEMP YES
#define DEF_SECURID_16 YES
#define DEF_SECURID_MASK 0xffffu
#define DEF_SECURID_PARITY YES
#define DEF_LOGDATE_YEAR NO
#define DEF_DMX_TSCALE 'C'
#define DEF_DMX_TOFFSET 0.0
#define DEF_ORE_TSCALE 'C'
#define DEF_ORE_TOFFSET 0.0
#define DEF_ORE_BPSCALE 1.0
#define DEF_ORE_BPOFFSET 0.0
#define DEF_ORE_BPUNITS "hPa"
#define DEF_ORE_WGTSCALE 1.0
#define DEF_ORE_WGTUNITS "kg"
#define DEF_ORE_LOWBATTERY 20
#define DEF_DISPLAY_ORE_ALL NO
#define DEF_ORE_CHGBITS_T 1
#define DEF_ORE_CHGBITS_RH 1
#define DEF_ORE_CHGBITS_BP 1
#define DEF_ORE_CHGBITS_WGT 1
#define DEF_ORE_CHGBITS_DT 1
#define DEF_ORE_CHGBITS_WSP 1
#define DEF_ORE_CHGBITS_WAVSP 1
#define DEF_ORE_CHGBITS_WDIR 1
#define DEF_ORE_CHGBITS_RRATE 1
#define DEF_ORE_CHGBITS_RTOT 1
#define DEF_ORE_CHGBITS_UV 1
#define DEF_ORE_DATA_ENTRY NATIVE
#define DEF_ORE_DISPLAY_CHAN YES
#define DEF_ORE_DISPLAY_BATLVL YES
#define DEF_OREID_16 NO
#define DEF_OREID_MASK 0xffffu
#define DEF_LOGDATE_UNIX NO
#define DEF_INACTIVE_TIMEOUT_ORE 14400 /* 4 hours */
#define DEF_DISPLAY_SENSOR_INTV NO
#define DEF_DATE_FORMAT YMD_ORDER
#define DEF_DATE_SEPARATOR '/'
#define DEF_LOCK_TIMEOUT 10
#define DEF_ORE_DISPLAY_FCAST NO
#define DEF_CM11A_QUERY_DELAY 0
#define DEF_ELS_NUMBER 1
#define DEF_ELS_VOLTAGE 0.0
#define DEF_ELS_CHGBITS_CURR 1
#define DEF_ORE_WINDSCALE 1.0
#define DEF_ORE_WINDUNITS "m/s"
#define DEF_ORE_WINDSENSORDIR 0
#define DEF_ORE_RAINRATESCALE 1.0
#define DEF_ORE_RAINRATEUNITS ""
#define DEF_ORE_RAINTOTSCALE 1.0
#define DEF_ORE_RAINTOTUNITS ""
#define DEF_ORE_WINDDIR_MODE (COMPASS_POINTS | COMPASS_ANGLE)
#define DEF_ORE_DISPLAY_COUNT NO
#define DEF_ORE_DISPLAY_BFT NO
#define DEF_SCANMODE FM_BREAK;
#define DEF_RFX_INLINE NO
#define DEF_OWL_CHGBITS_POWER 1
#define DEF_OWL_CHGBITS_ENERGY 1
#define DEF_OWL_CALIB_POWER 1.0
#define DEF_OWL_CALIB_ENERGY 1.0
#define DEF_OWL_VOLTAGE 230.0
#define DEF_OWL_DISPLAY_COUNT NO
#define DEF_ARM_REMOTE AUTOMATIC
#define DEF_ACTIVE_CHANGE NO
#define DEF_INACTIVE_HANDLING NEW
#define DEF_PROCESS_XMIT NO
#define DEF_SHOW_FLAGS_MODE NEW
#define DEF_RFX_MASTER RFXX10
#define DEF_RFX_SLAVE RFXX10
#define DEF_LAUNCHPATH_APPEND ""
#define DEF_LAUNCHPATH_PREFIX ""
#define DEF_FIX_STOPSTART_ERROR NO
#define DEF_CHKSUM_TIMEOUT 10
#define DTR_INIT LOW_STATE
#define RTS_INIT LOW_STATE
#define SPOOLFILE_ABSMIN 20
#define SPOOLFILE_ABSMAX 0x100000
/* Max errors to display before quitting when */
/* parsing configuration or schedule files. */
#define MAX_ERRORS 15
/* Bitmap flags for timers and tevents */
#define NO_EVENT 0
#define CLOCK_EVENT 1
#define DAWN_EVENT 2
#define DUSK_EVENT 4
#define SEC_EVENT 8
#define PRT_EVENT 16
#define COMB_EVENT 32
#define SUBST_EVENT 64
#define LOST_EVENT 128
#define TMP_EVENT 256
#define ACTIVE_EVENT 512
#define NOW_EVENT 1024
#define CHAIN_EVENT 2048
#define CANCEL_EVENT 4096
#define INVALID_EVENT 0xFFFF
#define TIME_EVENTS (CLOCK_EVENT | DAWN_EVENT | DUSK_EVENT)
#define NOCOPY_EVENTS (PRT_EVENT | LOST_EVENT)
/* Event cancellation flags */
#define MIN_DAWN_CANCEL 1
#define MAX_DAWN_CANCEL 2
#define MIN_DUSK_CANCEL 4
#define MAX_DUSK_CANCEL 8
/* Dawn/Dusk limit option flags */
#define DAWNGT 1
#define DAWNLT 2
#define DUSKGT 4
#define DUSKLT 8
/* Bitmap for shifted events */
#define SAME_DAY 0
#define PREV_DAY 1
#define NEXT_DAY 2
/* Bitmap used by function macro_index() */
#define MACRO_PARSER 1
#define TIMER_PARSER 2
#define TRIGGER_PARSER 4
#define CHAIN_PARSER 8
#define MACRO_DUPLICATE 16
#define DERIVED_MACRO 32
/* Macro modification bitmap */
#define UNMODIFIED 0
#define COMBINED 1
#define COMPRESSED 2
#define DELAY_MOD 4
#define SECURITY_MOD 8
#define TERMINATE 16
#define CHAINED 32
#define NULL_MACRO_INDEX 0
#define NULL_MACRO_OFFSET 0
#define NULL_TIME (120 * 0x0f + 0x7f) /* ( = 1927 minutes ) */
/* Flag values for valid Lat/Long. */
#define LATITUDE 1
#define LONGITUDE 2
/* Controls accepted by function get_freespace() */
#define ALL_TIMERS 1
#define CLK_TIMERS 2
/* Arguments for process_data() */
#define PROC_CHECK 1
#define PROC_UPLOAD 2
/* Arguments for direct_cmd() */
#define CMD_VERIFY 0
#define CMD_RUN 1
#define CMD_INT 2
/* Counter functions */
#define CNT_SET 0
#define CNT_INC 1
#define CNT_DEC 2
#define CNT_DSKPZ 3
#define CNT_DSKPNZ 4
#define CNT_DSKPNZIZ 5
/* Identifies macros which are used over the programmed interval */
#define NOTUSED 0
#define USED 1
#define ACTIVE_START 1
#define ACTIVE_STOP 2
/* Values for Trigger Off/On mode in schedule */
#define TRIGGER_OFF 0
#define TRIGGER_ON 1
/* Value for Trigger Tag */
#define TRIGGER_TAG 0x40
#define TIMER_EXEC 0
#define TRIGGER_EXEC 1
/* Values for CM11a security mode bits and offset adjustment */
#define SECURITY_OFF 0x00
#define SECURITY_ON 0x02
#define SECURITY_OFFSET_ADJUST 30
/* Bitmap flags for "as-of" dates and times */
#define ASIF_NONE 0
#define ASIF_DATE 1
#define ASIF_TIME 2
/* Controls for time_adjust() */
#define LGL2STD 0
#define STD2LGL 1
/* Bitmap flags for SCENE/USERSYN */
#define F_SCENE 1
#define F_USYN 2
/* How to interpret undefined legal times, e.g., in the */
/* USA, times between 02:00 and 02:59 on the day when */
/* Daylight Time goes into effect. */
#define STD_TIME 0
#define DST_TIME 1
#define UNDEF_TIME STD_TIME
/* An env variable name for use by the relay */
#define CLOCKSTAMP "HEYUCLOCKSTAMP"
/* Delay after setclock, reset, purge, or clear */
#define SETCLOCK_DELAY 2000 /* milliseconds */
/* Flags for parse_addr() function */
#define A_VALID 1
#define A_HCODE 2
#define A_BMAP 4
#define A_PLUS 8
#define A_MINUS 16
#define A_ALIAS 32
#define A_DUMMY 64
#define A_MULT 128
#define A_STAR 256
/* CM17A RF Timing modes */
#define RF_SLOW 0
#define RF_FAST 1
/* Origin of call to parse_config_tail() */
#define SRC_CONFIG 1
#define SRC_SCHED 2
#define SRC_ENVIRON 4
#define SRC_STOP 8
#define SRC_HELP 16
#define SRC_SYSCHECK 32
#define SRC_MULT 64
/* Phase synch modes */
#define NO_SYNC 0
#define RISE_SYNC 1
#define FALL_SYNC 2
/* RFXmitter frequency */
#define MHZ310 1
#define MHZ433 2
/* State engine command functions */
/* 3 bytes: header, function, data */
#define ST_COMMAND 0x7b /* header */
#define ST_INIT_ALL 0
#define ST_INIT 1
#define ST_WRITE 2
#define ST_LAUNCH 3
#define ST_LAUNCH_GLOBAL 4
#define ST_CHKSUM 5
#define ST_APPEND 6
#define ST_EXIT 7
#define ST_MSG 8
#define ST_XMITRF 9
#define ST_RESETRF 10
#define ST_REWIND 11
#define ST_INIT_OTHERS 12
#define ST_BUSYWAIT 13
#define ST_SOURCE 14
#define ST_FLAGS 15
#define ST_PFAIL 16
#define ST_SHOWBYTE 17
#define ST_CLRSTATUS 18
#define ST_VDATA 19
#define ST_RESTART 20
#define ST_SECFLAGS 21
#define ST_LONGVDATA 22
#define ST_RFFLOOD 23
#define ST_AUX_ADDR 24
#define ST_AUX_FUNC 25
#define ST_SETTIMER 26
#define ST_CLRTIMERS 27
#define ST_CLRTAMPER 28
#define ST_RFXTYPE 29
#define ST_RFXSERIAL 30
#define ST_RFXNOISEVL 31
#define ST_RFXRAWVL 32
#define ST_VARIABLE_LEN 33
#define ST_LOCKUP 34
#define ST_COUNTER 35
#define ST_GENLONG 36
#define ST_ORE_EMU 37
#define ST_SCRIPT 38
#define ST_SECURITY 39
#define ST_FLAGS32 40
#define ST_TESTPOINT 41
#define ST_SHOWBUFFER 42
/* Launch trigger modes */
#define TMODE_SIGNAL 0
#define TMODE_MODULE 1
/* Launcher types */
#define L_NORMAL 0x0001
#define L_POWERFAIL 0x0002
#define L_ADDRESS 0x0004
#define L_RFFLOOD 0x0008
#define L_TIMEOUT 0x0010
#define L_SENSORFAIL 0x0020
#define L_LOCKUP 0x0040
#define L_RFXJAM 0x0080
#define L_EXEC 0x0100
#define L_HOURLY 0x0200
#define L_ANY (L_NORMAL|L_POWERFAIL|L_ADDRESS|L_RFFLOOD|L_TIMEOUT|L_SENSORFAIL|L_LOCKUP|L_RFXJAM|L_EXEC|L_HOURLY)
/* Flags for powerfail time relative to relay startup */
#define R_ATSTART 1
#define R_NOTATSTART 2
/* Time in seconds defining R_ATSTART versus R_NOTATSTART */
#define ATSTART_DELAY 10
/* Daemon which launches script */
#define D_CMDLINE 0
#define D_ENGINE 1
#define D_RELAY 2
#define D_AUXDEV 3
#define D_AUXRCV 4
/* Flag modification modes */
#define CLRFLAG 0
#define SETFLAG 1
/* Sensor activity modes */
#define S_ACTIVE 0
#define S_INACTIVE 1
/* Bitmap definitions for Heyu script environment variables */
#define HEYUMAP_LEVEL 0x000000ff /* Lowest byte is level 0-100 */
#define HEYUMAP_APPL 0x00000100 /* Appliance (non-dimmable) module */
#define HEYUMAP_SPEND 0x00000200 /* Status pending state */
#define HEYUMAP_OFF 0x00000400 /* Off state */
#define HEYUMAP_ADDR 0x00000800 /* Addressed state */
#define HEYUMAP_CHG 0x00001000 /* Changed state */
#define HEYUMAP_DIM 0x00002000 /* Dimmed state */
#define HEYUMAP_SIGNAL 0x00004000 /* Signal state */
#define HEYUMAP_CLEAR 0x00008000 /* Clear state */
#define HEYUMAP_ALERT 0x00010000 /* Alert state */
#define HEYUMAP_AUXCLEAR 0x00020000 /* AuxClear state */
#define HEYUMAP_AUXALERT 0x00040000 /* AuxAlert state */
#define HEYUMAP_ACTIVE 0x00080000 /* Active */
#define HEYUMAP_INACTIVE 0x00100000 /* Inactive */
#define HEYUMAP_MODCHG 0x00200000 /* Module Change */
#define HEYUMAP_ON 0x00400000 /* On state */
#define FLAGMAP_LOBAT 0x00000001 /* Low battery */
#define FLAGMAP_ROLLOVER 0x00000002 /* Rollover flag */
#define FLAGMAP_SWMIN 0x00000004 /* Min switch */
#define FLAGMAP_SWMAX 0x00000008 /* Max switch */
#define FLAGMAP_MAIN 0x00000010 /* Main channel */
#define FLAGMAP_AUX 0x00000020 /* Aux channel */
#define FLAGMAP_TAMPER 0x00000040 /* Tamper flag */
#define FLAGMAP_TMIN 0x00000080 /* Tmin flag */
#define FLAGMAP_TMAX 0x00000100 /* Tmax flag */
#define FLAGMAP_RHMIN 0x00000200 /* RHmin flag */
#define FLAGMAP_RHMAX 0x00000400 /* RHmax flag */
#define FLAGMAP_BPMIN 0x00000800 /* BPmin flag */
#define FLAGMAP_BPMAX 0x00001000 /* BPmin flag */
#define FLAGMAP_DMXSET 0x00002000 /* DMX Set flag */
#define FLAGMAP_DMXHEAT 0x00004000 /* DMX Heat flag */
#define FLAGMAP_DMXINIT 0x00008000 /* DMX Init flag */
#define FLAGMAP_DMXTEMP 0x00010000 /* DMX Temp flag */
/* Bitmap definitions for Xtend script environment variables */
#define XTMAP_APPL 32 /* Appliance module */
#define XTMAP_ADDR 64 /* Addressed state */
#define XTMAP_ON 128 /* On state */
/* Night and Dark flags share space with 16 common flags */
#define NIGHT_FLAG (0x01 << 16)
#define DARK_FLAG (0x02 << 16)
/* Global security flags share space with 16 common flags plus */
/* night and dark flags so need to be shifted by 18 bits. */
#define GLOBSEC_SHIFT 18
#define GLOBSEC_ARMED (0x01 << GLOBSEC_SHIFT)
#define GLOBSEC_HOME (0x02 << GLOBSEC_SHIFT)
#define GLOBSEC_PENDING (0x04 << GLOBSEC_SHIFT)
#define GLOBSEC_TAMPER (0x08 << GLOBSEC_SHIFT)
#define GLOBSEC_SLIGHTS (0x10 << GLOBSEC_SHIFT)
#define GLOBSEC_FLOOD (0x20 << GLOBSEC_SHIFT)
#define GLOBSEC_RFXJAM (0x40 << GLOBSEC_SHIFT)
/* Unit Security and RFXMeter vflags */
#define SEC_LOBAT 0x00000001
#define SEC_HOME 0x00000002
#define SEC_AWAY 0x00000004
#define SEC_MIN 0x00000008
#define SEC_MAX 0x00000010
#define SEC_FLOOD 0x00000020
#define SEC_TAMPER 0x00000040
#define SEC_MAIN 0x00000080
#define SEC_AUX 0x00000100
#define RFX_ROLLOVER 0x00000200
#define RFX_JAM 0x00000400
#define DMX_HEAT 0x00000800
#define DMX_SET 0x00001000
#define DMX_INIT 0x00002000
#define ORE_TMIN 0x00004000
#define ORE_TMAX 0x00008000
#define ORE_RHMIN 0x00010000
#define ORE_RHMAX 0x00020000
#define ORE_BPMIN 0x00040000
#define ORE_BPMAX 0x00080000
#define SEC_FAULT 0x00100000
#define DMX_TEMP 0x00200000
/* Used for DS90 sensor model ID determination */
#define COMPUTE_AUX 1
#define COMPUTE_MAIN -1
/* Virtual data packet lengths */
#define LEN_VDATA 6
#define LEN_LONGVDATA 8
/* Types of data written to the spoolfile by heyu */
enum {SENT_WRMI, SENT_ADDR, SENT_FUNC, SENT_EXTFUNC, SENT_STCMD, SENT_OTHER,
SENT_MESSAGE, SENT_RF, SENT_FLAGS, SENT_PFAIL, SENT_CLRSTATUS,
SENT_VDATA, SENT_LONGVDATA, SENT_RFFLOOD, SENT_LOCKUP, SENT_SETTIMER, SENT_RFXTYPE,
SENT_RFXSERIAL, SENT_RFVARIABLE, SENT_COUNTER, SENT_GENLONG, SENT_ORE_EMU, SENT_SCRIPT,
SENT_KAKU, SENT_FLAGS32, SENT_INITSTATE, SENT_VISONIC, SENT_SHOWBUFFER};
/* X10 generic signal types */
enum {
AllOffSignal, LightsOnSignal, OnSignal, OffSignal,
DimSignal, BriSignal, LightsOffSignal, Ext3Signal, Ext3DimSignal,
AllOnSignal, PresetSignal, StatusSignal, StatusOnSignal, StatusOffSignal
};
/* Module masks */
enum {
AllOffMask, LightsOnMask, OnMask, OffMask, DimMask, BriMask,
BriDimMask, LightsOffMask, StdMask, Ext3Mask, Ext3DimMask, AllOnMask,
PresetMask, StatusMask, StatusOnMask, StatusOffMask,
LightsOnFullMask, OnFullMask, OnFullOffMask, ResumeMask,
TargMask, Exc16Mask, Exc8Mask, Exc4Mask, Ext0Mask, VdataMask,
ResumeDimMask, LightsOnUnaddrMask, LightsOffUnaddrMask, Ext3GrpExecMask,
Ext3GrpRelMask, Ext3GrpOffMask, Ext3GrpOffExecMask, Ext3GrpBriDimFullMask,
Ext3GrpBriDimMask, Ext3GrpRelT1Mask, Ext3GrpRelT2Mask, Ext3GrpRelT3Mask,
Ext3GrpRelT4Mask, Ext3StatusMask, Ext3GrpRemMask, PlcSensorMask, AddrMask,
PhysMask, DeferMask, OnOffUnaddrMask, NumModMasks
};
/* Virtual Module masks */
enum {VstdMask, VentMask, VsecMask, VrfxsMask, VrfxmMask, VdmxMask, VoreMask,
VtstampMask, VkakuMask, NumVmodMasks
};
/* KaKu Module masks */
enum {KoffMask, KonMask, KGoffMask, KGonMask, KpreMask, KGpreMask, KresumeMask,
KPhysMask, NumKmodMasks
};
/* State bitmap indexes */
enum {OnState, DimState, ModChgState, ChgState, LightsOnState, AlertState, ClearState,
AuxAlertState, AuxClearState, ActiveState, InactiveState, LoBatState,
ValidState, NullState, ActiveChgState, SpendState, TamperState,
AddrState, /* SwMinState, SwMaxState,*/ NumStates};
/* Launch trigger types */
enum {
AllOffTrig, LightsOnTrig, OnTrig, OffTrig, DimTrig, BriTrig,
LightsOffTrig, ExtendedTrig, HailReqTrig, HailAckTrig,
PresetTrig, PresetTrig2, DataXferTrig, StatusOnTrig, StatusOffTrig,
StatusReqTrig, AllOnTrig, ExtPowerUpTrig, VdataTrig, VdataMTrig, NumTriggers
};
/* Enum security trigger types */
enum {
PanicTrig, ArmTrig, DisarmTrig, AlertTrig, ClearTrig, TestTrig,
SecLightsOnTrig, SecLightsOffTrig, TamperTrig, DuskTrig, DawnTrig,
AkeyOnTrig, AkeyOffTrig, BkeyOnTrig, BkeyOffTrig, InactiveTrig, NumSecTriggers
};
/* Launch RFXSensor, RFXMeter, Digimax, Oregon trigger types */
enum {
RFXTempTrig, RFXTemp2Trig, RFXHumidTrig, RFXPressTrig, RFXVadTrig,
RFXPotTrig, RFXVsTrig, RFXLoBatTrig, RFXOtherTrig, RFXPulseTrig,
RFXPowerTrig, RFXWaterTrig, RFXGasTrig, RFXCountTrig,
DmxTempTrig, DmxOnTrig, DmxOffTrig, DmxSetPtTrig, NumRFXTriggers
};
/* Launch Oregon trigger types */