Search in sources :

Example 1 with TransitionType

use of org.opensmartgridplatform.domain.core.valueobjects.TransitionType in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method handleLightMeasurementDeviceTransition.

// === TRANSITION MESSAGE FROM LIGHT MEASUREMENT DEVICE ===
/**
 * Send transition message to SSLD's based on light measurement device trigger.
 *
 * @param organisationIdentification Organization issuing the request.
 * @param correlationUid The generated correlation UID.
 * @param event The light measurement {@link Event} for which to trigger transition messages.
 */
public void handleLightMeasurementDeviceTransition(final String organisationIdentification, final String correlationUid, final Event event) {
    LightMeasurementDevice lmd = this.lightMeasurementDeviceRepository.findByDeviceIdentification(event.getDeviceIdentification());
    if (lmd == null) {
        LOGGER.error("No light measurement device found for device identification: {}", event.getDeviceIdentification());
        return;
    }
    // Update last communication time for the LMD.
    lmd = this.updateLmdLastCommunicationTime(lmd);
    // Determine if the event is a duplicate. If so, quit.
    if (this.isDuplicateEvent(event, lmd)) {
        LOGGER.info("Duplicate event detected for light measurement device: {}. Event[id:{} {} {} {} {}]", lmd.getDeviceIdentification(), event.getId(), event.getDateTime(), event.getDescription(), event.getEventType(), event.getIndex());
        return;
    }
    // Retrieve the devices per mast/segment
    final CdmaRun cdmaRun = this.getCdmaDevicesPerMastSegment(lmd);
    // Determine the transition type based on the event of the LMD.
    final TransitionType transitionType = this.determineTransitionTypeForEvent(event);
    // Send SET_TRANSITION messages to the SSLDs.
    this.setTransitionService.setTransitionForCdmaRun(cdmaRun, organisationIdentification, correlationUid, transitionType);
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) CdmaRun(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun) TransitionType(org.opensmartgridplatform.domain.core.valueobjects.TransitionType)

Aggregations

CdmaRun (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun)1 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)1 TransitionType (org.opensmartgridplatform.domain.core.valueobjects.TransitionType)1