Search in sources :

Example 1 with OutageDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto in project open-smart-grid-platform by OSGP.

the class DataObjectToOutageListConverter method convert.

public List<OutageDto> convert(final DataObject source) throws ProtocolAdapterException {
    final List<OutageDto> eventList = new ArrayList<>();
    if (source == null) {
        throw new ProtocolAdapterException("DataObject should not be null");
    }
    final List<DataObject> dataObjects = source.getValue();
    for (final DataObject dataObject : dataObjects) {
        eventList.add(this.getOutageDto(dataObject));
    }
    return eventList;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) OutageDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto) ArrayList(java.util.ArrayList) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 2 with OutageDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto in project open-smart-grid-platform by OSGP.

the class DataObjectToOutageListConverter method getOutageDto.

private OutageDto getOutageDto(final DataObject outageDataObject) throws ProtocolAdapterException {
    final List<DataObject> outageData = outageDataObject.getValue();
    if (outageData == null) {
        throw new ProtocolAdapterException("outageData DataObject should not be null");
    }
    if (outageData.size() != NUMBER_OF_ELEMENTS) {
        throw new ProtocolAdapterException("outageData size should be " + NUMBER_OF_ELEMENTS);
    }
    final DateTime endTime = this.extractDateTime(outageData);
    final Long duration = this.extractEventDuration(outageData);
    final OutageDto outage = new OutageDto(endTime, duration);
    log.info("Converted dataObject to outage: {}", outage);
    return outage;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) OutageDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) DateTime(org.joda.time.DateTime)

Aggregations

DataObject (org.openmuc.jdlms.datatypes.DataObject)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 OutageDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1