use of org.opensmartgridplatform.domain.core.entities.ProtocolInfo in project open-smart-grid-platform by OSGP.
the class ProtocolRequestMessageJmsTemplateFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws SSLException {
for (final ProtocolInfo protocolInfo : this.protocolInfos) {
LOGGER.info("Initializing ProtocolRequestMessageJmsTemplate {}", protocolInfo.getKey());
this.init(protocolInfo);
}
}
use of org.opensmartgridplatform.domain.core.entities.ProtocolInfo in project open-smart-grid-platform by OSGP.
the class ProtocolResponseMessageListenerContainerFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws SSLException {
for (final ProtocolInfo protocolInfo : this.protocolInfos) {
LOGGER.info("Initializing ProtocolResponseMessageListenerContainer {}", protocolInfo.getKey());
this.init(protocolInfo);
}
}
use of org.opensmartgridplatform.domain.core.entities.ProtocolInfo in project open-smart-grid-platform by OSGP.
the class RtuDeviceService method addProtocolInfo.
private void addProtocolInfo(final RtuDevice rtuDevice, final org.opensmartgridplatform.domain.core.entities.RtuDevice rtuDeviceEntity) throws FunctionalException {
final ProtocolInfo protocolInfo = this.protocolInfoRepository.findByProtocolAndProtocolVersion(rtuDevice.getProtocolName(), rtuDevice.getProtocolVersion());
if (protocolInfo == null) {
throw new FunctionalException(FunctionalExceptionType.UNKNOWN_PROTOCOL_NAME_OR_VERSION, ComponentType.DOMAIN_DISTRIBUTION_AUTOMATION);
}
rtuDeviceEntity.updateProtocol(protocolInfo);
}
use of org.opensmartgridplatform.domain.core.entities.ProtocolInfo in project open-smart-grid-platform by OSGP.
the class LightMeasurementDeviceSteps method createLightMeasurementDevice.
/**
* Create a single light measurement device, including rights for the default organization.
*/
@Transactional("txMgrCore")
public LightMeasurementDevice createLightMeasurementDevice(final String deviceIdentification, final String code, final String color, final short digitalInput) {
final String deviceType = "LMD";
final InetAddress networkAddress = InetAddress.getLoopbackAddress();
final Date technicalInstallationDate = DateTime.now().withZone(DateTimeZone.UTC).toDate();
final ProtocolInfo protocolInfo = this.protocolInfoRepository.findByProtocolAndProtocolVersion("IEC61850", "1.0");
final LightMeasurementDevice lightMeasurementDevice = new LightMeasurementDevice(deviceIdentification);
lightMeasurementDevice.setTechnicalInstallationDate(technicalInstallationDate);
lightMeasurementDevice.updateRegistrationData(networkAddress, deviceType);
lightMeasurementDevice.updateProtocol(protocolInfo);
lightMeasurementDevice.updateInMaintenance(false);
lightMeasurementDevice.setDescription(deviceIdentification);
lightMeasurementDevice.setCode(code);
lightMeasurementDevice.setColor(color);
lightMeasurementDevice.setLastCommunicationTime(technicalInstallationDate.toInstant());
lightMeasurementDevice.setDigitalInput(digitalInput);
// Setting the default authorization both creates the device and adds
// the device authorization.
this.setDefaultDeviceAuthorizationForDevice(lightMeasurementDevice);
return this.lightMeasurementDeviceRepository.findByDeviceIdentification(deviceIdentification);
}
use of org.opensmartgridplatform.domain.core.entities.ProtocolInfo in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method updateKey.
// === UPDATE KEY ===
public void updateKey(final String organisationIdentification, @Identification final String deviceIdentification, @PublicKey final String publicKey, final Long protocolInfoId) throws FunctionalException {
LOGGER.debug("Updating key for device [{}] on behalf of organisation [{}]", deviceIdentification, organisationIdentification);
final Organisation organisation = this.findOrganisation(organisationIdentification);
this.isAllowed(organisation, PlatformFunction.UPDATE_KEY);
this.organisationDomainService.isOrganisationEnabled(organisation, ComponentType.WS_ADMIN);
final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification);
if (device == null) {
// Device not found, create new device
LOGGER.debug("Device [{}] does not exist, creating new device", deviceIdentification);
final Ssld ssld = new Ssld(deviceIdentification);
final DeviceAuthorization authorization = ssld.addAuthorization(organisation, DeviceFunctionGroup.OWNER);
final ProtocolInfo protocolInfo = this.protocolRepository.findById(protocolInfoId).orElseThrow(() -> new EntityNotFoundException("No protocol info record found with ID: " + protocolInfoId));
ssld.updateProtocol(protocolInfo);
this.authorizationRepository.save(authorization);
}
this.enqueueUpdateKeyRequest(organisationIdentification, deviceIdentification, publicKey);
}
Aggregations