-
Notifications
You must be signed in to change notification settings - Fork 27
/
modules.c
4385 lines (3746 loc) · 149 KB
/
modules.c
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
/*----------------------------------------------------------------------------+
| |
| X10 Module Attributes for HEYU |
| Copyright 2004-2008 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. |
| SwitchLinc and LampLinc are trademarks of Smarthome, Inc. |
| The author is not affiliated with any of these entities. |
| |
| 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
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <ctype.h>
#include "process.h"
#include "oregon.h"
/* Standard module attribute/response definitions for cflags */
/* Basic function codes 0-6 (maintain this order) */
#define UNOFF 0x00000001 /* All Units Off */
#define LION 0x00000002 /* All Lights ON */
#define MON 0x00000004 /* Simple module ON */
#define MOFF 0x00000008 /* Simple module OFF */
#define DIM 0x00000010 /* Dim 1-22 */
#define BRI 0x00000020 /* Bright 1-22 */
#define LIOFF 0x00000040 /* All Lights OFF */
/* Other attributes */
#define ALLON 0x00000080 /* All Units On */
#define STDX10 0x00000100 /* Standard X10 */
#define PRESET 0x00000200 /* Preset 1-32 */
#define BRIB4DIM 0x00000400 /* If OFF, full Brightness before dimming */
#define STAREQ 0x00000800 /* Responds to Status Request */
#define STAON 0x00001000 /* Sends StatusOn ack */
#define STAOFF 0x00002000 /* Sends StatusOff ack */
#define LIONFULL 0x00004000 /* All Lights ON -> Full brightness */
#define ONFULL 0x00008000 /* ON -> Full (or option) brightness */
#define ONFULLOFF 0x00010000 /* ON -> Full brightness if Off */
#define RESUME 0x00020000 /* ON resumes previous level */
#define RESUMEDIM 0x00040000 /* Dim/Bright first resumes previous level */
#define LIONUNAD 0x00080000 /* AllLightsOn unaddresses the module */
#define LIOFFUNAD 0x00100000 /* AllLightsOff unaddresses the module */
#define TARG 0x00200000 /* Is a target instead of a module */
#define EXC16 0x00400000 /* Last unit turns On (all others turn off) */
#define EXC8 0x00800000 /* Last unit turns On (others in group of 8 turn off) */
#define EXC4 0x01000000 /* Last unit turns On and others in group of 4 turn off) */
#define VDATA 0x02000000 /* Virtual data repository */
#define PLCSENSOR 0x04000000 /* PLC Sensor */
#define ADDRESSED 0x08000000 /* Has standard address */
#define PHYS 0x10000000 /* Is a physical module */
#define ONOFFUNAD 0x20000000 /* On or Off unaddresses the module (ACT bug) */
/* NOTE: Attributes STDX10, PRESET, and EXT3SW/EXT3DIM are */
/* mutually incompatible. */
/* Extended code module attributes for xflags */
/* (Group reference characteristic types are mutually incompatible.) */
#define XNON 0
#define X3SW 0x00000001 /* Extended codes Type 3 (switch only) */
#define X3DIM 0x00000002 /* Extended codes Type 3 with preset dim 0-63 */
#define X0SH 0x00000004 /* Extended code Type 0 shutter control */
#define X3GEXEC 0x00000008 /* Supports Extended Group Exec command */
#define X3GRC1 0x00000010 /* Group reference characteristic Type 1 (LM14A, AM14A) */
#define X3GRC2 0x00000020 /* Group reference characteristic Type 2 (LM465-1) */
#define X3GRC3 0x00000040 /* Group reference characteristic Type 3 (WS467-1) */
#define X3GRC4 0x00000080 /* Group reference characteristic Type 4 */
#define X3GOFF 0x00000100 /* Extended Group Off */
#define X3GOFFEX 0x00000200 /* Extended Group Off acts like Group Exec */
#define X3GBD 0x00000400 /* Extended Group Bright/Dim */
#define X3GBDFULL 0x00000800 /* Ext Grp Bri/Dim resumes, or brightens full if prev at level 0 */
#define X3STAT 0x00001000 /* Extended code status, i.e., 2-way */
#define X3GREM 0x00002000 /* Extended Group Remove works */
#define X0PRESET 0x00004000 /* Extended code Type 0 shutter preset */
/* Virtual model attributes for vflags */
#define VNON 0
#define VSTD 0x00000001 /* X10 Standard */
#define VENT 0x00000002 /* X10 Entertainment */
#define VSEC 0x00000004 /* X10 Security */
#define VRFXS 0x00000008 /* RFX Sensor */
#define VRFXM 0x00000010 /* RFX Meter */
#define VDMX 0x00000020 /* Digimax */
#define VORE 0x00000040 /* Oregon */
#define VKAKU 0x00000080 /* KAKU */
/* KaKu model attributes for kflags */
#define KOFF 0x00000001 /* Off */
#define KON 0x00000002 /* On */
#define KGOFF 0x00000004 /* Group Off */
#define KGON 0x00000008 /* Group On */
#define KPRE 0x00000010 /* Preset */
#define KGPRE 0x00000020 /* Group Preset */
#define KRESUME 0x00000040 /* Resume */
#define KPHYS 0x00000080 /* Physical module */
/* Module max dim levels */
#define MXL0 0
#define MXLS 210 /* Standard X10 modules 0-210 */
#define MXLP 31 /* Preset modules 0-31 (zero-base) */
#define MXLE 62 /* Extended code Type 3 dimmer modules 0-62 */
#define MXLEA 63 /* Extended code Type 3 appliance modules 0,63 */
#define MXLS0 25 /* Extended code Type 0 shutters 0-25 */
#define MXLV 255 /* Virtual modules 0-255 */
#define MXLK 15 /* KAKU modules 0-15 */
/* Standard module type attributes for cflags . To add a new module type, */
/* "OR" together its attributes here and add an entry in the modules */
/* table below. (Keep the table uncluttered, for future additions.) */
#define NOMATT 0
#define BASIC (UNOFF | MON | MOFF | ALLON | ADDRESSED | PHYS)
#define ACTBASIC (STDX10 | MON | MOFF | ALLON | ADDRESSED | PHYS | STAON | STAOFF | STAREQ)
#define ACTBUG (ACTBASIC | ONOFFUNAD)
#define STDAM (BASIC | STDX10)
#define STDLM (STDAM | DIM | BRI | BRIB4DIM | LION | ONFULLOFF)
#define STDWS (STDLM | LIOFF)
#define AMS (STDAM | STAON | STAOFF | STAREQ)
#define LMS (STDLM | STAON | STAOFF | STAREQ)
#define SIREN (STDAM | LION )
#define REM2 (STDX10 | TARG | MON | MOFF)
#define REM3 (STDX10 | TARG | MOFF | BRI | DIM)
#define REM4 (STDX10 | TARG | MON | MOFF | BRI | DIM)
#define REM6 (STDX10 | TARG | MON | MOFF | BRI | DIM | LION | UNOFF)
#define LM15A (STDAM | LION | LIONFULL | LIOFF | LIONUNAD | LIOFFUNAD)
#define XPS3 (STDAM | LION | LIONFULL | LIOFF)
#define XPD3 (STDLM | LIOFF)
#define PR511 (STDAM | STAON | STAOFF | STAREQ | LION | LIONFULL | LIOFF)
#define AM14A (BASIC | ALLON | STAON | STAOFF | STAREQ)
#define LM14A (AM14A | DIM | BRI | LION | LIOFF | RESUME | RESUMEDIM | LIOFFUNAD)
#define SL1AM (BASIC)
#define SL2AM (SL1AM | STAREQ)
#define SL1LM (BASIC | PRESET | DIM | BRI | LION | LIOFF | ONFULL)
#define SL2LM (SL1LM | STAREQ)
#define LL1LM (BASIC | PRESET | DIM | BRI | LION | LIOFF | LIONFULL | ONFULL)
#define LL2LM (LL1LM | STAREQ)
#define AMEXC16 (STDAM | EXC16)
#define AMEXC8 (STDAM | EXC8 )
#define AMEXC4 (STDAM | EXC4 )
#define CAMEXC4 (STDX10 | EXC4 | MON | MOFF | ADDRESSED | PHYS)
#define VIRT4 (TARG | MON | MOFF | BRI | DIM)
#define SHUT0 (MON | MOFF | RESUME | PHYS)
#define VIRTUAL (TARG | VDATA)
#define PALMPAD (TARG | MON | MOFF | BRI | DIM)
#define KEYCHAIN (TARG | MON | MOFF)
#define ONLYON (TARG | MON)
#define ONLYOFF (TARG | MOFF)
#define PLCSEN (TARG | MON | MOFF | ADDRESSED | PLCSENSOR)
#define MOTION (TARG | MON | MOFF)
#define LM_1 (BASIC | DIM | BRI | LION | LIOFF | RESUMEDIM | LIOFFUNAD)
#define WS_1 (BASIC | DIM | BRI | LION | RESUME)
/* Extended module type attributes for xflags */
#define XAM14A (X3SW | X3GEXEC | X3GRC1 | X3GOFFEX | X3STAT | X3GREM)
#define XLM14A (X3SW | X3GEXEC | X3DIM | X3GRC1 | X3GOFFEX | X3STAT | X3GREM)
#define XLM_1 (X3SW | X3GEXEC | X3DIM | X3GRC2 | X3GOFF | X3GBD | X3GBDFULL)
#define XWS_1 (X3SW | X3GEXEC | X3DIM | X3GRC3 | X3GOFFEX | X3GREM)
#define XSHUT0 (X0SH)
/* KaKu module type attributes */
#define KAM (KOFF | KON | KGOFF | KGON)
#define KLM (KAM | KPRE | KGPRE | KRESUME)
/* Module option functions */
int opt_onlevel(), opt_sremote(), opt_kremote(), opt_sensor(), opt_svsensor(), opt_ds90(), opt_sd90(),
opt_ur81a(), opt_ux17a(), opt_guru(), opt_aux(), opt_rfxsensor(), opt_rfxold(), opt_act(), opt_defer(),
opt_rfxtemp(),
opt_rfxpulse(), opt_rfxcount(), opt_rfxpower(), opt_rfxwater(), opt_rfxgas(),
opt_sd10(), opt_plcsensor(), opt_gb10(), opt_jam(), opt_digimax(),
opt_oreTH1(), opt_oreTH2(), opt_oreTH3(), opt_oreTH4(), opt_oreTH5(), opt_oreTH6(),
opt_oreTemp1(), opt_oreTemp2(), opt_oreTemp3(), opt_oreTHB1(), opt_oreTHB2(), opt_oreWeight1(),
opt_oreTemu(), opt_oreTHemu(), opt_oreTHBemu(), opt_x10std(), opt_oreignore(), opt_elsElec1(),
opt_bmb_sd18(),
opt_secignore(), opt_visonic(),
opt_oreWind1(), opt_oreWind2(), opt_oreWind3(),
opt_oreRain1(), opt_oreRain2(), opt_oreRain3(),
opt_oreUV1(), opt_oreUV2(), opt_kaku(), opt_owlElec2(), opt_owlElec2new(), opt_owlElec2rev(),
opt_oreDT1();
/* Decoder functions for modules */
int fn_ds10a(), fn_ds90(), fn_ms10a(), fn_sh624(), fn_kr10a(), fn_ur81a(),
fn_guru(), fn_rfxsensor(),
fn_rfxpulse(), fn_rfxcount(), fn_rfxpower(), fn_rfxwater(), fn_rfxgas(),
fn_sd10(), fn_sd90(), fn_ms90(), fn_ds18(), fn_gb10(), fn_svdata(), fn_jam(),
fn_kr15a(), fn_kr18(), fn_dm10(), fn_bmb_sd18(), fn_visonic();
extern int ore_maxmin_temp ( ALIAS *, int, char **, int * );
extern int ore_maxmin_rh ( ALIAS *, int, char **, int * );
extern int ore_maxmin_bp ( ALIAS *, int, char **, int * );
extern double celsius2temp ( double, char, double);
int sensor_timeout ( ALIAS *, int, char **, int * );
struct modules_st {
char *label; /* Case insensitive */
int maxlevel;
unsigned long vflags; /* Virtual attributes */
unsigned long cflags; /* Standard attributes */
unsigned long xflags; /* Extended code attributes */
int (*addopt_func)();
int (*xlate_func)();
} modules[] = {
{"NONE", MXLS, VNON, NOMATT, 0, NULL, NULL }, /* Has no attributes */
{"StdAM", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"AM", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"AM486", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"AM12", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Marmitek Standard X10 1-way Appliance Module */
{"PAM01", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"AM466", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"PAM02", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"SR227", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"PA011", MXLS, VNON, STDAM, 0, NULL, NULL }, /* Standard X10 1-way Appliance Module */
{"AMS", MXLS, VNON, AMS, 0, opt_defer, NULL }, /* 2-way Appliance Module */
{"RAIN8II", MXLS, VNON, AMS, 0, opt_defer, NULL }, /* Rain8II 2-way Irrigation Module */
{"RR501", MXLS, VNON, AMS, 0, NULL, NULL }, /* X10 Transceiver/Switch */
{"PAT01", MXLS, VNON, AMS, 0, NULL, NULL }, /* X10 Transceiver/Switch */
{"ACTAMS", MXLS, VNON, ACTBASIC, 0, opt_act, NULL}, /* ACT programmable appliance module */
{"RS114", MXLS, VNON, ACTBASIC, 0, opt_act, NULL}, /* ACT programmable appliance module */
{"ACTAMSBUG", MXLS, VNON, ACTBUG, 0, opt_act, NULL}, /* ACT as above with On/Off unaddress bug */
{"RF234", MXLS, VNON, ACTBUG, 0, opt_act, NULL}, /* ACT as above with On/Off unaddress bug */
{"StdLM", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Standard X10 1-way Lamp Module */
{"LM", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Standard X10 1-way Lamp Module */
{"LM465", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Standard X10 1-way Lamp Module */
{"LM12", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Marmitek X10 1-way Lamp Module */
{"LM465-1", MXLE, VNON, LM_1, XLM_1, NULL, NULL }, /* Redesigned (2007) X10 1-way Lamp Module */
{"LM-1", MXLE, VNON, LM_1, XLM_1, NULL, NULL }, /* Redesigned (2007) X10 1-way Lamp Module */
{"PLM03", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Standard X10 1-way Lamp Module */
{"PLM01", MXLS, VNON, STDLM, 0, NULL, NULL }, /* Standard X10 1-way Lamp Module */
{"StdWS", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 1-way Lamp Wall Switch */
{"WS", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 1-way Lamp Wall Switch */
{"WS467", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 1-way Lamp Wall Switch */
{"LW10U", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Marmitek Standard X10 1-way Lamp Wall Switch */
{"PLW01", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 1-way Lamp Wall Switch */
{"WS477", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 3-way Lamp Wall Switch */
{"PLW02", MXLS, VNON, STDWS, 0, NULL, NULL }, /* Standard X10 1-way Lamp Wall Switch */
{"WS467-1", MXLE, VNON, WS_1, XWS_1, NULL, NULL }, /* Redesigned (2007) X10 1-way Lamp Wall Switch */
{"WS-1", MXLE, VNON, WS_1, XWS_1, NULL, NULL }, /* Redesigned (2007) X10 1-way Lamp Wall Switch */
{"WS12A", MXLS, VNON, XPD3, 0, NULL, NULL }, /* X10 1-way Lamp Wall Switch */
{"XPD3", MXLS, VNON, XPD3, 0, NULL, NULL }, /* X10 Pro 1-way Lamp Wall Switch */
{"WS13A", MXLS, VNON, XPS3, 0, NULL, NULL }, /* X10 1-way non-dimming Wall Switch */
{"XPS3", MXLS, VNON, XPS3, 0, NULL, NULL }, /* X10 Pro 1-way non-dimming Wall Switch */
{"LM15A", MXLS, VNON, LM15A, 0, NULL, NULL }, /* X10 LM15A Socket Rocket */
{"LM15", MXLS, VNON, LM15A, 0, NULL, NULL }, /* Marmitek Socket Rocket */
{"PSM04", MXLS, VNON, LM15A, 0, NULL, NULL }, /* X10 Pro Socket Rocket */
{"LMS", MXLS, VNON, LMS, 0, NULL, NULL }, /* 2-way Lamp Module */
{"PR511", MXLS, VNON, PR511, 0, NULL, NULL }, /* X10 2-way Motion Sensor floodlight */
{"PHS01", MXLS, VNON, PR511, 0, NULL, NULL }, /* X10 Pro 2-way Motion Sensor floodlight */
{"AM14A", MXLEA, VNON, AM14A, XAM14A, NULL, NULL }, /* X10 2-way Appliance Module, 2-pin (AM14A) */
{"PAM21", MXLEA, VNON, AM14A, XAM14A, NULL, NULL }, /* X10 2-way Appliance Module, 2-pin (AM14A) */
{"AM15A", MXLEA, VNON, AM14A, XAM14A, NULL, NULL }, /* X10 2-way Appliance Module, 3-pin (AM15A) */
{"PAM22", MXLEA, VNON, AM14A, XAM14A, NULL, NULL }, /* X10 2-way Appliance Module, 3-pin (AM15A) */
{"LM14A", MXLE, VNON, LM14A, XLM14A, NULL, NULL }, /* X10 2-way Lamp Module (LM14A) */
{"PLM21", MXLE, VNON, LM14A, XLM14A, NULL, NULL }, /* X10 2-way Lamp Module (LM14A) */
{"SL1AM", MXLP, VNON, SL1AM, 0, NULL, NULL }, /* SwitchLinc 1-way Switch */
{"SL2AM", MXLP, VNON, SL2AM, 0, NULL, NULL }, /* SwitchLinc 2-way Switch */
{"SL1LM", MXLP, VNON, SL1LM, 0, opt_onlevel, NULL }, /* SwitchLinc 1-way Lamp Module */
{"SL2LM", MXLP, VNON, SL2LM, 0, opt_onlevel, NULL }, /* SwitchLinc 2-way Lamp Module */
{"SL2380W", MXLP, VNON, SL2LM, 0, opt_onlevel, NULL }, /* SwitchLinc 2380W Dimmer */
{"LL1LM", MXLP, VNON, LL1LM, 0, opt_onlevel, NULL }, /* LampLinc 1-way Dimmer */
{"LL2LM", MXLP, VNON, LL2LM, 0, opt_onlevel, NULL }, /* LampLink 2-way Dimmer */
{"LL2000STW", MXLP, VNON, LL2LM, 0, opt_onlevel, NULL }, /* LampLinc 2000STW Dimmer */
{"REMOTE2", MXLS, VNON, REM2, 0, NULL, NULL }, /* Remote transmitter, 2 function */
{"REMOTE3", MXLS, VNON, REM3, 0, NULL, NULL }, /* Remote transmitter, 3 function */
{"REMOTE4", MXLS, VNON, REM4, 0, NULL, NULL }, /* Remote transmitter, 4 function */
{"REMOTE6", MXLS, VNON, REM6, 0, NULL, NULL }, /* Remote transmitter, 6 function */
{"REMOTEP", MXLP, VNON, PRESET, 0, NULL, NULL }, /* Remote transmitter, Preset 1-32 only */
{"AMEXC", MXLS, VNON, AMEXC16, 0, NULL, NULL }, /* AM with exclusive-16 addressing */
{"AMEXC16", MXLS, VNON, AMEXC16, 0, NULL, NULL }, /* AM with exclusive addressing */
{"AMEXC8", MXLS, VNON, AMEXC8, 0, NULL, NULL }, /* AM with exclusive-8 addressing */
{"RAIN8", MXLS, VNON, AMEXC8, 0, NULL, NULL }, /* WGL Rain8 irrigation controller */
{"AMEXC4", MXLS, VNON, AMEXC4, 0, NULL, NULL }, /* AM with exclusive-4 addressing */
{"XM10A", MXLS, VNON, CAMEXC4, 0, NULL, NULL }, /* X10 camera power supply */
{"XM13A", MXLS, VNON, CAMEXC4, 0, NULL, NULL }, /* X10 camera power supply */
{"XM14A", MXLS, VNON, CAMEXC4, 0, NULL, NULL }, /* X10 pan/tilt power supply */
{"VIRT4", MXLV, VSTD, VIRT4, 0, opt_onlevel, NULL }, /* Virtual module, 4 function */
{"VDATA", MXLV, VSTD, VIRTUAL, 0, NULL, NULL }, /* Virtual module data */
{"PLCSENSOR", MXLS, VSTD, PLCSEN, 0, opt_plcsensor, NULL }, /* PLC Sensor target */
#ifdef HAVE_FEATURE_EXT0
{"SHUTTER", MXLS0, VNON, SHUT0, XSHUT0, NULL, NULL }, /* Extended code Type 0 shutter */
{"SW10", MXLS0, VNON, SHUT0, XSHUT0, NULL, NULL }, /* Marmitek SW10 shutter control */
#endif
{"DS10A", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ds10a }, /* X-10 USA D/W sensor */
{"DS10", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ds10a }, /* Marmitek D/W sensor */
{"DS10E", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ds10a }, /* Marmitek D/W sensor */
{"PDS01", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ds10a }, /* X10 Pro D/W sensor */
{"DS18", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ds18 }, /* ElekHomica D/W sensor, old? */
{"DS90", MXLV, VSEC, VIRTUAL, 0, opt_ds90, fn_ds90 }, /* Marmitek D/W sensor */
{"DS18-1", MXLV, VSEC, VIRTUAL, 0, opt_ds90, fn_ds90 }, /* ElekHomica D/W sensor */
{"MS10A", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ms10a },
{"MS90", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ms90 }, /* Marmitek Motion sensor */
{"MS18E", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ms90 }, /* BMB Home Solutions Motion sensor */
{"SD10", MXLV, VSEC, VIRTUAL, 0, opt_sd10, fn_sd10 },
{"BMB-SD18", MXLV, VSEC, VIRTUAL, 0, opt_bmb_sd18, fn_bmb_sd18}, /* BMB Smoke Detector */
{"EH-CWSD10", MXLV, VSEC, VIRTUAL, 0, opt_sd10, fn_sd10 }, /* ElekHomica Smoke detector */
{"EH-WD210", MXLV, VSEC, VIRTUAL, 0, opt_sd10, fn_sd10 }, /* ElekHomica Water detector */
{"GB10", MXLV, VSEC, VIRTUAL, 0, opt_gb10, fn_gb10 }, /* Marmitek Glass Break detector */
{"DM10", MXLV, VSEC, VIRTUAL, 0, opt_gb10, fn_dm10 }, /* Marmitek DM10 Motion/Dawn/Dusk sensor */
{"SD90", MXLV, VSEC, VIRTUAL, 0, opt_sd90, fn_sd90 }, /* Marmitek Smoke detector */
{"PMS01", MXLV, VSEC, VIRTUAL, 0, opt_sensor, fn_ms10a },
{"SH624", MXLV, VSEC, VIRTUAL, 0, opt_sremote, fn_sh624 }, /* Full size remotes */
{"PSR01", MXLV, VSEC, VIRTUAL, 0, opt_sremote, fn_sh624 },
{"KR18", MXLV, VSEC, VIRTUAL, 0, opt_kremote, fn_kr18 }, /* Keyfob remotes */
{"KR18E", MXLV, VSEC, VIRTUAL, 0, opt_kremote, fn_kr18 },
{"KR10A", MXLV, VSEC, VIRTUAL, 0, opt_kremote, fn_kr10a },
{"KR21", MXLV, VSEC, VIRTUAL, 0, opt_kremote, fn_kr10a },
{"PKR02", MXLV, VSEC, VIRTUAL, 0, opt_kremote, fn_kr10a },
{"KR15A", MXLV, VSEC, VIRTUAL, 0, opt_sremote, fn_kr15a }, /* Big Red Button */
{"SVDATA", MXLV, VSEC, VIRTUAL, 0, opt_sremote, fn_svdata }, /* Generic security remote */
{"SSVDATA", MXLV, VSEC, VIRTUAL, 0, opt_svsensor, fn_svdata }, /* Generic security sensor */
{"SEC_IGNORE", MXLV, VSEC, VIRTUAL, 0, opt_secignore, NULL },
{"UR81A", MXLV, VENT, VIRTUAL, 0, opt_ur81a, fn_ur81a },
{"UR51A", MXLV, VENT, VIRTUAL, 0, opt_ur81a, fn_ur81a },
{"UX17A", MXLV, VENT, VIRTUAL, 0, opt_ux17a, NULL },
{"UX23A", MXLV, VENT, VIRTUAL, 0, opt_ux17a, NULL },
{"GURU", MXLV, VENT, VIRTUAL, 0, opt_guru, fn_guru },
{"PALMPAD", MXLS, VSTD, PALMPAD, 0, opt_aux, NULL},
{"KR19A", MXLS, VSTD, PALMPAD, 0, opt_aux, NULL},
{"KR22", MXLS, VSTD, PALMPAD, 0, opt_aux, NULL},
{"KEYCHAIN", MXLS, VSTD, KEYCHAIN, 0, opt_aux, NULL},
{"ONLYON", MXLS, VSTD, ONLYON, 0, opt_aux, NULL},
{"ONLYOFF", MXLS, VSTD, ONLYOFF, 0, opt_aux, NULL},
{"MS12", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS12A", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS13", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS13A", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS14", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS14A", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS16", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
{"MS16A", MXLS, VSTD, MOTION, 0, opt_x10std, NULL},
#ifdef HAVE_FEATURE_ORE
{"ORE_TH1", MXLV, VORE, VIRTUAL, 0, opt_oreTH1, NULL},
{"THGR122NX", MXLV, VORE, VIRTUAL, 0, opt_oreTH1, NULL},
{"THGN123N", MXLV, VORE, VIRTUAL, 0, opt_oreTH1, NULL},
{"THGR228N", MXLV, VORE, VIRTUAL, 0, opt_oreTH1, NULL},
{"ORE_TH2", MXLV, VORE, VIRTUAL, 0, opt_oreTH2, NULL},
{"THGN800", MXLV, VORE, VIRTUAL, 0, opt_oreTH2, NULL},
{"THGR800", MXLV, VORE, VIRTUAL, 0, opt_oreTH2, NULL},
{"THGR810", MXLV, VORE, VIRTUAL, 0, opt_oreTH2, NULL},
{"ORE_TH3", MXLV, VORE, VIRTUAL, 0, opt_oreTH3, NULL},
{"RTGN318", MXLV, VORE, VIRTUAL, 0, opt_oreTH3, NULL},
{"RTGR328N", MXLV, VORE, VIRTUAL, 0, opt_oreTH3, NULL},
{"RTGR328N_TH", MXLV, VORE, VIRTUAL, 0, opt_oreTH3, NULL},
{"ORE_TH4", MXLV, VORE, VIRTUAL, 0, opt_oreTH4, NULL},
{"ORE_TH5", MXLV, VORE, VIRTUAL, 0, opt_oreTH5, NULL},
{"ORE_TH6", MXLV, VORE, VIRTUAL, 0, opt_oreTH6, NULL},
{"THGR918N", MXLV, VORE, VIRTUAL, 0, opt_oreTH6, NULL},
{"ORE_T1", MXLV, VORE, VIRTUAL, 0, opt_oreTemp1, NULL},
{"THR138", MXLV, VORE, VIRTUAL, 0, opt_oreTemp1, NULL},
{"ORE_T2", MXLV, VORE, VIRTUAL, 0, opt_oreTemp2, NULL},
{"THRN122N", MXLV, VORE, VIRTUAL, 0, opt_oreTemp2, NULL},
{"THN122N", MXLV, VORE, VIRTUAL, 0, opt_oreTemp2, NULL},
{"THN132N", MXLV, VORE, VIRTUAL, 0, opt_oreTemp2, NULL},
{"ORE_T3", MXLV, VORE, VIRTUAL, 0, opt_oreTemp3, NULL},
{"ORE_THB1", MXLV, VORE, VIRTUAL, 0, opt_oreTHB1, NULL},
{"BTHR918", MXLV, VORE, VIRTUAL, 0, opt_oreTHB1, NULL},
{"ORE_THB2", MXLV, VORE, VIRTUAL, 0, opt_oreTHB2, NULL},
{"BTHR968", MXLV, VORE, VIRTUAL, 0, opt_oreTHB2, NULL},
{"BTHR918N", MXLV, VORE, VIRTUAL, 0, opt_oreTHB2, NULL},
{"ORE_WGT1", MXLV, VORE, VIRTUAL, 0, opt_oreWeight1, NULL},
{"BWR102", MXLV, VORE, VIRTUAL, 0, opt_oreWeight1, NULL},
{"ORE_DT1", MXLV, VORE, VIRTUAL, 0, opt_oreDT1, NULL},
{"RTGR328N_DT", MXLV, VORE, VIRTUAL, 0, opt_oreDT1, NULL},
{"ORE_TEMU", MXLV, VORE, VIRTUAL, 0, opt_oreTemu, NULL}, /* Dummy */
{"ORE_THEMU", MXLV, VORE, VIRTUAL, 0, opt_oreTHemu, NULL}, /* Dummy */
{"ORE_THBEMU", MXLV, VORE, VIRTUAL, 0, opt_oreTHBemu, NULL}, /* Dummy */
{"ORE_IGNORE", MXLV, VORE, VIRTUAL, 0, opt_oreignore, NULL},
{"ORE_WIND1", MXLV, VORE, VIRTUAL, 0, opt_oreWind1, NULL},
{"ORE_WIND2", MXLV, VORE, VIRTUAL, 0, opt_oreWind2, NULL},
{"WGR800", MXLV, VORE, VIRTUAL, 0, opt_oreWind2, NULL},
{"ORE_WIND3", MXLV, VORE, VIRTUAL, 0, opt_oreWind3, NULL},
{"WGR918N", MXLV, VORE, VIRTUAL, 0, opt_oreWind3, NULL},
{"ORE_RAIN1", MXLV, VORE, VIRTUAL, 0, opt_oreRain1, NULL},
{"PCR918N", MXLV, VORE, VIRTUAL, 0, opt_oreRain1, NULL},
{"ORE_RAIN2", MXLV, VORE, VIRTUAL, 0, opt_oreRain2, NULL},
{"PCR800", MXLV, VORE, VIRTUAL, 0, opt_oreRain2, NULL},
{"ORE_RAIN3", MXLV, VORE, VIRTUAL, 0, opt_oreRain3, NULL},
{"ELS_CM113", MXLV, VORE, VIRTUAL, 0, opt_elsElec1, NULL},
{"ELS_ELEC1", MXLV, VORE, VIRTUAL, 0, opt_elsElec1, NULL},
{"ORE_ELS", MXLV, VORE, VIRTUAL, 0, opt_elsElec1, NULL},
{"ORE_UV1", MXLV, VORE, VIRTUAL, 0, opt_oreUV1, NULL},
{"ORE_UV2", MXLV, VORE, VIRTUAL, 0, opt_oreUV2, NULL},
{"OWL_ELEC2", MXLV, VORE, VIRTUAL, 0, opt_owlElec2new, NULL},
#endif /* HAVE_FEATURE_ORE */
#ifdef HAVE_FEATURE_RFXS
{"RFXSENSOR", MXLV, VRFXS, VIRTUAL, 0, opt_rfxsensor, fn_rfxsensor},
#endif /* HAVE_FEATURE_RFXS */
#ifdef HAVE_FEATURE_RFXM
{"RFXCOUNT", MXLV, VRFXM, VIRTUAL, 0, opt_rfxcount, fn_rfxcount},
{"RFXPOWER", MXLV, VRFXM, VIRTUAL, 0, opt_rfxpower, fn_rfxpower},
{"RFXWATER", MXLV, VRFXM, VIRTUAL, 0, opt_rfxwater, fn_rfxwater},
{"RFXGAS", MXLV, VRFXM, VIRTUAL, 0, opt_rfxgas, fn_rfxgas},
{"RFXPULSE", MXLV, VRFXM, VIRTUAL, 0, opt_rfxpulse, fn_rfxpulse},
#endif /* HAVE_FEATURE_RFXM */
#ifdef HAVE_FEATURE_DMX
{"DIGIMAX", MXLV, VDMX, VIRTUAL, 0, opt_digimax, NULL},
#endif /* HAVE_FEATURE_DMX */
#ifdef HAVE_FEATURE_KAKU
{"KAKU_S", MXLK, VKAKU, KAM, 0, opt_kaku, NULL},
{"KAKU_P", MXLK, VKAKU, KLM, 0, opt_kaku, NULL},
#endif /* HAVE_FEATURE_KAKU */
{"VISGEN", MXLV, VSEC, VIRTUAL, 0, opt_visonic, fn_visonic }, /* Generic Visonic */
};
static int ntypes = (sizeof(modules)/sizeof(struct modules_st));
unsigned int modmask[NumModMasks][16];
unsigned int vmodmask[NumVmodMasks][16];
unsigned int kmodmask[NumKmodMasks][16];
unsigned char maxdimlevel[16][16];
unsigned char ondimlevel[16][16];
extern CONFIG config;
extern CONFIG *configp;
/*-------------------------------------------------------+
| Return a pointer to a module xlate_func() |
+-------------------------------------------------------*/
int (*module_xlate_func(int index))()
{
return modules[index].xlate_func;
}
/*-------------------------------------------------------+
| Return the index in the module table for the argument |
| name, or -1 if not found |
| The comparison is case insensitive |
+-------------------------------------------------------*/
int lookup_module_type ( char *modelname )
{
char buffer[NAME_LEN + 1], label[NAME_LEN + 1];
int j;
strncpy2(buffer, modelname, sizeof(buffer) - 1);
strupper(buffer);
for ( j = 0; j < ntypes; j++ ) {
strncpy2(label, modules[j].label, sizeof(label) - 1);
strupper(label);
if ( strcmp(buffer, label) == 0 )
return j;
}
return -1;
}
/*-------------------------------------------------------+
| Pass back through the argument list the flags and |
| maxlevel values for module index 'module_type' |
+-------------------------------------------------------*/
void module_attributes ( int module_type,
unsigned long *vflags, unsigned long *cflags,
unsigned long *xflags, unsigned long *kflags, int *maxlevel )
{
if ( module_type >= 0 ) {
*vflags = modules[module_type].vflags;
*cflags = modules[module_type].cflags;
if ( *vflags & VKAKU ) {
*kflags = *cflags;
*cflags = 0;
}
else {
*kflags = 0;
}
*xflags = modules[module_type].xflags;
*maxlevel = modules[module_type].maxlevel;
}
else {
*vflags = 0;
*cflags = 0;
*xflags = 0;
*kflags = 0;
*maxlevel = 0;
}
return;
}
/*-------------------------------------------------------+
| Called by add_alias() to add options specified on the |
| ALIAS line in the config file. |
+-------------------------------------------------------*/
int add_module_options ( ALIAS *aliasp, int aliasindex,
char **tokens, int ntokens )
{
int type;
type = aliasp[aliasindex].modtype;
if ( modules[type].addopt_func == NULL ) {
if ( ntokens > 0 ) {
store_error_message("No parameters are supported for this module type.");
return 1;
}
return 0;
}
return modules[type].addopt_func(aliasp, aliasindex, tokens, &ntokens);
}
/*-------------------------------------------------------+
| Display options specified for an ALIAS. |
+-------------------------------------------------------*/
char *display_module_options (int aliasindex )
{
static char buffer[128];
ALIAS *aliasp;
long int optflags, optflags2;
int j, k;
int rh;
double tempc, bp;
char keystr[4], grpstr[4];
long secs;
aliasp = configp->aliasp;
if ( !aliasp )
return "";
optflags = aliasp[aliasindex].optflags;
optflags2 = aliasp[aliasindex].optflags2;
buffer[0] = '\0';
if ( optflags & MOPT_RESUME )
sprintf(buffer, "ONLEVEL RESUME");
else if ( optflags & MOPT_ONFULL && aliasp[aliasindex].flags & PRESET)
sprintf(buffer, "ONLEVEL %d", aliasp[aliasindex].onlevel + 1);
else if ( optflags & MOPT_ONFULL )
sprintf(buffer, "ONLEVEL %d", aliasp[aliasindex].onlevel);
if ( optflags & MOPT_SECURITY || optflags & MOPT_ENTERTAIN ) {
buffer[0] = '\0';
for ( j = 0; j < aliasp[aliasindex].nident; j++ )
sprintf(buffer + strlen(buffer), "0x%02lx ", aliasp[aliasindex].ident[j]);
}
if ( optflags & MOPT_MAIN ) strcat(buffer, "MAIN ");
if ( optflags & MOPT_AUX ) strcat(buffer, "AUX ");
if ( optflags & MOPT_TRANSCEIVE ) strcat(buffer, "TRANSCEIVE ");
if ( optflags & MOPT_RFFORWARD ) strcat(buffer, "RFFORWARD ");
if ( optflags & MOPT_RFIGNORE ) strcat(buffer, "RFIGNORE ");
if ( optflags & MOPT_REVERSE ) strcat(buffer, "REVERSE ");
if ( optflags2 & MOPT2_DUMMY ) strcat(buffer, "DUMMY ");
if ( optflags & MOPT_RFXSENSOR ) {
sprintf(buffer + strlen(buffer), "0x%02lx ", aliasp[aliasindex].ident[0]);
strcat(buffer, "T");
if ( optflags & MOPT_RFXRH ) strcat(buffer, "H ");
else if ( optflags & MOPT_RFXBP ) strcat(buffer, "B ");
else if ( optflags & MOPT_RFXVAD ) strcat(buffer, "V ");
else if ( optflags & MOPT_RFXPOT ) strcat(buffer, "P ");
else if ( optflags & MOPT_RFXT2 ) strcat(buffer, "T ");
else strcat(buffer, " ");
}
if ( optflags & MOPT_RFXMETER ) {
sprintf(buffer + strlen(buffer), "0x%02lx ", aliasp[aliasindex].ident[0]);
}
if ( optflags & MOPT_KAKU ) {
for ( j = 0; j < aliasp[aliasindex].nident; j++ ) {
*keystr = '\0';
for ( k = 0; k < 16; k++ ) {
if ( aliasp[aliasindex].kaku_keymap[j] & (1 << k) ) {
sprintf(keystr, "%d", k + 1);
break;
}
}
*grpstr = '\0';
for ( k = 0; k < 16; k++ ) {
if ( aliasp[aliasindex].kaku_grpmap[j] & (1 << k) ) {
sprintf(grpstr, "%c", k + 'A');
break;
}
}
sprintf(buffer + strlen(buffer), "0x%07lx %s%s ",
aliasp[aliasindex].ident[j], keystr, grpstr);
}
}
if ( optflags2 & MOPT2_TMIN ) {
tempc = (double)aliasp[aliasindex].tmin / 10.0;
sprintf(buffer + strlen(buffer), "TMIN "FMT_ORET"%c ",
celsius2temp(tempc, configp->ore_tscale, 0.0), configp->ore_tscale );
}
if ( optflags2 & MOPT2_TMAX ) {
tempc = (double)aliasp[aliasindex].tmax / 10.0;
sprintf(buffer + strlen(buffer), "TMAX "FMT_ORET"%c ",
celsius2temp(tempc, configp->ore_tscale, 0.0), configp->ore_tscale );
}
if ( optflags2 & MOPT2_RHMIN ) {
rh = aliasp[aliasindex].rhmin;
sprintf(buffer + strlen(buffer), "RHMIN %d%% ", rh);
}
if ( optflags2 & MOPT2_RHMAX ) {
rh = aliasp[aliasindex].rhmax;
sprintf(buffer + strlen(buffer), "RHMAX %d%% ", rh);
}
if ( optflags2 & MOPT2_BPMIN ) {
bp = (double)aliasp[aliasindex].bpmin;
sprintf(buffer + strlen(buffer), "BPMIN "FMT_OREBP"%s ",
(bp * configp->ore_bpscale) + configp->ore_bpoffset, configp->ore_bpunits );
}
if ( optflags2 & MOPT2_BPMAX ) {
bp = (double)aliasp[aliasindex].bpmax;
sprintf(buffer + strlen(buffer), "BPMAX "FMT_OREBP"%s ",
(bp * configp->ore_bpscale) + configp->ore_bpoffset, configp->ore_bpunits );
}
if ( optflags2 & MOPT2_SWHOME ) {
strcat(buffer + strlen(buffer), "SWHOME ");
}
if ( optflags2 & MOPT2_SWMAX ) {
strcat(buffer + strlen(buffer), "SWMAX ");
}
if ( optflags2 & MOPT2_DUMMY ) {
strcat(buffer + strlen(buffer), "DUMMY ");
}
/* Inactive timeout */
if ( optflags2 & MOPT2_IATO ) {
secs = aliasp[aliasindex].hb_timeout;
sprintf(buffer + strlen(buffer), "IATO %ld:%02ld:%02ld ", (secs / 3600L), (secs % 3600L) / 60L, (secs % 60));
}
/* ACT module options */
if ( optflags2 & MOPT2_AUF ) {
sprintf(buffer + strlen(buffer), "AUF ");
}
if ( optflags2 & MOPT2_ALO ) {
sprintf(buffer + strlen(buffer), "ALO ");
}
if ( optflags2 & MOPT2_ALF ) {
sprintf(buffer + strlen(buffer), "ALF ");
}
/* Defer update for 2-way modules with auto status response */
if ( optflags2 & MOPT2_DEFER ) {
sprintf(buffer + strlen(buffer), "DEFER ");
}
return buffer;
}
/*-------------------------------------------------------+
| Return a pointer to the module name corresponding to |
| the argument module_type. |
+-------------------------------------------------------*/
char *lookup_module_name ( int module_type )
{
if ( module_type >= 0 && module_type < ntypes )
return modules[module_type].label;
return "";
}
/*-------------------------------------------------------+
| Create the state filter determined by characteristics |
| of each module defined in the config file. |
+-------------------------------------------------------*/
void set_module_masks ( ALIAS *aliasp )
{
int j, ucode;
unsigned char hcode, maxlevel, onlevel;
unsigned int bitmap, vflags, cflags, xflags, kflags;
unsigned int defined[16];
if ( configp->module_types == NO ) {
for ( j = 0; j < NumModMasks; j++ ) {
for ( hcode = 0; hcode < 16; hcode++ )
modmask[j][hcode] = 0xffff;
}
return;
}
/* Default for undefined modules */
vflags = modules[configp->default_module].vflags;
cflags = modules[configp->default_module].cflags;
if ( vflags & VKAKU ) {
kflags = cflags;
cflags = 0;
}
else {
kflags = 0;
}
xflags = modules[configp->default_module].xflags;
maxlevel = modules[configp->default_module].maxlevel;
/* Record housecode|units with defined module type */
for ( j = 0; j < 16; j++ ) {
defined[j] = 0;
}
j = 0;
while ( aliasp && aliasp[j].line_no > 0 ) {
if ( aliasp[j].modtype >= 0 ) {
/* Module is defined */
hcode = hc2code(aliasp[j].housecode);
defined[hcode] |= aliasp[j].unitbmap;
}
j++;
}
/* Initialize to zero */
for ( j = 0; j < NumModMasks; j++ ) {
for ( hcode = 0; hcode < 16; hcode++ )
modmask[j][hcode] = 0;
}
for ( j = 0; j < NumVmodMasks; j++ ) {
for ( hcode = 0; hcode < 16; hcode++ )
vmodmask[j][hcode] = 0;
}
for ( j = 0; j < NumKmodMasks; j++ ) {
for ( hcode = 0; hcode < 16; hcode++ )
kmodmask[j][hcode] = 0;
}
/* Set the characteristic of undefined modules */
for ( hcode = 0; hcode < 16; hcode++ ) {
bitmap = ~defined[hcode];
/* Mark units which respond */
if ( cflags & ADDRESSED )
modmask[AddrMask][hcode] = bitmap;
if ( cflags & PHYS )
modmask[PhysMask][hcode] = bitmap;
if ( cflags & UNOFF )
modmask[AllOffMask][hcode] = bitmap;
if ( cflags & LION )
modmask[LightsOnMask][hcode] = bitmap;
if ( cflags & MON )
modmask[OnMask][hcode] = bitmap;
if ( cflags & MOFF )
modmask[OffMask][hcode] = bitmap;
if ( cflags & DIM )
modmask[DimMask][hcode] = bitmap;
if ( cflags & BRI )
modmask[BriMask][hcode] = bitmap;
if ( cflags & LIOFF )
modmask[LightsOffMask][hcode] = bitmap;
if ( cflags & BRIB4DIM )
modmask[BriDimMask][hcode] = bitmap;
if ( cflags & STDX10 )
modmask[StdMask][hcode] = bitmap;
if ( cflags & PRESET )
modmask[PresetMask][hcode] = bitmap;
if ( cflags & STAREQ )
modmask[StatusMask][hcode] = bitmap;
if ( cflags & STAON )
modmask[StatusOnMask][hcode] = bitmap;
if ( cflags & STAOFF )
modmask[StatusOffMask][hcode] = bitmap;
if ( cflags & LIONFULL )
modmask[LightsOnFullMask][hcode] = bitmap;
if ( cflags & ONFULL )
modmask[OnFullMask][hcode] = bitmap;
if ( cflags & ONFULLOFF )
modmask[OnFullOffMask][hcode] = bitmap;
if ( cflags & ALLON )
modmask[AllOnMask][hcode] = bitmap;
if ( cflags & RESUME )
modmask[ResumeMask][hcode] = bitmap;
if ( cflags & TARG )
modmask[TargMask][hcode] = bitmap;
if ( cflags & EXC16 )
modmask[Exc16Mask][hcode] = bitmap;
if ( cflags & EXC8 )
modmask[Exc8Mask][hcode] = bitmap;
if ( cflags & EXC4 )
modmask[Exc4Mask][hcode] = bitmap;
if ( cflags & VDATA || vflags & VKAKU )
modmask[VdataMask][hcode] = bitmap;
if ( cflags & RESUMEDIM )
modmask[ResumeDimMask][hcode] = bitmap;
if ( cflags & LIONUNAD )
modmask[LightsOnUnaddrMask][hcode] = bitmap;
if ( cflags & LIOFFUNAD )
modmask[LightsOffUnaddrMask][hcode] = bitmap;
if ( cflags & PLCSENSOR )
modmask[PlcSensorMask][hcode] = bitmap;
if ( cflags & ONOFFUNAD )
modmask[OnOffUnaddrMask][hcode] = bitmap;
if ( xflags & X0SH )
modmask[Ext0Mask][hcode] = bitmap;
if ( xflags & X3SW ) {
modmask[Ext3Mask][hcode] = bitmap;
modmask[AllOnMask][hcode] = bitmap;
}
if ( xflags & X3DIM )
modmask[Ext3DimMask][hcode] = bitmap;
if ( xflags & X3GEXEC )
modmask[Ext3GrpExecMask][hcode] = bitmap;
if ( xflags & X3GRC1 )
modmask[Ext3GrpRelT1Mask][hcode] = bitmap;
if ( xflags & X3GRC2 )
modmask[Ext3GrpRelT2Mask][hcode] = bitmap;
if ( xflags & X3GRC3 )
modmask[Ext3GrpRelT3Mask][hcode] = bitmap;
if ( xflags & X3GRC4 )
modmask[Ext3GrpRelT4Mask][hcode] = bitmap;
if ( xflags & X3GOFF )
modmask[Ext3GrpOffMask][hcode] = bitmap;
if ( xflags & X3GOFFEX )
modmask[Ext3GrpOffExecMask][hcode] = bitmap;
if ( xflags & X3GBD )
modmask[Ext3GrpBriDimMask][hcode] = bitmap;
if ( xflags & X3GBDFULL )
modmask[Ext3GrpBriDimFullMask][hcode] = bitmap;
if ( xflags & X3STAT )
modmask[Ext3StatusMask][hcode] = bitmap;
if ( xflags & X3GREM )
modmask[Ext3GrpRemMask][hcode] = bitmap;
if ( vflags & VSTD )
vmodmask[VstdMask][hcode] = bitmap;
if ( vflags & VENT )
vmodmask[VentMask][hcode] = bitmap;
if ( vflags & VSEC )
vmodmask[VsecMask][hcode] = bitmap;
if ( vflags & VRFXS )
vmodmask[VrfxsMask][hcode] = bitmap;
if ( vflags & VRFXM )
vmodmask[VrfxmMask][hcode] = bitmap;
if ( vflags & VDMX )
vmodmask[VdmxMask][hcode] = bitmap;
if ( vflags & VORE )
vmodmask[VoreMask][hcode] = bitmap;
if ( vflags & VKAKU )
vmodmask[VkakuMask][hcode] = bitmap;
if ( kflags & KON )
kmodmask[KonMask][hcode] = bitmap;
if ( kflags & KOFF )
kmodmask[KoffMask][hcode] = bitmap;
if ( kflags & KGON )
kmodmask[KGonMask][hcode] = bitmap;
if ( kflags & KGOFF )
kmodmask[KGoffMask][hcode] = bitmap;
if ( kflags & KPRE )
kmodmask[KpreMask][hcode] = bitmap;
if ( kflags & KGPRE )
kmodmask[KGpreMask][hcode] = bitmap;
if ( kflags & KRESUME )
kmodmask[KresumeMask][hcode] = bitmap;
if ( kflags & KPHYS )
kmodmask[KPhysMask][hcode] = bitmap;
if ( !vflags || (vflags & VSTD) )
vmodmask[VtstampMask][hcode] = bitmap;
/* Set max and on dim levels for each unit */
for ( ucode = 0; ucode < 16; ucode++ ) {
if ( bitmap & (1 << ucode) ) {
maxdimlevel[hcode][ucode] = maxlevel;
ondimlevel[hcode][ucode] = maxlevel;
}
}
}
/* Now fill in the characteristics of defined modules */
j = 0;
while ( aliasp && aliasp[j].line_no > 0 ) {
if ( aliasp[j].modtype < 0 ) {
/* Module is undefined */
j++;
continue;
}
hcode = hc2code(aliasp[j].housecode);
bitmap = aliasp[j].unitbmap;
cflags = aliasp[j].flags;
vflags = aliasp[j].vflags;
xflags = aliasp[j].xflags;
kflags = aliasp[j].kflags;
maxlevel = aliasp[j].maxlevel;
onlevel = aliasp[j].onlevel;
/* Mark units which respond */
if ( cflags & ADDRESSED )
modmask[AddrMask][hcode] |= bitmap;
if ( cflags & PHYS )
modmask[PhysMask][hcode] |= bitmap;
if ( cflags & UNOFF )
modmask[AllOffMask][hcode] |= bitmap;
if ( cflags & LION )
modmask[LightsOnMask][hcode] |= bitmap;
if ( cflags & MON )
modmask[OnMask][hcode] |= bitmap;
if ( cflags & MOFF )
modmask[OffMask][hcode] |= bitmap;
if ( cflags & DIM )
modmask[DimMask][hcode] |= bitmap;
if ( cflags & BRI )
modmask[BriMask][hcode] |= bitmap;
if ( cflags & LIOFF )
modmask[LightsOffMask][hcode] |= bitmap;
if ( cflags & BRIB4DIM )
modmask[BriDimMask][hcode] |= bitmap;
if ( cflags & STDX10 )
modmask[StdMask][hcode] |= bitmap;
if ( cflags & PRESET )
modmask[PresetMask][hcode] |= bitmap;
if ( cflags & STAREQ )
modmask[StatusMask][hcode] |= bitmap;
if ( cflags & STAON )
modmask[StatusOnMask][hcode] |= bitmap;
if ( cflags & STAOFF )
modmask[StatusOffMask][hcode] |= bitmap;
if ( cflags & LIONFULL )
modmask[LightsOnFullMask][hcode] |= bitmap;
if ( cflags & ONFULL )
modmask[OnFullMask][hcode] |= bitmap;
if ( cflags & ONFULLOFF )
modmask[OnFullOffMask][hcode] |= bitmap;
if ( cflags & ALLON )
modmask[AllOnMask][hcode] |= bitmap;
if ( cflags & RESUME )
modmask[ResumeMask][hcode] |= bitmap;
if ( cflags & TARG )
modmask[TargMask][hcode] |= bitmap;
if ( cflags & EXC16 )
modmask[Exc16Mask][hcode] |= bitmap;
if ( cflags & EXC8 )
modmask[Exc8Mask][hcode] |= bitmap;
if ( cflags & EXC4 )
modmask[Exc4Mask][hcode] |= bitmap;
if ( cflags & VDATA || vflags & VKAKU )
modmask[VdataMask][hcode] |= bitmap;
if ( cflags & RESUMEDIM )
modmask[ResumeDimMask][hcode] |= bitmap;
if ( cflags & LIONUNAD )
modmask[LightsOnUnaddrMask][hcode] |= bitmap;
if ( cflags & LIOFFUNAD )
modmask[LightsOffUnaddrMask][hcode] |= bitmap;
if ( cflags & PLCSENSOR )
modmask[PlcSensorMask][hcode] |= bitmap;
if ( cflags & ONOFFUNAD )
modmask[OnOffUnaddrMask][hcode] |= bitmap;
if ( xflags & X0SH )
modmask[Ext0Mask][hcode] |= bitmap;