Search in sources :

Example 6 with LightValue

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue in project open-smart-grid-platform by OSGP.

the class SetLightSteps method receivingASetLightRequestWithLightValues.

@When("^receiving a set light request with \"([^\"]*)\" light values$")
public void receivingASetLightRequestWithLightValues(final Integer nofLightValues, final Map<String, String> requestParameters) throws Throwable {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    for (int i = 0; i < nofLightValues; i++) {
        final LightValue lightValue = new LightValue();
        lightValue.setIndex(i + 2);
        lightValue.setDimValue(getInteger(requestParameters, PlatformKeys.KEY_DIMVALUE, PlatformDefaults.DEFAULT_DIMVALUE));
        lightValue.setOn(getBoolean(requestParameters, PlatformKeys.KEY_ON, PlatformDefaults.DEFAULT_ON));
        request.getLightValue().add(lightValue);
    }
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.setLight(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) When(io.cucumber.java.en.When)

Example 7 with LightValue

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue in project open-smart-grid-platform by OSGP.

the class AuthorizeDeviceFunctionsSteps method setLight.

private void setLight(final Map<String, String> requestParameters) throws WebServiceSecurityException, GeneralSecurityException, IOException {
    final SetLightRequest request = new SetLightRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    final LightValue lightValue = new LightValue();
    lightValue.setIndex(0);
    lightValue.setDimValue(100);
    lightValue.setOn(true);
    request.getLightValue().add(lightValue);
    ScenarioContext.current().put(PlatformPubliclightingKeys.RESPONSE, this.publicLightingAdHocManagementClient.setLight(request));
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest)

Example 8 with LightValue

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue in project open-smart-grid-platform by OSGP.

the class OsgpPublicLightingClientSoapService method switchLightRequest.

/**
 * Creates a SetLight request using the parameters deviceId and lightOn. Sends the request to the
 * platform using the WebServiceTemplate.
 *
 * <p>Returns the CorrelationId response from the Platform.
 */
public String switchLightRequest(final String deviceId, final boolean lightOn) {
    final SetLightRequest request = new SetLightRequest();
    final LightValue lightValue = new LightValue();
    lightValue.setOn(lightOn);
    final WebServiceTemplate template = this.soapRequestHelper.createPublicLightingRequest();
    request.setDeviceIdentification(deviceId);
    request.getLightValue().add(lightValue);
    final SetLightAsyncResponse response = (SetLightAsyncResponse) template.marshalSendAndReceive(request);
    return response.getAsyncResponse().getCorrelationUid();
}
Also used : LightValue(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) SetLightRequest(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest) SetLightAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)

Example 9 with LightValue

use of org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightValue 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)9 SetLightRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightRequest)6 When (io.cucumber.java.en.When)3 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)3 SetLightAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)2 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)2 Then (io.cucumber.java.en.Then)1 DeviceStatus (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.DeviceStatus)1 EventNotificationType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.EventNotificationType)1 GetStatusAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncRequest)1 GetStatusResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusResponse)1 LightType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LightType)1 LinkType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.LinkType)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.OsgpResultType)1 Schedule (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.Schedule)1 WindowType (org.opensmartgridplatform.adapter.ws.schema.publiclighting.schedulemanagement.WindowType)1 TariffSchedule (org.opensmartgridplatform.adapter.ws.schema.tariffswitching.schedulemanagement.TariffSchedule)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 DeviceLightStatus (org.opensmartgridplatform.webdemoapp.domain.DeviceLightStatus)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1