Search in sources :

Example 1 with DaliConfiguration

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration in project open-smart-grid-platform by OSGP.

the class SetConfigurationSteps method addFilledDaliConfigurationToConfiguration.

private void addFilledDaliConfigurationToConfiguration(final Map<String, String> requestParameters, final Configuration config) throws ArgumentNullOrEmptyException {
    final DaliConfiguration daliConfiguration = new DaliConfiguration();
    if (!StringUtils.isEmpty(getString(requestParameters, PlatformKeys.DC_LIGHTS))) {
        daliConfiguration.setNumberOfLights(getInteger(requestParameters, PlatformKeys.DC_LIGHTS));
    }
    final String dcMap = getString(requestParameters, PlatformKeys.DC_MAP);
    if (dcMap != null) {
        final String[] daliMapArray = dcMap.split(";");
        for (final String daliMapElement : daliMapArray) {
            final IndexAddressMap indexAddressMap = new IndexAddressMap();
            final String[] subDaliMapElement = daliMapElement.split(",");
            if (!StringUtils.isEmpty(subDaliMapElement[0])) {
                indexAddressMap.setIndex(Integer.parseInt(subDaliMapElement[0]));
            }
            if (subDaliMapElement.length == 2 && !StringUtils.isEmpty(subDaliMapElement[1])) {
                indexAddressMap.setAddress(Integer.parseInt(subDaliMapElement[1]));
            }
            daliConfiguration.getIndexAddressMap().add(indexAddressMap);
        }
    }
    config.setDaliConfiguration(daliConfiguration);
}
Also used : DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) IndexAddressMap(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap)

Example 2 with DaliConfiguration

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration in project open-smart-grid-platform by OSGP.

the class GetConfigurationSteps method thePlatformBuffersAGetConfigurationResponseMessageForDevice.

