This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from openhab/master
Update from openhab sources
- Loading branch information
Showing
845 changed files
with
69,926 additions
and
13,919 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
4 changes: 2 additions & 2 deletions
4
...les/core/org.openhab.core.drools/.project → .../action/org.openhab.action.astro/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
bundles/action/org.openhab.action.astro/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Manifest-Version: 1.0 | ||
Private-Package: org.openhab.action.astro.internal | ||
Ignore-Package: org.openhab.action.astro.internal | ||
Bundle-License: http://www.eclipse.org/legal/epl-v10.html | ||
Bundle-Name: openHAB Astro Action | ||
Bundle-SymbolicName: org.openhab.action.astro | ||
Bundle-Vendor: openHAB.org | ||
Bundle-Version: 1.7.0.qualifier | ||
Bundle-Activator: org.openhab.action.astro.internal.AstroActivator | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Description: This is the Astro action of the open Home Aut | ||
omation Bus (openHAB) | ||
Import-Package: org.apache.commons.lang.builder, | ||
org.openhab.core.items, | ||
org.openhab.core.library.items, | ||
org.openhab.core.library.types, | ||
org.openhab.core.scriptengine.action, | ||
org.openhab.core.types, | ||
org.osgi.framework, | ||
org.osgi.service.cm, | ||
org.osgi.service.component, | ||
org.slf4j | ||
Bundle-DocURL: http://www.openhab.org | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 | ||
Service-Component: OSGI-INF/action.xml | ||
Bundle-ClassPath: . | ||
Bundle-ActivationPolicy: lazy | ||
Require-Bundle: org.openhab.binding.astro |
21 changes: 21 additions & 0 deletions
21
bundles/action/org.openhab.action.astro/OSGI-INF/action.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2010-2015, openHAB.org and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" immediate="true" name="org.openhab.action.astro.action"> | ||
<implementation class="org.openhab.action.astro.internal.AstroActionService" /> | ||
|
||
<service> | ||
<provide interface="org.openhab.core.scriptengine.action.ActionService" /> | ||
</service> | ||
|
||
<property name="service.pid" type="String" value="org.openhab.astro.action" /> | ||
|
||
</scr:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source.. = src/main/java/,\ | ||
src/main/resources/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
OSGI-INF/ | ||
output.. = target/classes/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.openhab.bundles</groupId> | ||
<artifactId>action</artifactId> | ||
<version>1.7.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<bundle.symbolicName>org.openhab.action.astro</bundle.symbolicName> | ||
<bundle.namespace>org.openhab.action.astro</bundle.namespace> | ||
<deb.name>openhab-addon-action-astro</deb.name> | ||
<deb.description>openhab addon action astro</deb.description> | ||
</properties> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.openhab.action</groupId> | ||
<artifactId>org.openhab.action.astro</artifactId> | ||
|
||
<name>openHAB Astro Action</name> | ||
|
||
<packaging>eclipse-plugin</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.vafer</groupId> | ||
<artifactId>jdeb</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
85 changes: 85 additions & 0 deletions
85
...ction/org.openhab.action.astro/src/main/java/org/openhab/action/astro/internal/Astro.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.action.astro.internal; | ||
|
||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
import org.openhab.binding.astro.internal.calc.SunCalc; | ||
import org.openhab.binding.astro.internal.model.Sun; | ||
import org.openhab.core.scriptengine.action.ActionDoc; | ||
import org.openhab.core.scriptengine.action.ParamDoc; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This class provides static methods that can be used in automation rules for | ||
* calculating astronomical data. | ||
* | ||
* @author Gerhard Riegler | ||
* @since 1.7.0 | ||
*/ | ||
public class Astro { | ||
private static final Logger logger = LoggerFactory.getLogger(Astro.class); | ||
|
||
private static final SunCalc sunCalc = new SunCalc(); | ||
// simple microcache | ||
private static AstroConfig lastConfig; | ||
private static Sun lastSun; | ||
|
||
@ActionDoc(text = "Returns the sunrise start for the given date and coordinates") | ||
public static Calendar getAstroSunriseStart( | ||
@ParamDoc(name = "date", text = "The date to calculate the sunrise") Date date, | ||
@ParamDoc(name = "latitude", text = "The latitude") double latitude, | ||
@ParamDoc(name = "longitude", text = "The longitude") double longitude) { | ||
return getSun(date, latitude, longitude).getRise().getStart(); | ||
} | ||
|
||
@ActionDoc(text = "Returns the sunrise end for the given date and coordinates") | ||
public static Calendar getAstroSunriseEnd( | ||
@ParamDoc(name = "date", text = "The date to calculate the sunrise") Date date, | ||
@ParamDoc(name = "latitude", text = "The latitude") double latitude, | ||
@ParamDoc(name = "longitude", text = "The longitude") double longitude) { | ||
return getSun(date, latitude, longitude).getRise().getEnd(); | ||
} | ||
|
||
@ActionDoc(text = "Returns the sunset start for the given date and coordinates") | ||
public static Calendar getAstroSunsetStart( | ||
@ParamDoc(name = "date", text = "The date to calculate the sunset") Date date, | ||
@ParamDoc(name = "latitude", text = "The latitude") double latitude, | ||
@ParamDoc(name = "longitude", text = "The longitude") double longitude) { | ||
return getSun(date, latitude, longitude).getSet().getStart(); | ||
} | ||
|
||
@ActionDoc(text = "Returns the sunset end for the given date and coordinates") | ||
public static Calendar getAstroSunsetEnd( | ||
@ParamDoc(name = "date", text = "The date to calculate the sunset") Date date, | ||
@ParamDoc(name = "latitude", text = "The latitude") double latitude, | ||
@ParamDoc(name = "longitude", text = "The longitude") double longitude) { | ||
return getSun(date, latitude, longitude).getSet().getEnd(); | ||
} | ||
|
||
/** | ||
* Calculates the sun data. | ||
*/ | ||
private static Sun getSun(Date date, double latitude, double longitude) { | ||
if (date == null) { | ||
logger.warn("Unknown date: {}, using current date", date); | ||
date = new Date(); | ||
} | ||
AstroConfig config = new AstroConfig(date, latitude, longitude); | ||
if (lastConfig == null || !lastConfig.equals(config)) { | ||
Calendar cal = Calendar.getInstance(); | ||
cal.setTime(date); | ||
lastSun = sunCalc.getSunInfo(cal, latitude, longitude); | ||
lastConfig = config; | ||
} | ||
return lastSun; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...nhab.action.astro/src/main/java/org/openhab/action/astro/internal/AstroActionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.action.astro.internal; | ||
|
||
import org.openhab.core.scriptengine.action.ActionService; | ||
|
||
/** | ||
* This class registers an OSGi service for the Astro action. | ||
* | ||
* @author Gerhard Riegler | ||
* @since 1.7.0 | ||
*/ | ||
public class AstroActionService implements ActionService { | ||
|
||
public void activate() { | ||
} | ||
|
||
public void deactivate() { | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getActionClassName() { | ||
return Astro.class.getCanonicalName(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Class<?> getActionClass() { | ||
return Astro.class; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
....openhab.action.astro/src/main/java/org/openhab/action/astro/internal/AstroActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.action.astro.internal; | ||
|
||
import org.osgi.framework.BundleActivator; | ||
import org.osgi.framework.BundleContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Extension of the default OSGi bundle activator | ||
* | ||
* @author Gerhard Riegler | ||
* @since 1.7.0 | ||
*/ | ||
public final class AstroActivator implements BundleActivator { | ||
private static Logger logger = LoggerFactory.getLogger(AstroActivator.class); | ||
|
||
private static BundleContext context; | ||
|
||
/** | ||
* Called whenever the OSGi framework starts our bundle | ||
*/ | ||
public void start(BundleContext bc) throws Exception { | ||
context = bc; | ||
logger.debug("Astro action has been started."); | ||
} | ||
|
||
/** | ||
* Called whenever the OSGi framework stops our bundle | ||
*/ | ||
public void stop(BundleContext bc) throws Exception { | ||
context = null; | ||
logger.debug("Astro action has been stopped."); | ||
} | ||
|
||
/** | ||
* Returns the bundle context of this bundle | ||
* | ||
* @return the bundle context | ||
*/ | ||
public static BundleContext getContext() { | ||
return context; | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...org.openhab.action.astro/src/main/java/org/openhab/action/astro/internal/AstroConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (c) 2010-2015, openHAB.org and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.action.astro.internal; | ||
|
||
import java.util.Date; | ||
|
||
import org.apache.commons.lang.builder.EqualsBuilder; | ||
import org.apache.commons.lang.builder.HashCodeBuilder; | ||
|
||
/** | ||
* Holds the rule method parameters. | ||
* | ||
* @author Gerhard Riegler | ||
* @since 1.7.0 | ||
*/ | ||
public class AstroConfig { | ||
private Date date; | ||
private double latitude; | ||
private double longitude; | ||
|
||
/** | ||
* Creates a new AstroConfig. | ||
*/ | ||
public AstroConfig(Date date, double latitude, double longitude) { | ||
this.date = date; | ||
this.latitude = latitude; | ||
this.longitude = longitude; | ||
} | ||
|
||
/** | ||
* Returns the date to calculate astro data. | ||
*/ | ||
public Date getDate() { | ||
return date; | ||
} | ||
|
||
/** | ||
* The latitude to calculate astro data. | ||
*/ | ||
public double getLatitude() { | ||
return latitude; | ||
} | ||
|
||
/** | ||
* The longitude to calculate astro data. | ||
*/ | ||
public double getLongitude() { | ||
return longitude; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
return new HashCodeBuilder().append(date).append(latitude).append(longitude).toHashCode(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null || !(obj instanceof AstroConfig)) { | ||
return false; | ||
} | ||
AstroConfig config = (AstroConfig) obj; | ||
return new EqualsBuilder().append(date, config.getDate()).append(latitude, config.getLatitude()) | ||
.append(longitude, config.getLongitude()).isEquals(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
bundles/action/org.openhab.action.astro/src/main/resources/readme.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Bundle resources go in here! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
Oops, something went wrong.