Search in sources :

Example 11 with DataObject

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

the class SetActivityCalendarCommandExecutor method getDayProfileTablePassiveExecutor.

private DataObjectAttrExecutor getDayProfileTablePassiveExecutor(final Set<DayProfileDto> dayProfileSet) {
    final AttributeAddress dayProfileTablePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_DAY_PROFILE_TABLE_PASSIVE);
    final DataObject dayArray = DataObject.newArrayData(this.configurationMapper.mapAsList(dayProfileSet, DataObject.class));
    LOGGER.info("DayProfileTablePassive to set is: {}", this.dlmsHelper.getDebugInfo(dayArray));
    return new DataObjectAttrExecutor("DAYS", dayProfileTablePassive, dayArray, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_DAY_PROFILE_TABLE_PASSIVE);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DataObjectAttrExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DataObjectAttrExecutor)

Example 12 with DataObject

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

the class DefinableLoadProfile method getCaptureObjectDefinitions.

private List<CaptureObject> getCaptureObjectDefinitions() {
    final List<DataObject> captureObjectList = this.captureObjects.getValue();
    final List<CaptureObject> captureObjectDefinitions = new ArrayList<>();
    for (final DataObject captureObject : captureObjectList) {
        captureObjectDefinitions.add(CaptureObject.newCaptureObject(captureObject));
    }
    return captureObjectDefinitions;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Example 13 with DataObject

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

the class DefinableLoadProfile method reinitializeCaptureObjects.

private void reinitializeCaptureObjects(final List<DataObject> captureObjectList) throws IllegalAttributeAccessException {
    final List<CaptureObject> captureObjectInitList = new ArrayList<>();
    for (final DataObject captureObject : captureObjectList) {
        final CaptureObject initCaptureObject;
        try {
            initCaptureObject = CaptureObject.newCaptureObject(captureObject);
        } catch (final RuntimeException e) {
            LOGGER.error("Unable to create capture object from: {}", captureObject, e);
            throw new IllegalAttributeAccessException(AccessResultCode.OTHER_REASON, new IllegalArgumentException("Unable to create capture object from: " + captureObject, e));
        }
        if (!PROCESSORS_BY_CAPTURE_OBJECT.containsKey(initCaptureObject)) {
            LOGGER.error("No data processor configured for {}", initCaptureObject);
            throw new IllegalAttributeAccessException(AccessResultCode.OTHER_REASON, new IllegalArgumentException("No data processor configured for " + initCaptureObject));
        }
        captureObjectInitList.add(initCaptureObject);
    }
    this.captureObjectDefinitionCollection = DefinableLoadProfile.initCaptureObjects(captureObjectInitList);
}
Also used : IllegalAttributeAccessException(org.openmuc.jdlms.IllegalAttributeAccessException) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Example 14 with DataObject

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

the class ImageTransfer method setImageToActivateInfo.

private void setImageToActivateInfo() {
    /**
     * Expected image size is returned instead of the real received number of bytes. Real received
     * number of bytes is different because of 0 padded transfer blocks.
     */
    final DataObject imageInfo = DataObject.newStructureData(Arrays.asList(DataObject.newUInteger32Data(this.expectedImageSize), DataObject.newOctetStringData(this.identification), DataObject.newOctetStringData(this.signature)));
    this.imageToActivateInfo = DataObject.newArrayData(Arrays.asList(imageInfo));
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject)

Example 15 with DataObject

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

the class CaptureObjectDefinitionCollection method captureObjectsAsDataObject.

public DataObject captureObjectsAsDataObject() {
    final List<DataObject> initList = new ArrayList<>();
    final List<CaptureObject> captureObjects = this.allCaptureObjects();
    for (final CaptureObject captureObject : captureObjects) {
        initList.add(captureObject.asDataObject());
    }
    return DataObject.newArrayData(initList);
}
Also used : CaptureObject(org.opensmartgridplatform.simulator.protocol.dlms.cosem.CaptureObject) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

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