Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ad730e7
make monitoring for kf tracks
bloodyyugo Jun 1, 2021
907ca9c
update some drivers and steering files
bloodyyugo Jun 1, 2021
2bc1e75
start setting up headless drivers for new online monitoring
bloodyyugo Jun 30, 2021
e42b500
rearrange some stuff
bloodyyugo Jul 6, 2021
b8ba6e4
bunch of changes including adding an SvtCheckout steering driver
bloodyyugo Aug 21, 2021
c988c34
some tweaks to svt pulse plots
bloodyyugo Aug 22, 2021
d9c16bc
pulse plots were double correcting for trigphase and other offsets to…
bloodyyugo Aug 23, 2021
18e396e
minor change to plot axis
bloodyyugo Aug 23, 2021
a17002a
another minor change to axis ranges
bloodyyugo Aug 23, 2021
ebc395b
Merge branch 'master' into iss858
bloodyyugo Aug 27, 2021
f00832b
updated to plots; remove svt occupancy alarm
bloodyyugo Aug 27, 2021
ac2e2db
Merge branch 'master' into iss858
bloodyyugo Aug 28, 2021
9827022
get opening angle monitoring working with seed tracker
bloodyyugo Aug 30, 2021
8c6cc54
remove some plots
bloodyyugo Sep 7, 2021
844d229
Merge remote-tracking branch 'origin/iss883' into iss858
bloodyyugo Sep 9, 2021
99bc6f9
Merge remote-tracking branch 'origin/iss883' into iss858
bloodyyugo Sep 13, 2021
0c41bc5
add a KF opening angle mon driver...needed to make some KF classes pu…
bloodyyugo Sep 14, 2021
d5d19b5
finish KF opening angle plots and some minor tweaks
bloodyyugo Sep 15, 2021
5459326
Merge remote-tracking branch 'origin/Run2021' into iss858
bloodyyugo Sep 17, 2021
b663c2b
change fee plots around
bloodyyugo Sep 17, 2021
f37046b
add flag and code to remove pulser and faraday triggers from monitori…
bloodyyugo Sep 21, 2021
004c96d
add dumbness to make plots print in certain order
bloodyyugo Sep 21, 2021
8c74f87
add button to save both root and pdf files
bloodyyugo Oct 5, 2021
2f63172
something weird setting aida dir in this one driver
bloodyyugo Oct 5, 2021
1730ed9
fix bug where monitoring crashed after reconnecting and disconnecting
bloodyyugo Oct 24, 2021
c5326a5
Remove files that were accidentally added
JeremyMcCormick Feb 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions analysis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.hps.monitoring.application;

