From dc98a172f5afa9928de14fb3844ea5d0a95638f9 Mon Sep 17 00:00:00 2001 From: Moritz Ruth Date: Sat, 8 Jul 2023 13:34:35 +0200 Subject: [PATCH] commit #54 --- .../kotlin/de/moritzruth/lampenfieber/Test.kt | 15 ++++----------- .../de/moritzruth/lampenfieber/act/First.kt | 2 +- .../de/moritzruth/lampenfieber/act/Fourth.kt | 4 ++-- .../lampenfieber/device/FuturelightDmh160.kt | 13 +++++++------ .../lampenfieber/device/StairvilleClb4.kt | 2 +- .../theaterdsl/device/DynamicValue.kt | 17 ++++++++++++++--- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/de/moritzruth/lampenfieber/Test.kt b/src/main/kotlin/de/moritzruth/lampenfieber/Test.kt index 4654a8f..3c01de8 100644 --- a/src/main/kotlin/de/moritzruth/lampenfieber/Test.kt +++ b/src/main/kotlin/de/moritzruth/lampenfieber/Test.kt @@ -1,6 +1,6 @@ package de.moritzruth.lampenfieber -import de.moritzruth.lampenfieber.device.Washs +import de.moritzruth.lampenfieber.device.Tops import de.moritzruth.lampenfieber.device.devices import de.moritzruth.theaterdsl.dmx.EnttecOpenDmxUsb import de.moritzruth.theaterdsl.dmx.PerDeviceDmxDataWriter @@ -11,7 +11,6 @@ import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlin.math.roundToLong import kotlin.system.measureTimeMillis -import kotlin.time.Duration.Companion.seconds suspend fun main() = coroutineScope { EnttecOpenDmxUsb.start() @@ -38,14 +37,8 @@ suspend fun main() = coroutineScope { } suspend fun test() = coroutineScope { - Washs.both { - it.brightness.static(50.percent) - it.pointAtGuests() - } - - delay(4000) - - Washs.both { - it.pointAtCeiling(5.seconds) + Tops.both { + it.brightness.static(100.percent) + it.startRoomMovement(10.0) } } \ No newline at end of file diff --git a/src/main/kotlin/de/moritzruth/lampenfieber/act/First.kt b/src/main/kotlin/de/moritzruth/lampenfieber/act/First.kt index 080aa50..f21bef2 100644 --- a/src/main/kotlin/de/moritzruth/lampenfieber/act/First.kt +++ b/src/main/kotlin/de/moritzruth/lampenfieber/act/First.kt @@ -92,7 +92,7 @@ fun ShowBuilderContext.firstAct() = act("Erster Akt") { } lightStep(StepCue.Custom("Gitarren-Ton")) { - FrontLights.center.forEach { it.brightness.fade(0.percent, 30.seconds) } + FrontLights.all.forEach { it.brightness.fade(0.percent, 30.seconds) } Washs.both.forEach { it.colorWheelMode.static(CoemarProWash.ColorWheelMode.Rotate(20.percent)) } Tops.both.forEach { it.colorWheelMode.static(FuturelightDmh160.ColorWheelMode.Rotate(20.percent)) } } diff --git a/src/main/kotlin/de/moritzruth/lampenfieber/act/Fourth.kt b/src/main/kotlin/de/moritzruth/lampenfieber/act/Fourth.kt index d8a1eba..fd64497 100644 --- a/src/main/kotlin/de/moritzruth/lampenfieber/act/Fourth.kt +++ b/src/main/kotlin/de/moritzruth/lampenfieber/act/Fourth.kt @@ -239,10 +239,10 @@ fun ShowBuilderContext.fourthAct() = act("Vierter Akt") { step(StepCue.MusicEnd) { actors { // alle ab außer David - +"Paula / durch Mittelgang auf Fahrrad" + +"Paula / von links" } - rightSpotTarget = "Paula / im Mittelgang" + rightSpotTarget = "Paula und David (groß)" onRun { FrontLights.all.forEach { it.brightness.fade(20.percent, 6.seconds) } diff --git a/src/main/kotlin/de/moritzruth/lampenfieber/device/FuturelightDmh160.kt b/src/main/kotlin/de/moritzruth/lampenfieber/device/FuturelightDmh160.kt index 1b2ddea..ef3b5ac 100644 --- a/src/main/kotlin/de/moritzruth/lampenfieber/device/FuturelightDmh160.kt +++ b/src/main/kotlin/de/moritzruth/lampenfieber/device/FuturelightDmh160.kt @@ -7,6 +7,7 @@ import de.moritzruth.theaterdsl.device.PercentageDV import de.moritzruth.theaterdsl.dmx.DmxAddress import de.moritzruth.theaterdsl.dmx.DmxDataWriter import de.moritzruth.theaterdsl.dmx.DmxValue +import de.moritzruth.theaterdsl.value.Angle import de.moritzruth.theaterdsl.value.Percentage import de.moritzruth.theaterdsl.value.degrees import kotlinx.collections.immutable.persistentSetOf @@ -15,8 +16,8 @@ import kotlin.time.Duration.Companion.minutes class FuturelightDmh160(override val firstChannel: DmxAddress, private val isRight: Boolean) : Device { companion object { - private const val PAN_LIMIT = 630f // degrees - private const val TILT_LIMIT = 270f // degrees + private const val PAN_LIMIT = 630.0 // degrees + private const val TILT_LIMIT = 270.0 // degrees } override val numberOfChannels: UInt = 16u @@ -81,7 +82,7 @@ class FuturelightDmh160(override val firstChannel: DmxAddress, private val isRig FROST(DmxValue(192u)) } - val pan = AngleDV() + val pan = AngleDV(maximumValue = Angle(PAN_LIMIT)) val tilt = AngleDV() val brightness = PercentageDV() val colorWheelMode = ConcreteDV(ColorWheelMode.White) @@ -90,9 +91,9 @@ class FuturelightDmh160(override val firstChannel: DmxAddress, private val isRig val prismRotationSpeed = PercentageDV() fun startRoomMovement(rotationsPerMinute: Double) { // TODO: Test - val period = 1.minutes / rotationsPerMinute - pan.rampUp(period) // spin - tilt.sine(period, minimum = 100.degrees, maximum = 120.degrees, start = 120.degrees) + val period = (1.minutes / rotationsPerMinute) * 2 + pan.rampUp(period * (PAN_LIMIT / 360.0)) // spin + tilt.sine(period, minimum = 90.degrees, maximum = 120.degrees, start = 120.degrees) } override val dvs = persistentSetOf( diff --git a/src/main/kotlin/de/moritzruth/lampenfieber/device/StairvilleClb4.kt b/src/main/kotlin/de/moritzruth/lampenfieber/device/StairvilleClb4.kt index f636a91..661a628 100644 --- a/src/main/kotlin/de/moritzruth/lampenfieber/device/StairvilleClb4.kt +++ b/src/main/kotlin/de/moritzruth/lampenfieber/device/StairvilleClb4.kt @@ -24,7 +24,7 @@ class StairvilleClb4(override val firstChannel: DmxAddress) : Device { override fun writeDmxData(writer: DmxDataWriter, isLightBehindCurtainOn: Boolean) { if (isLightBehindCurtainOn) { - repeat(2) { + repeat(3) { writer.writeRaw(DmxValue(255u)) writer.writeRaw(DmxValue(255u)) writer.writeRaw(DmxValue(255u)) diff --git a/src/main/kotlin/de/moritzruth/theaterdsl/device/DynamicValue.kt b/src/main/kotlin/de/moritzruth/theaterdsl/device/DynamicValue.kt index df4fec2..35cba29 100644 --- a/src/main/kotlin/de/moritzruth/theaterdsl/device/DynamicValue.kt +++ b/src/main/kotlin/de/moritzruth/theaterdsl/device/DynamicValue.kt @@ -40,6 +40,7 @@ abstract class DoubleDV(private val initialStaticValue: Double) : DynamicValu } data class Ramp(val period: Duration, val start: Double, val end: Double) : State + data class TriangleWave(val period: Duration, val start: Double, val end: Double) : State data class Step(val steps: ImmutableList, val interval: Duration, val startIndex: Int) : State data class PulseOnce(val rampUpDuration: Duration, val rampDownDuration: Duration, val peakValue: Double, val start: Double, val end: Double) : State } @@ -71,7 +72,18 @@ abstract class DoubleDV(private val initialStaticValue: Double) : DynamicValu (fromZeroToOne * (s.maximum - s.minimum) + s.minimum) } - is State.Ramp -> elapsedTime.inWholeMilliseconds.rem(s.period.inWholeMilliseconds) * (s.end - s.start) + s.start + is State.Ramp -> { + val progress = elapsedTime.inWholeMilliseconds.toDouble() / s.period.inWholeMilliseconds + val clampedProcess = progress.mod(1.0) + + clampedProcess * (s.end - s.start) + s.start + } + + is State.TriangleWave -> { + val progress = elapsedTime.inWholeMilliseconds.toDouble() / s.period.inWholeMilliseconds + val clampedProcess = progress.mod(1.0) + 1.0 + } is State.Step -> { val index = (elapsedTime / s.interval).toInt() + s.startIndex @@ -150,11 +162,10 @@ class PercentageDV(initialStaticValue: Percentage = 0.percent) : DoubleDV(initialStaticValue.degrees) { +class AngleDV(initialStaticValue: Angle = 0.degrees, override val maximumValue: Angle = 360.degrees) : DoubleDV(initialStaticValue.degrees) { override fun fromDomain(value: Angle): Double = value.degrees override fun toDomain(value: Double): Angle = Angle(value) override val minimumValue: Angle = 0.degrees - override val maximumValue: Angle = 360.degrees } class ConcreteDV(private val initialStaticValue: T) : DynamicValue {