3 added + 3 removed + 9 modified, total 15 files
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringAnalysisFactory.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringAnalysisFactory.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -16,6 +16,7 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: MonitoringAnalysisFactory.java,v 1.4 2013/12/10 07:36:40 jeremy Exp $
*/
+// FIXME: Move to plotting package.
public class MonitoringAnalysisFactory extends AnalysisFactory {
public MonitoringAnalysisFactory() {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplication.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringApplication.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -77,6 +77,7 @@
import org.hps.monitoring.record.etevent.EtConnection;
import org.hps.monitoring.record.etevent.EtConnectionParameters;
import org.hps.monitoring.record.etevent.EtEventSource;
+import org.hps.monitoring.subsys.et.EtSystemStripCharts;
import org.lcsim.job.JobControlManager;
import org.lcsim.util.aida.AIDA;
@@ -149,7 +150,8 @@
private static Logger logger;
private Handler logHandler;
private DefaultTableModel logTableModel;
- static final String[] logTableColumns = { "Source", "Message", "Date", "Level" };
+ //static final String[] logTableColumns = { "Source", "Message", "Date", "Level" };
+ static final String[] logTableColumns = { "Message", "Date", "Level" };
private JTable logTable;
private Level defaultLogMessageLevel = Level.INFO;
@@ -268,24 +270,27 @@
jobPanel.addActionListener(actionListener);
// Create the container for the tabbed pane.
- JPanel tabsPanel = new JPanel();
- c = new GridBagConstraints();
- c.gridx = 0;
- c.gridy = 2;
- c.fill = GridBagConstraints.BOTH;
- c.weightx = c.weighty = 1.0;
- c.insets = new Insets(0, 0, 0, 10);
- leftPanel.add(tabsPanel, c);
+ //JPanel tabsPanel = new JPanel();
+ //c = new GridBagConstraints();
+ //c.gridx = 0;
+ //c.gridy = 2;
+ //c.fill = GridBagConstraints.BOTH;
+ //c.weightx = c.weighty = 1.0;
+ //c.insets = new Insets(0, 0, 0, 10);
+ //leftPanel.add(tabsPanel, c);
// Tab panels.
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
- c.weightx = c.weighty = 1.0;
+ c.weightx = c.weighty = 1.0;
+ c.gridx = 0;
+ c.gridy = 2;
tabs = new JTabbedPane();
tabs.addTab("Connection Settings", connectionPanel);
tabs.addTab("Event Monitor", eventPanel);
tabs.addTab("Job Settings", jobPanel);
- tabsPanel.add(tabs, c);
+ //tabsPanel.add(tabs, c);
+ leftPanel.add(tabs, c);
// Layout attributes for the entire left panel.
c = new GridBagConstraints();
@@ -483,22 +488,16 @@
* Puts log messages into the application's log table GUI component.
*/
public void publish(LogRecord record) {
- Object[] row = new Object[] { record.getLoggerName(), // source
+ Object[] row = new Object[] { /*record.getLoggerName(),*/ // source
record.getMessage(), // message
dateFormat.format(new Date(record.getMillis())), // date
record.getLevel() }; // level
logTableModel.insertRow(logTable.getRowCount(), row);
}
- /**
- * Close the handler (no-op).
- */
public void close() throws SecurityException {
}
- /**
- * Flush the handler (no-op).
- */
public void flush() {
}
}
@@ -657,6 +656,7 @@
private void saveJobSettings() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Save Job Settings");
+ fc.setCurrentDirectory(new File("."));
int r = fc.showSaveDialog(leftPanel);
if (r == JFileChooser.APPROVE_OPTION) {
File f = fc.getSelectedFile();
@@ -678,6 +678,7 @@
private void loadJobSettings() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Load Job Settings");
+ fc.setCurrentDirectory(new File("."));
int r = fc.showOpenDialog(leftPanel);
if (r == JFileChooser.APPROVE_OPTION) {
File f = fc.getSelectedFile();
@@ -854,6 +855,7 @@
private void logToFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Log File");
+ fc.setCurrentDirectory(new File("."));
int fcs = fc.showSaveDialog(mainPanel);
if (fcs == JFileChooser.APPROVE_OPTION) {
final File logFile = fc.getSelectedFile();
@@ -868,7 +870,6 @@
redirectStdOutAndErrToFile(logFile);
SwingUtilities.invokeLater(new Runnable() {
-
public void run() {
jobPanel.setLogToFile(true);
jobPanel.setLogFile(logFile.getPath());
@@ -1044,6 +1045,7 @@
private void chooseScreenshot() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Save Screenshot");
+ fc.setCurrentDirectory(new File("."));
int r = fc.showSaveDialog(mainPanel);
if (r == JFileChooser.APPROVE_OPTION) {
String fileName = fc.getSelectedFile().getPath();
@@ -1425,6 +1427,7 @@
private void saveLogToFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Save Log File");
+ fc.setCurrentDirectory(new File("."));
int fcs = fc.showSaveDialog(mainPanel);
if (fcs == JFileChooser.APPROVE_OPTION) {
final File logFile = fc.getSelectedFile();
@@ -1551,6 +1554,10 @@
eventProcessing.setDetectorName(this.getDetectorName());
eventProcessing.add(this.jobManager.getDriverExecList());
eventProcessing.add(new EventPanelUpdater(eventPanel));
+
+ // TEST
+ eventProcessing.add(new EtSystemStripCharts());
+
eventProcessing.setStopOnEndRun();
if (!this.disconnectOnError())
eventProcessing.setContinueOnErrors();
@@ -1594,29 +1601,42 @@
*/
private void stopSession() {
- // Request event processing to stop.
- eventProcessing.finish();
-
- // Wait for the event processing thread to finish.
- try {
- logger.log(Level.FINER, "Waiting for event processing to finish before disconnecting.");
- eventProcessingThread.join();
- logger.log(Level.FINER, "Event processing finished.");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- // Reset event processing objects.
- eventProcessing = null;
- eventProcessingThread = null;
-
- // Perform various end of job cleanup.
- endJob();
+ Runnable runnable = new Runnable() {
- // Disconnect from the ET server.
- disconnect();
+ public void run() {
- // Stop the session timer.
- stopSessionTimer();
+ logger.log(Level.INFO, "Stopping session.");
+
+ // Request event processing to stop.
+ eventProcessing.finish();
+
+ // Wait for the event processing thread to finish.
+ try {
+ logger.log(Level.FINER, "Waiting for event processing to finish before disconnecting.");
+ eventProcessingThread.join();
+ logger.log(Level.FINER, "Event processing finished.");
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ // Reset event processing objects.
+ eventProcessing = null;
+ eventProcessingThread = null;
+
+ // Perform various end of job cleanup.
+ endJob();
+
+ // Disconnect from the ET server.
+ disconnect();
+
+ // Stop the session timer.
+ stopSessionTimer();
+
+ logger.log(Level.INFO, "Session done.");
+ }
+ };
+
+ Thread thread = new Thread(runnable);
+ thread.start();
}
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringPlotFactory.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/MonitoringPlotFactory.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -10,6 +10,11 @@
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
+import org.hps.monitoring.plotting.StripChartBuilder;
+import org.hps.monitoring.plotting.StripChartUpdater;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+
/**
* This class implements an AIDA IPlotterFactory for the monitoring application.
* It extends the JFree plotter by putting plots into tabs. Each plotter factory
@@ -20,7 +25,8 @@
* @author Jeremy McCormick <[log in to unmask]>
* @version $Id: MonitoringPlotFactory.java,v 1.6 2013/12/10 07:36:40 jeremy Exp $
*/
-class MonitoringPlotFactory extends PlotterFactory {
+// FIXME: Move to plotting package.
+public class MonitoringPlotFactory extends PlotterFactory {
/* The name of the factory which will be used in naming tabs in the monitoring app. */
String name = null;
@@ -98,5 +104,31 @@
plotterPanel.add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER);
tabs.addTab(plotterName, plotterPanel);
tabs.setTabComponentAt(tabs.getTabCount() - 1, new JLabel(plotterName));
+ }
+
+ private void addChart(JFreeChart chart) {
+ ChartPanel panel = new ChartPanel(chart);
+ tabs.addTab(chart.getTitle().getText(), panel);
+ tabs.setTabComponentAt(tabs.getTabCount() - 1, new JLabel(chart.getTitle().getText()));
}
+
+ /**
+ * Create a strip chart with a pure JFreeChart implementation.
+ * It will be automatically updated from a {@link StripChartUpdater}.
+ * Similar to AIDA plots, the chart will be given a sub-tab in the tab
+ * of this factory.
+ *
+ * @param title The title of the chart.
+ * @param yAxisLabel The y axis label.
+ * @param size The buffer size of the series which determines how much data displays.
+ * @param updater The updater which will update the chart in real time.
+ * @return The modified <tt>StripChartUpdater</tt> which points to the new chart.
+ */
+ public StripChartUpdater createStripChart(String title, String yAxisLabel, int size, StripChartUpdater updater) {
+ JFreeChart stripChart = StripChartBuilder.createDynamicTimeSeriesChart(title, yAxisLabel, size);
+ stripChart.getLegend().setVisible(false); /* Legend turned off for now. */
+ addChart(stripChart);
+ updater.setChart(stripChart);
+ return updater;
+ }
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -0,0 +1,72 @@
+package org.hps.monitoring.plotting;
+
+import java.util.Date;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.time.DynamicTimeSeriesCollection;
+import org.jfree.data.time.Second;
+import org.jfree.data.time.TimeSeries;
+import org.jfree.data.time.TimeSeriesCollection;
+
+public final class StripChartBuilder {
+
+ private StripChartBuilder() {
+ }
+
+ /**
+ * This is appropriate for a strip chart that will be updated at fixed intervals on a timer.
+ * @param title
+ * @param yAxisLabel
+ * @param size
+ * @return
+ */
+ public static JFreeChart createDynamicTimeSeriesChart(String title, String yAxisLabel, int size) {
+ final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(1, size, new Second());
+ dataset.setTimeBase(new Second(new Date()));
+ dataset.addSeries(new float[] {}, 0, "Default Dataset");
+
+ final JFreeChart result = ChartFactory.createTimeSeriesChart(title, "hh:mm:ss", yAxisLabel, dataset, true, true, false);
+ final XYPlot plot = result.getXYPlot();
+ plot.getDomainAxis().setAutoRange(true);
+ NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
+ rangeAxis.setRange(0., 1.);
+ rangeAxis.setAutoRange(true);
+ rangeAxis.setAutoRangeIncludesZero(true);
+ return result;
+ }
+
+ /**
+ * This should be used when the time period for updating is variable. (I think???)
+ * @param title
+ * @param yAxisLabel
+ * @param maxAge
+ * @param maxCount
+ * @return
+ */
+ /*
+ To update chart of this type:
+ sensorSeries.add(new Minute(new Date()), newData);
+ */
+ // TODO: test case
+ public static JFreeChart createTimeSeriesChart(String title, String yAxisLabel, int maxAge, int maxCount) {
+
+ TimeSeriesCollection dataset = new TimeSeriesCollection();
+ TimeSeries timeSeries = new TimeSeries("Default Dataset");
+ timeSeries.setMaximumItemAge(maxAge);
+ timeSeries.setMaximumItemCount(maxCount);
+
+ final JFreeChart result = ChartFactory.createTimeSeriesChart(title, "hh:mm:ss", yAxisLabel, dataset, true, true, false);
+ final XYPlot plot = result.getXYPlot();
+ plot.getDomainAxis().setAutoRange(true);
+ ValueAxis rangeAxis = plot.getRangeAxis();
+ rangeAxis.setAutoRange(true);
+ rangeAxis.setAutoRangeMinimumSize(1.0);
+ return result;
+ }
+
+
+}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -0,0 +1,39 @@
+package org.hps.monitoring.plotting;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.data.time.DynamicTimeSeriesCollection;
+
+/**
+ * A <tt>TimerTask</tt> to update a strip chart at a regular interval.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public abstract class StripChartUpdater extends TimerTask {
+
+ DynamicTimeSeriesCollection dataset;
+ long updateIntervalMillis = 1000;
+
+ public StripChartUpdater() {
+ }
+
+ public void setChart(JFreeChart chart) {
+ this.dataset = (DynamicTimeSeriesCollection)chart.getXYPlot().getDataset();
+ }
+
+ public void setUpdateIntervalMillis(long updateIntervalMillis) {
+ this.updateIntervalMillis = updateIntervalMillis;
+ }
+
+ public void run() {
+ dataset.advanceTime();
+ dataset.appendData(new float[] { nextValue() });
+ }
+
+ public void schedule(Timer timer) {
+ timer.schedule(this, 0, updateIntervalMillis);
+ }
+
+ public abstract float nextValue();
+}
\ No newline at end of file
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/record/etevent/EtConnection.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -47,7 +47,7 @@
* Get the ET system.
* @return The ET system.
*/
- public EtSystem getEtSystem() {
+ EtSystem getEtSystem() {
return sys;
}
@@ -55,7 +55,7 @@
* Get the ET attachment.
* @return The ET attachment.
*/
- public EtAttachment getEtAttachment() {
+ EtAttachment getEtAttachment() {
return att;
}
@@ -157,7 +157,7 @@
* @throws EtWakeUpException
* @throws EtClosedException
*/
- public EtEvent[] readEtEvents()
+ EtEvent[] readEtEvents()
throws IOException, EtException, EtDeadException,
EtEmptyException, EtBusyException, EtTimeoutException,
EtWakeUpException, EtClosedException {
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/HasSystemInfo.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/HasSystemInfo.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,12 +0,0 @@
-package org.hps.monitoring.subsys;
-
-/**
- * A simple mix-in interface for objects that carry {@link SystemInfo}
- * about some detector system.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public interface HasSystemInfo {
-
- SystemInfo getSystemInfo();
-
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemInfo.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemInfo.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,26 +0,0 @@
-package org.hps.monitoring.subsys;
-
-/**
- * Basic interface for information about a detector sub-system.
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public interface SystemInfo {
-
- /**
- * The name of the sub-system e.g. "SVT".
- * @return The name of the sub-system.
- */
- String getName();
-
- /**
- * The current status of the sub-system.
- * @return The sub-system status.
- */
- SystemStatus getStatus();
-
- /**
- * The set of statistics attached to the sub-system.
- * @return The sub-system's statistics.
- */
- SystemStatistics getStatistics();
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemInfoImpl.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemInfoImpl.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,33 +0,0 @@
-package org.hps.monitoring.subsys;
-
-/**
- * Implementation of {@link SystemInfo}.
- *
- * @author Jeremy McCormick <[log in to unmask]>
- */
-public class SystemInfoImpl implements SystemInfo {
-
- String systemName = "";
- SystemStatus status = new SystemStatusImpl();
- SystemStatistics stats = new SystemStatisticsImpl();
-
- public SystemInfoImpl(String systemName) {
- this.systemName = systemName;
- }
-
- @Override
- public String getName() {
- return systemName;
- }
-
- @Override
- public SystemStatus getStatus() {
- return status;
- }
-
- @Override
- public SystemStatistics getStatistics() {
- return stats;
- }
-
-}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,6 +1,7 @@
package org.hps.monitoring.subsys;
import java.io.PrintStream;
+import java.util.TimerTask;
/**
* This is an interface for a set of basic statistics
@@ -63,7 +64,7 @@
* Get the number of events in the current tick.
* @return The number of events in the current tick.
*/
- long getEventsSinceTick();
+ long getEventsInTick();
/**
* Get the total number of events processed thusfar.
@@ -73,7 +74,7 @@
/**
* Get the average number of events per second in the session.
- * It simply divides the number of events by the time.
+ * It simply divides the number of events by the session time.
* @return The average events per second.
*/
double getAverageEventsPerSecond();
@@ -82,20 +83,34 @@
* Get the number of bytes received in the current tick.
* @return The number of bytes received in the tick.
*/
- long getBytesSinceTick();
+ long getBytesInTick();
/**
* Get the total number of megabytes of data received thusfar.
* @return The amount of data in megabytes received in the session.
*/
- double getCumulativeMegaBytes();
+ double getCumulativeMb();
/**
* Get the average Mb per second of the session, which is the
* total amount of data divided by the total time.
* @return The average megabytes per second.
*/
- double getAverageMegaBytesPerSecond();
+ double getAverageMbPerSecond();
+
+ /**
+ * Get the immediate event rate which is the number of events received
+ * in the current tick over the time elapsed in the tick.
+ * @return The event rate in [events/second].
+ */
+ double getEventRate();
+
+ /**
+ * Get the immediate data rate which is the amount of data in bytes received
+ * in the current tick over the tim elapsed in the tick.
+ * @return The data rate in [bytes/second].
+ */
+ public double getDataRateBytes();
/**
* Get the number of milliseconds since the last tick.
@@ -113,6 +128,11 @@
* Print tick statistics.
* @param ps The PrintStream for display.
*/
- void printTick(PrintStream ps);
+ void printTick(PrintStream ps);
+ /**
+ * Add subtask which will execute right before a new tick.
+ * @param subtask The subtask to execute.
+ */
+ void addSubTask(TimerTask subtask);
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -2,9 +2,13 @@
import java.io.PrintStream;
import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
+import org.hps.monitoring.plotting.StripChartUpdater;
+
/**
* Implementation of {@link SystemStatistics}.
*
@@ -27,6 +31,7 @@
static final double milliToSecond = 0.001;
static final DecimalFormat decimalFormat = new DecimalFormat("#.##");
Timer timer;
+ List<TimerTask> subtasks = new ArrayList<TimerTask>();
@Override
public void update(int size) {
@@ -75,12 +80,12 @@
}
@Override
- public double getCumulativeMegaBytes() {
+ public double getCumulativeMb() {
return bytesToMb(totalBytes);
}
@Override
- public double getAverageMegaBytesPerSecond() {
+ public double getAverageMbPerSecond() {
try {
return Double.parseDouble(decimalFormat.format(bytesToMb(totalBytes) / millisToSeconds(getTimeElapsedMillis())));
} catch (NumberFormatException e) {
@@ -89,12 +94,12 @@
}
@Override
- public long getEventsSinceTick() {
+ public long getEventsInTick() {
return eventsSinceTick;
}
@Override
- public long getBytesSinceTick() {
+ public long getBytesInTick() {
return bytesSinceTick;
}
@@ -102,6 +107,22 @@
public long getTickElapsedMillis() {
return tickElapsedMillis;
}
+
+ @Override
+ public double getEventRate() {
+ if (eventsSinceTick > 0 && tickElapsedMillis > 0)
+ return (double)eventsSinceTick / millisToSeconds(tickElapsedMillis);
+ else
+ return 0.;
+ }
+
+ @Override
+ public double getDataRateBytes() {
+ if (bytesSinceTick > 0 && tickElapsedMillis > 0)
+ return (double)bytesSinceTick / millisToSeconds(tickElapsedMillis);
+ else
+ return 0.;
+ }
@Override
public void start() {
@@ -114,6 +135,12 @@
// Start Timer task which executes at tick length.
TimerTask task = new TimerTask() {
public void run() {
+
+ // Run sub-tasks.
+ for (TimerTask subtask : subtasks) {
+ subtask.run();
+ }
+
nextTick();
}
};
@@ -137,7 +164,7 @@
ps.println(" getTimeElapsedMillis = " + this.getTimeElapsedMillis());
ps.println(" getCumulativeEvents = " + this.getCumulativeEvents());
ps.println(" getAverageEventsPerSecond = " + this.getAverageEventsPerSecond());
- ps.println(" getAverageMegaBytesPerSecond = " + this.getAverageMegaBytesPerSecond());
+ ps.println(" getAverageMegaBytesPerSecond = " + this.getAverageMbPerSecond());
}
@@ -145,10 +172,15 @@
public void printTick(PrintStream ps) {
ps.println("tick statistics ...");
ps.println(" getTickElapsedMillis = " + this.getTickElapsedMillis());
- ps.println(" getEventsSinceTick = " + this.getEventsSinceTick());
- ps.println(" getBytesSinceTick = " + this.getBytesSinceTick());
+ ps.println(" getEventsSinceTick = " + this.getEventsInTick());
+ ps.println(" getBytesSinceTick = " + this.getBytesInTick());
}
+ @Override
+ public void addSubTask(TimerTask subtask) {
+ this.subtasks.add(subtask);
+ }
+
void addEvent() {
eventsSinceTick += 1;
totalEvents += 1;
@@ -179,4 +211,70 @@
tickElapsedMillis = 0;
tickStartMillis = System.currentTimeMillis();
}
+
+ public abstract class SystemStatisticsUpdater extends StripChartUpdater {
+ SystemStatisticsUpdater() {
+ addSubTask(this);
+ }
+ }
+
+ public class AverageEventRateUpdater extends SystemStatisticsUpdater {
+
+ @Override
+ public float nextValue() {
+ return (float)getAverageEventsPerSecond();
+ }
+ }
+
+ public class EventsInTickUpdater extends SystemStatisticsUpdater {
+
+ @Override
+ public float nextValue() {
+ return getEventsInTick();
+ }
+ }
+
+ public class CumulativeEventsUpdater extends SystemStatisticsUpdater {
+ @Override
+ public float nextValue() {
+ return getCumulativeEvents();
+ }
+ }
+
+ public class BytesInTickUpdater extends SystemStatisticsUpdater {
+ @Override
+ public float nextValue() {
+ return getBytesInTick();
+ }
+ }
+
+ public class AverageMbUpdater extends SystemStatisticsUpdater {
+ @Override
+ public float nextValue() {
+ return (float)getAverageMbPerSecond();
+ }
+ }
+
+ public class CumulativeMbUpdater extends SystemStatisticsUpdater {
+ @Override
+ public float nextValue() {
+ return (float)getCumulativeMb();
+ }
+ }
+
+ public class EventRateUpdater extends SystemStatisticsUpdater {
+
+ @Override
+ public float nextValue() {
+ return (float)getEventRate();
+ }
+ }
+
+ public class DataRateUpdater extends SystemStatisticsUpdater {
+
+ @Override
+ public float nextValue() {
+ return (float)getDataRateBytes();
+ }
+ }
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,17 +1,20 @@
package org.hps.monitoring.subsys;
/**
- * The system status describes the state of a system, e.g. whether
- * it is okay or some level of error has occurred. Listeners can
- * be registered which will be notified whenever the status changes,
- * in order to update a GUI, trip an alarm, etc.
+ * The <tt>SystemStatus</tt> describes the state of a system, e.g. whether it is okay
+ * or some level of error has occurred. Listeners can be registered, which will
+ * be notified whenever the status changes, in order to update a GUI, trip an alarm, etc.
*
+ * There is one <tt>SystemStatus</tt> object for each quantity to be monitored
+ * on a sub-system. New objects are not created when the status changes. Instead,
+ * the <tt>StatusCode</tt> is changed with a custom message describing the new state.
+ *
* @author Jeremy McCormick <[log in to unmask]>
*/
public interface SystemStatus {
/**
- * Code that represents the system's overall status.
+ * Code that represents the status of the monitoring quantity.
*/
enum StatusCode {
@@ -25,10 +28,12 @@
int code;
String name;
+ String description;
StatusCode(int code, String name, String description) {
this.code = code;
this.name = name;
+ this.description = description;
}
int getRawCode() {
@@ -37,10 +42,19 @@
String getName() {
return name;
- }
+ }
+
+ String getDescription() {
+ return description;
+ }
}
/**
+ * Get the name of the sub-system e.g. "SVT".
+ */
+ String getSystemName();
+
+ /**
* Get the current status code.
* @return The current status code.
*/
@@ -51,13 +65,21 @@
* @return The current message
*/
String getMessage();
+
+ /**
+ * Get the description of the system status.
+ * This is used to differentiate multiple monitoring points
+ * on the same sub-system so it could be something like "SVT occupancy rates".
+ * @return The description of the system status.
+ */
+ String getDescription();
/**
* Set the current status code, which will cause the last changed
* time to be set and the listeners to be notified.
* @param code The new status code.
*/
- void setStatus(StatusCode code, String message);
+ void setStatusCode(StatusCode code, String message);
/**
* Get the time when the system status last changed.
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -13,10 +13,29 @@
long lastChangedMillis;
String message;
List<SystemStatusListener> listeners = new ArrayList<SystemStatusListener>();
+ String systemName = "";
+ String description = "";
- SystemStatusImpl() {
+ SystemStatusImpl(String systemName, String description) {
+ this.systemName = systemName;
+ this.description = description;
setCurrentTime();
}
+
+ @Override
+ public String getSystemName() {
+ return systemName;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
@Override
public StatusCode getStatusCode() {
@@ -24,7 +43,7 @@
}
@Override
- public void setStatus(StatusCode code, String message) {
+ public void setStatusCode(StatusCode code, String message) {
this.code = code;
this.message = message;
setCurrentTime();
@@ -40,12 +59,7 @@
public long getLastChangedMillis() {
return lastChangedMillis;
}
-
- @Override
- public String getMessage() {
- return message;
- }
-
+
void notifyListeners() {
for (SystemStatusListener listener : listeners) {
listener.statusChanged(this);
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-06-10 23:01:18 UTC (rev 698)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -1,11 +1,6 @@
package org.hps.monitoring.subsys.et;
import org.hps.monitoring.record.etevent.EtEventProcessor;
-import org.hps.monitoring.subsys.HasSystemInfo;
-import org.hps.monitoring.subsys.SystemInfo;
-import org.hps.monitoring.subsys.SystemInfoImpl;
-import org.hps.monitoring.subsys.SystemStatus.StatusCode;
-import org.jlab.coda.et.EtEvent;
/**
* This is a barebones implementation of an ET system monitor.
@@ -13,29 +8,57 @@
* and set basic system statuses.
* @author Jeremy McCormick <[log in to unmask]>
*/
-public class EtSystemMonitor extends EtEventProcessor implements HasSystemInfo {
+public class EtSystemMonitor extends EtEventProcessor {
+ /*
+//implements HasSystemInfo {
- SystemInfo info = new SystemInfoImpl("EtSystem");
+ //SystemInfo info = new SystemInfoImpl("EtSystem");
+ SystemStatistics stats = new SystemStatisticsImpl();
+ // TEST: strip chart stuff
+ JFrame plotFrame;
+ JFreeChart stripChart;
+ StripChartUpdater updater;
+ Timer timer;
+
+ MonitoringPlotFactory plotFactory = (MonitoringPlotFactory) AIDA.defaultInstance().analysisFactory().createPlotterFactory("ET System Monitoring");
+
@Override
public void startJob() {
- info.getStatistics().start();
- info.getStatus().setStatus(StatusCode.OKAY, "EtSystemMonitor set okay.");
+ stats.start();
+ //info.getStatus().setStatus(StatusCode.OKAY, "EtSystemMonitor set okay.");
+
+ // TEST: setup strip chart
+ JFreeChart stripChart = plotFactory.createStripChart("Average Event Rate", "Event Count", 100);
+ updater = new AverageEventRateUpdater();
+ updater.setChart(stripChart);
+ timer = updater.start();
}
@Override
public void processEvent(EtEvent event) {
- info.getStatistics().update(event.getLength());
+ stats.update(event.getLength());
+ //info.getStatistics()
}
@Override
public void endJob() {
- info.getStatistics().stop();
- info.getStatus().setStatus(StatusCode.OFFLINE, "EtSystemMonitor set offline.");
+ //info.getStatistics().stop();
+ stats.stop();
+ //info.getStatus().setStatus(StatusCode.OFFLINE, "EtSystemMonitor set offline.");
+
+ // TEST: stop timer for updating strip chart
+ timer.cancel();
+ timer.purge();
}
+
+ class AverageEventRateUpdater extends StripChartUpdater {
- @Override
- public SystemInfo getSystemInfo() {
- return info;
+ @Override
+ public float nextValue() {
+ return (float)stats.getAverageEventsPerSecond();
+ }
+
}
+ */
}
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java (rev 0)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java 2014-06-11 21:12:13 UTC (rev 699)
@@ -0,0 +1,85 @@
+package org.hps.monitoring.subsys.et;
+
+import org.hps.monitoring.MonitoringPlotFactory;
+import org.hps.monitoring.record.etevent.EtEventProcessor;
+import org.hps.monitoring.subsys.SystemStatisticsImpl;
+import org.jlab.coda.et.EtEvent;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ * A basic set of strip charts for monitoring the ET system.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class EtSystemStripCharts extends EtEventProcessor {
+
+ SystemStatisticsImpl stats = new SystemStatisticsImpl();
+ MonitoringPlotFactory plotFactory = (MonitoringPlotFactory)
+ AIDA.defaultInstance().analysisFactory().createPlotterFactory("ET System Monitoring");
+
+ /**
+ * Setup the strip charts for ET system monitoring and start accumulating statistics.
+ */
+ @Override
+ public void startJob() {
+
+ plotFactory.createStripChart(
+ "Event Rate",
+ "Event Count",
+ 100,
+ stats.new EventRateUpdater());
+
+ plotFactory.createStripChart(
+ "Average Event Rate",
+ "Event Count",
+ 100,
+ stats.new AverageEventRateUpdater());
+
+ plotFactory.createStripChart(
+ "Events in Tick",
+ "Event Count",
+ 100,
+ stats.new EventsInTickUpdater());
+
+ plotFactory.createStripChart(
+ "Cumulative Events",
+ "Event Count",
+ 100,
+ stats.new CumulativeEventsUpdater());
+
+ plotFactory.createStripChart(
+ "Data Rate",
+ "Bytes",
+ 100,
+ stats.new DataRateUpdater());
+
+ plotFactory.createStripChart(
+ "Bytes in Tick",
+ "Bytes",
+ 100,
+ stats.new BytesInTickUpdater());
+
+ plotFactory.createStripChart(
+ "Average Megabytes",
+ "Megabytes",
+ 100,
+ stats.new AverageMbUpdater());
+
+ plotFactory.createStripChart(
+ "Cumulative Megabytes",
+ "Megabytes",
+ 100,
+ stats.new CumulativeMbUpdater());
+
+ stats.start();
+ }
+
+ @Override
+ public void processEvent(EtEvent event) {
+ stats.update(event.getLength());
+ }
+
+ @Override
+ public void endJob() {
+ stats.stop();
+ }
+}
SVNspam 0.1