use of org.openmuc.jdlms.AccessResultCode in project open-smart-grid-platform by OSGP.
the class ConfigurationService method setPushSetupSms.
public void setPushSetupSms(final DlmsConnectionManager conn, final DlmsDevice device, final PushSetupSmsDto pushSetupSms, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
LOGGER.info("Push Setup Sms to set on the device: {}", pushSetupSms);
final AccessResultCode accessResultCode = this.setPushSetupSmsCommandExecutor.execute(conn, device, pushSetupSms, messageMetadata);
if (AccessResultCode.SUCCESS != accessResultCode) {
throw new ProtocolAdapterException("AccessResultCode for set push setup sms was not SUCCESS: " + accessResultCode);
}
}
use of org.openmuc.jdlms.AccessResultCode in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutor method clearStatusMaskForChannel.
private void clearStatusMaskForChannel(final DlmsConnectionManager conn, final int channel, final DlmsDevice device) throws IOException, ProtocolAdapterException {
final AttributeAddress readMBusStatusAttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.READ_MBUS_STATUS, channel);
final AttributeAddress clearMBusStatusAttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.CLEAR_MBUS_STATUS, channel);
final AttributeAddress clientSetupMbus = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.CLIENT_SETUP_MBUS, channel);
final long statusMask = this.readStatus(conn, channel, readMBusStatusAttributeAddress);
if (statusMask == 0L) {
return;
}
final AccessResultCode resultCode = this.setClearStatusMask(statusMask, conn, channel, clearMBusStatusAttributeAddress);
if (resultCode != AccessResultCode.SUCCESS) {
throw new ProtocolAdapterException("Unable to set clear status mask for M-Bus channel " + channel + ", AccessResultCode=" + resultCode + ".");
}
final MethodResult methodResult = this.resetAlarm(conn, channel, clientSetupMbus.getInstanceId());
if (methodResult.getResultCode() != MethodResultCode.SUCCESS) {
throw new ProtocolAdapterException("Call for RESET_ALARM was unsuccessful for M-Bus channel " + channel + ", MethodResultCode=" + methodResult.getResultCode() + ".");
}
}
use of org.openmuc.jdlms.AccessResultCode in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final AlarmNotificationsDto alarmNotifications, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final AttributeAddress alarmFilter1AttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.ALARM_FILTER_1, null);
final AccessResultCode resultCodeAlarmFilter1 = this.setAlarmNotifications(conn, alarmNotifications, alarmFilter1AttributeAddress, DlmsObjectType.ALARM_REGISTER_1);
final Optional<AttributeAddress> alarmFilter2AttributeAddress = this.dlmsObjectConfigService.findAttributeAddress(device, DlmsObjectType.ALARM_FILTER_2, null);
if (!alarmFilter2AttributeAddress.isPresent()) {
return resultCodeAlarmFilter1;
} else {
return this.setAlarmNotifications(conn, alarmNotifications, alarmFilter2AttributeAddress.get(), DlmsObjectType.ALARM_REGISTER_2);
}
}
use of org.openmuc.jdlms.AccessResultCode 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, device);
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.AccessResultCode in project open-smart-grid-platform by OSGP.
the class SetPushSetupAlarmCommandExecutorTest method testSetSendDestinationAndMethod.
@ParameterizedTest
@EnumSource(Protocol.class)
void testSetSendDestinationAndMethod(final Protocol protocol) throws ProtocolAdapterException, IOException {
// SETUP
final DlmsDevice device = this.createDlmsDevice(protocol);
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
final PushSetupAlarmDto pushSetupAlarmDto = new PushSetupAlarmDto.Builder().withSendDestinationAndMethod(SEND_DESTINATION_AND_METHOD).build();
// CALL
final AccessResultCode resultCode = this.executor.execute(this.conn, device, pushSetupAlarmDto, this.messageMetadata);
// VERIFY
assertThat(resultCode).isEqualTo(AccessResultCode.SUCCESS);
verify(this.dlmsConnection, times(1)).set(this.setParameterArgumentCaptor.capture());
final List<SetParameter> setParameters = this.setParameterArgumentCaptor.getAllValues();
this.verifySendDestinationAndMethodParameter(setParameters.get(0), protocol);
}
Aggregations