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