Search in sources :

Example 1 with MessageTypeDto

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

the class DlmsHelper method readSendDestinationAndMethod.

public SendDestinationAndMethodDto readSendDestinationAndMethod(final DataObject resultData, final String description) throws ProtocolAdapterException {
    final List<DataObject> sendDestinationAndMethodElements = this.readList(resultData, description);
    if (sendDestinationAndMethodElements == null) {
        return null;
    }
    final TransportServiceTypeDto transportService = this.readTransportServiceType(sendDestinationAndMethodElements.get(0), "Transport Service from " + description);
    final String destination = this.readString(sendDestinationAndMethodElements.get(1), "Destination from " + description);
    final MessageTypeDto message = this.readMessageType(sendDestinationAndMethodElements.get(2), "Message from " + description);
    return new SendDestinationAndMethodDto(transportService, destination, message);
}
Also used : SendDestinationAndMethodDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SendDestinationAndMethodDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) TransportServiceTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.TransportServiceTypeDto) BitString(org.openmuc.jdlms.datatypes.BitString) MessageTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MessageTypeDto)

Example 2 with MessageTypeDto

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

the class DlmsHelper method readMessageType.

public MessageTypeDto readMessageType(final DataObject resultData, final String description) throws ProtocolAdapterException {
    final Number number = this.readNumber(resultData, description, "Enum");
    if (number == null) {
        return null;
    }
    final MessageTypeDto message;
    final int enumValue = number.intValue();
    switch(enumValue) {
        case 0:
            message = MessageTypeDto.A_XDR_ENCODED_X_DLMS_APDU;
            break;
        case 1:
            message = MessageTypeDto.XML_ENCODED_X_DLMS_APDU;
            break;
        default:
            if (enumValue < 128 || enumValue > 255) {
                LOGGER.error("Unexpected Enum value for MessageType: {}", enumValue);
                throw new ProtocolAdapterException("Unknown Enum value for MessageType: " + enumValue);
            }
            message = MessageTypeDto.MANUFACTURER_SPECIFIC;
    }
    return message;
}
Also used : ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) MessageTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MessageTypeDto)

Aggregations

MessageTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.MessageTypeDto)2 BitString (org.openmuc.jdlms.datatypes.BitString)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 SendDestinationAndMethodDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SendDestinationAndMethodDto)1 TransportServiceTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.TransportServiceTypeDto)1