-
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
18 changed files
with
31,194 additions
and
72 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
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
58 changes: 58 additions & 0 deletions
58
...src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/lightmanager/json/LmAirProject.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,58 @@ | ||
package de.visualdigits.kotlin.klanglicht.model.lightmanager.json | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import java.io.File | ||
import java.io.InputStream | ||
import java.util.SortedMap | ||
|
||
class LmAirProject( | ||
val settings: Settings? = null, | ||
val marker: Map<String, Marker>? = null, | ||
val devices: Map<String, Device>? = null, | ||
val scenes: List<Scene> = listOf(), | ||
val actuators: List<Actuator> = listOf() | ||
) { | ||
|
||
@JsonIgnore val scenesMap: Map<Int, Scene> = determineScenes() | ||
@JsonIgnore val actuatorsMap: Map<Int, Actuator> = determineActuators() | ||
|
||
private fun determineScenes( | ||
scenes: List<Scene> = this.scenes, | ||
scenesMap: SortedMap<Int, Scene> = sortedMapOf() | ||
): Map<Int, Scene> { | ||
scenes.forEach { s -> | ||
scenesMap[s.properties?.index!!] = s | ||
determineScenes(s.children, scenesMap) | ||
} | ||
return scenesMap | ||
} | ||
|
||
private fun determineActuators( | ||
actuators: List<Actuator> = this.actuators, | ||
actuatorsMap: SortedMap<Int, Actuator> = sortedMapOf() | ||
): Map<Int, Actuator> { | ||
actuators.forEach { actuator -> | ||
actuatorsMap[actuator.properties?.index!!] = actuator | ||
scenes.forEach { scene -> | ||
if (scene.containsActuator(actuator.properties.index!!)) { | ||
actuator.usedByScenes.add(scene) | ||
} | ||
} | ||
determineActuators(actuator.children, actuatorsMap) | ||
} | ||
return actuatorsMap | ||
} | ||
|
||
companion object { | ||
private val mapper = jacksonObjectMapper() | ||
|
||
fun unmarshall(file: File): LmAirProject = mapper.readValue(file, LmAirProject::class.java) | ||
|
||
fun unmarshall(ins: InputStream): LmAirProject = mapper.readValue(ins, LmAirProject::class.java) | ||
|
||
fun unmarshall(s: String): LmAirProject = mapper.readValue(s, LmAirProject::class.java) | ||
|
||
fun unmarshall(bytes: ByteArray): LmAirProject = mapper.readValue(bytes, LmAirProject::class.java) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...le-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/lightmanager/json/NType.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.kotlin.klanglicht.model.lightmanager.json | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue | ||
|
||
enum class NType( | ||
@JsonValue val ntype: Int | ||
) { | ||
|
||
irlan(1), | ||
scene(9), | ||
marker(8), | ||
pause(10), | ||
child(13) | ||
} |
65 changes: 0 additions & 65 deletions
65
...-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/lightmanager/json/Project.kt
This file was deleted.
Oops, something went wrong.
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
...test/kotlin/de/visualdigits/kotlin/klanglicht/model/lightmanager/json/LmAirProjectTest.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.kotlin.klanglicht.model.lightmanager.json | ||
|
||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
|
||
class LmAirProjectTest { | ||
|
||
@Test | ||
fun testLoadModel() { | ||
val config = LmAirProject.unmarshall(File(ClassLoader.getSystemResource("lmair/lmair-config.json").toURI())) | ||
println(config) | ||
} | ||
} |
Oops, something went wrong.