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.tivo.internal.service;
15 import java.util.Date;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * TivoStatusData class stores the data from the last status query from the TiVo and any other errors / status
23 * @author Jayson Kubilis (DigitalBytes) - Initial contribution
24 * @author Andrew Black (AndyXMB) - minor updates, removal of unused functions.
25 * @author Michael Lobstein - Updated for OH3
29 public class TivoStatusData {
30 private boolean cmdOk = false;
31 private Date time = new Date();
32 private int channelNum = -1;
33 private int subChannelNum = -1;
34 private boolean isRecording = false;
35 private String msg = "NO STATUS QUERIED YET";
36 private boolean pubToUI = true;
37 private ConnectionStatus connectionStatus = ConnectionStatus.INIT;
39 public TivoStatusData() {
43 * {@link TivoStatusData} class stores the data from the last status query from the TiVo and any other errors /
46 * @param cmdOk boolean true = last command executed correctly, false = last command failed with error message
48 * @param channelNum int = channel number, -1 indicates no channel received. Valid channel range 1-9999.
50 * @param subChannelNum int = sub-channel number, -1 indicates no sub-channel received. Valid sub-channel range
53 * @param isRecording boolean true = indicates the current channel is recording
55 * @param msg string status message from the TiVo socket
57 * @param pubToUI boolean true = this status needs to be published to the UI / Thing, false = do not publish (or it
60 * @param connectionStatus ConnectionStatus enum UNKNOWN= test not run/default, OFFLINE = offline, STANDBY = TiVo is
61 * in standby, ONLINE = Online
64 public TivoStatusData(boolean cmdOk, int channelNum, int subChannelNum, boolean isRecording, String msg,
65 boolean pubToUI, ConnectionStatus connectionStatus) {
67 this.time = new Date();
68 this.channelNum = channelNum;
69 this.subChannelNum = subChannelNum;
70 this.isRecording = isRecording;
72 this.pubToUI = pubToUI;
73 this.connectionStatus = connectionStatus;
76 public enum ConnectionStatus {
85 * {@link TivoStatusData} class stores the data from the last status query from the TiVo and any other errors /
88 * @param cmdOk boolean true = last command executed correctly, false = last command failed with error message
89 * @param channelNum int = channel number, -1 indicates no channel received. Valid channel range 1-9999.
90 * @param msg string status message from the TiVo socket
91 * @param pubToUI boolean true = this status needs to be published to the UI, false = do not publish (or it
93 * @param connectionStatus enum UNKNOWN= test not run/default, OFFLINE = offline, STANDBY = TiVo is in standby
97 public String toString() {
98 return "TivoStatusData [cmdOk=" + cmdOk + ", time=" + time + ", channelNum=" + channelNum + ", subChannelNum="
99 + subChannelNum + ", msg=" + msg + ", pubToUI=" + pubToUI + ", connectionStatus=" + connectionStatus
104 * {@link #isCmdOK()} indicates if the last command executed correctly.
106 * @return cmdOk boolean true = executed correctly, false = last command failed with error message
108 public boolean isCmdOk() {
113 * {@link} sets the value indicating if the last command executed correctly.
115 * @param cmdOk boolean true = executed correctly, false = last command failed with error message
117 public void setCmdOk(boolean cmdOk) {
122 * {@link getChannelNum} gets the channel number, -1 indicates no channel received. Valid channel range 1-9999.
124 * @return the channel number
126 public int getChannelNum() {
131 * {@link setChannelNum} sets the channel number, -1 indicates no channel received. Valid channel range 1-9999.
133 * @param channelNum the new channel number
135 public void setChannelNum(int channelNum) {
136 this.channelNum = channelNum;
140 * {@link getSubChannelNum} gets the sub channel number, -1 indicates no sub channel received. Valid channel range
143 * @return the sub channel number
145 public int getSubChannelNum() {
146 return subChannelNum;
150 * {@link setSubChannelNum} sets the sub channel number, -1 indicates no sub channel received. Valid channel range
153 * @param subChannelNum the new sub channel number
155 public void setSubChannelNum(int subChannelNum) {
156 this.subChannelNum = subChannelNum;
160 * {@link setRecording} set to true if current channel is recording
162 * @param isRecording true = current channel is recording
164 public void setRecording(boolean isRecording) {
165 this.isRecording = isRecording;
169 * {@link getPubToUI} get status indicating if current channel is recording
171 * @return isRecording true = current channel is recording
173 public boolean isRecording() {
178 * {@link getMsg} gets status message string
182 public String getMsg() {
187 * {@link setPubToUI} set to true if this status needs to be published to the channel / UI / Thing, false = do not
188 * publish (or it already has been).
190 * @param pubToUI true = publish status to the channel objects
192 public void setPubToUI(boolean pubToUI) {
193 this.pubToUI = pubToUI;
197 * {@link getPubToUI} get status indicating that the event needs to be published to the channel / UI / Thing, false
198 * = do not publish (or it already has been).
200 * @return pubToUI true = publish status to the channel objects
202 public boolean getPubToUI() {
207 * {@link setConnectionStatus} indicates the state of the connection / connection tests. Drives online/offline state
209 * Thing and connection process.
211 * @param connectionStatus enum UNKNOWN= test not run/default, OFFLINE = offline, STANDBY = TiVo is in standby,
214 public void setConnectionStatus(ConnectionStatus connectionStatus) {
215 this.connectionStatus = connectionStatus;
219 * {@link getConnectionStatus} returns the state of the connection / connection tests. Drives online/offline state
221 * Thing and connection process.
223 * @return ConnectionStatus enum UNKNOWN= test not run/default, OFFLINE = offline, STANDBY = TiVo is in standby,
226 public ConnectionStatus getConnectionStatus() {
227 return connectionStatus;