Search in sources :

Example 1 with ConfigurationFlag

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.

the class SimulatedConfigurationObjectSteps method createFlagsForConfigurationObject.

private JsonNode createFlagsForConfigurationObject(final ConfigurationFlags configurationFlags, final JsonNodeFactory jsonNodeFactory) {
    final int bitStringLength = 16;
    final char[] flags = new char[bitStringLength];
    for (int i = 0; i < bitStringLength; i++) {
        flags[i] = '0';
    }
    if (configurationFlags != null && configurationFlags.getConfigurationFlag() != null) {
        final List<ConfigurationFlag> configurationFlagList = configurationFlags.getConfigurationFlag();
        for (final ConfigurationFlag configurationFlag : configurationFlagList) {
            if (configurationFlag.isEnabled()) {
                flags[configurationFlag.getConfigurationFlagType().ordinal()] = '1';
            }
        }
    }
    return this.jsonObjectCreator.createAttributeValue("bit-string", new String(flags), jsonNodeFactory);
}
Also used : ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag)

Example 2 with ConfigurationFlag

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.

the class ConfigurationObjectFactory method setConfigurationFlags.

private static void setConfigurationFlags(final ConfigurationObject configurationObject, final Map<String, String> requestParameters) {
    if (!hasConfigurationFlags(requestParameters)) {
        return;
    }
    final ConfigurationFlags configurationFlags = new ConfigurationFlags();
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    final int numberOfFlags = Integer.parseInt(requestParameters.get(PlatformSmartmeteringKeys.CONFIGURATION_FLAG_COUNT));
    for (int i = 1; i <= numberOfFlags; i++) {
        configurationFlagList.add(getConfigurationFlag(requestParameters, i));
    }
    configurationFlags.getConfigurationFlag().addAll(configurationFlagList);
    configurationObject.setConfigurationFlags(configurationFlags);
}
Also used : ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)

Example 3 with ConfigurationFlag

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.

the class ConfigurationObjectFactory method forGprsOperationModeAndFlags.

public static ConfigurationObject forGprsOperationModeAndFlags(final GprsOperationModeType gprsOperationMode, final Set<ConfigurationFlagType> enableFlags, final Set<ConfigurationFlagType> disableFlags) {
    final ConfigurationObject configurationObject = new ConfigurationObject();
    configurationObject.setGprsOperationMode(gprsOperationMode);
    final List<ConfigurationFlag> configurationFlagList = new ArrayList<>();
    configurationFlagList.addAll(getFlags(enableFlags, true));
    configurationFlagList.addAll(getFlags(disableFlags, false));
    if (!configurationFlagList.isEmpty()) {
        final ConfigurationFlags configurationFlags = new ConfigurationFlags();
        configurationFlags.getConfigurationFlag().addAll(configurationFlagList);
        configurationObject.setConfigurationFlags(configurationFlags);
    }
    return configurationObject;
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject) ArrayList(java.util.ArrayList) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)

Example 4 with ConfigurationFlag

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.

the class ConfigurationObjectFactory method getConfigurationFlag.

private static ConfigurationFlag getConfigurationFlag(final Map<String, String> parameters, final int index) {
    final ConfigurationFlag configurationFlag = new ConfigurationFlag();
    configurationFlag.setConfigurationFlagType(getConfigurationFlagType(parameters, index));
    configurationFlag.setEnabled(getConfigurationFlagEnabled(parameters, index));
    return configurationFlag;
}
Also used : ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag)

Example 5 with ConfigurationFlag

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectRequestMappingTest method testWithCompleteObject.

/**
 * Tests if mapping succeeds with a complete SetConfigurationRequestData object.
 */
@Test
public void testWithCompleteObject() {
    // build test data
    final ConfigurationObject configurationObject = new ConfigurationObject();
    final ConfigurationFlag configurationFlag = new ConfigurationFlag();
    configurationFlag.setConfigurationFlagType(FLAGTYPE);
    configurationFlag.setEnabled(ISENABLED);
    final ConfigurationFlags configurationFlags = new ConfigurationFlags();
    configurationFlags.getConfigurationFlag().add(configurationFlag);
    configurationObject.setConfigurationFlags(configurationFlags);
    configurationObject.setGprsOperationMode(GPRSTYPE);
    final SetConfigurationObjectRequestData setConfigurationObjectRequestData = new SetConfigurationObjectRequestData();
    setConfigurationObjectRequestData.setConfigurationObject(configurationObject);
    final SetConfigurationObjectRequest requestOriginal = new SetConfigurationObjectRequest();
    requestOriginal.setDeviceIdentification(DEVICE_ID);
    requestOriginal.setSetConfigurationObjectRequestData(setConfigurationObjectRequestData);
    // actual mapping
    final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest requestMapped = this.configurationMapper.map(requestOriginal, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SetConfigurationObjectRequest.class);
    // check mapping
    assertThat(requestMapped).isNotNull();
    assertThat(requestMapped.getDeviceIdentification()).isEqualTo(DEVICE_ID);
    assertThat(requestMapped.getSetConfigurationObjectRequestData()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getGprsOperationMode()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0)).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0).getConfigurationFlagType()).isNotNull();
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getGprsOperationMode().name()).isEqualTo(GPRSTYPE.name());
    assertThat(requestMapped.getSetConfigurationObjectRequestData().getConfigurationObject().getConfigurationFlags().getFlags().get(0).getConfigurationFlagType().name()).isEqualTo(FLAGTYPE.name());
}
Also used : ConfigurationObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject) SetConfigurationObjectRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequest) ConfigurationFlag(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag) ConfigurationFlags(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags) SetConfigurationObjectRequestData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequestData) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationFlag (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlag)7 ArrayList (java.util.ArrayList)3 ConfigurationFlags (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlags)3 ConfigurationObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationObject)2 Test (org.junit.jupiter.api.Test)1 ConfigurationFlagType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.ConfigurationFlagType)1 SetConfigurationObjectRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequest)1 SetConfigurationObjectRequestData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SetConfigurationObjectRequestData)1