Search in sources :

Example 11 with FadeAction

use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.

the class FadeActionTest method checkWithoutFadingWithoutHold.

@Test
public void checkWithoutFadingWithoutHold() {
    FadeAction fadeAction = new FadeAction(0, testValue, 0);
    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 * testValue));
    assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
    fadeAction.reset();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
Also used : FadeAction(org.eclipse.smarthome.binding.dmx.internal.action.FadeAction) DmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.DmxChannel) Test(org.junit.Test)

Example 12 with FadeAction

use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.

the class FadeActionTest method checkWithFadingWithHold.

@Test
public void checkWithFadingWithHold() {
    FadeAction fadeAction = new FadeAction(testFadeTime, testValue, testHoldTime);
    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 + testFadeTime / 2), is(256 * testValue / 2));
    assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime), is(256 * testValue));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime + testHoldTime / 2), is(256 * testValue));
    assertThat(fadeAction.getState(), is(ActionState.RUNNING));
    assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime + testHoldTime), is(256 * testValue));
    assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
    fadeAction.reset();
    assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
Also used : FadeAction(org.eclipse.smarthome.binding.dmx.internal.action.FadeAction) DmxChannel(org.eclipse.smarthome.binding.dmx.internal.multiverse.DmxChannel) Test(org.junit.Test)

Example 13 with FadeAction

use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.

the class DmxChannelTest method checkMultipleInfiniteFadeAction.

@Test
public void checkMultipleInfiniteFadeAction() {
    dmxChannel.addChannelAction(new FadeAction(1000, 243, 0));
    dmxChannel.addChannelAction(new FadeAction(1000, 127, 0));
    dmxChannel.getNewValue(currentTime);
    assertThat(dmxChannel.hasRunningActions(), is(true));
    Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 0);
    // check first action completes
    dmxChannel.getNewValue(currentTime);
    currentTime += 1000;
    dmxChannel.getNewValue(currentTime);
    assertThat(dmxChannel.hasRunningActions(), is(true));
    Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 243);
    // check second action completes
    dmxChannel.getNewValue(currentTime);
    currentTime += 1000;
    dmxChannel.getNewValue(currentTime);
    assertThat(dmxChannel.hasRunningActions(), is(true));
    Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 127);
    // check first action completes again
    currentTime += 1000;
    dmxChannel.getNewValue(currentTime);
    assertThat(dmxChannel.hasRunningActions(), is(true));
    Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 243);
}
Also used : FadeAction(org.eclipse.smarthome.binding.dmx.internal.action.FadeAction) Test(org.junit.Test)

Example 14 with FadeAction

use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.

the class DmxChannelTest method setAndClearAction.

@Test
public void setAndClearAction() {
    // has action
    dmxChannel.setChannelAction(new FadeAction(0, 100, -1));
    assertThat(dmxChannel.hasRunningActions(), is(true));
    // clear action
    dmxChannel.clearAction();
    assertThat(dmxChannel.hasRunningActions(), is(false));
}
Also used : FadeAction(org.eclipse.smarthome.binding.dmx.internal.action.FadeAction) Test(org.junit.Test)

Aggregations

FadeAction (org.eclipse.smarthome.binding.dmx.internal.action.FadeAction)14 Test (org.junit.Test)10 DmxChannel (org.eclipse.smarthome.binding.dmx.internal.multiverse.DmxChannel)8 ValueSet (org.eclipse.smarthome.binding.dmx.internal.ValueSet)4 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)4 RefreshType (org.eclipse.smarthome.core.types.RefreshType)4 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)3 IncreaseDecreaseType (org.eclipse.smarthome.core.library.types.IncreaseDecreaseType)3 PercentType (org.eclipse.smarthome.core.library.types.PercentType)3 ResumeAction (org.eclipse.smarthome.binding.dmx.internal.action.ResumeAction)2 BaseDmxChannel (org.eclipse.smarthome.binding.dmx.internal.multiverse.BaseDmxChannel)2 Vector (java.util.Vector)1 HSBType (org.eclipse.smarthome.core.library.types.HSBType)1 StringType (org.eclipse.smarthome.core.library.types.StringType)1