2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.comfoair.internal;
15 import java.util.ArrayList;
16 import java.util.List;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Class to encapsulate all data which is needed to send a cmd to comfoair
24 * @author Holger Hees - Initial Contribution
25 * @author Hans Böhm - Refactoring
28 public class ComfoAirCommand {
30 private final List<String> keys;
31 private @Nullable Integer requestCmd;
32 private @Nullable Integer replyCmd;
33 private int[] requestData;
34 private final @Nullable Integer requestValue;
35 private final @Nullable Integer dataPosition;
41 * command as byte value
43 * reply command as byte value
49 * request byte position
52 public ComfoAirCommand(String key, @Nullable Integer requestCmd, @Nullable Integer replyCmd, int[] data,
53 @Nullable Integer dataPosition, @Nullable Integer requestValue) {
54 this.keys = new ArrayList<String>();
56 this.requestCmd = requestCmd;
57 this.replyCmd = replyCmd;
58 this.requestData = data;
59 this.dataPosition = dataPosition;
60 this.requestValue = requestValue;
64 * Constructor for basic read command
66 public ComfoAirCommand(String key) {
67 this.keys = new ArrayList<String>();
69 ComfoAirCommandType commandType = ComfoAirCommandType.getCommandTypeByKey(key);
70 if (commandType != null) {
71 this.requestCmd = commandType.getReadCommand() == 0 ? null : commandType.getReadCommand();
72 this.replyCmd = commandType.getReadReplyCommand();
74 this.requestData = ComfoAirCommandType.Constants.EMPTY_INT_ARRAY;
75 this.dataPosition = null;
76 this.requestValue = null;
81 * additional command key
83 public void addKey(String key) {
88 * @return command keys
90 public List<String> getKeys() {
95 * @return command byte value
97 public @Nullable Integer getRequestCmd() {
102 * @return request data as byte values
104 public int[] getRequestData() {
109 * @return acknowledge cmd byte value
111 public @Nullable Integer getReplyCmd() {
116 * @return request value as byte value
118 public @Nullable Integer getRequestValue() {
123 * @return position of request byte
125 public @Nullable Integer getDataPosition() {
130 * set request command byte value
132 public void setRequestCmd(@Nullable Integer newRequestCmd) {
133 requestCmd = newRequestCmd;
137 * set reply command byte value
139 public void setReplyCmd(@Nullable Integer newReplyCmd) {
140 replyCmd = newReplyCmd;
144 * set request data byte values
146 public void setRequestData(int[] newRequestData) {
147 requestData = newRequestData;