]> git.basschouten.com Git - openhab-addons.git/blob
fbcbc281fa5b8778d9edffa002462e60fc3daf93
[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.astro.internal.model;
14
15 import java.util.Calendar;
16
17 import javax.measure.quantity.Angle;
18 import javax.measure.quantity.Dimensionless;
19 import javax.measure.quantity.Time;
20
21 import org.openhab.core.library.types.QuantityType;
22 import org.openhab.core.library.unit.Units;
23
24 /**
25  * Holds the calculates moon phase informations.
26  *
27  * @author Gerhard Riegler - Initial contribution
28  * @author Christoph Weitkamp - Introduced UoM
29  */
30 public class MoonPhase {
31     private Calendar firstQuarter;
32     private Calendar full;
33     private Calendar thirdQuarter;
34     private Calendar newCalendar;
35     private double age;
36     private double illumination;
37     private double agePercent;
38     private double ageDegree;
39
40     private MoonPhaseName name;
41
42     /**
43      * Returns the date at which the moon is in the first quarter.
44      */
45     public Calendar getFirstQuarter() {
46         return firstQuarter;
47     }
48
49     /**
50      * Sets the date at which the moon is in the first quarter.
51      */
52     public void setFirstQuarter(Calendar firstQuarter) {
53         this.firstQuarter = firstQuarter;
54     }
55
56     /**
57      * Returns the date of the full moon.
58      */
59     public Calendar getFull() {
60         return full;
61     }
62
63     /**
64      * Sets the date of the full moon.
65      */
66     public void setFull(Calendar full) {
67         this.full = full;
68     }
69
70     /**
71      * Returns the date at which the moon is in the third quarter.
72      */
73     public Calendar getThirdQuarter() {
74         return thirdQuarter;
75     }
76
77     /**
78      * Sets the date at which the moon is in the third quarter.
79      */
80     public void setThirdQuarter(Calendar thirdQuarter) {
81         this.thirdQuarter = thirdQuarter;
82     }
83
84     /**
85      * Returns the date of the new moon.
86      */
87     public Calendar getNew() {
88         return newCalendar;
89     }
90
91     /**
92      * Sets the date of the new moon.
93      */
94     public void setNew(Calendar newCalendar) {
95         this.newCalendar = newCalendar;
96     }
97
98     /**
99      * Returns the age in days.
100      */
101     public QuantityType<Time> getAge() {
102         return new QuantityType<>(age, Units.DAY);
103     }
104
105     /**
106      * Sets the age in days.
107      */
108     public void setAge(double age) {
109         this.age = age;
110     }
111
112     /**
113      * Returns the illumination.
114      */
115     public QuantityType<Dimensionless> getIllumination() {
116         return new QuantityType<>(illumination, Units.PERCENT);
117     }
118
119     /**
120      * Sets the illumination.
121      */
122     public void setIllumination(double illumination) {
123         this.illumination = illumination;
124     }
125
126     /**
127      * Returns the phase name.
128      */
129     public MoonPhaseName getName() {
130         return name;
131     }
132
133     /**
134      * Sets the phase name.
135      */
136     public void setName(MoonPhaseName name) {
137         this.name = name;
138     }
139
140     /**
141      * Returns the age in degree.
142      */
143     public QuantityType<Angle> getAgeDegree() {
144         return new QuantityType<>(ageDegree, Units.DEGREE_ANGLE);
145     }
146
147     /**
148      * Sets the age in degree.
149      */
150     public void setAgeDegree(double ageDegree) {
151         this.ageDegree = ageDegree;
152     }
153
154     /**
155      * Returns the age in percent.
156      */
157     public QuantityType<Dimensionless> getAgePercent() {
158         return new QuantityType<>(agePercent, Units.PERCENT);
159     }
160
161     /**
162      * Sets the age in percent.
163      */
164     public void setAgePercent(double agePercent) {
165         this.agePercent = agePercent;
166     }
167 }