Search in sources :

Example 6 with LightValue

use of org.opensmartgridplatform.oslp.Oslp.LightValue in project open-smart-grid-platform by OSGP.

the class OslpChannelHandler method handleSetLightRequest.

private void handleSetLightRequest(final Device device, final SetLightRequest request) {
    // Device simulator will only use first light value,
    // other light values will be ignored
    final LightValue lightValue = request.getValues(0);
    device.setLightOn(lightValue.getOn());
    if (lightValue.hasDimValue()) {
        final int dimValue = lightValue.getDimValue().byteAt(0);
        device.setDimValue(dimValue);
    } else {
        device.setDimValue(null);
    }
    final Oslp.Event event = device.isLightOn() ? Oslp.Event.LIGHT_EVENTS_LIGHT_ON : Oslp.Event.LIGHT_EVENTS_LIGHT_OFF;
    final String description = "setLightRequest [SET_LIGHT] SCHED[-]";
    this.sendEvent(device, event, description);
}
Also used : LightValue(org.opensmartgridplatform.oslp.Oslp.LightValue) ByteString(com.google.protobuf.ByteString) Oslp(org.opensmartgridplatform.oslp.Oslp)

Aggregations

LightValue (org.opensmartgridplatform.oslp.Oslp.LightValue)6 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Builder (org.opensmartgridplatform.oslp.Oslp.GetStatusResponse.Builder)2 Given (io.cucumber.java.en.Given)1 Then (io.cucumber.java.en.Then)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 EventNotificationType (org.opensmartgridplatform.domain.core.valueobjects.EventNotificationType)1 Oslp (org.opensmartgridplatform.oslp.Oslp)1 GetStatusResponse (org.opensmartgridplatform.oslp.Oslp.GetStatusResponse)1 LightType (org.opensmartgridplatform.oslp.Oslp.LightType)1 Builder (org.opensmartgridplatform.oslp.Oslp.LightValue.Builder)1 LinkType (org.opensmartgridplatform.oslp.Oslp.LinkType)1 Message (org.opensmartgridplatform.oslp.Oslp.Message)1 Status (org.opensmartgridplatform.oslp.Oslp.Status)1 DeviceOutputSetting (org.opensmartgridplatform.webdevicesimulator.domain.entities.DeviceOutputSetting)1 LightType (org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LightType)1 LinkType (org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LinkType)1