use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutor method getCellInfo.
private CellInfoDto getCellInfo(final List<GetResult> getResultList) {
final GetResult result = getResultList.get(RESULT_CELL_INFO_INDEX);
if (result.getResultCode() != AccessResultCode.SUCCESS) {
return null;
}
final List<DataObject> cellInfoDataObjects = result.getResultData().getValue();
if (cellInfoDataObjects != null) {
return new CellInfoDto(cellInfoDataObjects.get(CELL_INFO_CELL_ID_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_LOCATION_ID_INDEX).getValue(), SignalQualityDto.fromIndexValue((short) cellInfoDataObjects.get(CELL_INFO_SIGNAL_QUALITY_INDEX).getValue()), BitErrorRateDto.fromIndexValue((short) cellInfoDataObjects.get(CELL_INFO_BIT_ERROR_RATE_INDEX).getValue()), cellInfoDataObjects.get(CELL_INFO_MOBILE_COUNTRY_CODE_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_MOBILE_NETWORK_CODE_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_CHANNEL_NUMBER_INDEX).getValue());
} else {
return null;
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutor method createGetGsmDiagnosticResponse.
private GetGsmDiagnosticResponseDto createGetGsmDiagnosticResponse(final List<GetResult> getResultList) throws ProtocolAdapterException {
final String operator = this.getOperator(getResultList);
final ModemRegistrationStatusDto registrationStatus = this.getRegistrationStatus(getResultList);
final CircuitSwitchedStatusDto circuitSwitchedStatus = this.getCircuitSwitchedStatus(getResultList);
final PacketSwitchedStatusDto packetSwitchedStatusDto = this.getPacketSwitchedStatus(getResultList);
final CellInfoDto cellInfo = this.getCellInfo(getResultList);
final List<AdjacentCellInfoDto> adjacentCells = this.getAdjacentCells(getResultList);
final Date captureTimeDto = this.getCaptureTime(getResultList);
return new GetGsmDiagnosticResponseDto(operator, registrationStatus, circuitSwitchedStatus, packetSwitchedStatusDto, cellInfo, adjacentCells, captureTimeDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutorIntegrationTest method testExecute.
private void testExecute(final Protocol protocol, final CommunicationMethod method, final boolean expectObjectNotFound) throws Exception {
// SETUP
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
// Reset stub
this.connectionStub.clearRequestedAttributeAddresses();
// Create device with requested protocol version and communication method
final DlmsDevice device = this.createDlmsDevice(protocol, method);
// Create request object
final GetGsmDiagnosticRequestDto request = new GetGsmDiagnosticRequestDto();
// Get expected addresses
final AttributeAddress expectedAddressOperator = this.createAttributeAddress(method, 2);
final AttributeAddress expectedAddressRegistrationStatus = this.createAttributeAddress(method, 3);
final AttributeAddress expectedAddressCsStatus = this.createAttributeAddress(method, 4);
final AttributeAddress expectedAddressPsStatus = this.createAttributeAddress(method, 5);
final AttributeAddress expectedAddressCellInfo = this.createAttributeAddress(method, 6);
final AttributeAddress expectedAddressAdjacentCells = this.createAttributeAddress(method, 7);
final AttributeAddress expectedAddressCaptureTime = this.createAttributeAddress(method, 8);
// Reading of capture_time is disabled for now, therefore only 6 addresses expected
final int expectedTotalNumberOfAttributeAddresses = 6;
// Set responses in stub
this.setResponseForOperator(expectedAddressOperator);
this.setResponseForRegistrationStatus(expectedAddressRegistrationStatus);
this.setResponseForCsStatus(expectedAddressCsStatus);
this.setResponseForPsStatus(expectedAddressPsStatus);
this.setResponseForCellInfo(expectedAddressCellInfo);
this.setResponseForAdjacentCells(expectedAddressAdjacentCells);
this.setResponseForCaptureTime(expectedAddressCaptureTime);
// CALL
GetGsmDiagnosticResponseDto response = null;
try {
response = this.executor.execute(this.connectionManagerStub, device, request, messageMetadata);
} catch (final ProtocolAdapterException e) {
if (expectObjectNotFound) {
assertThat(e.getMessage()).isEqualTo("Did not find GSM_DIAGNOSTIC object with communication method " + method.getMethodName() + " for device 6789012");
return;
} else {
fail("Unexpected ProtocolAdapterException: " + e.getMessage());
}
}
// VERIFY
// Get resulting requests from connection stub
final List<AttributeAddress> requestedAttributeAddresses = this.connectionStub.getRequestedAttributeAddresses();
assertThat(requestedAttributeAddresses.size()).isEqualTo(expectedTotalNumberOfAttributeAddresses);
// Check response
assertThat(response).isNotNull();
assertThat(response).isNotNull();
assertThat(response.getOperator()).isEqualTo("Operator");
assertThat(response.getModemRegistrationStatus()).isEqualTo(ModemRegistrationStatusDto.REGISTERED_ROAMING);
assertThat(response.getCircuitSwitchedStatus()).isEqualTo(CircuitSwitchedStatusDto.INACTIVE);
assertThat(response.getPacketSwitchedStatus()).isEqualTo(PacketSwitchedStatusDto.CDMA);
final CellInfoDto cellInfo = response.getCellInfo();
assertThat(cellInfo.getCellId()).isEqualTo(93L);
assertThat(cellInfo.getLocationId()).isEqualTo(2232);
assertThat(cellInfo.getSignalQuality()).isEqualTo(SignalQualityDto.MINUS_87_DBM);
assertThat(cellInfo.getBitErrorRate()).isEqualTo(BitErrorRateDto.RXQUAL_6);
assertThat(cellInfo.getMobileCountryCode()).isEqualTo(204);
assertThat(cellInfo.getMobileNetworkCode()).isEqualTo(66);
assertThat(cellInfo.getChannelNumber()).isEqualTo(107);
final List<AdjacentCellInfoDto> adjacentCells = response.getAdjacentCells();
assertThat(adjacentCells.size()).isEqualTo(3);
assertThat(adjacentCells.get(0).getCellId()).isEqualTo(85L);
assertThat(adjacentCells.get(0).getSignalQuality()).isEqualTo(SignalQualityDto.MINUS_65_DBM);
// Reading of capture_time is disabled, so don't check the capture time
// assertThat(response.getCaptureTime())
// .isEqualTo(new DateTime(2021, 4, 1, 9, 28, DateTimeZone.UTC).toDate());
}
Aggregations