use of org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException in project open-smart-grid-platform by OSGP.
the class DeviceInstallationServiceTest method testHandleGetStatusResponseOkLmdStatusNull.
@Test
public void testHandleGetStatusResponseOkLmdStatusNull() throws FunctionalException {
when(this.domainCoreMapper.map(null, DeviceStatus.class)).thenReturn(null);
final Device mockedDevice = Mockito.mock(Device.class);
when(mockedDevice.getDeviceType()).thenReturn(LightMeasurementDevice.LMD_TYPE);
when(this.deviceDomainService.searchDevice(TEST_DEVICE)).thenReturn(mockedDevice);
this.deviceInstallationService.handleGetStatusResponse(null, CORRELATION_IDS, TEST_MESSAGE_TYPE, MESSAGE_PRIORITY, ResponseMessageResultType.OK, null);
verify(this.webServiceResponseMessageSender).send(this.argumentResponseMessage.capture());
assertThat(this.argumentResponseMessage.getValue()).usingRecursiveComparison().isEqualTo(this.createNewResponseMessage(ResponseMessageResultType.NOT_OK, new TechnicalException(ComponentType.DOMAIN_CORE, "Light measurement device was not able to report light sensor status", new NoDeviceResponseException()), null));
}
use of org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException in project open-smart-grid-platform by OSGP.
the class OslpChannelHandlerClient method channelInactive.
@Override
public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
final String channelId = ctx.channel().id().asLongText();
if (this.callbackHandlers.containsKey(channelId)) {
this.callbackHandlers.get(channelId).getDeviceResponseHandler().handleException(new NoDeviceResponseException());
this.callbackHandlers.remove(channelId);
}
super.channelInactive(ctx);
}
use of org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method handleLmd.
private void handleLmd(final DeviceStatus status, final GetStatusResponse response) {
if (status != null) {
final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(null, status.getLightValues(), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
// Return mapped status using GetStatusResponse instance.
response.setDeviceStatusMapped(deviceStatusMapped);
} else {
// No status received, create bad response.
response.setDeviceStatusMapped(null);
response.setOsgpException(new TechnicalException(ComponentType.DOMAIN_PUBLIC_LIGHTING, "Light measurement device was not able to report light sensor status", new NoDeviceResponseException()));
response.setResult(ResponseMessageResultType.NOT_OK);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException in project open-smart-grid-platform by OSGP.
the class DeviceInstallationService method handleSsld.
private void handleSsld(final String deviceIdentification, final DeviceStatus status, final GetStatusResponse response) {
// Find device and output settings.
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
final List<DeviceOutputSetting> deviceOutputSettings = ssld.getOutputSettings();
// Create map with external relay number as key set.
final Map<Integer, DeviceOutputSetting> dosMap = new HashMap<>();
for (final DeviceOutputSetting dos : deviceOutputSettings) {
dosMap.put(dos.getExternalId(), dos);
}
if (status != null) {
// Map the DeviceStatus for SSLD.
final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(FilterLightAndTariffValuesHelper.filterTariffValues(status.getLightValues(), dosMap, DomainType.TARIFF_SWITCHING), FilterLightAndTariffValuesHelper.filterLightValues(status.getLightValues(), dosMap, DomainType.PUBLIC_LIGHTING), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
deviceStatusMapped.setBootLoaderVersion(status.getBootLoaderVersion());
deviceStatusMapped.setCurrentConfigurationBackUsed(status.getCurrentConfigurationBackUsed());
deviceStatusMapped.setCurrentIp(status.getCurrentIp());
deviceStatusMapped.setCurrentTime(status.getCurrentTime());
deviceStatusMapped.setDcOutputVoltageCurrent(status.getDcOutputVoltageCurrent());
deviceStatusMapped.setDcOutputVoltageMaximum(status.getDcOutputVoltageMaximum());
deviceStatusMapped.setEventNotificationsMask(status.getEventNotificationsMask());
deviceStatusMapped.setExternalFlashMemSize(status.getExternalFlashMemSize());
deviceStatusMapped.setFirmwareVersion(status.getFirmwareVersion());
deviceStatusMapped.setHardwareId(status.getHardwareId());
deviceStatusMapped.setInternalFlashMemSize(status.getInternalFlashMemSize());
deviceStatusMapped.setLastInternalTestResultCode(status.getLastInternalTestResultCode());
deviceStatusMapped.setMacAddress(status.getMacAddress());
deviceStatusMapped.setMaximumOutputPowerOnDcOutput(status.getMaximumOutputPowerOnDcOutput());
deviceStatusMapped.setName(status.getName());
deviceStatusMapped.setNumberOfOutputs(status.getNumberOfOutputs());
deviceStatusMapped.setSerialNumber(status.getSerialNumber());
deviceStatusMapped.setStartupCounter(status.getStartupCounter());
// Return mapped status using GetStatusResponse instance.
response.setDeviceStatusMapped(deviceStatusMapped);
} else {
// No status received, create bad response.
response.setDeviceStatusMapped(null);
response.setOsgpException(new TechnicalException(ComponentType.DOMAIN_CORE, "SSLD was not able to report relay status", new NoDeviceResponseException()));
response.setResult(ResponseMessageResultType.NOT_OK);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException in project open-smart-grid-platform by OSGP.
the class DeviceInstallationService method handleLmd.
private void handleLmd(final DeviceStatus status, final GetStatusResponse response) {
if (status != null) {
final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(null, status.getLightValues(), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
// Return mapped status using GetStatusResponse instance.
response.setDeviceStatusMapped(deviceStatusMapped);
} else {
// No status received, create bad response.
response.setDeviceStatusMapped(null);
response.setOsgpException(new TechnicalException(ComponentType.DOMAIN_CORE, "Light measurement device was not able to report light sensor status", new NoDeviceResponseException()));
response.setResult(ResponseMessageResultType.NOT_OK);
}
}
Aggregations