Search in sources :

Example 16 with SetParameter

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

the class ClearMBusStatusOnAllChannelsCommandExecutor method setClearStatusMask.

private AccessResultCode setClearStatusMask(final long statusMask, final DlmsConnectionManager conn, final Integer channel, final AttributeAddress attributeAddress) throws IOException {
    final SetParameter parameter = new SetParameter(attributeAddress, DataObject.newUInteger32Data(statusMask));
    conn.getDlmsMessageListener().setDescription("ClearMBusStatusOnAllChannels-setClearStatusMask for channel" + channel + " - writing status mask " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
    log.info("Writing clear status mask {} for M-Bus channel {} with attributeAddress: {}.", statusMask, channel, attributeAddress);
    return conn.getConnection().set(parameter);
}
Also used : SetParameter(org.openmuc.jdlms.SetParameter)

Example 17 with SetParameter

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

the class SetAlarmNotificationsCommandExecutor method writeUpdatedAlarmNotifications.

private AccessResultCode writeUpdatedAlarmNotifications(final DlmsConnectionManager conn, final long alarmFilterLongValue, final AttributeAddress alarmFilterValue) throws IOException {
    final DataObject value = DataObject.newUInteger32Data(alarmFilterLongValue);
    final SetParameter setParameter = new SetParameter(alarmFilterValue, value);
    conn.getDlmsMessageListener().setDescription("SetAlarmNotifications write updated value " + alarmFilterLongValue + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(alarmFilterValue));
    return conn.getConnection().set(setParameter);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SetParameter(org.openmuc.jdlms.SetParameter)

Example 18 with SetParameter

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

the class SetClockConfigurationCommandExecutor method execute.

@Override
public Void execute(final DlmsConnectionManager conn, final DlmsDevice device, final SetClockConfigurationRequestDto object, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    this.dlmsLogWrite(conn, ATTRIBUTE_TIME_ZONE);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_TIME_ZONE, DataObject.newInteger16Data(object.getTimeZoneOffset())), "Timezone");
    final CosemDateTime daylightSavingsBegin = this.configurationMapper.map(object.getDaylightSavingsBegin(), CosemDateTime.class);
    this.dlmsLogWrite(conn, ATTRIBUTE_DAYLIGHT_SAVINGS_BEGIN);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_DAYLIGHT_SAVINGS_BEGIN, DataObject.newOctetStringData(daylightSavingsBegin.encode())), "Daylight savings begin");
    final CosemDateTime daylightSavingsEnd = this.configurationMapper.map(object.getDaylightSavingsEnd(), CosemDateTime.class);
    this.dlmsLogWrite(conn, ATTRIBUTE_DAYLIGHT_SAVINGS_END);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_DAYLIGHT_SAVINGS_END, DataObject.newOctetStringData(daylightSavingsEnd.encode())), "Daylight savinds end");
    this.dlmsLogWrite(conn, ATTRIBUTE_DAYLIGHT_SAVINGS_ENABLED);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_DAYLIGHT_SAVINGS_ENABLED, DataObject.newBoolData(object.isDaylightSavingsEnabled())), "Daylight savings enabled");
    return null;
}
Also used : CosemDateTime(org.openmuc.jdlms.datatypes.CosemDateTime) SetParameter(org.openmuc.jdlms.SetParameter)

Example 19 with SetParameter

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

the class ClearMBusStatusOnAllChannelsCommandExecutorTest method assertClearStatus.

private void assertClearStatus(final List<SetParameter> setParameters) {
    for (int i = 1; i <= 4; i++) {
        final SetParameter setParameter = setParameters.get(i - 1);
        assertThat(((Number) setParameter.getData().getValue()).longValue()).isEqualTo(STATUS_MASK);
        final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
        assertThat(attributeAddress.getInstanceId().asDecimalString()).isEqualTo(OBIS_CODE_TEMPLATE_CLEAR_STATUS.replaceAll("<c>", String.valueOf(i)));
        assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID_CLEAR_STATUS);
    }
}
Also used : AttributeAddress(org.openmuc.jdlms.AttributeAddress) SetParameter(org.openmuc.jdlms.SetParameter)

Example 20 with SetParameter

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

the class ConfigureDefinableLoadProfileCommandExecutor method writeCapturePeriod.

private void writeCapturePeriod(final DlmsConnectionManager conn, final long capturePeriod) throws ProtocolAdapterException {
    this.dlmsLogWrite(conn, ATTRIBUTE_CAPTURE_PERIOD, ATTRIBUTE_NAME_CAPTURE_PERIOD);
    this.writeAttribute(conn, new SetParameter(ATTRIBUTE_CAPTURE_PERIOD, DataObject.newUInteger32Data(capturePeriod)), ATTRIBUTE_NAME_CAPTURE_PERIOD);
}
Also used : 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