use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method getFirmwareVersion.
@Override
public void getFirmwareVersion(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
final List<FirmwareVersionDto> firmwareVersions = new Iec61850GetFirmwareVersionCommand().getFirmwareVersionFromDevice(this.iec61850Client, deviceConnection);
final GetFirmwareVersionDeviceResponse deviceResponse = new GetFirmwareVersionDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), firmwareVersions);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
}
this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method setTransition.
@Override
public void setTransition(final SetTransitionDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection devCon = null;
try {
final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
devCon = deviceConnection;
new Iec61850TransitionCommand().transitionDevice(this.iec61850Client, deviceConnection, deviceRequest.getTransitionTypeContainer());
this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
this.enableReporting(deviceConnection, deviceRequest);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
}
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method updateFirmware.
@Override
public void updateFirmware(final UpdateFirmwareDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
new Iec61850UpdateFirmwareCommand().pushFirmwareToDevice(this.iec61850Client, deviceConnection, deviceRequest.getFirmwareDomain().concat(deviceRequest.getFirmwareUrl()), deviceRequest.getFirmwareModuleData());
this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
}
this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class DeviceRegistrationService method disableRegistration.
/**
* After the device has registered with the platform successfully, the
* device has to be informed that the registration worked. Disable an
* attribute so the device will stop attempting to register once a minute.
*
* @param deviceIdentification
* The device identification.
* @param ipAddress
* The IP address of the device.
* @param ied
* The type of IED.
* @param serverName
* The server name.
*
* @throws ProtocolAdapterException
* In case the connection to the device can not be established
* or the connection breaks during communication.
*/
public void disableRegistration(final String deviceIdentification, final InetAddress ipAddress, final IED ied, final String serverName) throws ProtocolAdapterException {
final DeviceConnection deviceConnection = this.iec61850DeviceConnectionService.connectWithoutConnectionCaching(ipAddress.getHostAddress(), deviceIdentification, "", ied, serverName, LogicalDevice.LIGHTING.getDescription());
final Function<Void> function = new Function<Void>() {
@Override
public Void apply(final DeviceMessageLog deviceMessageLog) throws Exception {
DeviceRegistrationService.this.disableRegistration(deviceConnection);
DeviceRegistrationService.this.setLocationInformation(deviceConnection);
if (DeviceRegistrationService.this.isReportingAfterDeviceRegistrationEnabled) {
LOGGER.info("Reporting enabled for device: {}", deviceConnection.getDeviceIdentification());
DeviceRegistrationService.this.enableReporting(deviceConnection);
} else {
LOGGER.info("Reporting disabled for device: {}", deviceIdentification);
DeviceRegistrationService.this.iec61850DeviceConnectionService.disconnect(deviceConnection, null);
}
return null;
}
};
this.iec61850DeviceConnectionService.sendCommandWithRetry(function, deviceIdentification);
}
use of org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850DaRtuDeviceService method getData.
@Override
public void getData(final DaDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final DaRtuDeviceRequestMessageProcessor messageProcessor) throws JMSException {
try {
final String serverName = this.getServerName(deviceRequest);
final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
final Serializable dataResponse = this.handleGetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest, messageProcessor);
final DaDeviceResponse deviceResponse = new DaDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, dataResponse);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
LOGGER.error("Could not connect to device after all retries", se);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
} catch (final Exception e) {
LOGGER.error("Unexpected exception during Get Data", e);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleException(e, deviceResponse);
}
}
Aggregations