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.globalcache.internal.command;
15 import java.util.concurrent.LinkedBlockingQueue;
17 import org.openhab.binding.globalcache.internal.GlobalCacheBindingConstants.CommandType;
18 import org.openhab.core.thing.Thing;
19 import org.openhab.core.types.Command;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * The {@link CommandSendserial} class sends a serial command string to the device.
26 * @author Mark Hilbush - Initial contribution
28 public class CommandSendserial extends AbstractCommand {
29 private final Logger logger = LoggerFactory.getLogger(CommandSendserial.class);
31 private Command command;
33 public CommandSendserial(Thing thing, Command command, LinkedBlockingQueue<RequestMessage> queue, String mod,
34 String con, String code) {
35 super(thing, queue, "sendserial", CommandType.SERIAL1);
36 // Check to see if this is for the second serial port on a GC-100-12
37 if (isGC100Model12() && mod.equals("2")) {
38 setCommandType(CommandType.SERIAL2);
40 this.command = command;
41 this.deviceCommand = code;
45 public void parseSuccessfulReply() {
46 if (deviceReply == null) {
53 public void logSuccess() {
54 logger.debug("Execute '{}' succeeded for command {} on thing {} at {}", commandName, command.toString(),
55 thing.getUID().getId(), ipAddress);
59 public void logFailure() {
60 logger.error("Execute '{}' failed on thing {} at {}: errorCode={}, errorMessage={}", commandName,
61 thing.getUID().getId(), ipAddress, errorCode, errorMessage);