]> git.basschouten.com Git - openhab-addons.git/blob
bd284a4b4b487f01a704cc760f6ee8ef44c26938
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.globalcache.internal.command;
14
15 import java.util.concurrent.LinkedBlockingQueue;
16
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;
22
23 /**
24  * The {@link CommandSendserial} class sends a serial command string to the device.
25  *
26  * @author Mark Hilbush - Initial contribution
27  */
28 public class CommandSendserial extends AbstractCommand {
29     private final Logger logger = LoggerFactory.getLogger(CommandSendserial.class);
30
31     private Command command;
32
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() && "2".equals(mod)) {
38             setCommandType(CommandType.SERIAL2);
39         }
40         this.command = command;
41         this.deviceCommand = code;
42     }
43
44     @Override
45     public void parseSuccessfulReply() {
46         if (deviceReply == null) {
47             return;
48         }
49         // decode response
50     }
51
52     @Override
53     public void logSuccess() {
54         logger.debug("Execute '{}' succeeded for command {} on thing {} at {}", commandName, command.toString(),
55                 thing.getUID().getId(), ipAddress);
56     }
57
58     @Override
59     public void logFailure() {
60         logger.error("Execute '{}' failed on thing {} at {}: errorCode={}, errorMessage={}", commandName,
61                 thing.getUID().getId(), ipAddress, errorCode, errorMessage);
62     }
63 }