Search in sources :

Example 1 with DeviceLightStatus

use of org.opensmartgridplatform.webdemoapp.domain.DeviceLightStatus in project open-smart-grid-platform by OSGP.

the class PublicLightingController method getStatusRequest.

/**
 * Creates a view to show the device details from a async GetStatus request. This function is
 * called from the async controller as soon as the getStatus request is processed by the platform
 */
public ModelAndView getStatusRequest(final DeviceStatus deviceStatus, final String deviceIdentification) {
    final ModelAndView modelView = new ModelAndView(DEVICE);
    final DeviceLightStatus deviceLightStatus = new DeviceLightStatus();
    deviceLightStatus.setDeviceId(deviceIdentification);
    final LightValue lightValue = deviceStatus.getLightValues().get(0);
    if (lightValue != null) {
        int lv = LIGHT_OFF;
        if (lightValue.getDimValue() == null) {
            if (lightValue.isOn()) {
                lv = LIGHT_ON;
            }
        } else {
            lv = lightValue.getDimValue();
        }
        deviceLightStatus.setLightOn(lightValue.isOn());
        deviceLightStatus.setLightValue(lv);
    }
    modelView.addObject("command", new DeviceLightStatus());
    modelView.addObject(DEVICE, deviceLightStatus);
    return modelView;
}
Also used : DeviceLightStatus(org.opensmartgridplatform.webdemoapp.domain.DeviceLightStatus) LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) ModelAndView(org.springframework.web.servlet.ModelAndView)

Aggregations

LightValue (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue)1 DeviceLightStatus (org.opensmartgridplatform.webdemoapp.domain.DeviceLightStatus)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1