use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class DlmsHelperTest method testGetWithListWorkaround.
@Test
public void testGetWithListWorkaround() throws ProtocolAdapterException, IOException {
final DlmsConnection dlmsConnection = mock(DlmsConnection.class);
final DlmsConnectionManager connectionManager = mock(DlmsConnectionManager.class);
final DlmsDevice dlmsDevice = mock(DlmsDevice.class);
when(connectionManager.getConnection()).thenReturn(dlmsConnection);
final AttributeAddress[] attrAddresses = new AttributeAddress[1];
attrAddresses[0] = mock(AttributeAddress.class);
when(dlmsDevice.isWithListSupported()).thenReturn(false);
this.dlmsHelper.getWithList(connectionManager, dlmsDevice, attrAddresses);
verify(dlmsConnection).get(attrAddresses[0]);
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class SetRandomisationSettingsCommandExecutorTest method init.
@BeforeEach
public void init() throws ProtocolAdapterException, IOException {
// SETUP
final Protocol smr51 = Protocol.SMR_5_1;
this.device = this.createDlmsDevice(smr51);
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
final AttributeAddress address = new AttributeAddress(1, new ObisCode("0.1.94.31.12.255"), 1);
this.dataDto = new SetRandomisationSettingsRequestDataDto(0, 1, 1, 1);
final ConfigurationFlagsDto currentConfigurationFlagsDto = new ConfigurationFlagsDto(this.getFlags());
final ConfigurationObjectDto currentConfigurationObjectDto = new ConfigurationObjectDto(currentConfigurationFlagsDto);
when(this.protocolServiceLookup.lookupGetService(smr51)).thenReturn(this.getConfigurationObjectService);
when(this.protocolServiceLookup.lookupSetService(smr51)).thenReturn(this.setConfigurationObjectService);
when(this.getConfigurationObjectService.getConfigurationObject(this.dlmsConnectionManager)).thenReturn(currentConfigurationObjectDto);
when(this.setConfigurationObjectService.setConfigurationObject(any(DlmsConnectionManager.class), any(ConfigurationObjectDto.class), any(ConfigurationObjectDto.class))).thenReturn(AccessResultCode.SUCCESS);
when(this.dlmsObjectConfigService.getAttributeAddress(this.device, DlmsObjectType.RANDOMISATION_SETTINGS, null)).thenReturn(address);
when(this.dlmsConnectionManager.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutorTest method shouldExecuteForProtocol_SMR_5_1.
@Test
void shouldExecuteForProtocol_SMR_5_1() throws ProtocolAdapterException, IOException {
final DlmsDevice dlmsDevice_5_1 = new DlmsDevice("SMR 5.1 device");
dlmsDevice_5_1.setProtocol("SMR", "5.1");
for (int channel = 1; channel <= 4; channel++) {
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.READ_MBUS_STATUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.EXTENDED_REGISTER.id(), OBIS_CODE_TEMPLATE_READ_STATUS.replaceAll("<c>", Integer.toString(channel)), ExtendedRegisterAttribute.VALUE.attributeId()));
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.CLEAR_MBUS_STATUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_TEMPLATE_CLEAR_STATUS.replaceAll("<c>", Integer.toString(channel)), DataAttribute.VALUE.attributeId()));
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.CLIENT_SETUP_MBUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.MBUS_CLIENT.id(), OBIS_CODE_TEMPLATE_MBUS_CLIENT_SETUP.replaceAll("<c>", Integer.toString(channel)), DataAttribute.VALUE.attributeId()));
}
when(this.connectionManager.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.connectionManager.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.get(this.attributeAddressArgumentCaptor.capture())).thenReturn(this.getResult);
when(this.getResult.getResultData()).thenReturn(DataObject.newUInteger32Data(STATUS_MASK));
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenReturn(AccessResultCode.SUCCESS);
when(this.methodResult.getResultCode()).thenReturn(MethodResultCode.SUCCESS);
when(this.dlmsConnection.action(this.methodParameterArgumentCaptor.capture())).thenReturn(this.methodResult);
this.executor.execute(this.connectionManager, dlmsDevice_5_1, this.dto, this.messageMetadata);
this.assertCurrentStatusAttributeAddresses(this.attributeAddressArgumentCaptor.getAllValues());
this.assertClearStatus(this.setParameterArgumentCaptor.getAllValues());
this.assertMethodResetAlarm(this.methodParameterArgumentCaptor.getAllValues());
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutorTest method shouldSkipIfStatusIsZero.
@Test
void shouldSkipIfStatusIsZero() throws ProtocolAdapterException, IOException {
final DlmsDevice dlmsDevice_5_1 = new DlmsDevice("SMR 5.1 device");
dlmsDevice_5_1.setProtocol("SMR", "5.1");
for (int channel = 1; channel <= 4; channel++) {
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.READ_MBUS_STATUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.EXTENDED_REGISTER.id(), OBIS_CODE_TEMPLATE_READ_STATUS.replaceAll("<c>", Integer.toString(channel)), ExtendedRegisterAttribute.VALUE.attributeId()));
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.CLEAR_MBUS_STATUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_TEMPLATE_CLEAR_STATUS.replaceAll("<c>", Integer.toString(channel)), DataAttribute.VALUE.attributeId()));
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice_5_1, DlmsObjectType.CLIENT_SETUP_MBUS, channel)).thenReturn(new AttributeAddress(InterfaceClass.MBUS_CLIENT.id(), OBIS_CODE_TEMPLATE_MBUS_CLIENT_SETUP.replaceAll("<c>", Integer.toString(channel)), DataAttribute.VALUE.attributeId()));
}
when(this.connectionManager.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.connectionManager.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.get(this.attributeAddressArgumentCaptor.capture())).thenReturn(this.getResult);
when(this.getResult.getResultData()).thenReturn(DataObject.newUInteger32Data(0L));
this.executor.execute(this.connectionManager, dlmsDevice_5_1, this.dto, this.messageMetadata);
this.assertCurrentStatusAttributeAddresses(this.attributeAddressArgumentCaptor.getAllValues());
verify(this.dlmsConnection, never()).set(any(SetParameter.class));
verify(this.dlmsConnection, never()).action(any(MethodParameter.class));
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method setupAlarmRegister1.
void setupAlarmRegister1(final DlmsDevice dlmsDevice) throws ProtocolAdapterException, IOException {
dlmsDevice.setProtocol("SMR", "5.2");
when(this.dlmsObjectConfigService.getAttributeAddress(dlmsDevice, DlmsObjectType.ALARM_REGISTER_1, null)).thenReturn(new AttributeAddress(InterfaceClass.DATA.id(), OBIS_CODE_ALARM_REGISTER_1, DataAttribute.VALUE.attributeId()));
when(this.connectionManager.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.connectionManager.getConnection()).thenReturn(this.dlmsConnection);
}
Aggregations