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.modbus.e3dc.internal.dto;
15 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.modbus.e3dc.internal.modbus.Data;
21 * The {@link WallboxArray} Data object for E3DC Info Block
23 * @author Bernd Weymann - Initial contribution
26 public class WallboxArray implements Data {
27 private byte[] wbArray;
30 * For decoding see Modbus Register Mapping Chapter 3.1.2 page 15
31 * The Registers for Wallbox Control are declared as uint16 but shall be handled as Bit registers => see chapter
34 * @param bArray - Modbus Registers as bytes from 40088 to 40095
36 public WallboxArray(byte[] bArray) {
41 * Return the 2 bytes according to the Wallbox ID.
43 * @param id Wallbox ID valid from 0 - 7
44 * @return WallboxBlock initialized with the Modbus registers from the given ID
46 public Optional<WallboxBlock> getWallboxBlock(int id) {
47 if (id >= 0 && id < 8) {
48 int byteIndex = id * 2;
49 return Optional.of(new WallboxBlock(new byte[] { wbArray[byteIndex + 1], wbArray[byteIndex * 2] }));
51 return Optional.empty();