link start!
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.schema.NSlot;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class ActionQueue {
|
||||
private Entry temp;
|
||||
private HashMap map;
|
||||
private Entry head;
|
||||
private Entry tail;
|
||||
private int peak;
|
||||
|
||||
public final int size() {
|
||||
return this.map.size();
|
||||
}
|
||||
|
||||
public final int peak() {
|
||||
return this.peak;
|
||||
}
|
||||
|
||||
public final void enqueue(BComponent bComponent, Action action, BValue bValue) {
|
||||
this.temp.init(bComponent, action, bValue);
|
||||
if (this.map.get(this.temp) != null) {
|
||||
return;
|
||||
}
|
||||
Entry entry = this.temp;
|
||||
this.temp = new Entry();
|
||||
this.map.put(entry, this);
|
||||
if (this.tail == null) {
|
||||
this.head = this.tail = entry;
|
||||
} else {
|
||||
this.tail.next = entry;
|
||||
this.tail = entry;
|
||||
}
|
||||
if (this.map.size() > this.peak) {
|
||||
this.peak = this.map.size();
|
||||
}
|
||||
}
|
||||
|
||||
public final Entry reset() {
|
||||
Entry entry = this.head;
|
||||
this.map.clear();
|
||||
this.tail = null;
|
||||
this.head = null;
|
||||
return entry;
|
||||
}
|
||||
|
||||
public final Iterator iterator() {
|
||||
return this.map.keySet().iterator();
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.temp = new Entry();
|
||||
this.map = new HashMap();
|
||||
}
|
||||
|
||||
public ActionQueue() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
public static final class Entry {
|
||||
public BComponent component;
|
||||
public Action action;
|
||||
public BValue arg;
|
||||
public int hashCode;
|
||||
public Entry next;
|
||||
|
||||
public final void init(BComponent bComponent, Action action, BValue bValue) {
|
||||
this.component = bComponent;
|
||||
this.action = action;
|
||||
this.arg = bValue;
|
||||
this.hashCode = bComponent.hashCode() ^ ((NSlot)((Object)action)).index;
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
Entry entry = (Entry)object;
|
||||
boolean bl = false;
|
||||
if (this.component == entry.component && this.action == entry.action) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,563 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.SortUtil
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.Nre;
|
||||
import com.tridium.sys.engine.ActionQueue;
|
||||
import com.tridium.sys.engine.EngineUtil;
|
||||
import com.tridium.sys.engine.NClockTicket;
|
||||
import com.tridium.sys.engine.TicketQueue;
|
||||
import com.tridium.sys.resource.ResourceReport;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyDir;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BStation;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.NotRunningException;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Sys;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class EngineManager {
|
||||
static DecimalFormat timeFormat = new DecimalFormat("#.000 ms");
|
||||
public static final Log log = Log.getLog("sys.engine");
|
||||
public static long engineSleepPeriod = 20L;
|
||||
private static final int SYSTEM_CLOCK_CHANGE_TOLERANCE = 1000;
|
||||
public static long shortTimerThreshold = 2100L;
|
||||
public static long mediumTimerThreshold = 61000L;
|
||||
private long startTicks;
|
||||
private volatile int scanCount;
|
||||
private int ticketScanCount;
|
||||
private long totalTicksInsideScan;
|
||||
private long lastTotalTicksInsideScan;
|
||||
private long deltaTicksInsideScan;
|
||||
private long peakTicksInsideScan;
|
||||
private boolean suspended;
|
||||
private ActionQueue actionQueue;
|
||||
private BComponent currentComponent;
|
||||
private Action currentAction;
|
||||
private long lastMillisVsTicksDelta;
|
||||
public TicketQueue shortTimers;
|
||||
public TicketQueue mediumTimers;
|
||||
public TicketQueue longTimers;
|
||||
|
||||
public void start(BComponent bComponent) {
|
||||
if (!bComponent.isRunning()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.activateLinks(bComponent);
|
||||
EngineUtil.started(bComponent);
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextComponent()) {
|
||||
if (Flags.isNoRun(bComponent, slotCursor.property())) continue;
|
||||
slotCursor.get().asComponent().start();
|
||||
}
|
||||
EngineUtil.descendantsStarted(bComponent);
|
||||
}
|
||||
|
||||
private final void activateLinks(BComponent bComponent) {
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextObject()) {
|
||||
BObject bObject = slotCursor.get();
|
||||
if (!(bObject instanceof BLink)) continue;
|
||||
EngineUtil.activate((BLink)bObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(BComponent bComponent) {
|
||||
if (bComponent.isRunning()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.deactivateLinks(bComponent);
|
||||
EngineUtil.stopped(bComponent);
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextComponent()) {
|
||||
slotCursor.get().asComponent().stop();
|
||||
}
|
||||
EngineUtil.descendantsStopped(bComponent);
|
||||
}
|
||||
|
||||
private final void deactivateLinks(BComponent bComponent) {
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextObject()) {
|
||||
BObject bObject = slotCursor.get();
|
||||
if (!(bObject instanceof BLink)) continue;
|
||||
EngineUtil.deactivate((BLink)bObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void stationStarted(BComponent bComponent) {
|
||||
EngineUtil.stationStarted(bComponent);
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextComponent()) {
|
||||
this.stationStarted(slotCursor.get().asComponent());
|
||||
}
|
||||
}
|
||||
|
||||
public void atSteadyState(BComponent bComponent) {
|
||||
if (!bComponent.isRunning()) {
|
||||
log.warning("Not running: " + bComponent);
|
||||
return;
|
||||
}
|
||||
EngineUtil.atSteadyState(bComponent);
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextComponent()) {
|
||||
this.atSteadyState(slotCursor.get().asComponent());
|
||||
}
|
||||
}
|
||||
|
||||
void execute() {
|
||||
long l = Clock.ticks();
|
||||
this.checkIfSystemClockChanged();
|
||||
this.shortTimers.check();
|
||||
this.mediumTimers.check();
|
||||
this.longTimers.check();
|
||||
this.checkAsyncActions();
|
||||
long l2 = Clock.ticks();
|
||||
long l3 = l2 - l;
|
||||
if (l3 > this.peakTicksInsideScan) {
|
||||
this.peakTicksInsideScan = l3;
|
||||
}
|
||||
this.totalTicksInsideScan += l3;
|
||||
++this.scanCount;
|
||||
if (this.scanCount % 10 == 0) {
|
||||
this.deltaTicksInsideScan = this.totalTicksInsideScan - this.lastTotalTicksInsideScan;
|
||||
this.lastTotalTicksInsideScan = this.totalTicksInsideScan;
|
||||
}
|
||||
}
|
||||
|
||||
private final void checkIfSystemClockChanged() {
|
||||
long l = this.getSystemClockWarp();
|
||||
if (l != 0L) {
|
||||
log.warning("System clock modified: " + l + "ms");
|
||||
this.clockChanged(Sys.getStation(), BRelTime.make(l));
|
||||
}
|
||||
}
|
||||
|
||||
private final long getMillisVsTicksDelta() {
|
||||
long l = Clock.ticks();
|
||||
long l2 = Clock.millis();
|
||||
long l3 = Clock.ticks();
|
||||
if (l3 - l > 1000L) {
|
||||
return 0L;
|
||||
}
|
||||
long l4 = l3 - l2;
|
||||
return l4 >= 0L ? l4 : -l4;
|
||||
}
|
||||
|
||||
private final long getSystemClockWarp() {
|
||||
long l = this.getMillisVsTicksDelta();
|
||||
if (l == 0L) {
|
||||
return 0L;
|
||||
}
|
||||
long l2 = l - this.lastMillisVsTicksDelta;
|
||||
if (Math.abs(l2) < 1000L) {
|
||||
return 0L;
|
||||
}
|
||||
this.lastMillisVsTicksDelta = l;
|
||||
return l2;
|
||||
}
|
||||
|
||||
public void clockChanged(BComponent bComponent, BRelTime bRelTime) {
|
||||
try {
|
||||
if (bComponent == null) {
|
||||
return;
|
||||
}
|
||||
EngineUtil.clockChanged(bComponent, bRelTime);
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextComponent()) {
|
||||
this.clockChanged(slotCursor.get().asComponent(), bRelTime);
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void enqueueAction(BComponent bComponent, Action action, BValue bValue) {
|
||||
ActionQueue actionQueue = this.actionQueue;
|
||||
synchronized (actionQueue) {
|
||||
if (bComponent == this.currentComponent && action == this.currentAction) {
|
||||
return;
|
||||
}
|
||||
this.actionQueue.enqueue(bComponent, action, bValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
void checkAsyncActions() {
|
||||
var1_1 = null;
|
||||
var2_2 = this.actionQueue;
|
||||
synchronized (var2_2) {
|
||||
var1_1 = this.actionQueue.reset();
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl6 : MonitorExitStatement: MONITOREXIT : var2_2
|
||||
if (true) ** GOTO lbl17
|
||||
}
|
||||
do {
|
||||
this.currentComponent = var1_1.component;
|
||||
this.currentAction = var1_1.action;
|
||||
EngineUtil.doInvoke(var1_1.component, var1_1.action, var1_1.arg, null);
|
||||
var4_3 = var1_1;
|
||||
var1_1 = var1_1.next;
|
||||
var4_3.next = null;
|
||||
lbl17:
|
||||
// 2 sources
|
||||
|
||||
} while (var1_1 != null);
|
||||
this.currentComponent = null;
|
||||
this.currentAction = null;
|
||||
}
|
||||
|
||||
public NClockTicket schedule(BComponent bComponent, BRelTime bRelTime, Action action, BValue bValue) {
|
||||
if (!bComponent.isRunning()) {
|
||||
throw new NotRunningException();
|
||||
}
|
||||
if (action == null) {
|
||||
throw new NullPointerException("Null action");
|
||||
}
|
||||
long l = bRelTime.getMillis();
|
||||
if (l <= 0L) {
|
||||
throw new IllegalArgumentException("time <= 0");
|
||||
}
|
||||
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
|
||||
nClockTicket.nextUpdate = -(Clock.ticks() + l);
|
||||
nClockTicket.period = 0L;
|
||||
this.enqueueTicket(nClockTicket);
|
||||
return nClockTicket;
|
||||
}
|
||||
|
||||
public NClockTicket schedule(BComponent bComponent, BAbsTime bAbsTime, Action action, BValue bValue) {
|
||||
if (!bComponent.isRunning()) {
|
||||
throw new NotRunningException();
|
||||
}
|
||||
if (action == null) {
|
||||
throw new NullPointerException("Null action");
|
||||
}
|
||||
long l = bAbsTime.getMillis();
|
||||
if (l <= 0L) {
|
||||
throw new IllegalArgumentException("time <= 0");
|
||||
}
|
||||
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
|
||||
nClockTicket.nextUpdate = l;
|
||||
nClockTicket.period = 0L;
|
||||
this.enqueueTicket(nClockTicket);
|
||||
return nClockTicket;
|
||||
}
|
||||
|
||||
public NClockTicket schedulePeriodically(BComponent bComponent, BRelTime bRelTime, Action action, BValue bValue) {
|
||||
if (!bComponent.isRunning()) {
|
||||
throw new NotRunningException();
|
||||
}
|
||||
if (action == null) {
|
||||
throw new NullPointerException("Null action");
|
||||
}
|
||||
long l = bRelTime.getMillis();
|
||||
if (l <= 0L) {
|
||||
throw new IllegalArgumentException("period <= 0");
|
||||
}
|
||||
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
|
||||
nClockTicket.nextUpdate = -(Clock.ticks() + l);
|
||||
nClockTicket.period = l;
|
||||
this.enqueueTicket(nClockTicket);
|
||||
return nClockTicket;
|
||||
}
|
||||
|
||||
public NClockTicket schedulePeriodically(BComponent bComponent, BAbsTime bAbsTime, BRelTime bRelTime, Action action, BValue bValue) {
|
||||
if (!bComponent.isRunning()) {
|
||||
throw new NotRunningException();
|
||||
}
|
||||
if (action == null) {
|
||||
throw new NullPointerException("Null action");
|
||||
}
|
||||
long l = bAbsTime.getMillis();
|
||||
long l2 = bRelTime.getMillis();
|
||||
if (l <= 0L) {
|
||||
throw new IllegalArgumentException("start <= 0");
|
||||
}
|
||||
if (l2 <= 0L) {
|
||||
throw new IllegalArgumentException("period <= 0");
|
||||
}
|
||||
NClockTicket nClockTicket = new NClockTicket(bComponent, action, bValue);
|
||||
nClockTicket.nextUpdate = l;
|
||||
nClockTicket.period = l2;
|
||||
this.enqueueTicket(nClockTicket);
|
||||
return nClockTicket;
|
||||
}
|
||||
|
||||
void enqueueTicket(NClockTicket nClockTicket) {
|
||||
long l = nClockTicket.period;
|
||||
if (l <= 0L) {
|
||||
l = nClockTicket.millisLeft();
|
||||
}
|
||||
if (l < shortTimerThreshold) {
|
||||
this.shortTimers.enqueue(nClockTicket);
|
||||
} else if (l < mediumTimerThreshold) {
|
||||
this.mediumTimers.enqueue(nClockTicket);
|
||||
} else {
|
||||
this.longTimers.enqueue(nClockTicket);
|
||||
}
|
||||
}
|
||||
|
||||
public void reportResources(ResourceReport resourceReport) {
|
||||
double d = (double)this.totalTicksInsideScan / (double)this.scanCount;
|
||||
double d2 = (double)this.deltaTicksInsideScan / 10.0;
|
||||
double d3 = Clock.ticks() - this.startTicks;
|
||||
double d4 = (double)this.totalTicksInsideScan / d3 * 100.0;
|
||||
resourceReport.put("engine.scan.lifetime", timeFormat.format(d));
|
||||
resourceReport.put("engine.scan.peak", timeFormat.format(this.peakTicksInsideScan));
|
||||
resourceReport.put("engine.scan.recent", timeFormat.format(d2));
|
||||
resourceReport.put("engine.scan.usage", "" + (int)d4 + '%');
|
||||
resourceReport.put("engine.queue.shortTimers", this.shortTimers.size + " (Peak " + this.shortTimers.peak + ')');
|
||||
resourceReport.put("engine.queue.mediumTimers", this.mediumTimers.size + " (Peak " + this.mediumTimers.peak + ')');
|
||||
resourceReport.put("engine.queue.longTimers", this.longTimers.size + " (Peak " + this.longTimers.peak + ')');
|
||||
resourceReport.put("engine.queue.actions", this.actionQueue.size() + " (Peak " + this.actionQueue.peak() + ')');
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
SummaryPage summaryPage = new SummaryPage();
|
||||
Nre.spySysManagers.add("engineManager", summaryPage);
|
||||
summaryPage.add("shortTimers", new TicketQueuePage(this.shortTimers));
|
||||
summaryPage.add("mediumTimers", new TicketQueuePage(this.mediumTimers));
|
||||
summaryPage.add("longTimers", new TicketQueuePage(this.longTimers));
|
||||
summaryPage.add("asyncQueue", new AsyncQueuePage());
|
||||
summaryPage.add("hogs", new HogsPage());
|
||||
}
|
||||
|
||||
static String timeStr(long l) {
|
||||
return l + "ms [" + BRelTime.toString(l) + ']';
|
||||
}
|
||||
|
||||
public void suspend() {
|
||||
this.suspended = true;
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
this.suspended = false;
|
||||
}
|
||||
|
||||
public int getCycles() {
|
||||
return this.scanCount;
|
||||
}
|
||||
|
||||
public long getTotalTicksInsideCycle() {
|
||||
return this.totalTicksInsideScan;
|
||||
}
|
||||
|
||||
public float getAvgerageTicks() {
|
||||
double d = (double)this.deltaTicksInsideScan / 10.0;
|
||||
return (float)d;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.lastTotalTicksInsideScan = 0L;
|
||||
this.deltaTicksInsideScan = 0L;
|
||||
this.peakTicksInsideScan = 0L;
|
||||
this.suspended = false;
|
||||
this.actionQueue = new ActionQueue();
|
||||
this.shortTimers = new TicketQueue(100, 1000);
|
||||
this.mediumTimers = new TicketQueue(1000, 10000);
|
||||
this.longTimers = new TicketQueue(1000, 30000);
|
||||
}
|
||||
|
||||
public EngineManager() {
|
||||
this.this();
|
||||
this.startTicks = Clock.ticks();
|
||||
this.lastMillisVsTicksDelta = this.getMillisVsTicksDelta();
|
||||
new EngineThread().start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class SummaryPage
|
||||
extends SpyDir {
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
double d = (double)EngineManager.this.totalTicksInsideScan / (double)EngineManager.this.scanCount;
|
||||
double d2 = (double)EngineManager.this.deltaTicksInsideScan / 10.0;
|
||||
BComponent bComponent = EngineManager.this.currentComponent;
|
||||
Action action = EngineManager.this.currentAction;
|
||||
spyWriter.startProps();
|
||||
spyWriter.prop((Object)"atSteadyState", Sys.atSteadyState());
|
||||
spyWriter.prop((Object)"suspended", "" + EngineManager.this.suspended);
|
||||
spyWriter.prop((Object)"scanCount", "" + EngineManager.this.scanCount);
|
||||
spyWriter.prop((Object)"runtime", EngineManager.timeStr(Clock.ticks() - EngineManager.this.startTicks));
|
||||
spyWriter.prop((Object)"totalTicksInsideScan", EngineManager.timeStr(EngineManager.this.totalTicksInsideScan));
|
||||
spyWriter.prop((Object)"averageTime/scan", d + "ms");
|
||||
spyWriter.prop((Object)"averageTimeLast10Scan", d2 + "ms");
|
||||
spyWriter.prop((Object)"peakScanTime", EngineManager.this.peakTicksInsideScan + "ms");
|
||||
spyWriter.trTitle("Actions", 2);
|
||||
spyWriter.prop((Object)"currentComponent", bComponent == null ? "null" : bComponent.toDebugString());
|
||||
spyWriter.prop((Object)"currentAction", action);
|
||||
spyWriter.prop((Object)("<a href='" + spyWriter.href("asyncQueue") + "'>Async Action Queue</a>"), EngineManager.this.actionQueue.size() + " (Peak " + EngineManager.this.actionQueue.peak() + ')');
|
||||
spyWriter.prop((Object)("<a href='" + spyWriter.href("hogs") + "'>Engine Hogs</a>"), "");
|
||||
spyWriter.trTitle("Short Timers (" + shortTimerThreshold + "ms or less)", 2);
|
||||
EngineManager.this.shortTimers.writeSummary(spyWriter, "shortTimers");
|
||||
spyWriter.trTitle("Medium Timers (" + shortTimerThreshold + "ms to " + mediumTimerThreshold + "ms)", 2);
|
||||
EngineManager.this.mediumTimers.writeSummary(spyWriter, "mediumTimers");
|
||||
spyWriter.trTitle("Long Timers (" + mediumTimerThreshold + "ms or greater)", 2);
|
||||
EngineManager.this.longTimers.writeSummary(spyWriter, "longTimers");
|
||||
spyWriter.endProps();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TicketQueuePage
|
||||
extends Spy {
|
||||
TicketQueue q;
|
||||
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
long l = Clock.millis();
|
||||
long l2 = Clock.ticks();
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle("Timer Clock.Ticket Queue: " + BAbsTime.make(), 6);
|
||||
spyWriter.w("<tr>").th("Mode").th("Next Update").th("Period").th("Component").th("Action").th("ActionArg").w("</tr>\n");
|
||||
int n = 0;
|
||||
NClockTicket nClockTicket = this.q.head;
|
||||
while (nClockTicket != null) {
|
||||
long l3 = nClockTicket.millisLeft();
|
||||
if (++n > 1000) {
|
||||
spyWriter.tr("more...", "", "", "", "", "");
|
||||
break;
|
||||
}
|
||||
spyWriter.tr(nClockTicket.nextUpdate < 0L ? "ticks" : "millis", EngineManager.timeStr(l3), "" + nClockTicket.period, nClockTicket.component.toDebugString(), nClockTicket.action, nClockTicket.arg);
|
||||
nClockTicket = nClockTicket.next;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
TicketQueuePage(TicketQueue ticketQueue) {
|
||||
this.q = ticketQueue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AsyncQueuePage
|
||||
extends Spy {
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle("Async Action Queue", 2);
|
||||
spyWriter.w("<tr>").th("Component").th("Action").w("</tr>\n");
|
||||
ActionQueue actionQueue = EngineManager.this.actionQueue;
|
||||
synchronized (actionQueue) {
|
||||
int n = 0;
|
||||
Iterator iterator = EngineManager.this.actionQueue.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (++n > 1000) {
|
||||
spyWriter.tr("more...", "");
|
||||
break;
|
||||
}
|
||||
ActionQueue.Entry entry = (ActionQueue.Entry)iterator.next();
|
||||
spyWriter.tr(entry.component.toDebugString(), entry.action);
|
||||
}
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class HogsPage
|
||||
extends Spy {
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
BStation bStation = Sys.getStation();
|
||||
if (bStation == null) {
|
||||
spyWriter.w("Not station VM");
|
||||
return;
|
||||
}
|
||||
Object[] objectArray = bStation.getComponentSpace().getAllComponents();
|
||||
Object[] objectArray2 = new Long[objectArray.length];
|
||||
Long l = new Long(0L);
|
||||
int n = 0;
|
||||
while (n < objectArray.length) {
|
||||
objectArray2[n] = (Long)((BObject)objectArray[n]).fw(22);
|
||||
if (objectArray2[n] == null) {
|
||||
objectArray2[n] = l;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)false);
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle("Engine Hogs", 4);
|
||||
spyWriter.w("<tr>").th("Rank").th("Component").th("Type").th("Total Time").w("</tr>\n");
|
||||
n = 0;
|
||||
while (n < 100 && n < objectArray.length) {
|
||||
Object object = objectArray[n];
|
||||
if (objectArray2[n] == l) break;
|
||||
long l2 = (Long)objectArray2[n];
|
||||
spyWriter.tr("" + n, ((BComponent)object).toPathString(), ((BComponent)object).getType(), EngineManager.timeStr(l2 / 1000000L));
|
||||
++n;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class EngineThread
|
||||
extends Thread {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(engineSleepPeriod);
|
||||
if (EngineManager.this.suspended) continue;
|
||||
EngineManager.this.execute();
|
||||
continue;
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Error in run", throwable);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public EngineThread() {
|
||||
super(Nre.mainThreadGroup, "Nre:Engine");
|
||||
this.setDaemon(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.EngineManager;
|
||||
import com.tridium.sys.schema.ComponentSlotMap;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.ActionInvokeException;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Topic;
|
||||
|
||||
public final class EngineUtil {
|
||||
public static final Log log = EngineManager.log;
|
||||
|
||||
public static final void invoke(BComponent bComponent, Action action, BValue bValue, Context context) {
|
||||
try {
|
||||
bComponent.invoke(action, bValue, context);
|
||||
}
|
||||
catch (ActionInvokeException actionInvokeException) {
|
||||
log.error("Action failed: " + action, actionInvokeException.getCause());
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Action failed: " + action, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void doInvoke(BComponent bComponent, Action action, BValue bValue, Context context) {
|
||||
try {
|
||||
((ComponentSlotMap)bComponent.fw(1)).invoke(action, bValue, context, true);
|
||||
}
|
||||
catch (ActionInvokeException actionInvokeException) {
|
||||
log.error("Action failed: " + action, actionInvokeException.getCause());
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Action failed: " + action, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void fire(BComponent bComponent, Topic topic, BValue bValue) {
|
||||
try {
|
||||
bComponent.fire(topic, bValue);
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Topic failed: " + topic, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void activate(BLink bLink) {
|
||||
try {
|
||||
if (bLink.isEnabled()) {
|
||||
bLink.activate();
|
||||
}
|
||||
}
|
||||
catch (UnresolvedException unresolvedException) {
|
||||
log.error("Cannot activate link \"" + EngineUtil.toString(bLink) + "\": " + unresolvedException.getMessage());
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot activate link \"" + EngineUtil.toString(bLink) + '\"', throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void deactivate(BLink bLink) {
|
||||
try {
|
||||
if (bLink.isActive()) {
|
||||
bLink.deactivate();
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot deactivate link \"" + EngineUtil.toString(bLink) + '\"', throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void started(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(11, null, null, null, null);
|
||||
bComponent.started();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot start component: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void stopped(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(12, null, null, null, null);
|
||||
bComponent.stopped();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot stop component: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void descendantsStarted(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(13, null, null, null, null);
|
||||
bComponent.descendantsStarted();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot start component: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void descendantsStopped(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(14, null, null, null, null);
|
||||
bComponent.descendantsStopped();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Cannot stop component: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void stationStarted(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(23, null, null, null, null);
|
||||
bComponent.stationStarted();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Failed stationStarted: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void atSteadyState(BComponent bComponent) {
|
||||
try {
|
||||
bComponent.fw(20, null, null, null, null);
|
||||
bComponent.atSteadyState();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Failed atSteadyState: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void clockChanged(BComponent bComponent, BRelTime bRelTime) {
|
||||
try {
|
||||
bComponent.clockChanged(bRelTime);
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
log.error("Failed clockChanged: " + EngineUtil.toString(bComponent), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String toString(Object object) {
|
||||
try {
|
||||
return String.valueOf(object);
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
return object.getClass().getName() + "???";
|
||||
}
|
||||
}
|
||||
|
||||
public static final void activateLinks(BComponent bComponent) {
|
||||
try {
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextObject()) {
|
||||
BObject bObject = slotCursor.get();
|
||||
if (bObject instanceof BLink) {
|
||||
EngineUtil.activate((BLink)bObject);
|
||||
}
|
||||
if (!(bObject instanceof BComponent)) continue;
|
||||
EngineUtil.activateLinks((BComponent)bObject);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static final void deactivateLinks(BComponent bComponent) {
|
||||
try {
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
while (slotCursor.nextObject()) {
|
||||
BObject bObject = slotCursor.get();
|
||||
if (bObject instanceof BLink) {
|
||||
EngineUtil.deactivate((BLink)bObject);
|
||||
}
|
||||
if (!(bObject instanceof BComponent)) continue;
|
||||
EngineUtil.deactivateLinks((BComponent)bObject);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.SortUtil
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.Nre;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.spy.SpyDir;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BComponentEvent;
|
||||
import javax.baja.sys.BasicContext;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Subscriber;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class LeaseManager {
|
||||
static final Log log = Log.getLog("sys.lease");
|
||||
HashMap map;
|
||||
public final Subscriber subscriber;
|
||||
|
||||
public long getLeaseExpiration(BComponent bComponent) {
|
||||
Entry entry = (Entry)this.map.get(bComponent);
|
||||
if (entry == null) {
|
||||
return -1;
|
||||
}
|
||||
return entry.expiration;
|
||||
}
|
||||
|
||||
public void lease(BComponent bComponent, int n, long l) {
|
||||
this.subscriber.subscribe(bComponent, n, (Context)new LeaseContext(l));
|
||||
}
|
||||
|
||||
public void lease(BComponent[] bComponentArray, int n, long l) {
|
||||
this.subscriber.subscribe(bComponentArray, n, (Context)new LeaseContext(l));
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
void checkLease(BComponent bComponent, LeaseContext leaseContext) {
|
||||
HashMap hashMap = this.map;
|
||||
synchronized (hashMap) {
|
||||
block6: {
|
||||
Entry entry;
|
||||
block5: {
|
||||
entry = (Entry)this.map.get(bComponent);
|
||||
if (entry != null) break block5;
|
||||
entry = new Entry();
|
||||
entry.component = bComponent;
|
||||
entry.expiration = leaseContext.expiration;
|
||||
this.map.put(bComponent, entry);
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Lease new: " + bComponent.toPathString() + ' ' + leaseContext.millis + "ms");
|
||||
}
|
||||
break block6;
|
||||
}
|
||||
entry.expiration = Math.max(entry.expiration, leaseContext.expiration);
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Lease renew: " + bComponent.toPathString() + ' ' + leaseContext.millis + "ms");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
Nre.spySysManagers.add("leaseManager", new SummaryPage());
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.map = new HashMap();
|
||||
this.subscriber = new LeaseSubscriber();
|
||||
}
|
||||
|
||||
public LeaseManager() {
|
||||
this.this();
|
||||
new LeaseThread().start();
|
||||
}
|
||||
|
||||
static class Entry {
|
||||
BComponent component;
|
||||
long expiration;
|
||||
|
||||
Entry() {
|
||||
}
|
||||
}
|
||||
|
||||
static class LeaseContext
|
||||
extends BasicContext {
|
||||
long millis;
|
||||
long expiration;
|
||||
|
||||
LeaseContext(long l) {
|
||||
this.millis = l;
|
||||
this.expiration = Clock.ticks() + l;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class SummaryPage
|
||||
extends SpyDir {
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
Object[] objectArray = LeaseManager.this.map.values().toArray(new Entry[LeaseManager.this.map.size()]);
|
||||
Object[] objectArray2 = new String[objectArray.length];
|
||||
int n = 0;
|
||||
while (n < objectArray2.length) {
|
||||
objectArray2[n] = "" + ((Entry)objectArray[n]).component.getNavOrd();
|
||||
++n;
|
||||
}
|
||||
SortUtil.sort((Object[])objectArray2, (Object[])objectArray);
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle("Lease Manager", 3);
|
||||
spyWriter.w("<tr>").th("Component").th("Type").th("Time Left").w("</tr>");
|
||||
n = 0;
|
||||
while (n < objectArray.length) {
|
||||
Object object = objectArray[n];
|
||||
BComponent bComponent = ((Entry)object).component;
|
||||
String string = ((Entry)object).expiration - Clock.ticks() + "ms";
|
||||
spyWriter.tr(objectArray2[n], bComponent.getType(), string);
|
||||
++n;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class LeaseSubscriber
|
||||
extends Subscriber {
|
||||
public void event(BComponentEvent bComponentEvent) {
|
||||
}
|
||||
|
||||
public boolean doesHandleEvent(int n) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void subscribed(BComponent bComponent, Context context) {
|
||||
LeaseManager.this.checkLease(bComponent, (LeaseContext)context);
|
||||
}
|
||||
|
||||
LeaseSubscriber() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class LeaseThread
|
||||
extends Thread {
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void run() {
|
||||
var1_1 = new ArrayList<BComponent>();
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
var1_1.clear();
|
||||
var2_2 = Clock.ticks();
|
||||
var4_4 = LeaseManager.this.map;
|
||||
synchronized (var4_4) {
|
||||
var6_6 = LeaseManager.this.map.values().toArray(new Entry[LeaseManager.this.map.size()]);
|
||||
var7_7 = 0;
|
||||
while (true) {
|
||||
block12: {
|
||||
if (var7_7 < var6_6.length) break block12;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 3, 7, 8] lbl18 : MonitorExitStatement: MONITOREXIT : var4_4
|
||||
var6_5 = 0;
|
||||
if (true) ** GOTO lbl42
|
||||
}
|
||||
var8_9 = var6_6[var7_7];
|
||||
if (var8_9.expiration < var2_2) {
|
||||
var1_1.add(var8_9.component);
|
||||
LeaseManager.this.map.remove(var8_9.component);
|
||||
if (LeaseManager.log.isTraceOn()) {
|
||||
LeaseManager.log.trace("Expired: " + var8_9.component.toPathString());
|
||||
}
|
||||
}
|
||||
++var7_7;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable var2_3) {
|
||||
LeaseManager.log.error("Error in run", var2_3);
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
var7_8 = (BComponent)var1_1.get(var6_5);
|
||||
try {
|
||||
LeaseManager.this.subscriber.unsubscribe(var7_8);
|
||||
}
|
||||
catch (Throwable var8_10) {
|
||||
LeaseManager.log.error("Cannot unsubscribe: " + var7_8);
|
||||
}
|
||||
++var6_5;
|
||||
lbl42:
|
||||
// 2 sources
|
||||
|
||||
} while (var6_5 < var1_1.size());
|
||||
}
|
||||
}
|
||||
|
||||
public LeaseThread() {
|
||||
super(Nre.mainThreadGroup, "Nre:Lease");
|
||||
this.setDaemon(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.NKnob;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.Slot;
|
||||
|
||||
public final class LocalKnob
|
||||
extends NKnob {
|
||||
private static int idCounter = 0;
|
||||
public final BLink link;
|
||||
|
||||
public final boolean isLocal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean isProxy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void copyFrom(NKnob nKnob) {
|
||||
Thread.dumpStack();
|
||||
}
|
||||
|
||||
public final BLink getLink() {
|
||||
return this.link;
|
||||
}
|
||||
|
||||
public final BOrd getTargetOrd() {
|
||||
return this.link.getTargetComponent().getOrdInSpace();
|
||||
}
|
||||
|
||||
public final BComponent getTargetComponent() {
|
||||
return this.link.getTargetComponent();
|
||||
}
|
||||
|
||||
public final String getTargetSlotName() {
|
||||
return this.link.getTargetSlotName();
|
||||
}
|
||||
|
||||
public final Slot getTargetSlot() {
|
||||
return this.link.getTargetSlot();
|
||||
}
|
||||
|
||||
public final BOrd getSourceOrd() {
|
||||
return this.link.getSourceOrd();
|
||||
}
|
||||
|
||||
public final BComponent getSourceComponent() {
|
||||
return this.link.getSourceComponent();
|
||||
}
|
||||
|
||||
public final String getSourceSlotName() {
|
||||
return this.link.getSourceSlotName();
|
||||
}
|
||||
|
||||
public final Slot getSourceSlot() {
|
||||
return this.link.getSourceSlot();
|
||||
}
|
||||
|
||||
public LocalKnob(BLink bLink) {
|
||||
super(idCounter++);
|
||||
this.link = bLink;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.EngineUtil;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.ExpiredTicketException;
|
||||
|
||||
public final class NClockTicket
|
||||
implements Clock.Ticket {
|
||||
long nextUpdate;
|
||||
long period;
|
||||
BComponent component;
|
||||
Action action;
|
||||
BValue arg;
|
||||
NClockTicket next;
|
||||
|
||||
public final void cancel() {
|
||||
this.nextUpdate = 0L;
|
||||
this.period = -1;
|
||||
this.component = null;
|
||||
this.action = null;
|
||||
this.arg = null;
|
||||
}
|
||||
|
||||
public final boolean isExpired() {
|
||||
boolean bl = false;
|
||||
if (this.component == null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final BComponent getComponent() {
|
||||
if (this.isExpired()) {
|
||||
throw new ExpiredTicketException();
|
||||
}
|
||||
return this.component;
|
||||
}
|
||||
|
||||
public final Action getAction() {
|
||||
if (this.isExpired()) {
|
||||
throw new ExpiredTicketException();
|
||||
}
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public final BValue getActionArgument() {
|
||||
if (this.isExpired()) {
|
||||
throw new ExpiredTicketException();
|
||||
}
|
||||
return this.arg;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
if (this.isExpired()) {
|
||||
return "Ticket: expired";
|
||||
}
|
||||
BFacets bFacets = BFacets.make("showMilliseconds", BBoolean.TRUE);
|
||||
return "Ticket nextUpdate=" + BAbsTime.make(Clock.millis() + this.millisLeft()).toString(bFacets) + " period=" + this.period;
|
||||
}
|
||||
|
||||
public final long millisLeft() {
|
||||
if (this.nextUpdate < 0L) {
|
||||
return -this.nextUpdate - Clock.ticks();
|
||||
}
|
||||
return this.nextUpdate - Clock.millis();
|
||||
}
|
||||
|
||||
final long process(long l, long l2) {
|
||||
BComponent bComponent = this.component;
|
||||
Action action = this.action;
|
||||
BValue bValue = this.arg;
|
||||
if (bComponent == null) {
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
if (!bComponent.isRunning()) {
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
if (this.nextUpdate < 0L) {
|
||||
if (l >= -this.nextUpdate) {
|
||||
if (this.period == 0L) {
|
||||
this.cancel();
|
||||
} else {
|
||||
this.nextUpdate = -(l + this.period);
|
||||
}
|
||||
EngineUtil.invoke(bComponent, action, bValue, null);
|
||||
}
|
||||
} else if (l2 >= this.nextUpdate) {
|
||||
if (this.period == 0L) {
|
||||
this.cancel();
|
||||
} else {
|
||||
this.nextUpdate += this.period;
|
||||
}
|
||||
EngineUtil.invoke(bComponent, action, bValue, null);
|
||||
}
|
||||
if (this.component == null || this.nextUpdate == 0L) {
|
||||
return Long.MIN_VALUE;
|
||||
}
|
||||
if (this.nextUpdate < 0L) {
|
||||
return -this.nextUpdate - l;
|
||||
}
|
||||
return this.nextUpdate - l2;
|
||||
}
|
||||
|
||||
public NClockTicket(BComponent bComponent, Action action, BValue bValue) {
|
||||
this.component = bComponent;
|
||||
this.action = action;
|
||||
this.arg = bValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import javax.baja.sys.Knob;
|
||||
|
||||
public abstract class NKnob
|
||||
implements Knob {
|
||||
public final int id;
|
||||
|
||||
public abstract boolean isLocal();
|
||||
|
||||
public abstract boolean isProxy();
|
||||
|
||||
public abstract void copyFrom(NKnob var1);
|
||||
|
||||
public String toString() {
|
||||
String string = "???";
|
||||
try {
|
||||
string = String.valueOf(this.getTargetOrd());
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(this.getSourceSlotName()).append("->").append(string).append('.').append(this.getTargetSlotName());
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
NKnob(int n) {
|
||||
this.id = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.NKnob;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.Slot;
|
||||
|
||||
public final class ProxyKnob
|
||||
extends NKnob {
|
||||
BComponent source;
|
||||
Slot sourceSlot;
|
||||
BOrd targetOrd;
|
||||
String targetSlot;
|
||||
|
||||
public final boolean isLocal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean isProxy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final BLink getLink() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final BOrd getTargetOrd() {
|
||||
return this.targetOrd;
|
||||
}
|
||||
|
||||
public final BComponent getTargetComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getTargetSlotName() {
|
||||
return this.targetSlot;
|
||||
}
|
||||
|
||||
public final Slot getTargetSlot() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final BOrd getSourceOrd() {
|
||||
return this.source.getOrdInSpace();
|
||||
}
|
||||
|
||||
public final BComponent getSourceComponent() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public final String getSourceSlotName() {
|
||||
return this.sourceSlot.getName();
|
||||
}
|
||||
|
||||
public final Slot getSourceSlot() {
|
||||
return this.sourceSlot;
|
||||
}
|
||||
|
||||
public final void copyFrom(NKnob nKnob) {
|
||||
try {
|
||||
ProxyKnob proxyKnob = (ProxyKnob)nKnob;
|
||||
this.targetOrd = proxyKnob.targetOrd;
|
||||
this.targetSlot = proxyKnob.targetSlot;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ProxyKnob(int n, BComponent bComponent, Slot slot, BOrd bOrd, String string) {
|
||||
super(n);
|
||||
this.source = bComponent;
|
||||
this.sourceSlot = slot;
|
||||
this.targetOrd = bOrd;
|
||||
this.targetSlot = string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.EngineManager;
|
||||
import com.tridium.sys.engine.NKnob;
|
||||
import com.tridium.sys.schema.NSlot;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.sys.ActionInvokeException;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.BValue;
|
||||
|
||||
public final class SlotKnobs {
|
||||
private static final NKnob[] noKnobs = new NKnob[0];
|
||||
public final BComponent sourceComponent;
|
||||
public final NSlot sourceSlot;
|
||||
public NKnob[] knobs;
|
||||
public int size;
|
||||
|
||||
public final void propagate(BValue bValue) {
|
||||
int n = 0;
|
||||
while (n < this.size) {
|
||||
BLink bLink = null;
|
||||
try {
|
||||
bLink = this.knobs[n].getLink();
|
||||
if (bLink != null && bLink.isEnabled()) {
|
||||
bLink.propagate(bValue);
|
||||
}
|
||||
}
|
||||
catch (ActionInvokeException actionInvokeException) {
|
||||
EngineManager.log.error("Link propogate: " + bLink, actionInvokeException.getCause());
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
EngineManager.log.error("Link propogate: " + bLink, throwable);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final NKnob get(int n) {
|
||||
int n2 = 0;
|
||||
while (n2 < this.size) {
|
||||
if (this.knobs[n2].id == n) {
|
||||
return this.knobs[n2];
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final NKnob[] list() {
|
||||
NKnob[] nKnobArray = new NKnob[this.size];
|
||||
System.arraycopy(this.knobs, 0, nKnobArray, 0, this.size);
|
||||
return nKnobArray;
|
||||
}
|
||||
|
||||
public final void appendTo(ArrayList arrayList) {
|
||||
int n = 0;
|
||||
while (n < this.size) {
|
||||
arrayList.add(this.knobs[n]);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final void add(NKnob nKnob) {
|
||||
if (this.size >= this.knobs.length) {
|
||||
NKnob[] nKnobArray = new NKnob[Math.max(this.size * 2, 4)];
|
||||
System.arraycopy(this.knobs, 0, nKnobArray, 0, this.knobs.length);
|
||||
this.knobs = nKnobArray;
|
||||
}
|
||||
this.knobs[this.size++] = nKnob;
|
||||
}
|
||||
|
||||
public final void remove(NKnob nKnob) {
|
||||
int n = 0;
|
||||
while (n < this.size) {
|
||||
if (this.knobs[n] == nKnob) {
|
||||
if (n < this.knobs.length) {
|
||||
System.arraycopy(this.knobs, n + 1, this.knobs, n, this.knobs.length - n - 1);
|
||||
}
|
||||
this.knobs[this.size - 1] = null;
|
||||
--this.size;
|
||||
return;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public SlotKnobs(BComponent bComponent, NSlot nSlot, NKnob nKnob) {
|
||||
this(bComponent, nSlot);
|
||||
this.knobs = new NKnob[]{nKnob};
|
||||
this.size = 1;
|
||||
}
|
||||
|
||||
public SlotKnobs(BComponent bComponent, NSlot nSlot) {
|
||||
this.sourceComponent = bComponent;
|
||||
this.sourceSlot = nSlot;
|
||||
this.knobs = noKnobs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.sys.engine;
|
||||
|
||||
import com.tridium.sys.engine.EngineManager;
|
||||
import com.tridium.sys.engine.NClockTicket;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.Clock;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TicketQueue {
|
||||
public int minScan;
|
||||
public int maxScan;
|
||||
int scanCount;
|
||||
long totalTicksInsideScan;
|
||||
int size;
|
||||
int peak;
|
||||
NClockTicket head;
|
||||
NClockTicket tail;
|
||||
long nextScan;
|
||||
final Object lock;
|
||||
|
||||
public void check() {
|
||||
long l = Clock.ticks();
|
||||
if (this.nextScan >= l) {
|
||||
return;
|
||||
}
|
||||
long l2 = this.scan();
|
||||
long l3 = Clock.ticks();
|
||||
if (l2 < (long)this.minScan) {
|
||||
l2 = this.minScan;
|
||||
}
|
||||
if (l2 > (long)this.maxScan) {
|
||||
l2 = this.maxScan;
|
||||
}
|
||||
this.nextScan = l + l2;
|
||||
this.totalTicksInsideScan += l3 - l;
|
||||
++this.scanCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void enqueue(NClockTicket nClockTicket) {
|
||||
Object object = this.lock;
|
||||
synchronized (object) {
|
||||
block5: {
|
||||
block4: {
|
||||
if (this.tail != null) break block4;
|
||||
this.head = this.tail = nClockTicket;
|
||||
break block5;
|
||||
}
|
||||
this.tail.next = nClockTicket;
|
||||
this.tail = nClockTicket;
|
||||
}
|
||||
++this.size;
|
||||
if (this.size > this.peak) {
|
||||
this.peak = this.size;
|
||||
}
|
||||
this.nextScan = 0L;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final long scan() {
|
||||
long l;
|
||||
NClockTicket nClockTicket;
|
||||
NClockTicket nClockTicket2;
|
||||
NClockTicket nClockTicket3 = null;
|
||||
Object object = this.lock;
|
||||
synchronized (object) {
|
||||
nClockTicket3 = this.head;
|
||||
this.tail = null;
|
||||
this.head = null;
|
||||
this.size = 0;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 2] lbl9 : MonitorExitStatement: MONITOREXIT : var2_2
|
||||
nClockTicket2 = null;
|
||||
nClockTicket = null;
|
||||
l = Long.MAX_VALUE;
|
||||
}
|
||||
long l2 = Clock.ticks();
|
||||
long l3 = Clock.millis();
|
||||
int n = 0;
|
||||
while (nClockTicket3 != null) {
|
||||
NClockTicket nClockTicket4 = nClockTicket3.next;
|
||||
nClockTicket3.next = null;
|
||||
long l4 = nClockTicket3.process(l2, l3);
|
||||
if (l4 != Long.MIN_VALUE) {
|
||||
l = Math.min(l, l4);
|
||||
if (nClockTicket == null) {
|
||||
nClockTicket2 = nClockTicket = nClockTicket3;
|
||||
} else {
|
||||
nClockTicket.next = nClockTicket3;
|
||||
nClockTicket = nClockTicket3;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
nClockTicket3 = nClockTicket4;
|
||||
}
|
||||
object = this.lock;
|
||||
synchronized (object) {
|
||||
block11: {
|
||||
block13: {
|
||||
block12: {
|
||||
if (nClockTicket2 == null) break block11;
|
||||
if (this.head != null) break block12;
|
||||
this.head = nClockTicket2;
|
||||
this.tail = nClockTicket;
|
||||
break block13;
|
||||
}
|
||||
nClockTicket.next = this.head;
|
||||
this.head = nClockTicket2;
|
||||
}
|
||||
this.size += n;
|
||||
if (this.size > this.peak) {
|
||||
this.peak = this.size;
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeSummary(SpyWriter spyWriter, String string) throws Exception {
|
||||
long l = Clock.ticks();
|
||||
String string2 = this.nextScan < l ? "next cycle" : EngineManager.timeStr(this.nextScan - l);
|
||||
spyWriter.prop((Object)"scanCount", "" + this.scanCount);
|
||||
spyWriter.prop((Object)"totalTicksInsideScan", EngineManager.timeStr(this.totalTicksInsideScan));
|
||||
spyWriter.prop((Object)("<a href='" + spyWriter.href(string) + "'>Queue</a>"), this.size + " (Peak " + this.peak + ')');
|
||||
spyWriter.prop((Object)"nextScan", string2);
|
||||
spyWriter.prop((Object)"scanBounds", this.minScan + "ms - " + this.maxScan + "ms");
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.lock = new Object();
|
||||
}
|
||||
|
||||
public TicketQueue(int n, int n2) {
|
||||
this.this();
|
||||
this.minScan = n;
|
||||
this.maxScan = n2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user