Search in sources :

Example 71 with ProtocolAdapterException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.

the class SetPushSetupAlarmCommandExecutor method setSendDestinationAndMethod.

private AccessResultCode setSendDestinationAndMethod(final DlmsConnectionManager conn, final PushSetupAlarmDto pushSetupAlarm) throws ProtocolAdapterException {
    LOGGER.info("Setting Send destination and method of Push Setup Alarm: {}", pushSetupAlarm.getSendDestinationAndMethod());
    final SetParameter setParameterSendDestinationAndMethod = this.getSetParameterSendDestinationAndMethod(pushSetupAlarm);
    final AccessResultCode resultCode = this.doSetRequest("PushSetupAlarm, Send destination and method", conn, setParameterSendDestinationAndMethod);
    if (resultCode != null) {
        return resultCode;
    } else {
        throw new ProtocolAdapterException("Error setting Alarm push setup data (destination and method.");
    }
}
Also used : AccessResultCode(org.openmuc.jdlms.AccessResultCode) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SetParameter(org.openmuc.jdlms.SetParameter)

Example 72 with ProtocolAdapterException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.

the class SetPushSetupAlarmCommandExecutor method setPushObjectList.

private AccessResultCode setPushObjectList(final DlmsConnectionManager conn, final PushSetupAlarmDto pushSetupAlarm) throws ProtocolAdapterException {
    LOGGER.info("Setting Push Object List of Push Setup Alarm: {}", pushSetupAlarm.getPushObjectList());
    // Before setting the push object list, verify if the objects in the list are really present in
    // the meter
    this.verifyPushObjects(pushSetupAlarm.getPushObjectList(), conn);
    final SetParameter setParameterPushObjectList = this.getSetParameterPushObjectList(pushSetupAlarm);
    final AccessResultCode resultCode = this.doSetRequest("PushSetupAlarm, push object list", conn, setParameterPushObjectList);
    if (resultCode != null) {
        return resultCode;
    } else {
        throw new ProtocolAdapterException("Error setting Alarm push setup data (push object list).");
    }
}
Also used : AccessResultCode(org.openmuc.jdlms.AccessResultCode) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) SetParameter(org.openmuc.jdlms.SetParameter)

Example 73 with ProtocolAdapterException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.

the class ImageTransfer method waitForImageInitiation.

private void waitForImageInitiation() throws OsgpException {
    final Future<Integer> newStatus = EXECUTOR_SERVICE.submit(new ImageTransferStatusChangeWatcher(ImageTransferStatus.NOT_INITIATED, this.properties.getInitiationStatusCheckInterval(), this.properties.getInitiationStatusCheckTimeout()));
    final int status;
    try {
        status = newStatus.get();
    } catch (final InterruptedException | ExecutionException e) {
        throw new ProtocolAdapterException("", e);
    }
    if (status != ImageTransferStatus.INITIATED.getValue()) {
        throw new ImageTransferException(EXCEPTION_MSG_IMAGE_TRANSFER_NOT_INITIATED);
    }
}
Also used : ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) ExecutionException(java.util.concurrent.ExecutionException) ImageTransferException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ImageTransferException)

Example 74 with ProtocolAdapterException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.

the class ImageTransfer method waitForImageVerification.

private void waitForImageVerification() throws OsgpException {
    final Future<Integer> newStatus = EXECUTOR_SERVICE.submit(new ImageTransferStatusChangeWatcher(ImageTransferStatus.VERIFICATION_INITIATED, this.properties.getVerificationStatusCheckInterval(), this.properties.getVerificationStatusCheckTimeout()));
    final int status;
    try {
        status = newStatus.get();
    } catch (final InterruptedException | ExecutionException e) {
        throw new ProtocolAdapterException("", e);
    }
    if (status == ImageTransferStatus.VERIFICATION_FAILED.getValue()) {
        throw new ImageTransferException(EXCEPTION_MSG_IMAGE_NOT_VERIFIED);
    }
}
Also used : ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) ExecutionException(java.util.concurrent.ExecutionException) ImageTransferException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ImageTransferException)

Example 75 with ProtocolAdapterException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException in project open-smart-grid-platform by OSGP.

the class ImageTransfer method getImageTransferStatus.

private int getImageTransferStatus() throws ProtocolAdapterException {
    this.connector.getDlmsMessageListener().setDescription("ImageTransfer read image_transfer_status, read attribute: " + JdlmsObjectToStringUtil.describeAttributes(this.imageTransferCosem.createAttributeAddress(ImageTransferAttribute.IMAGE_TRANSFER_STATUS)));
    final DataObject imageTransferStatusData = this.imageTransferCosem.readAttribute(ImageTransferAttribute.IMAGE_TRANSFER_STATUS);
    if (imageTransferStatusData == null || !imageTransferStatusData.isNumber()) {
        throw new ProtocolAdapterException(EXCEPTION_MSG_IMAGE_TRANSFER_STATUS_NOT_READ);
    }
    return (Integer) imageTransferStatusData.getValue();
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Aggregations

ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)95 DataObject (org.openmuc.jdlms.datatypes.DataObject)32 Test (org.junit.jupiter.api.Test)22 AccessResultCode (org.openmuc.jdlms.AccessResultCode)15 GetResult (org.openmuc.jdlms.GetResult)15 AttributeAddress (org.openmuc.jdlms.AttributeAddress)14 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)10 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)9 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)9 BitString (org.openmuc.jdlms.datatypes.BitString)7 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)7 ObisCode (org.openmuc.jdlms.ObisCode)6 SetParameter (org.openmuc.jdlms.SetParameter)5 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)5 DateTime (org.joda.time.DateTime)4 DlmsObjectType (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType)4 ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)4 Date (java.util.Date)3 List (java.util.List)3