]> git.basschouten.com Git - openhab-addons.git/blob
d3890f9527e3594e37fcdf913d8bce0ba00dfd01
[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.robonect.internal.model;
14
15 /**
16  * An object holding the timer information of the mower status.
17  * 
18  * @author Marco Meyer - Initial contribution
19  */
20 public class Timer {
21
22     /**
23      * an enum defining the possible timer status.
24      */
25     public enum TimerMode {
26         /**
27          * timer is inactive. No timer is set or the mower is not in AUTO mode.
28          */
29         INACTIVE(0),
30
31         /**
32          * timer is active. The period of the timer is active and the mower is executing it in AUTO mode.
33          */
34         ACTIVE(1),
35
36         /**
37          * timer is standby. A timer is set, the mower is in AUTO mode but the timer period did not start yet.
38          */
39         STANDBY(2);
40
41         private int code;
42
43         TimerMode(int code) {
44             this.code = code;
45         }
46
47         public int getCode() {
48             return code;
49         }
50
51         public static TimerMode fromCode(int code) {
52             for (TimerMode status : TimerMode.values()) {
53                 if (status.code == code) {
54                     return status;
55                 }
56             }
57             return INACTIVE;
58         }
59     }
60
61     private TimerMode status;
62
63     private NextTimer next;
64
65     /**
66      * @return - the timer mode. see {@link TimerMode}
67      */
68     public TimerMode getStatus() {
69         return status;
70     }
71
72     /**
73      * @return - information about when the next timer execution will be. See {@link NextTimer}
74      */
75     public NextTimer getNext() {
76         return next;
77     }
78
79     public void setStatus(TimerMode status) {
80         this.status = status;
81     }
82
83     public void setNext(NextTimer next) {
84         this.next = next;
85     }
86 }