diff --git a/fda.ui.cdump/pom.xml b/fda.ui.cdump/pom.xml
index fd83def..1f930ab 100644
--- a/fda.ui.cdump/pom.xml
+++ b/fda.ui.cdump/pom.xml
@@ -92,6 +92,11 @@
0.9.6-SNAPSHOT
jar
+
+ ch.psi
+ ch.psi.fdaq
+ 0.0.1-SNAPSHOT
+
diff --git a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form
index a75903f..9eeb9e0 100644
--- a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form
+++ b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.form
@@ -1,4 +1,4 @@
-
+
diff --git a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java
index 9ec9585..52d2363 100644
--- a/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java
+++ b/fda.ui.cdump/src/main/java/ch/psi/fda/ui/cdump/CdumpExecutionTopComponent.java
@@ -20,6 +20,8 @@ import ch.psi.cdump.CdumpConfiguration;
import ch.psi.cdump.CdumpService;
import ch.psi.cdump.RunConfiguration;
import ch.psi.fda.ui.preferences.api.Preferences;
+import ch.psi.fdaq.FdaqConfiguration;
+import ch.psi.fdaq.FdaqService;
import java.io.File;
import java.util.Date;
import java.util.logging.Level;
@@ -47,6 +49,7 @@ public final class CdumpExecutionTopComponent extends TopComponent {
private static final String PREFERRED_ID = "CdumpExecutionTopComponent";
private CdumpService service;
+ private FdaqService fdaqService;
public CdumpExecutionTopComponent() {
initComponents();
@@ -73,6 +76,11 @@ public final class CdumpExecutionTopComponent extends TopComponent {
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
+ jPanel1 = new javax.swing.JPanel();
+ jLabel3 = new javax.swing.JLabel();
+ jLabel4 = new javax.swing.JLabel();
+ jTextField2 = new javax.swing.JTextField();
+ jButton2 = new javax.swing.JButton();
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(RunConfiguration.rates));
@@ -89,6 +97,48 @@ public final class CdumpExecutionTopComponent extends TopComponent {
}
});
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel3.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel4.text")); // NOI18N
+
+ jTextField2.setText(org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jTextField2.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jButton2.text")); // NOI18N
+ jButton2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton2ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel3)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addComponent(jLabel4)
+ .addGap(18, 18, 18)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jButton2))
+ .addContainerGap(113, Short.MAX_VALUE))
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel4)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton2)
+ .addContainerGap(90, Short.MAX_VALUE))
+ );
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -106,6 +156,7 @@ public final class CdumpExecutionTopComponent extends TopComponent {
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)))
.addComponent(jButton1))
.addContainerGap(108, Short.MAX_VALUE))
+ .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -120,7 +171,8 @@ public final class CdumpExecutionTopComponent extends TopComponent {
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
- .addContainerGap(187, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
@@ -163,12 +215,56 @@ public final class CdumpExecutionTopComponent extends TopComponent {
}
}//GEN-LAST:event_jButton1ActionPerformed
+ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
+ if(jButton2.getText().equals("Start")){
+ try{
+ // Start acquisition
+ startAcquisitionFdaq();
+ jButton2.setText("Stop");
+ }
+ catch(Exception e){
+ NotifyDescriptor d = new NotifyDescriptor.Message("Unable to start data acquisition:\n" + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
+ DialogDisplayer.getDefault().notifyLater(d);
+
+ // Print exception to output window of the application
+ InputOutput io = IOProvider.getDefault().getIO("Error", false);
+ // Set output console visible
+ io.select();
+ io.getOut().println("Cannot start fdaq");
+ e.printStackTrace(io.getErr());
+ }
+ }
+ else {
+ try{
+ // Stop acquisition
+ jButton2.setText("Start");
+ stopAcquisitionFdaq();
+ }
+ catch(Exception e){
+ NotifyDescriptor d = new NotifyDescriptor.Message("Unable to stop data acquisition:\n" + e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
+ DialogDisplayer.getDefault().notifyLater(d);
+
+ // Print exception to output window of the application
+ InputOutput io = IOProvider.getDefault().getIO("Error", false);
+ // Set output console visible
+ io.select();
+ io.getOut().println("Cannot stop fdaq");
+ e.printStackTrace(io.getErr());
+ }
+ }
+ }//GEN-LAST:event_jButton2ActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
+ private javax.swing.JButton jButton2;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
+ private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
/**
* Gets default instance. Do not use directly: reserved for *.settings files only,
@@ -288,4 +384,34 @@ public final class CdumpExecutionTopComponent extends TopComponent {
// throw new RuntimeException(e);
// }
}
+
+
+ public void startAcquisitionFdaq() {
+ Preferences p = Lookup.getDefault().lookup(Preferences.class);
+ System.setProperty(FdaqService.APP_HOME, p.getHome().getAbsolutePath());
+
+ Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.INFO, "Start fdaq acquisition");
+
+ // Calculate data file location/name
+ String fname = jTextField2.getText();
+ FdaqConfiguration cc = FdaqConfiguration.getInstance();
+ String d = cc.getDataDirectory() + "/" + cc.replaceMacros(cc.getFilePrefix(), new Date(), fname) + fname + ".txt";
+ File f = new File(d);
+ f.getParentFile().mkdirs(); // Create data base directory
+
+ // Create execution service
+ fdaqService = new FdaqService();
+
+ // Take data
+ fdaqService.startAcquisition(f);
+ }
+
+ public void stopAcquisitionFdaq() {
+
+ if(fdaqService != null){
+ Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.INFO, "Stop fdaq acquisition");
+ fdaqService.stopAcquisition();
+ }
+ }
+
}
diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties
index 2aca7f7..8418d47 100644
--- a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties
+++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/cdump/Bundle.properties
@@ -10,3 +10,7 @@ CdumpExecutionTopComponent.jButton1.text=Start
CTL_CdumpExecutionAction=Stream Detector Acquisition
CTL_CdumpExecutionTopComponent=Stream Detector Acquisition
HINT_CdumpExecutionTopComponent=This is a Continuous Execution window
+CdumpExecutionTopComponent.jLabel3.text=Fdaq Testing
+CdumpExecutionTopComponent.jLabel4.text=Scan Name
+CdumpExecutionTopComponent.jTextField2.text=
+CdumpExecutionTopComponent.jButton2.text=Start
diff --git a/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/fdaq/Bundle.properties b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/fdaq/Bundle.properties
new file mode 100644
index 0000000..b04939a
--- /dev/null
+++ b/fda.ui.cdump/src/main/resources/ch/psi/fda/ui/fdaq/Bundle.properties
@@ -0,0 +1,21 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+# Localized module labels. Defaults taken from POM (, , ) if unset.
+#OpenIDE-Module-Name=
+#OpenIDE-Module-Short-Description=
+#OpenIDE-Module-Long-Description=
+#OpenIDE-Module-Display-Category=
+FdaqTopComponent.jLabel1.text=Sampling Rate
+FdaqTopComponent.jTextField1.text=
+FdaqTopComponent.jLabel2.text=Scan Name
+FdaqTopComponent.jButton1.text=Start
+# Localized module labels. Defaults taken from POM (, , ) if unset.
+#OpenIDE-Module-Name=
+#OpenIDE-Module-Short-Description=
+#OpenIDE-Module-Long-Description=
+#OpenIDE-Module-Display-Category=
+FdaqTopComponent.jLabel1.text_1=Sampling Rate
+FdaqTopComponent.jTextField1.text_1=
+FdaqTopComponent.jLabel2.text_1=Scan Name
+FdaqTopComponent.jButton1.text_1=Start