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();
}
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);
}
}
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());
}
}
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());
}
}
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);
}
}
Aggregations