/**
* These strings are used to identify <code>ActionEvent</code> commands in the MonitoringApplication.
* These strings are used to identify <code>ActionEvent</code> commands in the
* MonitoringApplication.
*/
final class Commands {

Expand Down Expand Up @@ -51,7 +52,8 @@ final class Commands {
static final String DATA_SOURCE_CHANGED = "dataSourceChanged";

/**
* Reset the application window to its default settings including scroll pane positions.
* Reset the application window to its default settings including scroll
* pane positions.
*/
static final String DEFAULT_WINDOW = "defaultWindow";

Expand Down Expand Up @@ -154,7 +156,7 @@ final class Commands {
* Action when plot is selected from a tab.
*/
static final String PLOT_SELECTED = "PlotSelected";

/**
* Enable plot pop-up window.
*/
Expand All @@ -166,7 +168,8 @@ final class Commands {
static final String PROCESSING_STAGE_CHANGED = "processingStageChanged";

/**
* Select one of the items from the recent files list to be the current data source.
* Select one of the items from the recent files list to be the current data
* source.
*/
static final String RECENT_FILE_SELECTED = "recentFileSelected";

Expand All @@ -185,6 +188,11 @@ final class Commands {
*/
static final String SAVE_PLOTS = "savePlots";

/**
* Save the plots to a ROOT, AIDA or PDF file.
*/
static final String SAVE_ROOT_AND_PDF = "savePlotsRootPdf";

/**
* Save a screenshot from the window graphics.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import org.hps.monitoring.application.model.ConnectionStatusModel;

/**
* This is the panel with buttons for connecting or disconnecting from the session and controlling the application when
* This is the panel with buttons for connecting or disconnecting from the
* session and controlling the application when
* event processing is paused.
*/
@SuppressWarnings("serial")
Expand Down Expand Up @@ -53,6 +54,11 @@ static ImageIcon getImageIcon(final String resource) {
return new ImageIcon(image);
}

/**
* Button for saving PDF & root files
*/
private final JButton saveButton;

/**
* Button for connect and disconnect which is toggled depending on state.
*/
Expand Down Expand Up @@ -84,6 +90,7 @@ static ImageIcon getImageIcon(final String resource) {
connectionModel.addPropertyChangeListener(this);

setLayout(new FlowLayout());
this.saveButton = addButton("/monitoringButtonGraphics/icons8-multicast-64.png", Commands.SAVE_ROOT_AND_PDF, listener, true);
this.connectButton = addButton(DISCONNECTED_ICON, Commands.CONNECT, listener, true);
this.resumeButton = addButton("/toolbarButtonGraphics/media/Play24.gif", Commands.RESUME, listener, false);
this.pauseButton = addButton("/toolbarButtonGraphics/media/Pause24.gif", Commands.PAUSE, listener, false);
Expand Down Expand Up @@ -125,7 +132,8 @@ private JButton addButton(final String resource, final String actionCommand, fin
}

/**
* Handle property change events to set status from changes to the connection status model.
* Handle property change events to set status from changes to the
* connection status model.
*
* @param evt the <code>PropertyChangeEvent</code> to handle
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -60,9 +62,11 @@
import org.lcsim.util.log.DefaultLogFormatter;

/**
* This is the primary class that implements the data monitoring GUI application.
* This is the primary class that implements the data monitoring GUI
* application.
* <p>
* It should not be used directly. Instead the {@link Main} class should be used from the command line.
* It should not be used directly. Instead the {@link Main} class should be used
* from the command line.
*
*/
final class MonitoringApplication implements ActionListener, PropertyChangeListener {
Expand Down Expand Up @@ -99,7 +103,8 @@ public void publish(final LogRecord record) {
}

/**
* Log handler which publishes messages to a stream (console or file in this case).
* Log handler which publishes messages to a stream (console or file in this
* case).
*/
class MonitoringApplicationStreamHandler extends StreamHandler {

Expand Down Expand Up @@ -217,27 +222,30 @@ static MonitoringApplication create(final Configuration configuration) {
private EventProcessing processing;

/**
* The model which has information about the current run and events being processed.
* The model which has information about the current run and events being
* processed.
*/
private final RunModel runModel = new RunModel();

/**
* The handler for putting messages into the log table.
*/
private MonitoringApplicationStreamHandler streamHandler;

/**
* Class for displayed a pop-up of selected region.
* Initialization is delayed until after AIDA is properly configured.
*/
private ChartPopup popup = null;

private boolean plotPopupEnabled = true;

/**
* Instantiate and show the monitoring application with the given configuration.
* Instantiate and show the monitoring application with the given
* configuration.
*
* @param userConfiguration the Configuration object containing application settings
* @param userConfiguration the Configuration object containing application
* settings
*/
MonitoringApplication(final Configuration userConfiguration) {

Expand Down Expand Up @@ -309,6 +317,8 @@ public void actionPerformed(final ActionEvent e) {
runDisconnectThread();
} else if (Commands.SAVE_PLOTS.equals(command)) {
savePlots();
} else if (Commands.SAVE_ROOT_AND_PDF.equals(command)) {
savePlotsRootPdf();
} else if (Commands.EXIT.equals(command)) {
// This will trigger the window closing action that cleans everything up.
this.frame.dispose();
Expand Down Expand Up @@ -351,10 +361,11 @@ public void actionPerformed(final ActionEvent e) {
} else if (Commands.PLOT_POPUP.equals(command)) {
this.plotPopupEnabled = ((JCheckBox) e.getSource()).isSelected();
}
}
}

/**
* Redirect <code>System.out</code> and <code>System.err</code> to a chosen file.
* Redirect <code>System.out</code> and <code>System.err</code> to a chosen
* file.
*/
private void chooseLogFile() {
final JFileChooser fc = new JFileChooser();
Expand Down Expand Up @@ -485,7 +496,8 @@ private List<String> getRunData() {
}

/**
* Get the run model with information about the run and event(s) currently being processed.
* Get the run model with information about the run and event(s) currently
* being processed.
*
* @return the run model
*/
Expand All @@ -494,10 +506,12 @@ RunModel getRunModel() {
}

/**
* This method sets the configuration on the model, which fires a change for every property.
* This method sets the configuration on the model, which fires a change for
* every property.
*
* @param configuration the new configuration
* @param merge <code>true</code> to merge the configuration into the current one rather than replace it
* @param merge <code>true</code> to merge the configuration into the
* current one rather than replace it
*/
private void loadConfiguration(final Configuration configuration, final boolean merge) {

Expand Down Expand Up @@ -581,7 +595,8 @@ private void logToFile(final File file) {
}

/**
* Send <code>System.out</code> and <code>System.err</code> back to the terminal, e.g. if they were previously sent
* Send <code>System.out</code> and <code>System.err</code> back to the
* terminal, e.g. if they were previously sent
* to a file.
*/
private void logToTerminal() {
Expand Down Expand Up @@ -761,6 +776,53 @@ private void savePlots() {
}
}

/**
* Save plots to an AIDA, ROOT or PDF file using a file chooser.
*/
private void savePlotsRootPdf() {
int runNum = this.runModel.getRunNumber();
String stationName = this.configurationModel.getStationName();
String timestamp = DateTimeFormatter.ofPattern("yyyy-MM-dd:HH:mm:ss").format(LocalDateTime.now());
String plotsDir=this.configurationModel.getPlotsDir();
String pdfOut = plotsDir+"/"+stationName + "-run" + runNum + "-" + timestamp + ".pdf";
String rootOut = plotsDir+"/"+stationName + "-run" + runNum + "-" + timestamp + ".root";

final File pdfFile = new File(pdfOut);
final File rootFile = new File(rootOut);
if (!pdfFile.exists()) {
String fileName = pdfFile.getAbsolutePath();
try {
// Write out all plot graphics from the tabs to a single PDF file.
ExportPdf.write(MonitoringPlotFactory.getPlotterRegistry().getPlotters(), fileName,
getRunData());
LOGGER.info("saved plots to " + fileName);
DialogUtil.showInfoDialog(this.frame, "Plots Saved", "Plots were successfully saved to " + '\n'
+ fileName);
} catch (final IOException e) {
this.errorHandler.setError(e).setMessage("Error Saving Plots").printStackTrace().log()
.showErrorDialog();
}
} else {
DialogUtil.showErrorDialog(this.frame, "File Exists", "Selected file already exists.");
}

if (!rootFile.exists()) {
String fileName = rootFile.getAbsolutePath();
try {
AIDA.defaultInstance().saveAs(fileName);
LOGGER.info("saved plots to " + fileName);
DialogUtil.showInfoDialog(this.frame, "Plots Saved", "Plots were successfully saved to " + '\n'
+ fileName);
} catch (final IOException e) {
this.errorHandler.setError(e).setMessage("Error Saving Plots").printStackTrace().log()
.showErrorDialog();
}
} else {
DialogUtil.showErrorDialog(this.frame, "File Exists", "Selected already exists.");
}

}

/**
* Save a screenshot to a file using a file chooser.
*/
Expand Down Expand Up @@ -805,7 +867,8 @@ private void saveSettings() {
}

/**
* Export a JTable's data to a comma-delimited text file using a file chooser.
* Export a JTable's data to a comma-delimited text file using a file
* chooser.
*
* @param table the table to export
*/
Expand Down Expand Up @@ -857,7 +920,7 @@ public void regionSelected(final PlotterRegion region) {
if (region != null) {
MonitoringApplication.this.frame.getPlotInfoPanel().setCurrentRegion(region);
}

if (plotPopupEnabled) {
popup.update(region);
}
Expand All @@ -866,7 +929,7 @@ public void regionSelected(final PlotterRegion region) {

// Perform global configuration of the JFreeChart back end.
AnalysisFactory.configure();

this.popup = new ChartPopup();
}

Expand Down Expand Up @@ -981,7 +1044,8 @@ private synchronized void startSession() {
* Save a screenshot to an output file.
*
* @param fileName the name of the output file
* @param format the output file format (must be accepted by <code>ImageIO</code>)
* @param format the output file format (must be accepted by
* <code>ImageIO</code>)
*/
private void writeScreenshot(final String fileName, final String format) {
this.frame.repaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public final class ConfigurationModel extends AbstractModel {
*/
private static final int MAX_RECENT_FILES = 10;

/**
* The directory to store plots (pdf and root) files in
*/
private static final String PLOTS_DIR_PROPERTY="PlotsDir";

/**
* The ET TCP/IP port.
*/
Expand Down Expand Up @@ -431,7 +436,14 @@ public Boolean getLogToFile() {
public Long getMaxEvents() {
return this.configuration.getLong(MAX_EVENTS_PROPERTY);
}

/**
* Get the directory to but root and pdf files
* @return directory name
*/
public String getPlotsDir(){
return this.configuration.get(PLOTS_DIR_PROPERTY);
}

/**
* Get the ET TCP/IP port value.
*
Expand Down
Loading