use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutorTest method setUp.
@BeforeEach
public void setUp() {
this.setParametersReceived = new ArrayList<>();
this.device = new DlmsDevice("SuperAwesomeHeroicRockstarDevice");
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(new DlmsHelper(), dlmsObjectConfigConfiguration.getDlmsObjectConfigs()) {
@Override
public Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type, final Integer channel) {
switch(type) {
case ALARM_FILTER_1:
return Optional.of(new AttributeAddress(40, "0.0.97.98.10.255", 2));
case ALARM_FILTER_2:
return Optional.of(new AttributeAddress(40, "0.0.97.98.11.255", 2));
}
return Optional.empty();
}
};
this.executor = new SetAlarmNotificationsCommandExecutor(dlmsObjectConfigService);
final DlmsConnectionStub conn = new DlmsConnectionStub() {
@Override
public AccessResultCode set(final SetParameter setParameter) {
SetAlarmNotificationsCommandExecutorTest.this.setParametersReceived.add(setParameter);
return AccessResultCode.SUCCESS;
}
};
// Set the return value to 10 (0b1010):
// REPLACE_BATTERY enabled, AUXILIARY_EVENT enabled.
conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.10.255", 2), DataObject.newInteger32Data(10));
conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.11.255", 2), DataObject.newInteger32Data(0));
this.connMgr = new DlmsConnectionManagerStub(conn);
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorDsmr4IT method captureSetParameterStructureData.
private List<DataObject> captureSetParameterStructureData() throws IOException {
verify(this.dlmsConnection).set(this.setParameterArgumentCaptor.capture());
final SetParameter setParameter = this.setParameterArgumentCaptor.getValue();
final DataObject setParameterData = setParameter.getData();
return setParameterData.getValue();
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetAdministrativeStatusCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final AdministrativeStatusTypeDto administrativeStatusType, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
LOGGER.info("Set administrative status by issuing get request for class id: {}, obis code: {}, attribute id: {}", CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final DataObject value = DataObject.newEnumerateData(this.configurationMapper.map(administrativeStatusType, Integer.class));
final SetParameter setParameter = new SetParameter(attributeAddress, value);
conn.getDlmsMessageListener().setDescription("SetAdminstrativeStatus to " + administrativeStatusType + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
try {
return conn.getConnection().set(setParameter);
} catch (final IOException e) {
throw new ConnectionException(e);
}
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetPushSetupSmsCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final PushSetupSmsDto pushSetupSms, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final SetParameter setParameterSendDestinationAndMethod = this.getSetParameter(pushSetupSms);
final AccessResultCode resultCode = this.doSetRequest("PushSetupSms, Send destination and method", conn, setParameterSendDestinationAndMethod);
if (resultCode != null) {
return resultCode;
} else {
throw new ProtocolAdapterException("Error setting Sms push setup data.");
}
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class ConfigureDefinableLoadProfileCommandExecutor method writeCaptureObjects.
private void writeCaptureObjects(final DlmsConnectionManager conn, final List<CaptureObjectDefinitionDto> captureObjects) throws ProtocolAdapterException {
this.dlmsLogWrite(conn, ATTRIBUTE_CAPTURE_OBJECTS, ATTRIBUTE_NAME_CAPTURE_OBJECTS);
this.writeAttribute(conn, new SetParameter(ATTRIBUTE_CAPTURE_OBJECTS, DataObject.newArrayData(this.mapCaptureObjects(captureObjects))), ATTRIBUTE_NAME_CAPTURE_OBJECTS);
}
Aggregations