Search in sources :

Example 1 with SetParameter

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

the class ClearAlarmRegisterCommandExecutor method executeForAlarmRegister.

public AccessResultCode executeForAlarmRegister(final DlmsConnectionManager conn, final AttributeAddress alarmRegisterAttributeAddress) {
    log.info("Clear alarm register {}", JdlmsObjectToStringUtil.describeAttributes(alarmRegisterAttributeAddress));
    final DataObject data = DataObject.newUInteger32Data(ALARM_CODE);
    final SetParameter setParameter = new SetParameter(alarmRegisterAttributeAddress, data);
    conn.getDlmsMessageListener().setDescription("ClearAlarmRegister, with alarm code = " + ALARM_CODE + JdlmsObjectToStringUtil.describeAttributes(alarmRegisterAttributeAddress));
    try {
        return conn.getConnection().set(setParameter);
    } catch (final IOException e) {
        throw new ConnectionException(e);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) IOException(java.io.IOException) SetParameter(org.openmuc.jdlms.SetParameter) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)

Example 2 with SetParameter

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

the class SetConfigurationObjectService method setConfigurationObject.

public AccessResultCode setConfigurationObject(final DlmsConnectionManager conn, final ConfigurationObjectDto configurationToSet, final ConfigurationObjectDto configurationOnDevice) throws ProtocolAdapterException {
    final DataObject dataObject = this.buildSetParameterData(configurationToSet, configurationOnDevice);
    LOGGER.info("ConfigurationObject SetParameter Data : {}", this.dlmsHelper.getDebugInfo(dataObject));
    final AttributeAddress attributeAddress = AttributeAddressFactory.getConfigurationObjectAddress();
    final SetParameter setParameter = new SetParameter(attributeAddress, dataObject);
    conn.getDlmsMessageListener().setDescription("SetConfigurationObject AttributeAddress: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
    return this.getAccessResultCode(conn, setParameter);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) SetParameter(org.openmuc.jdlms.SetParameter)

Example 3 with SetParameter

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

the class SetSpecialDaysCommandExecutor method execute.

@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final List<SpecialDayDto> specialDays, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final StringBuilder specialDayData = new StringBuilder();
    final List<DataObject> specialDayEntries = new ArrayList<>();
    int i = 0;
    for (final SpecialDayDto specialDay : specialDays) {
        specialDayData.append(", ").append(specialDay.getDayId()).append(" => ").append(specialDay.getSpecialDayDate());
        final List<DataObject> specDayEntry = new ArrayList<>();
        specDayEntry.add(DataObject.newUInteger16Data(i));
        specDayEntry.add(this.dlmsHelper.asDataObject(specialDay.getSpecialDayDate()));
        specDayEntry.add(DataObject.newUInteger8Data((short) specialDay.getDayId()));
        final DataObject dayStruct = DataObject.newStructureData(specDayEntry);
        specialDayEntries.add(dayStruct);
        i += 1;
    }
    final AttributeAddress specialDaysTableEntries = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
    final DataObject entries = DataObject.newArrayData(specialDayEntries);
    final SetParameter request = new SetParameter(specialDaysTableEntries, entries);
    final String specialDayValues;
    if (specialDayData.length() == 0) {
        specialDayValues = "";
    } else {
        specialDayValues = ", values [" + specialDayData.substring(2) + "]";
    }
    conn.getDlmsMessageListener().setDescription("SetSpecialDays" + specialDayValues + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(specialDaysTableEntries));
    try {
        return conn.getConnection().set(request);
    } catch (final IOException e) {
        throw new ConnectionException(e);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) IOException(java.io.IOException) SetParameter(org.openmuc.jdlms.SetParameter) SpecialDayDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SpecialDayDto) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)

Example 4 with SetParameter

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

the class SynchronizeTimeCommandExecutor method execute.

@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final SynchronizeTimeRequestDto synchronizeTimeRequestDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final DateTime dt = DateTime.now();
    final DataObject time = this.dlmsHelper.asDataObject(dt, synchronizeTimeRequestDto.getDeviation(), synchronizeTimeRequestDto.isDst());
    final SetParameter setParameter = new SetParameter(ATTRIBUTE_TIME, time);
    conn.getDlmsMessageListener().setDescription("SynchronizeTime to " + dt + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_TIME));
    try {
        return conn.getConnection().set(setParameter);
    } catch (final IOException e) {
        throw new ConnectionException(e);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) IOException(java.io.IOException) SetParameter(org.openmuc.jdlms.SetParameter) DateTime(org.joda.time.DateTime) ConnectionException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)

Example 5 with SetParameter

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

the class SetRandomisationSettingsCommandExecutor method writeRandomisationSettings.

private void writeRandomisationSettings(final DlmsConnectionManager conn, final DlmsDevice device, final int randomisationStartWindow, final int multiplicationFactor, final int numberOfRetries) throws ProtocolAdapterException {
    final AttributeAddress randomisationSettingsAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.RANDOMISATION_SETTINGS, null);
    final DataObject randomisationStartWindowObject = DataObject.newUInteger32Data(randomisationStartWindow);
    final DataObject multiplicationFactorObject = DataObject.newUInteger16Data(multiplicationFactor);
    final DataObject numberOfRetriesObject = DataObject.newUInteger16Data(numberOfRetries);
    final DataObject randomisationSettingsObject = DataObject.newStructureData(randomisationStartWindowObject, multiplicationFactorObject, numberOfRetriesObject);
    final SetParameter setRandomisationSettings = new SetParameter(randomisationSettingsAddress, randomisationSettingsObject);
    this.writeAttribute(conn, setRandomisationSettings);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) AttributeAddress(org.openmuc.jdlms.AttributeAddress) SetParameter(org.openmuc.jdlms.SetParameter)

Aggregations

SetParameter (org.openmuc.jdlms.SetParameter)31 AttributeAddress (org.openmuc.jdlms.AttributeAddress)14 DataObject (org.openmuc.jdlms.datatypes.DataObject)12 AccessResultCode (org.openmuc.jdlms.AccessResultCode)11 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)5 ConnectionException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ConnectionException)4 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)4 ActivityCalendarDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActivityCalendarDto)4 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 CosemDateDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateDto)3 CosemTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemTimeDto)3 PushSetupAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushSetupAlarmDto)3 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 CosemDateTime (org.openmuc.jdlms.datatypes.CosemDateTime)1 DlmsObjectConfigConfiguration (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigConfiguration)1 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)1