Search in sources :

Example 11 with DmxChannel

use of org.smarthomej.binding.dmx.internal.multiverse.DmxChannel in project addons by smarthomej.

the class FadeActionTest method checkWithFadingWithHold.

@Test
public void checkWithFadingWithHold() {
    FadeAction fadeAction = new FadeAction(TEST_FADE_TIME, TEST_VALUE, TEST_HOLD_TIME);
    DmxChannel testChannel = new DmxChannel(0, 1, 0);
    testChannel.setValue(0);
    long startTime = System.currentTimeMillis();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
    assertThat(fadeAction.getNewValue(testChannel, startTime), is(0));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_FADE_TIME / 2), is(256 * TEST_VALUE / 2));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_FADE_TIME), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_FADE_TIME + TEST_HOLD_TIME / 2), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_FADE_TIME + TEST_HOLD_TIME), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
    fadeAction.reset();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
Also used : FadeAction(org.smarthomej.binding.dmx.internal.action.FadeAction) DmxChannel(org.smarthomej.binding.dmx.internal.multiverse.DmxChannel) Test(org.junit.jupiter.api.Test)

Example 12 with DmxChannel

use of org.smarthomej.binding.dmx.internal.multiverse.DmxChannel in project addons by smarthomej.

the class FadeActionTest method checkWithoutFadingWithHold.

@Test
public void checkWithoutFadingWithHold() {
    FadeAction fadeAction = new FadeAction(0, TEST_VALUE, TEST_HOLD_TIME);
    DmxChannel testChannel = new DmxChannel(0, 1, 0);
    testChannel.setValue(0);
    long startTime = System.currentTimeMillis();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
    assertThat(fadeAction.getNewValue(testChannel, startTime), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_HOLD_TIME / 2), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + TEST_HOLD_TIME), is(256 * TEST_VALUE));
    assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
    fadeAction.reset();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
Also used : FadeAction(org.smarthomej.binding.dmx.internal.action.FadeAction) DmxChannel(org.smarthomej.binding.dmx.internal.multiverse.DmxChannel) Test(org.junit.jupiter.api.Test)

Aggregations

DmxChannel (org.smarthomej.binding.dmx.internal.multiverse.DmxChannel)12 FadeAction (org.smarthomej.binding.dmx.internal.action.FadeAction)11 Test (org.junit.jupiter.api.Test)6 BaseDmxChannel (org.smarthomej.binding.dmx.internal.multiverse.BaseDmxChannel)6 OnOffType (org.openhab.core.library.types.OnOffType)4 RefreshType (org.openhab.core.types.RefreshType)4 ValueSet (org.smarthomej.binding.dmx.internal.ValueSet)4 DecimalType (org.openhab.core.library.types.DecimalType)3 IncreaseDecreaseType (org.openhab.core.library.types.IncreaseDecreaseType)3 PercentType (org.openhab.core.library.types.PercentType)3 ResumeAction (org.smarthomej.binding.dmx.internal.action.ResumeAction)2 ArrayList (java.util.ArrayList)1 HSBType (org.openhab.core.library.types.HSBType)1 StringType (org.openhab.core.library.types.StringType)1 Bridge (org.openhab.core.thing.Bridge)1 ChannelUID (org.openhab.core.thing.ChannelUID)1 DmxBridgeHandler (org.smarthomej.binding.dmx.internal.DmxBridgeHandler)1