-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,434 additions
and
2,302 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
18 changes: 18 additions & 0 deletions
18
.../src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMCondition.kt
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,18 @@ | ||
package de.visualdigits.klanglicht.hardware.lightmanager.model.lm | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes | ||
import com.fasterxml.jackson.annotation.JsonSubTypes.Type | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo | ||
import de.visualdigits.klanglicht.model.preferences.Preferences | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.WRAPPER_OBJECT | ||
) | ||
@JsonSubTypes( | ||
Type(name = "night", value = LMConditionNight::class), | ||
) | ||
abstract class LMCondition { | ||
|
||
abstract fun evaluate(prefs: Preferences): Boolean | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMConditionNight.kt
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,14 @@ | ||
package de.visualdigits.klanglicht.hardware.lightmanager.model.lm | ||
|
||
import de.visualdigits.klanglicht.model.preferences.Preferences | ||
import de.visualdigits.solartime.SolarTime | ||
import java.time.ZonedDateTime | ||
|
||
class LMConditionNight( | ||
val value: Boolean = true | ||
) : LMCondition() { | ||
|
||
override fun evaluate(prefs: Preferences): Boolean { | ||
return value == SolarTime.switchLightsOn(ZonedDateTime.now(), prefs.installationLat, prefs.installationLon) | ||
} | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
...src/test/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMScenesTest.kt
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,13 @@ | ||
package de.visualdigits.klanglicht.hardware.lightmanager.model.lm | ||
|
||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
|
||
class LMScenesTest { | ||
|
||
@Test | ||
fun testReadScenes() { | ||
val scenes = LMScenes.readValue(File(ClassLoader.getSystemResource(".klanglicht/resources/scenes.yml").toURI())) | ||
println(scenes) | ||
} | ||
} |
Oops, something went wrong.