Elog does not depend on G_CS_ELOG_add script, but on elog bin only instead.
This commit is contained in:
@@ -8,12 +8,12 @@ import ch.psi.pshell.framework.App;
|
||||
import ch.psi.pshell.framework.Context;
|
||||
import ch.psi.pshell.framework.Panel;
|
||||
import ch.psi.pshell.framework.Setup;
|
||||
import ch.psi.pshell.utils.Elog;
|
||||
import ch.psi.pshell.utils.State;
|
||||
import ch.psi.pshell.utils.Chrono;
|
||||
import ch.psi.pshell.swing.SwingUtils;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.pshell.swing.SwingUtils.OptionType;
|
||||
import ch.psi.pshell.utils.Sys;
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
@@ -28,12 +28,20 @@ import javax.swing.JTextField;
|
||||
*
|
||||
*/
|
||||
public class Correlation extends Panel {
|
||||
|
||||
final String facility;
|
||||
|
||||
public Correlation() {
|
||||
initComponents();
|
||||
this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
|
||||
plot.getAxis(Plot.AxisId.X).setLabel(null);
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel(null);
|
||||
|
||||
String facility = System.getenv().getOrDefault("PSI_GFA_FACILITY", "") ;
|
||||
if (facility.isEmpty()){
|
||||
facility = System.getenv().getOrDefault("FACILITY", "SF") ;
|
||||
}
|
||||
this.facility = facility;
|
||||
|
||||
}
|
||||
|
||||
boolean hasArg(String arg) {
|
||||
@@ -215,50 +223,7 @@ public class Correlation extends Panel {
|
||||
//Callback to perform update - in event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
void elog(String logbook, String title, String message, String[] attachments) throws Exception {
|
||||
String domain = "";
|
||||
String category = "Info";
|
||||
String entry = "";
|
||||
StringBuffer cmd = new StringBuffer();
|
||||
|
||||
cmd.append("G_CS_ELOG_add -l \"").append(logbook).append("\" ");
|
||||
cmd.append("-a \"Author=").append(Sys.getUserName()).append("\" ");
|
||||
cmd.append("-a \"Application=pshell\" ");
|
||||
cmd.append("-a \"Entry=").append(entry).append("\" ");
|
||||
cmd.append("-a \"Title=").append(title).append("\" ");
|
||||
cmd.append("-a \"Category=").append(category).append("\" ");
|
||||
cmd.append("-a \"Domain=").append(domain).append("\" ");
|
||||
for (String attachment : attachments) {
|
||||
cmd.append("-f \"").append(attachment).append("\" ");
|
||||
}
|
||||
cmd.append("-n 1 ");
|
||||
cmd.append("\"").append(message).append("\" ");
|
||||
System.out.println(cmd.toString());
|
||||
|
||||
final Process process = Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
|
||||
new Thread(() -> {
|
||||
try {
|
||||
process.waitFor();
|
||||
int bytes = process.getInputStream().available();
|
||||
if (bytes>0){
|
||||
byte[] arr = new byte[bytes];
|
||||
process.getInputStream().read(arr, 0, bytes);
|
||||
System.out.println(new String(arr));
|
||||
}
|
||||
bytes = process.getErrorStream().available();
|
||||
if (bytes>0){
|
||||
byte[] arr = new byte[bytes];
|
||||
process.getErrorStream().read(arr, 0, bytes);
|
||||
System.err.println(new String(arr));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println(ex);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
@@ -554,8 +519,7 @@ public class Correlation extends Panel {
|
||||
|
||||
private void comboTypeXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeXActionPerformed
|
||||
if (comboTypeX.getSelectedIndex()==0){
|
||||
//textDevX.configure(ChannelSelector.Type.Epics, "http://epics-boot-info.psi.ch", "swissfel", 5000);
|
||||
textDevX.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", "swissfel", 5000);
|
||||
textDevX.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", facility.equals("SLS") ? "sls" : "swissfel", 5000);
|
||||
} else if (comboTypeX.getSelectedIndex()==1){
|
||||
textDevX.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
|
||||
} else if (comboTypeX.getSelectedIndex()==2){
|
||||
@@ -565,7 +529,7 @@ public class Correlation extends Panel {
|
||||
|
||||
private void comboTypeYActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeYActionPerformed
|
||||
if (comboTypeY.getSelectedIndex()==0){
|
||||
textDevY.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", "swissfel", 5000);
|
||||
textDevY.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", facility.equals("SLS") ? "sls" : "swissfel", 5000);
|
||||
} else if (comboTypeY.getSelectedIndex()==1){
|
||||
textDevY.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
|
||||
} else if (comboTypeY.getSelectedIndex()==2){
|
||||
@@ -582,7 +546,10 @@ public class Correlation extends Panel {
|
||||
layout.columnWidths = new int[]{0, 180}; //Minimum width
|
||||
layout.rowHeights = new int[]{30, 30, 30}; //Minimum height
|
||||
panel.setLayout(layout);
|
||||
JComboBox comboLogbook = new JComboBox(new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"});
|
||||
String[] logbooks = facility.equals("SLS") ?
|
||||
new String[]{"SLS", "SLS Development", "SLS Measurement Data"} :
|
||||
new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"};
|
||||
JComboBox comboLogbook = new JComboBox(logbooks);
|
||||
JTextField textComment = new JTextField();
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 0;
|
||||
@@ -607,7 +574,7 @@ public class Correlation extends Panel {
|
||||
message.append("Quadratic fit: ").append(textQuadratic.getText()).append("\n");
|
||||
message.append("Peak: ").append(textPeak.getText()).append("\n");
|
||||
message.append("Comment: ").append(textComment.getText()).append("\n");
|
||||
elog((String) comboLogbook.getSelectedItem(), "Correlation Panel Snapshot", message.toString(), new String[]{snapshotFile});
|
||||
Elog.log((String) comboLogbook.getSelectedItem(), "Correlation Panel Snapshot", message.toString(), new String[]{snapshotFile});
|
||||
}
|
||||
}catch (Exception ex){
|
||||
showException(ex);
|
||||
|
||||
Reference in New Issue
Block a user