]> git.basschouten.com Git - openhab-addons.git/blob
d07c04a312071a5e64cc1b35370fb80c3d1bdfda
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.dali.internal.protocol;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.dali.internal.handler.DaliException;
17
18 /**
19  * The {@link DaliStandardCommand} represents different types of commands for
20  * controlling DALI equipment.
21  *
22  * @author Robert Schmid - Initial contribution
23  */
24 @NonNullByDefault
25 public class DaliStandardCommand extends DaliGearCommandBase {
26
27     private DaliStandardCommand(DaliAddress target, int cmdval, int param, boolean sendTwice) throws DaliException {
28         super(target.addToFrame(new DaliForwardFrame(16, new byte[] { 0x1, (byte) (cmdval | (param & 0b1111)) })),
29                 sendTwice);
30     }
31
32     public static DaliStandardCommand createOffCommand(DaliAddress target) throws DaliException {
33         return new DaliStandardCommand(target, 0x00, 0, false);
34     }
35
36     public static DaliStandardCommand createUpCommand(DaliAddress target) throws DaliException {
37         return new DaliStandardCommand(target, 0x01, 0, false);
38     }
39
40     public static DaliStandardCommand createDownCommand(DaliAddress target) throws DaliException {
41         return new DaliStandardCommand(target, 0x02, 0, false);
42     }
43
44     public static DaliStandardCommand createStepUpCommand(DaliAddress target) throws DaliException {
45         return new DaliStandardCommand(target, 0x03, 0, false);
46     }
47
48     public static DaliStandardCommand createStepDownCommand(DaliAddress target) throws DaliException {
49         return new DaliStandardCommand(target, 0x04, 0, false);
50     }
51
52     public static DaliStandardCommand createRecallMaxLevelCommand(DaliAddress target) throws DaliException {
53         return new DaliStandardCommand(target, 0x05, 0, false);
54     }
55
56     public static DaliStandardCommand createRecallMinLevelCommand(DaliAddress target) throws DaliException {
57         return new DaliStandardCommand(target, 0x06, 0, false);
58     }
59
60     public static DaliStandardCommand createStepDownAndOffCommand(DaliAddress target) throws DaliException {
61         return new DaliStandardCommand(target, 0x07, 0, false);
62     }
63
64     public static DaliStandardCommand createOnAndStepUpCommand(DaliAddress target) throws DaliException {
65         return new DaliStandardCommand(target, 0x08, 0, false);
66     }
67
68     public static DaliStandardCommand createEnableDAPCSequenceCommand(DaliAddress target) throws DaliException {
69         return new DaliStandardCommand(target, 0x09, 0, false);
70     }
71
72     public static DaliStandardCommand createGoToSceneCommand(DaliAddress target, int scene) throws DaliException {
73         return new DaliStandardCommand(target, 0x10, scene, false);
74     }
75
76     public static DaliStandardCommand createResetCommand(DaliAddress target) throws DaliException {
77         return new DaliStandardCommand(target, 0x20, 0, true);
78     }
79
80     public static DaliStandardCommand createQueryStatusCommand(DaliAddress target) throws DaliException {
81         return new DaliStandardCommand(target, 0x90, 0, false);
82     }
83
84     public static DaliStandardCommand createQueryContentDTR0Command(DaliAddress target) throws DaliException {
85         return new DaliStandardCommand(target, 0x98, 0, false);
86     }
87
88     public static DaliStandardCommand createQueryActualLevelCommand(DaliAddress target) throws DaliException {
89         return new DaliStandardCommand(target, 0xa0, 0, false);
90     }
91
92     public static DaliStandardCommand createActivateCommand(DaliAddress target) throws DaliException {
93         return new DaliStandardCommand(target, 0xe2, 0, false);
94     }
95
96     public static DaliStandardCommand createQueryColorValueCommand(DaliAddress target) throws DaliException {
97         return new DaliStandardCommand(target, 0xfa, 0, false);
98     }
99
100     // Global commands sent to special addresses
101
102     public static DaliStandardCommand createSetDTR0Command(int value) throws DaliException {
103         return new DaliStandardCommand(DaliAddress.createRawAddress(0xa3), value, 0, false);
104     }
105
106     public static DaliStandardCommand createSetDTR1Command(int value) throws DaliException {
107         return new DaliStandardCommand(DaliAddress.createRawAddress(0xc3), value, 0, false);
108     }
109
110     public static DaliStandardCommand createSetDTR2Command(int value) throws DaliException {
111         return new DaliStandardCommand(DaliAddress.createRawAddress(0xc5), value, 0, false);
112     }
113
114     public static DaliStandardCommand createSetDeviceTypeCommand(int value) throws DaliException {
115         return new DaliStandardCommand(DaliAddress.createRawAddress(0xc1), value, 0, false);
116     }
117
118     // DT8 (color temperature and single-channel RGB) commands
119
120     public static DaliStandardCommand createSetRgbDimlevelCommand(DaliAddress target) throws DaliException {
121         return new DaliStandardCommand(target, 0xeb, 0, false);
122     }
123
124     public static DaliStandardCommand createSetColorTemperatureCommand(DaliAddress target) throws DaliException {
125         return new DaliStandardCommand(target, 0xe7, 0, false);
126     }
127 }