Search in sources :

Example 86 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class GetAssociationLnObjectsCommandExecutor method convertMethodAccessDescriptor.

private MethodAccessDescriptorDto convertMethodAccessDescriptor(final List<DataObject> methodAccessDescriptor) throws ProtocolAdapterException {
    final List<MethodAccessItemDto> methodAccessItems = new ArrayList<>();
    for (final DataObject methodAccessItemRaw : methodAccessDescriptor) {
        final List<DataObject> methodAccessItem = methodAccessItemRaw.getValue();
        methodAccessItems.add(new MethodAccessItemDto(this.dlmsHelper.readLong(methodAccessItem.get(ACCESS_RIGHTS_METHOD_ACCESS_METHOD_ID_INDEX), "").intValue(), MethodAccessModeTypeDto.values()[this.dlmsHelper.readLong(methodAccessItem.get(ACCESS_RIGHTS_METHOD_ACCESS_ACCESS_MODE_INDEX), "").intValue()]));
    }
    return new MethodAccessDescriptorDto(methodAccessItems);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) MethodAccessItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessItemDto) ArrayList(java.util.ArrayList) MethodAccessDescriptorDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.MethodAccessDescriptorDto)

Example 87 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class DeviceChannelsHelper method readIdentificationNumber.

private String readIdentificationNumber(final List<GetResult> resultList, final int index, final DlmsObject clientSetupObject, final String description) throws ProtocolAdapterException {
    final GetResult getResult = resultList.get(index);
    final DataObject resultData = getResult.getResultData();
    if (resultData == null) {
        return null;
    } else {
        final Long identification = this.dlmsHelper.readLong(resultData, description);
        final IdentificationNumber identificationNumber;
        if (this.identificationNumberStoredAsBcdOnDevice(clientSetupObject)) {
            identificationNumber = IdentificationNumber.fromBcdRepresentationAsLong(identification);
        } else {
            identificationNumber = IdentificationNumber.fromNumericalRepresentation(identification);
        }
        return identificationNumber.getTextualRepresentation();
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult)

Example 88 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class ImageTransfer method imageTransferEnabled.

/**
 * Check image transfer enabled value of the COSEM server.
 *
 * @return image transfer enabled
 */
public boolean imageTransferEnabled() throws ProtocolAdapterException {
    this.connector.getDlmsMessageListener().setDescription("ImageTransfer read image_transfer_enabled, read attribute: " + JdlmsObjectToStringUtil.describeAttributes(this.imageTransferCosem.createAttributeAddress(ImageTransferAttribute.IMAGE_TRANSFER_ENABLED)));
    final DataObject transferEnabled = this.imageTransferCosem.readAttribute(ImageTransferAttribute.IMAGE_TRANSFER_ENABLED);
    if (transferEnabled == null || !transferEnabled.isBoolean()) {
        throw new ProtocolAdapterException(EXCEPTION_MSG_IMAGE_TRANSFER_ENABLED_NOT_READ);
    }
    return (Boolean) transferEnabled.getValue();
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 89 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class ImageTransfer method activateImage.

/**
 * The image is activated.
 */
public void activateImage() throws OsgpException {
    final DataObject parameter = DataObject.newInteger8Data((byte) 0);
    this.setDescriptionForMethodCall(ImageTransferMethod.IMAGE_ACTIVATE, parameter);
    final MethodResultCode imageActivate = this.imageTransferCosem.callMethod(ImageTransferMethod.IMAGE_ACTIVATE, parameter);
    if (imageActivate == null) {
        throw new ProtocolAdapterException(EXCEPTION_MSG_IMAGE_ACTIVATE_NOT_CALLED);
    }
}
Also used : MethodResultCode(org.openmuc.jdlms.MethodResultCode) DataObject(org.openmuc.jdlms.datatypes.DataObject) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 90 with DataObject

use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.

the class ImageTransfer method readImageBlockSize.

private int readImageBlockSize() throws ProtocolAdapterException {
    this.connector.getDlmsMessageListener().setDescription("ImageTransfer read image_block_size, read attribute: " + JdlmsObjectToStringUtil.describeAttributes(this.imageTransferCosem.createAttributeAddress(ImageTransferAttribute.IMAGE_BLOCK_SIZE)));
    final DataObject imageBlockSizeData = this.imageTransferCosem.readAttribute(ImageTransferAttribute.IMAGE_BLOCK_SIZE);
    if (imageBlockSizeData == null || !imageBlockSizeData.isNumber()) {
        throw new ProtocolAdapterException(EXCEPTION_MSG_IMAGE_BLOCK_SIZE_NOT_READ);
    }
    final Long imageBlockSizeValue = imageBlockSizeData.getValue();
    this.imageBlockSize = imageBlockSizeValue.intValue();
    this.imageBlockSizeReadFlag = true;
    return this.imageBlockSize;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Aggregations

DataObject (org.openmuc.jdlms.datatypes.DataObject)176 ArrayList (java.util.ArrayList)46 AttributeAddress (org.openmuc.jdlms.AttributeAddress)36 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)34 Test (org.junit.jupiter.api.Test)31 GetResult (org.openmuc.jdlms.GetResult)23 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)16 DateTime (org.joda.time.DateTime)15 CosemDateTime (org.openmuc.jdlms.datatypes.CosemDateTime)14 SetParameter (org.openmuc.jdlms.SetParameter)12 DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)11 BitString (org.openmuc.jdlms.datatypes.BitString)10 ObisCode (org.openmuc.jdlms.ObisCode)9 IOException (java.io.IOException)8 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)7 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)6 List (java.util.List)5 MethodResultCode (org.openmuc.jdlms.MethodResultCode)5 AttributeAddressForProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.AttributeAddressForProfile)5 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)5