Search in sources :

Example 6 with CdmaRun

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method getCdmaDevicesPerMastSegment.

private CdmaRun getCdmaDevicesPerMastSegment(final LightMeasurementDevice lmd) {
    // Find all SSLDs which need to receive a SET_TRANSITION message.
    final List<CdmaDevice> devicesForLmd = this.ssldRepository.findCdmaBatchDevicesInUseForLmd(lmd, DeviceLifecycleStatus.IN_USE);
    final CdmaRun cdmaRun = new CdmaRun();
    devicesForLmd.forEach(cdmaRun::add);
    return cdmaRun;
}
Also used : CdmaRun(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun) CdmaDevice(org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice)

Example 7 with CdmaRun

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun 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)

Example 8 with CdmaRun

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun in project open-smart-grid-platform by OSGP.

the class CdmaRunTest method twoBatches.

@Test
public void twoBatches() {
    // The CDMA run will contain two batches for mast segment 200/1.
    // Within the timeout of 1000 milliseconds, only the send for device cd1
    // should take place.
    final CdmaRun run = new CdmaRun();
    run.add(new CdmaDevice("cd1", this.loopbackAddress, "200/1", (short) 1));
    run.add(new CdmaDevice("cd2", this.loopbackAddress, "200/1", (short) 2));
    this.service.setTransitionForCdmaRun(run, "LianderNetManagement", "two-batches-cdma-run-test", TransitionType.NIGHT_DAY);
    this.verifySentMessages(1);
}
Also used : CdmaRun(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun) CdmaDevice(org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice) Test(org.junit.jupiter.api.Test)

Aggregations

CdmaRun (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun)8 Test (org.junit.jupiter.api.Test)6 CdmaDevice (org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice)6 CdmaMastSegment (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment)1 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)1 TransitionType (org.opensmartgridplatform.domain.core.valueobjects.TransitionType)1