use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method handleOslpResponseGetStatus.
private void handleOslpResponseGetStatus(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
DeviceStatusDto deviceStatus = null;
if (oslpResponse.getPayloadMessage().hasGetStatusResponse()) {
final Oslp.GetStatusResponse getStatusResponse = oslpResponse.getPayloadMessage().getGetStatusResponse();
final Oslp.Status oslpStatus = getStatusResponse.getStatus();
if (oslpStatus == Oslp.Status.OK) {
// Required properties.
final List<LightValueDto> lightValues = this.mapper.mapAsList(getStatusResponse.getValueList(), LightValueDto.class);
final LinkTypeDto preferredType = getStatusResponse.getPreferredLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getPreferredLinktype(), LinkTypeDto.class);
final LinkTypeDto actualLinkType = getStatusResponse.getActualLinktype().equals(Oslp.LinkType.LINK_NOT_SET) ? null : this.mapper.map(getStatusResponse.getActualLinktype(), LinkTypeDto.class);
final LightTypeDto lightType = getStatusResponse.getLightType().equals(Oslp.LightType.LT_NOT_SET) ? null : this.mapper.map(getStatusResponse.getLightType(), LightTypeDto.class);
final int eventNotificationMask = getStatusResponse.getEventNotificationMask();
deviceStatus = new DeviceStatusDto(lightValues, preferredType, actualLinkType, lightType, eventNotificationMask);
// Optional properties.
if (getStatusResponse.hasBootLoaderVersion()) {
deviceStatus.setBootLoaderVersion(getStatusResponse.getBootLoaderVersion());
}
if (getStatusResponse.getCurrentConfigurationBackUsed() != null && getStatusResponse.getCurrentConfigurationBackUsed().toByteArray().length == 1) {
deviceStatus.setCurrentConfigurationBackUsed(this.convertCurrentConfigurationBankUsed(getStatusResponse.getCurrentConfigurationBackUsed()));
}
if (getStatusResponse.hasCurrentIp()) {
deviceStatus.setCurrentIp(getStatusResponse.getCurrentIp());
}
if (getStatusResponse.hasCurrentTime()) {
deviceStatus.setCurrentTime(getStatusResponse.getCurrentTime());
}
if (getStatusResponse.hasDcOutputVoltageCurrent()) {
deviceStatus.setDcOutputVoltageCurrent(getStatusResponse.getDcOutputVoltageCurrent());
}
if (getStatusResponse.hasDcOutputVoltageMaximum()) {
deviceStatus.setDcOutputVoltageMaximum(getStatusResponse.getDcOutputVoltageMaximum());
}
if (getStatusResponse.hasEventNotificationMask()) {
deviceStatus.setEventNotificationsMask(getStatusResponse.getEventNotificationMask());
}
if (getStatusResponse.hasExternalFlashMemSize()) {
deviceStatus.setExternalFlashMemSize(getStatusResponse.getExternalFlashMemSize());
}
if (getStatusResponse.hasFirmwareVersion()) {
deviceStatus.setFirmwareVersion(getStatusResponse.getFirmwareVersion());
}
if (getStatusResponse.hasHardwareId()) {
deviceStatus.setHardwareId(getStatusResponse.getHardwareId());
}
if (getStatusResponse.hasInternalFlashMemSize()) {
deviceStatus.setInternalFlashMemSize(getStatusResponse.getInternalFlashMemSize());
}
if (getStatusResponse.hasLastInternalTestResultCode()) {
deviceStatus.setLastInternalTestResultCode(getStatusResponse.getLastInternalTestResultCode());
}
if (getStatusResponse.getMacAddress() != null && !getStatusResponse.getMacAddress().isEmpty()) {
deviceStatus.setMacAddress(this.convertMacAddress(getStatusResponse.getMacAddress()));
}
if (getStatusResponse.hasMaximumOutputPowerOnDcOutput()) {
deviceStatus.setMaximumOutputPowerOnDcOutput(getStatusResponse.getMaximumOutputPowerOnDcOutput());
}
if (getStatusResponse.hasName()) {
deviceStatus.setName(getStatusResponse.getName());
}
if (getStatusResponse.hasNumberOfOutputs()) {
deviceStatus.setNumberOfOutputs(getStatusResponse.getNumberOfOutputs());
}
if (getStatusResponse.hasSerialNumber()) {
deviceStatus.setSerialNumber(this.convertSerialNumber(getStatusResponse.getSerialNumber()));
}
if (getStatusResponse.hasStartupCounter()) {
deviceStatus.setStartupCounter(getStatusResponse.getStartupCounter());
}
} else {
// handle failure by throwing exceptions if needed
LOGGER.error("Unable to convert Oslp.GetStatusResponse");
}
}
final DeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceStatus);
deviceResponseHandler.handleResponse(deviceResponse);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class CommonGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class PublicLightingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor method handleGetStatusDeviceResponse.
private void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = null;
DeviceStatusDto status = null;
try {
final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
status = response.getDeviceStatus();
} catch (final Exception e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device status", e);
}
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(osgpException).dataObject(status).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
Aggregations