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.max.internal.message;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * The {@link SMessage} contains information about Command execution results
22 * @author Bernd Michael Helm (bernd.helm at helmundwalter.de) - Initial contribution
23 * @author Marcel Verpaalen - OH2 version + parsing of the message
26 public final class SMessage extends Message {
27 private final Logger logger = LoggerFactory.getLogger(SMessage.class);
29 private int dutyCycle;
30 private int freeMemorySlots;
31 private boolean commandDiscarded = false;
33 public SMessage(String raw) {
36 String[] tokens = this.getPayload().split(Message.DELIMETER);
38 if (tokens.length == 3) {
40 dutyCycle = Integer.parseInt(tokens[0], 16);
41 commandDiscarded = tokens[1].contentEquals("1");
42 freeMemorySlots = Integer.parseInt(tokens[2], 16);
43 } catch (Exception e) {
44 logger.debug("Exception occurred during parsing of S message: {}", e.getMessage(), e);
47 logger.debug("Unexpected # of tolkens ({}) received in S message: {}", tokens.length, this.getPayload());
51 public int getDutyCycle() {
55 public int getFreeMemorySlots() {
56 return freeMemorySlots;
59 public boolean isCommandDiscarded() {
60 return commandDiscarded;
64 public void debug(Logger logger) {
65 logger.trace("=== S Message === ");
66 logger.trace("\tRAW : {}", this.getPayload());
67 logger.trace("\tDutyCycle : {}", this.dutyCycle);
68 logger.trace("\tCommand Discarded : {}", this.commandDiscarded);
69 logger.trace("\tFreeMemorySlots : {}", this.freeMemorySlots);
73 public MessageType getType() {