Search in sources :

Example 6 with ProtocolInfo

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);
    }
}
Also used : ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo)

Example 7 with 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);
    }
}
Also used : ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo)

Example 8 with 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);
}
Also used : ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 9 with 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);
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) InetAddress(java.net.InetAddress) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with ProtocolInfo

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);
}
Also used : Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Device(org.opensmartgridplatform.domain.core.entities.Device) DeviceAuthorization(org.opensmartgridplatform.domain.core.entities.DeviceAuthorization) ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo) EntityNotFoundException(javax.persistence.EntityNotFoundException) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld)

Aggregations

ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)15 Device (org.opensmartgridplatform.domain.core.entities.Device)4 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)3 ArrayList (java.util.ArrayList)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.jupiter.api.Test)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 DlmsDeviceBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DlmsDeviceBuilder)2 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)2 EventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto)2 EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)2 InetAddress (java.net.InetAddress)1 Date (java.util.Date)1 JMSException (javax.jms.JMSException)1 ObjectMessage (javax.jms.ObjectMessage)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 DeviceBuilder (org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.DeviceBuilder)1