]> git.basschouten.com Git - openhab-addons.git/blob
2d0da97f402a94b2ac5fec6c00d352d71014077d
[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
19 /**
20  * The {@link RequestMessage} class is responsible for storing the command to be sent to the GlobalCache
21  * device and for storing whether the command is serial or not.
22  *
23  * @author Mark Hilbush - Initial contribution
24  */
25 public class RequestMessage {
26     private LinkedBlockingQueue<ResponseMessage> rcvQueue;
27     private String deviceCommand;
28     private CommandType commandType;
29     private String commandName;
30
31     public RequestMessage(String commandName, CommandType commandType, String deviceCommand,
32             LinkedBlockingQueue<ResponseMessage> rcvQueue) {
33         this.commandName = commandName;
34         this.commandType = commandType;
35         this.deviceCommand = deviceCommand;
36         this.rcvQueue = rcvQueue;
37     }
38
39     public String getDeviceCommand() {
40         return deviceCommand;
41     }
42
43     public String getCommandName() {
44         return commandName;
45     }
46
47     public CommandType getCommandType() {
48         return commandType;
49     }
50
51     public boolean isCommand() {
52         return commandType == CommandType.COMMAND;
53     }
54
55     public boolean isSerial() {
56         return commandType == CommandType.SERIAL1 || commandType == CommandType.SERIAL2;
57     }
58
59     public boolean isSerial1() {
60         return commandType == CommandType.SERIAL1;
61     }
62
63     public boolean isSerial2() {
64         return commandType == CommandType.SERIAL2;
65     }
66
67     public LinkedBlockingQueue<ResponseMessage> getReceiveQueue() {
68         return rcvQueue;
69     }
70 }