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;
}
Aggregations