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.ism8.server;
15 import java.nio.ByteBuffer;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * The {@link SetDatapointValueMessage} is a message within the KNX frame containing
21 * the information of one data point
23 * @author Hans-Reiner Hoffmann - Initial contribution
26 public class SetDatapointValueMessage {
29 private byte[] data = new byte[0];
32 public SetDatapointValueMessage() {
35 public SetDatapointValueMessage(byte[] data) throws IllegalArgumentException {
36 if (data.length < 5) {
37 throw new IllegalArgumentException("Data size too small for a SetDatapointValueMessage.");
40 this.setId(Byte.toUnsignedInt(data[0]) * 256 + Byte.toUnsignedInt(data[1]));
41 this.setCommand(data[2]);
42 this.setLength(data[3]);
43 if (data.length < (this.getLength() + 4)) {
44 throw new IllegalArgumentException("Data size incorrect (" + data.length + "/" + this.getLength() + ").");
47 ByteBuffer list = ByteBuffer.allocate(this.getLength() + 4);
48 list.put(data, 0, this.getLength() + 4);
49 this.setData(list.array());
53 * Gets the ID of the data-point message
61 * Sets the ID of the data-point message
64 public void setId(int value) {
69 * Gets the command of the data-point message
72 public byte getCommand() {
77 * Sets the command of the data-point message
80 public void setCommand(byte value) {
85 * Gets the length of the data-point message
88 public byte getLength() {
93 * Sets the length of the data-point message
96 public void setLength(byte value) {
101 * Gets the data array of the data-point message
104 public byte[] getData() {
109 * Sets the data array of the data-point message
112 public void setData(byte[] value) {