Skip to content

Commit

Permalink
ffirst code for spring boot
Browse files Browse the repository at this point in the history
  • Loading branch information
sknull committed Oct 10, 2023
1 parent 14811d8 commit a51d29e
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 51 deletions.
36 changes: 36 additions & 0 deletions docs/colors-lmair.txt
Original file line number Diff line number Diff line change
@@ -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&
2 changes: 1 addition & 1 deletion klanglicht-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>de.visualdigits.kotlin</groupId>
<artifactId>klanglicht-kt</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>klanglicht-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ package de.visualdigits.kotlin.klanglicht.model.parameter

interface Fadeable<T : Fadeable<T>> {

/**
* Fades this instance towards the given instance using the given factor 0.0 .. 1.0.
*/
fun fade(other: Any, factor: Double): T
}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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) ->
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SimpleTest {
baseChannel = baseChannel,
parameters = mutableListOf(
IntParameter("MasterDimmer", 0),
RGBWColor(255, 0, 0, 0)
RGBWColor(255, 0, 0, 128)
)
)
)
Expand All @@ -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()
}
Expand Down
77 changes: 73 additions & 4 deletions klanglicht-rest/pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

<properties>
<version.spring-boot>3.1.2</version.spring-boot>
</properties>

<parent>
<groupId>de.visualdigits.kotlin</groupId>
<artifactId>klanglicht-kt</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>klanglicht-rest</artifactId>
<version>${revision}</version>

<dependencies>
<!-- project dependencies -->
<dependency>
<groupId>de.visualdigits.kotlin</groupId>
<artifactId>klanglicht-core</artifactId>
<version>${revision}</version>
</dependency>

<!-- kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${version.kotlin}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${version.kotlin}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${version.kotlin}</version>
</dependency>

<!-- spring boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${version.spring-boot}</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${version.spring-boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${version.spring-boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${version.spring-boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${version.spring-boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>${version.spring-boot}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${version.spring-boot}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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<String>) {
runApplication<KlangLichtMain>(*args)
}
Original file line number Diff line number Diff line change
@@ -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) {

}
}
18 changes: 0 additions & 18 deletions klanglicht-rest/src/main/resources/log4j.xml

This file was deleted.

32 changes: 32 additions & 0 deletions klanglicht-rest/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />

<appender name="SERVER" class="ch.qos.logback.core.FileAppender">
<file>server.log</file>
<append>true</append>
<encoder>
<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>

<appender name="REQUEST" class="ch.qos.logback.core.FileAppender">
<file>request.log</file>
<append>true</append>
<encoder>
<pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>

<logger name="de.visualdigits.common.configuration.SimpleRequestLoggingFilter" level="DEBUG" additivity="false">
<appender-ref ref="REQUEST"/>
</logger>

<logger name="org.springframework.web" level="INFO">
<appender-ref ref="SERVER"/>
</logger>

<root level="INFO">
<appender-ref ref="SERVER" />
</root>
</configuration>
11 changes: 11 additions & 0 deletions klanglicht-rest/src/main/resources/templates/foo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset = "ISO-8859-1" />
<link href = "css/styles.css" rel = "stylesheet"/>
<title>Spring Boot Application</title>
</head>
<body>
<h4>Welcome to Thymeleaf Spring Boot web application</h4>
</body>
</html>
2 changes: 1 addition & 1 deletion klanglicht-yamaha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>de.visualdigits.kotlin</groupId>
<artifactId>klanglicht-kt</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>klanglicht-yamaha</artifactId>
Expand Down
29 changes: 12 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
<properties>
<revision>1.0-SNAPSHOT</revision>

<java-version>11</java-version>
<compilerVersion>11</compilerVersion>
<project.build.source>11</project.build.source>
<project.build.target>11</project.build.target>
<kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
<java-version>17</java-version>
<compilerVersion>17</compilerVersion>
<project.build.source>17</project.build.source>
<project.build.target>17</project.build.target>
<kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<kotlin.code.style>official</kotlin.code.style>

<version.jackson>2.14.1</version.jackson>
<version.kotlin>1.8.20</version.kotlin>
<version.jackson>2.15.1</version.jackson>
<version.kotlin>1.9.0</version.kotlin>
<version.log4j>1.2.17</version.log4j>
<version.slf4j>2.0.5</version.slf4j>
<version.junit.jupiter>5.9.2</version.junit.jupiter>
<version.junit.jupiter>5.10.0</version.junit.jupiter>
</properties>

<repositories>
Expand All @@ -54,7 +54,7 @@
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
<version>1.5.0</version>
<version>1.7.2</version>
</dependency>

<!-- commons -->
Expand Down Expand Up @@ -108,14 +108,9 @@

<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${version.log4j}</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.8</version>
</dependency>

<!-- testing -->
Expand Down

0 comments on commit a51d29e

Please sign in to comment.