use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method handleOslpResponseGetActualPowerUsage.
private void handleOslpResponseGetActualPowerUsage(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
final DeviceResponse deviceResponse = this.buildDeviceResponseGetActualPowerUsage(deviceRequest, oslpResponse);
deviceResponseHandler.handleResponse(deviceResponse);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method handleOslpResponseSwitchFirmware.
private void handleOslpResponseSwitchFirmware(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
final DeviceResponse deviceResponse = this.buildDeviceResponseSwitchFirmware(deviceRequest, oslpResponse);
deviceResponseHandler.handleResponse(deviceResponse);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method handleOslpResponseSetTransition.
private void handleOslpResponseSetTransition(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
DeviceMessageStatus status;
if (oslpResponse.getPayloadMessage().hasSetTransitionResponse()) {
final Oslp.Status oslpStatus = oslpResponse.getPayloadMessage().getSetTransitionResponse().getStatus();
status = this.mapper.map(oslpStatus, DeviceMessageStatus.class);
} else {
status = DeviceMessageStatus.FAILURE;
}
final DeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), status);
deviceResponseHandler.handleResponse(deviceResponse);
}
use of com.alliander.osgp.adapter.protocol.oslp.elster.device.DeviceResponse 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.DeviceResponse in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method handleOslpResponseUpdateDeviceSslCertification.
private void handleOslpResponseUpdateDeviceSslCertification(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse, final DeviceResponseHandler deviceResponseHandler) {
this.saveOslpResponseLogEntry(deviceRequest, oslpResponse);
this.updateSequenceNumber(deviceRequest.getDeviceIdentification(), oslpResponse);
final DeviceResponse deviceResponse = this.buildDeviceResponseUpdateDeviceSslCertification(deviceRequest, oslpResponse);
deviceResponseHandler.handleResponse(deviceResponse);
}
Aggregations