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