From a51d29e56da158da0997f7b57d08ed47916695e9 Mon Sep 17 00:00:00 2001 From: "SKN-SWIFT-X\\sknull" Date: Tue, 10 Oct 2023 08:56:40 +0200 Subject: [PATCH] ffirst code for spring boot --- docs/colors-lmair.txt | 36 +++++++++ klanglicht-core/pom.xml | 2 +- .../klanglicht/model/parameter/Fadeable.kt | 3 + .../klanglicht/model/parameter/Scene.kt | 15 ++-- .../kotlin/klanglicht/dmx/SimpleTest.kt | 7 +- klanglicht-rest/pom.xml | 77 ++++++++++++++++++- .../kotlin/klanglicht/rest/KlangLichtMain.kt | 11 +++ .../rest/controller/KlangLichtController.kt | 25 ++++++ klanglicht-rest/src/main/resources/log4j.xml | 18 ----- .../src/main/resources/logback.xml | 32 ++++++++ .../src/main/resources/templates/foo.html | 11 +++ klanglicht-yamaha/pom.xml | 2 +- pom.xml | 29 +++---- 13 files changed, 217 insertions(+), 51 deletions(-) create mode 100644 docs/colors-lmair.txt create mode 100644 klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/KlangLichtMain.kt create mode 100644 klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/controller/KlangLichtController.kt delete mode 100644 klanglicht-rest/src/main/resources/log4j.xml create mode 100644 klanglicht-rest/src/main/resources/logback.xml create mode 100644 klanglicht-rest/src/main/resources/templates/foo.html diff --git a/docs/colors-lmair.txt b/docs/colors-lmair.txt new file mode 100644 index 0000000..62a0180 --- /dev/null +++ b/docs/colors-lmair.txt @@ -0,0 +1,36 @@ +red ff0000 +green 00ff00 +blue 0000ff + +yellow ffff00 +magenta ff00ff +cyan 00ffff + +orange ff8000 +purple 8000ff + +dark red 400000 +dark green 004000 +dark blue 000040 + +dark yellow 404000 +dark magenta 400040 +dark cyan 004040 + +Background purple-green {group:background;color:#8000ff,#004000,#8000ff,#004000} bicolor purple-green 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=8000ff,004000,8000ff,004000,8000ff,004000,8000ff&turnOn=true& +Background green-purple {group:background;color:#004000,#8000ff,#004000,#8000ff} bicolor green-purple 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=004000,8000ff,004000,8000ff,004000,8000ff,004000&turnOn=true& + +Background blue-green {group:background;color:#0000ff,#004000,#0000ff,#004000} bicolor blue-green 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=0000ff,00ff00,0000ff,00ff00,0000ff,00ff00,0000ff&turnOn=true& +Background green-blue {group:background;color:#004000,#0000ff,#004000,#0000ff} bicolor green-blue 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=00ff00,0000ff,00ff00,0000ff,00ff00,0000ff,00ff00&turnOn=true& + +Background blue-cyan {group:background;color:#0000ff,#00ffff,#0000ff,#00ffff} bicolor blue-cyan 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=0000ff,00ffff,0000ff,00ffff,0000ff,00ffff,0000ff&turnOn=true& +Background cyan-blue {group:background;color:#00ffff,#0000ff,#00ffff,#0000ff} bicolor cyan-blue 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=00ffff,0000ff,00ffff,0000ff,00ffff,0000ff,00ffff&turnOn=true& + +Background blue-yellow {group:background;color:#0000ff,#ffff00,#0000ff,#ffff00} bicolor blue-yellow 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=0000ff,ffff00,0000ff,ffff00,0000ff,ffff00,0000ff&turnOn=true& +Background yellow-blue {group:background;color:#ffff00,#0000ff,#ffff00,#0000ff} bicolor yellow-blue 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=ffff00,0000ff,ffff00,0000ff,ffff00,0000ff,ffff00&turnOn=true& + +Background green-yellow {group:background;color:#00ff00,#ffff00,#00ff00,#ffff00} bicolor green-yellow 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=00ff00,ffff00,00ff00,ffff00,00ff00,ffff00,00ff00&turnOn=true& +Background yellow-green {group:background;color:#ffff00,#00ff00,#ffff00,#00ff00} bicolor yellow-green 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=ffff00,00ff00,ffff00,00ff00,ffff00,00ff00,ffff00&turnOn=true& + +Background purple-yellow {group:background;color:#8000ff,#ffff00,#8000ff,#ffff00} bicolor purple-yellow 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=8000ff,ffff00,8000ff,ffff00,8000ff,ffff00,8000ff&turnOn=true& +Background yellow-purple {group:background;color:#ffff00,#8000ff,#ffff00,#8000ff} bicolor yellow-purple 192.168.178.30:8888/v1/hybrid/json/hexColor?hexColors=ffff00,8000ff,ffff00,8000ff,ffff00,8000ff,ffff00&turnOn=true& diff --git a/klanglicht-core/pom.xml b/klanglicht-core/pom.xml index 5a2e6a6..abf3217 100644 --- a/klanglicht-core/pom.xml +++ b/klanglicht-core/pom.xml @@ -9,7 +9,7 @@ de.visualdigits.kotlin klanglicht-kt ${revision} - ../pom.xml + ../pom.xml klanglicht-core diff --git a/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Fadeable.kt b/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Fadeable.kt index 118d209..2f46509 100644 --- a/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Fadeable.kt +++ b/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Fadeable.kt @@ -2,5 +2,8 @@ package de.visualdigits.kotlin.klanglicht.model.parameter interface Fadeable> { + /** + * Fades this instance towards the given instance using the given factor 0.0 .. 1.0. + */ fun fade(other: Any, factor: Double): T } diff --git a/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Scene.kt b/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Scene.kt index eb8831e..d25ae22 100644 --- a/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Scene.kt +++ b/klanglicht-core/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/parameter/Scene.kt @@ -1,11 +1,9 @@ package de.visualdigits.kotlin.klanglicht.model.parameter import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder -import de.visualdigits.kotlin.klanglicht.model.color.RGBAColor import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences import java.io.File import java.lang.IllegalArgumentException -import kotlin.math.ceil class Scene( val name: String, @@ -25,7 +23,7 @@ class Scene( ): Scene { return if (other is Scene) { Scene( - name = "Fram $factor", + name = "Frame $factor", parameterSet = parameterSet .zip(other.parameterSet) .map { (paramsFrom, paramsTo) -> @@ -41,11 +39,14 @@ class Scene( preferences: Preferences ) { val dmxFrameTime = preferences.dmx.frameTime // millis - val steps = ceil(fadeDuration.toDouble() / dmxFrameTime.toDouble()).toInt() - val step = 1.0 / steps - for (f in 0..steps) { - preferences.setScene(fade(other, step * f)) + val step = 1.0 / fadeDuration.toDouble() * dmxFrameTime.toDouble() + var factor = 0.0 + + while (factor < 1.0) { + preferences.setScene(fade(other, factor)) + factor += step Thread.sleep(dmxFrameTime) } + preferences.setScene(other) } } diff --git a/klanglicht-core/src/test/kotlin/de/visualdigits/kotlin/klanglicht/dmx/SimpleTest.kt b/klanglicht-core/src/test/kotlin/de/visualdigits/kotlin/klanglicht/dmx/SimpleTest.kt index d80138a..5ba04cb 100644 --- a/klanglicht-core/src/test/kotlin/de/visualdigits/kotlin/klanglicht/dmx/SimpleTest.kt +++ b/klanglicht-core/src/test/kotlin/de/visualdigits/kotlin/klanglicht/dmx/SimpleTest.kt @@ -60,7 +60,7 @@ class SimpleTest { baseChannel = baseChannel, parameters = mutableListOf( IntParameter("MasterDimmer", 0), - RGBWColor(255, 0, 0, 0) + RGBWColor(255, 0, 0, 128) ) ) ) @@ -82,8 +82,9 @@ class SimpleTest { val dmxRepeater = DmxRepeater(preferences.dmxInterface, preferences.dmx.frameTime) dmxRepeater.start() - scene1.fade(scene2, 3000, preferences) - scene2.fade(scene1, 3000, preferences) + val fadeDuration = 5000L + scene1.fade(scene2, fadeDuration, preferences) + scene2.fade(scene1, fadeDuration, preferences) dmxRepeater.join() } diff --git a/klanglicht-rest/pom.xml b/klanglicht-rest/pom.xml index fa3e007..4c1ada5 100644 --- a/klanglicht-rest/pom.xml +++ b/klanglicht-rest/pom.xml @@ -1,18 +1,87 @@ - + 4.0.0 jar + + 3.1.2 + + de.visualdigits.kotlin klanglicht-kt ${revision} - ../pom.xml + ../pom.xml klanglicht-rest ${revision} + + + + de.visualdigits.kotlin + klanglicht-core + ${revision} + + + + + org.jetbrains.kotlin + kotlin-reflect + ${version.kotlin} + + + org.jetbrains.kotlin + kotlin-maven-noarg + ${version.kotlin} + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${version.kotlin} + + + + + org.springframework.boot + spring-boot-starter-parent + ${version.spring-boot} + pom + + + + org.springframework.boot + spring-boot-starter-web + ${version.spring-boot} + + + org.springframework.boot + spring-boot-starter-tomcat + ${version.spring-boot} + + + org.springframework.boot + spring-boot-starter-thymeleaf + ${version.spring-boot} + + + org.springframework.boot + spring-boot-starter-actuator + ${version.spring-boot} + + + org.springframework.boot + spring-boot-starter-logging + ${version.spring-boot} + + + + org.springframework.boot + spring-boot-starter-test + ${version.spring-boot} + test + + diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/KlangLichtMain.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/KlangLichtMain.kt new file mode 100644 index 0000000..2e3b2b2 --- /dev/null +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/KlangLichtMain.kt @@ -0,0 +1,11 @@ +package de.visualdigits.kotlin.klanglicht.rest + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +open class KlangLichtMain + +fun main(args: Array) { + runApplication(*args) +} diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/controller/KlangLichtController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/controller/KlangLichtController.kt new file mode 100644 index 0000000..3c1aecc --- /dev/null +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/controller/KlangLichtController.kt @@ -0,0 +1,25 @@ +package de.visualdigits.kotlin.klanglicht.rest.controller + +import de.visualdigits.kotlin.klanglicht.model.parameter.Scene +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Controller +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping + +@Controller +@RequestMapping("/dmx/v1") +class KlangLichtController { + + private val log = LoggerFactory.getLogger(KlangLichtController::class.java) + + @GetMapping("hello") + fun hello(): String { + log.info("### hello world!") + return "foo" + } + + @GetMapping("setScene") + fun setScene(scene: Scene) { + + } +} diff --git a/klanglicht-rest/src/main/resources/log4j.xml b/klanglicht-rest/src/main/resources/log4j.xml deleted file mode 100644 index 691a38f..0000000 --- a/klanglicht-rest/src/main/resources/log4j.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/klanglicht-rest/src/main/resources/logback.xml b/klanglicht-rest/src/main/resources/logback.xml new file mode 100644 index 0000000..95988f4 --- /dev/null +++ b/klanglicht-rest/src/main/resources/logback.xml @@ -0,0 +1,32 @@ + + + + + + server.log + true + + %d %-4relative [%thread] %-5level %logger{35} - %msg%n + + + + + request.log + true + + %d %-4relative [%thread] %-5level %logger{35} - %msg%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/klanglicht-rest/src/main/resources/templates/foo.html b/klanglicht-rest/src/main/resources/templates/foo.html new file mode 100644 index 0000000..d6b6da6 --- /dev/null +++ b/klanglicht-rest/src/main/resources/templates/foo.html @@ -0,0 +1,11 @@ + + + + + + Spring Boot Application + + +

Welcome to Thymeleaf Spring Boot web application

+ + diff --git a/klanglicht-yamaha/pom.xml b/klanglicht-yamaha/pom.xml index 0688754..9844ec9 100644 --- a/klanglicht-yamaha/pom.xml +++ b/klanglicht-yamaha/pom.xml @@ -9,7 +9,7 @@ de.visualdigits.kotlin klanglicht-kt ${revision} - ../pom.xml + ../pom.xml klanglicht-yamaha diff --git a/pom.xml b/pom.xml index ed96446..ad8e5bd 100644 --- a/pom.xml +++ b/pom.xml @@ -20,21 +20,21 @@ 1.0-SNAPSHOT - 11 - 11 - 11 - 11 - 11 + 17 + 17 + 17 + 17 + 17 UTF-8 official - 2.14.1 - 1.8.20 + 2.15.1 + 1.9.0 1.2.17 2.0.5 - 5.9.2 + 5.10.0 @@ -54,7 +54,7 @@ org.jetbrains.kotlinx kotlinx-coroutines-core-jvm - 1.5.0 + 1.7.2 @@ -108,14 +108,9 @@ - org.slf4j - slf4j-reload4j - ${version.slf4j} - - - log4j - log4j - ${version.log4j} + ch.qos.logback + logback-classic + 1.4.8