use of org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager in project open-smart-grid-platform by OSGP.
the class GetFirmwareVersionsCommandExecutorTest method setUp.
@BeforeEach
public void setUp() {
this.executor = new GetFirmwareVersionsCommandExecutor(this.helperService);
this.connectionHolder = new DlmsConnectionManager(null, null, null, this.listener, null);
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager 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.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Processing {} response message", this.messageType.name());
}
// Get metadata from message and update message type to update
// firmware
final MessageMetadata messageMetadata = new MessageMetadata.Builder(MessageMetadata.fromMessage(message)).withMessageType(MessageType.UPDATE_FIRMWARE.name()).build();
final Serializable messageObject = message.getObject();
final ThrowingConsumer<DlmsConnectionManager> taskForConnectionManager = conn -> this.processMessageTasks(messageObject, messageMetadata, conn);
try {
this.createAndHandleConnectionForDevice(this.domainHelperService.findDlmsDevice(messageMetadata), messageMetadata, taskForConnectionManager);
} catch (final OsgpException e) {
LOGGER.error("Something went wrong with the DlmsConnection", e);
}
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutor method execute.
@Override
public GetGsmDiagnosticResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final GetGsmDiagnosticRequestDto getGsmDiagnosticQuery, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final DlmsObject dlmsObject = this.dlmsObjectConfigService.getDlmsObjectForCommunicationMethod(device, DlmsObjectType.GSM_DIAGNOSTIC);
final AttributeAddress[] addresses = this.createAttributeAddresses(dlmsObject);
final String addressesDescriptions = JdlmsObjectToStringUtil.describeAttributes(addresses);
conn.getDlmsMessageListener().setDescription("Get GsmDiagnostic, retrieve attributes: " + addressesDescriptions);
LOGGER.info("Get GsmDiagnostic, retrieve attributes: {}", addressesDescriptions);
final List<GetResult> getResultList = this.dlmsHelper.getAndCheck(conn, device, "Get GsmDiagnostic", addresses);
LOGGER.info("GetResultList: {}", describeGetResults(getResultList));
if (!getResultList.stream().allMatch(result -> result.getResultCode() == AccessResultCode.SUCCESS)) {
throw new ProtocolAdapterException("Get gsm diagnostic failed for " + device.getDeviceId());
}
return this.createGetGsmDiagnosticResponse(getResultList);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager in project open-smart-grid-platform by OSGP.
the class DlmsHelperTest method testGetWithListSupported.
@Test
public void testGetWithListSupported() 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(true);
this.dlmsHelper.getWithList(connectionManager, dlmsDevice, attrAddresses);
verify(dlmsConnection).get(Arrays.asList(attrAddresses));
}
Aggregations