Search in sources :

Example 1 with PushObject

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

the class PushSetupAlarmMappingTest method createPushObjectList.

private static List<PushObject> createPushObjectList() {
    final PushObject pushObject = new PushObject();
    final ObisCodeValues obisCode = new ObisCodeValues();
    obisCode.setA((short) PUSH_OBJECT_OBIS_CODE.getA());
    obisCode.setB((short) PUSH_OBJECT_OBIS_CODE.getB());
    obisCode.setC((short) PUSH_OBJECT_OBIS_CODE.getC());
    obisCode.setD((short) PUSH_OBJECT_OBIS_CODE.getD());
    obisCode.setE((short) PUSH_OBJECT_OBIS_CODE.getE());
    obisCode.setF((short) PUSH_OBJECT_OBIS_CODE.getF());
    pushObject.setClassId(PUSH_OBJECT_CLASS_ID);
    pushObject.setLogicalName(obisCode);
    pushObject.setAttributeIndex((byte) PUSH_OBJECT_ATTRIBUTE_ID);
    pushObject.setDataIndex(PUSH_OBJECT_DATA_INDEX);
    return Collections.singletonList(pushObject);
}
Also used : ObisCodeValues(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ObisCodeValues) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject)

Example 2 with PushObject

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

the class PushObjectConverter method convertTo.

@Override
public PushObject convertTo(final CosemObjectDefinition source, final Type<PushObject> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final ObisCodeValues obisCodeValues = this.mapperFacade.map(source.getLogicalName(), ObisCodeValues.class);
    final PushObject convertedPushObject = new PushObject();
    convertedPushObject.setClassId(source.getClassId());
    convertedPushObject.setLogicalName(obisCodeValues);
    convertedPushObject.setAttributeIndex((byte) source.getAttributeIndex());
    convertedPushObject.setDataIndex(source.getDataIndex());
    return convertedPushObject;
}
Also used : ObisCodeValues(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ObisCodeValues) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject)

Example 3 with PushObject

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

the class PushSetupAlarmConverter method convertTo.

@Override
public org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm convertTo(final PushSetupAlarm source, final Type<org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm pushSetupAlarm = new org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm();
    if (source.hasSendDestinationAndMethod()) {
        final SendDestinationAndMethod sendDestinationAndMethod = source.getSendDestinationAndMethod();
        final String destination = sendDestinationAndMethod.getDestination();
        if (!destination.matches("\\S++:\\d++")) {
            throw new IllegalArgumentException("Unable to parse destination as \"<host>:<port>\": " + destination);
        }
        final String[] hostAndPort = destination.split(":");
        pushSetupAlarm.setHost(hostAndPort[0]);
        pushSetupAlarm.setPort(new BigInteger(hostAndPort[1]));
    }
    if (source.hasPushObjectList()) {
        final List<PushObject> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), PushObject.class);
        pushSetupAlarm.getPushObjectList().addAll(convertedPushObjectList);
    }
    return pushSetupAlarm;
}
Also used : SendDestinationAndMethod(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) BigInteger(java.math.BigInteger)

Example 4 with PushObject

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

the class SetPushSetupAlarmRequestBuilder method getPushObjectList.

private List<PushObject> getPushObjectList(final Map<String, String> parameters) {
    final List<String> pushObjectClassIds = Arrays.asList(getString(parameters, "PushObjectClassIds", DEFAULT_CLASS_IDS).split(","));
    final List<String> pushObjectObisCodes = Arrays.asList(getString(parameters, "PushObjectObisCodes", DEFAULT_OBIS_CODES).split(","));
    final List<String> pushObjectAttributeIds = Arrays.asList(getString(parameters, "PushObjectAttributeIds", DEFAULT_ATTRIBUTE_IDS).split(","));
    final List<String> pushObjectDataIndexes = Arrays.asList(getString(parameters, "PushObjectDataIndexes", DEFAULT_DATA_INDEXES).split(","));
    return IntStream.range(0, pushObjectClassIds.size()).mapToObj(i -> {
        final PushObject pushObject = new PushObject();
        pushObject.setClassId(Integer.parseInt(pushObjectClassIds.get(i)));
        pushObject.setLogicalName(this.convertObisCode(pushObjectObisCodes.get(i)));
        pushObject.setAttributeIndex(Byte.parseByte(pushObjectAttributeIds.get(i)));
        pushObject.setDataIndex(Integer.parseInt(pushObjectDataIndexes.get(i)));
        return pushObject;
    }).collect(Collectors.toList());
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) SetPushSetupAlarmRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.SetPushSetupAlarmRequest) ObisCodeValues(org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ObisCodeValues) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) Collectors(java.util.stream.Collectors) List(java.util.List) ReadSettingsHelper.getInteger(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger) Map(java.util.Map) PlatformSmartmeteringKeys(org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys) BigInteger(java.math.BigInteger) Collections(java.util.Collections) PushSetupAlarm(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)

Example 5 with PushObject

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

the class PushSetupAlarmConverter method convertFrom.

@Override
public PushSetupAlarm convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm source, final Type<PushSetupAlarm> destinationType, final MappingContext context) {
    if (source == null) {
        return null;
    }
    final PushSetupAlarm.Builder builder = new PushSetupAlarm.Builder();
    if (source.getHost() != null && source.getPort() != null) {
        final String destination = source.getHost() + ":" + source.getPort();
        final SendDestinationAndMethod sendDestinationAndMethod = new SendDestinationAndMethod(TransportServiceType.TCP, destination, MessageType.A_XDR_ENCODED_X_DLMS_APDU);
        builder.withSendDestinationAndMethod(sendDestinationAndMethod);
    }
    final List<PushObject> sourcePushObjects = source.getPushObjectList();
    if (sourcePushObjects != null) {
        final List<CosemObjectDefinition> convertedPushObjectList = this.mapperFacade.mapAsList(source.getPushObjectList(), CosemObjectDefinition.class);
        builder.withPushObjectList(convertedPushObjectList);
    }
    return builder.build();
}
Also used : SendDestinationAndMethod(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod) PushSetupAlarm(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm) PushObject(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject) CosemObjectDefinition(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)

Aggregations

PushObject (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushObject)5 ObisCodeValues (org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.ObisCodeValues)3 BigInteger (java.math.BigInteger)2 PushSetupAlarm (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PushSetupAlarm)2 SendDestinationAndMethod (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SendDestinationAndMethod)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 SetPushSetupAlarmRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.SetPushSetupAlarmRequest)1 PushSetupAlarm (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.PushSetupAlarm)1 ReadSettingsHelper.getInteger (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 PlatformSmartmeteringKeys (org.opensmartgridplatform.cucumber.platform.smartmetering.PlatformSmartmeteringKeys)1 CosemObjectDefinition (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CosemObjectDefinition)1