Search in sources :

Example 1 with PublishedPointRT

use of com.serotonin.m2m2.rt.publish.PublishedPointRT in project ma-core-public by infiniteautomation.

the class PublisherRT method initialize.

protected void initialize(SendThread sendThread) {
    this.sendThread = sendThread;
    sendThread.initialize(false);
    for (T p : vo.getPoints()) pointRTs.add(new PublishedPointRT<T>(p, this));
    if (vo.isSendSnapshot()) {
        // Add a schedule to send the snapshot
        long snapshotPeriodMillis = Common.getMillis(vo.getSnapshotSendPeriodType(), vo.getSnapshotSendPeriods());
        snapshotTask = new TimeoutTask(new FixedRateTrigger(0, snapshotPeriodMillis), this);
    }
    checkForDisabledPoints();
}
Also used : FixedRateTrigger(com.serotonin.timer.FixedRateTrigger) DataPointRT(com.serotonin.m2m2.rt.dataImage.DataPointRT) TimeoutTask(com.serotonin.m2m2.util.timeout.TimeoutTask)

Example 2 with PublishedPointRT

use of com.serotonin.m2m2.rt.publish.PublishedPointRT in project ma-core-public by infiniteautomation.

the class RuntimeManagerImpl method startPublishedPoint.

@Override
public void startPublishedPoint(PublishedPointVO vo) {
    // Ensure that the published point is saved and enabled.
    Assert.isTrue(vo.getId() > 0, "Published point must be saved");
    Assert.isTrue(vo.isEnabled(), "Published point not enabled");
    ensureState(ILifecycleState.INITIALIZING, ILifecycleState.RUNNING);
    // Only add the published point if its publisher is enabled.
    PublisherRT<? extends PublisherVO, ? extends PublishedPointVO, ? extends SendThread> pub = runningPublishers.get(vo.getPublisherId());
    if (pub != null) {
        PublishedPointRT point = publishedPointCache.computeIfAbsent(vo.getId(), k -> new PublishedPointRT(vo, pub));
        // Initialize it, will fail if published point is already initializing or running
        point.initialize(false);
    }
}
Also used : PublishedPointRT(com.serotonin.m2m2.rt.publish.PublishedPointRT)

Example 3 with PublishedPointRT

use of com.serotonin.m2m2.rt.publish.PublishedPointRT in project ma-core-public by infiniteautomation.

the class PublisherRT method checkForDisabledPoints.

private synchronized void checkForDisabledPoints() {
    int badPointId = -1;
    String disabledPoint = null;
    pointListChangeLock.readLock().lock();
    try {
        for (PublishedPointRT<POINT> rt : publishedPoints) {
            if (!rt.isPointEnabled()) {
                badPointId = rt.getVo().getDataPointId();
                disabledPoint = dataPointDao.getXidById(badPointId);
                break;
            }
        }
    } finally {
        pointListChangeLock.readLock().unlock();
    }
    boolean foundBadPoint = badPointId != -1;
    if (pointEventActive != foundBadPoint) {
        pointEventActive = foundBadPoint;
        if (pointEventActive) {
            // A published point has been terminated, was never enabled, or no longer exists.
            TranslatableMessage lm;
            if (disabledPoint == null)
                // The point is missing
                lm = new TranslatableMessage("event.publish.pointMissing", badPointId);
            else
                lm = new TranslatableMessage("event.publish.pointDisabled", disabledPoint);
            Common.eventManager.raiseEvent(pointDisabledEventType, Common.timer.currentTimeMillis(), true, vo.getAlarmLevel(POINT_DISABLED_EVENT, AlarmLevels.URGENT), lm, createEventContext());
        } else
            // Everything is good
            Common.eventManager.returnToNormal(pointDisabledEventType, Common.timer.currentTimeMillis());
    }
}
Also used : TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage)

Example 4 with PublishedPointRT

use of com.serotonin.m2m2.rt.publish.PublishedPointRT in project ma-core-public by MangoAutomation.

the class PublisherRT method checkForDisabledPoints.

private synchronized void checkForDisabledPoints() {
    int badPointId = -1;
    String disabledPoint = null;
    pointListChangeLock.readLock().lock();
    try {
        for (PublishedPointRT<POINT> rt : publishedPoints) {
            if (!rt.isPointEnabled()) {
                badPointId = rt.getVo().getDataPointId();
                disabledPoint = dataPointDao.getXidById(badPointId);
                break;
            }
        }
    } finally {
        pointListChangeLock.readLock().unlock();
    }
    boolean foundBadPoint = badPointId != -1;
    if (pointEventActive != foundBadPoint) {
        pointEventActive = foundBadPoint;
        if (pointEventActive) {
            // A published point has been terminated, was never enabled, or no longer exists.
            TranslatableMessage lm;
            if (disabledPoint == null)
                // The point is missing
                lm = new TranslatableMessage("event.publish.pointMissing", badPointId);
            else
                lm = new TranslatableMessage("event.publish.pointDisabled", disabledPoint);
            Common.eventManager.raiseEvent(pointDisabledEventType, Common.timer.currentTimeMillis(), true, vo.getAlarmLevel(POINT_DISABLED_EVENT, AlarmLevels.URGENT), lm, createEventContext());
        } else
            // Everything is good
            Common.eventManager.returnToNormal(pointDisabledEventType, Common.timer.currentTimeMillis());
    }
}
Also used : TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage)

Example 5 with PublishedPointRT

use of com.serotonin.m2m2.rt.publish.PublishedPointRT in project ma-core-public by MangoAutomation.

the class RuntimeManagerImpl method startPublishedPoint.

@Override
public void startPublishedPoint(PublishedPointVO vo) {
    // Ensure that the published point is saved and enabled.
    Assert.isTrue(vo.getId() > 0, "Published point must be saved");
    Assert.isTrue(vo.isEnabled(), "Published point not enabled");
    ensureState(ILifecycleState.INITIALIZING, ILifecycleState.RUNNING);
    // Only add the published point if its publisher is enabled.
    PublisherRT<? extends PublisherVO, ? extends PublishedPointVO, ? extends SendThread> pub = runningPublishers.get(vo.getPublisherId());
    if (pub != null) {
        PublishedPointRT point = publishedPointCache.computeIfAbsent(vo.getId(), k -> new PublishedPointRT(vo, pub));
        // Initialize it, will fail if published point is already initializing or running
        point.initialize(false);
    }
}
Also used : PublishedPointRT(com.serotonin.m2m2.rt.publish.PublishedPointRT)

Aggregations

TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)2 PublishedPointRT (com.serotonin.m2m2.rt.publish.PublishedPointRT)2 DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)1 TimeoutTask (com.serotonin.m2m2.util.timeout.TimeoutTask)1 FixedRateTrigger (com.serotonin.timer.FixedRateTrigger)1