@Then("^the platform buffers a get configuration response message for device \"([^\"]*)\"$")
public void thePlatformBuffersAGetConfigurationResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResponseData) throws Throwable {
    final GetConfigurationAsyncRequest request = new GetConfigurationAsyncRequest();
    final AsyncRequest asyncRequest = new AsyncRequest();
    asyncRequest.setDeviceId(deviceIdentification);
    asyncRequest.setCorrelationUid((String) ScenarioContext.current().get(PlatformKeys.KEY_CORRELATION_UID));
    request.setAsyncRequest(asyncRequest);
    final GetConfigurationResponse response = Wait.untilAndReturn(() -> {
        final GetConfigurationResponse retval = this.client.getGetConfiguration(request);
        assertThat(retval).isNotNull();
        assertThat(retval.getResult()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RESULT, OsgpResultType.class));
        return retval;
    });
    final Configuration configuration = response.getConfiguration();
    assertThat(configuration).isNotNull();
    if (expectedResponseData.containsKey(PlatformKeys.KEY_LIGHTTYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_LIGHTTYPE)) && configuration.getLightType() != null) {
        assertThat(configuration.getLightType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_LIGHTTYPE, LightType.class));
    }
    final DaliConfiguration daliConfiguration = configuration.getDaliConfiguration();
    if (daliConfiguration != null) {
        if (expectedResponseData.containsKey(PlatformKeys.DC_LIGHTS) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.DC_LIGHTS)) && daliConfiguration.getNumberOfLights() != 0) {
            assertThat(daliConfiguration.getNumberOfLights()).isEqualTo((int) getInteger(expectedResponseData, PlatformKeys.DC_LIGHTS));
        }
        if (expectedResponseData.containsKey(PlatformKeys.DC_MAP) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.DC_MAP)) && daliConfiguration.getIndexAddressMap() != null) {
            final List<IndexAddressMap> indexAddressMapList = daliConfiguration.getIndexAddressMap();
            final String[] dcMapArray = getString(expectedResponseData, PlatformKeys.DC_MAP).split(";");
            for (int i = 0; i < dcMapArray.length; i++) {
                final String[] dcMapArrayElements = dcMapArray[i].split(",");
                assertThat(indexAddressMapList.get(i).getIndex()).isEqualTo(Integer.parseInt(dcMapArrayElements[0]));
                assertThat(indexAddressMapList.get(i).getAddress()).isEqualTo(Integer.parseInt(dcMapArrayElements[1]));
            }
        }
    }
    final RelayConfiguration relayConfiguration = configuration.getRelayConfiguration();
    if (relayConfiguration != null) {
        if (expectedResponseData.containsKey(PlatformKeys.RELAY_CONF) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.RELAY_CONF)) && relayConfiguration.getRelayMap() != null) {
            final List<RelayMap> relayMapList = relayConfiguration.getRelayMap();
            final String[] rcMapArray = getString(expectedResponseData, PlatformKeys.RELAY_CONF).split(";");
            for (int i = 0; i < rcMapArray.length; i++) {
                final String[] rcMapArrayElements = rcMapArray[i].split(",");
                if (rcMapArrayElements.length > 0 && relayMapList.size() > 0) {
                    assertThat(relayMapList.get(i).getIndex()).isEqualTo(Integer.parseInt(rcMapArrayElements[0]));
                    assertThat(relayMapList.get(i).getAddress()).isEqualTo(Integer.parseInt(rcMapArrayElements[1]));
                    if (expectedResponseData.containsKey(PlatformKeys.KEY_RELAY_TYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_RELAY_TYPE)) && relayMapList.get(i).getRelayType() != null) {
                        assertThat(relayMapList.get(i).getRelayType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_RELAY_TYPE, RelayType.class));
                    }
                }
            }
        }
    }
    if (expectedResponseData.containsKey(PlatformKeys.KEY_PREFERRED_LINKTYPE) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.KEY_PREFERRED_LINKTYPE)) && configuration.getPreferredLinkType() != null) {
        assertThat(configuration.getPreferredLinkType()).isEqualTo(getEnum(expectedResponseData, PlatformKeys.KEY_PREFERRED_LINKTYPE, LinkType.class));
    }
    if (expectedResponseData.containsKey(PlatformKeys.OSGP_IP_ADDRESS) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.OSGP_IP_ADDRESS))) {
        assertThat(configuration.getOsgpIpAddress()).isEqualTo(getString(expectedResponseData, PlatformKeys.OSGP_IP_ADDRESS));
    }
    if (expectedResponseData.containsKey(PlatformKeys.OSGP_PORT) && StringUtils.isNotBlank(expectedResponseData.get(PlatformKeys.OSGP_PORT))) {
        assertThat(configuration.getOsgpPortNumber()).isEqualTo(getInteger(expectedResponseData, PlatformKeys.OSGP_PORT));
    }
}
Also used : LightType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType) GetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest) AsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest) DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration) RelayConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration) Configuration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) GetConfigurationResponse(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse) IndexAddressMap(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap) GetConfigurationAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest) RelayType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayType) OsgpResultType(org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType) RelayConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration) RelayMap(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayMap) LinkType(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType) Then(io.cucumber.java.en.Then)

Example 3 with DaliConfiguration

use of org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration in project open-smart-grid-platform by OSGP.

the class ConfigurationManagementMapperTest method aSourceDaliConfiguration.

private DaliConfiguration aSourceDaliConfiguration(final int numberOfLights, final int index1, final int address1, final int index2, final int address2) {
    final DaliConfiguration daliConfiguration = new DaliConfiguration();
    daliConfiguration.setNumberOfLights(numberOfLights);
    daliConfiguration.getIndexAddressMap().add(this.aSourceIndexAddressMap(index1, address1));
    daliConfiguration.getIndexAddressMap().add(this.aSourceIndexAddressMap(index2, address2));
    return daliConfiguration;
}
Also used : DaliConfiguration(org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration)

Aggregations

DaliConfiguration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.DaliConfiguration)3 IndexAddressMap (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.IndexAddressMap)2 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)2 Then (io.cucumber.java.en.Then)1 AsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.common.AsyncRequest)1 OsgpResultType (org.opensmartgridplatform.adapter.ws.schema.core.common.OsgpResultType)1 Configuration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.Configuration)1 GetConfigurationAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationAsyncRequest)1 GetConfigurationResponse (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.GetConfigurationResponse)1 LightType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LightType)1 LinkType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.LinkType)1 RelayConfiguration (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayConfiguration)1 RelayMap (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayMap)1 RelayType (org.opensmartgridplatform.adapter.ws.schema.core.configurationmanagement.RelayType)1