Added visualization to Fdaq

This commit is contained in:
2014-08-29 16:18:10 +02:00
parent 61e3b4806c
commit ab6aaecc97
7 changed files with 244 additions and 38 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>ch.psi</groupId>
<artifactId>fda.ui</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
</parent>
<artifactId>fda.ui.application</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>fda.ui</artifactId>
<groupId>ch.psi</groupId>
<version>3.1.3</version>
<version>3.1.4</version>
</parent>
<artifactId>fda.ui.module</artifactId>

View File

@@ -32,7 +32,7 @@
</Group>
<Component id="jButton1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="108" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Component id="jPanel1" alignment="1" max="32767" attributes="0"/>
</Group>
@@ -62,7 +62,7 @@
<Component class="javax.swing.JComboBox" name="jComboBox1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new javax.swing.DefaultComboBoxModel(RunConfiguration.rates)" type="code"/>
<Connection code="new javax.swing.DefaultComboBoxModel(Cdump.SAMPLING_RATES)" type="code"/>
</Property>
</Properties>
</Component>
@@ -106,14 +106,34 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jTextField2" min="-2" pref="176" max="-2" attributes="0"/>
</Group>
<Component id="jButton2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jTextField2" min="-2" pref="176" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="21" pref="21" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="comboNumberPoints" max="32767" attributes="0"/>
<Component id="comboSubsampling" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="checkPlot" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jButton2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="113" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -121,15 +141,32 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" pref="14" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextField2" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextField2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="checkPlot" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboNumberPoints" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboSubsampling" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="90" max="32767" attributes="0"/>
<EmptySpace pref="68" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -166,6 +203,63 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="ch/psi/fda/ui/cdump/Bundle.properties" key="CdumpExecutionTopComponent.jLabel5.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="ch/psi/fda/ui/cdump/Bundle.properties" key="CdumpExecutionTopComponent.jLabel6.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboNumberPoints">
<Properties>
<Property name="editable" type="boolean" value="true"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="7">
<StringItem index="0" value="100"/>
<StringItem index="1" value="200"/>
<StringItem index="2" value="500"/>
<StringItem index="3" value="1000"/>
<StringItem index="4" value="2000"/>
<StringItem index="5" value="5000"/>
<StringItem index="6" value="10000"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboSubsampling">
<Properties>
<Property name="editable" type="boolean" value="true"/>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="5">
<StringItem index="0" value="1"/>
<StringItem index="1" value="10"/>
<StringItem index="2" value="100"/>
<StringItem index="3" value="1000"/>
<StringItem index="4" value="10000"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="2"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkPlot">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="ch/psi/fda/ui/cdump/Bundle.properties" key="CdumpExecutionTopComponent.checkPlot.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="checkPlotActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -21,14 +21,21 @@ import ch.psi.fda.cdump.Cdump;
import ch.psi.fda.cdump.CdumpConfiguration;
import ch.psi.fda.fdaq.Fdaq;
import ch.psi.fda.fdaq.FdaqConfiguration;
import ch.psi.fda.model.v1.Visualization;
import ch.psi.fda.serializer.SerializerTXT;
import ch.psi.fda.ui.ee.PlotVisualizerTopComponent;
import ch.psi.fda.ui.preferences.api.Preferences;
import ch.psi.fda.ui.visualizer.Visualizer;
import ch.psi.fda.vdescriptor.LinePlot;
import ch.psi.fda.vdescriptor.VDescriptor;
import ch.psi.fda.vdescriptor.XYSeries;
import ch.psi.jcae.ChannelService;
import ch.psi.jcae.impl.DefaultChannelService;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -86,6 +93,11 @@ public final class CdumpExecutionTopComponent extends TopComponent {
jLabel4 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
comboNumberPoints = new javax.swing.JComboBox();
comboSubsampling = new javax.swing.JComboBox();
checkPlot = new javax.swing.JCheckBox();
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(Cdump.SAMPLING_RATES));
@@ -115,6 +127,26 @@ public final class CdumpExecutionTopComponent extends TopComponent {
}
});
org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel5.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.jLabel6.text")); // NOI18N
comboNumberPoints.setEditable(true);
comboNumberPoints.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "100", "200", "500", "1000", "2000", "5000", "10000" }));
comboNumberPoints.setSelectedIndex(3);
comboSubsampling.setEditable(true);
comboSubsampling.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "10", "100", "1000", "10000" }));
comboSubsampling.setSelectedIndex(2);
checkPlot.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(checkPlot, org.openide.util.NbBundle.getMessage(CdumpExecutionTopComponent.class, "CdumpExecutionTopComponent.checkPlot.text")); // NOI18N
checkPlot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
checkPlotActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@@ -124,24 +156,50 @@ public final class CdumpExecutionTopComponent extends TopComponent {
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton2))
.addGap(18, 18, 18)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton2))
.addContainerGap(113, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(comboNumberPoints, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboSubsampling, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(checkPlot))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.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))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.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))
.addGap(18, 18, 18)
.addComponent(jButton2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(checkPlot)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(comboNumberPoints, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(comboSubsampling, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(68, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@@ -160,7 +218,7 @@ public final class CdumpExecutionTopComponent extends TopComponent {
.addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)))
.addComponent(jButton1))
.addContainerGap(108, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, 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(
@@ -259,7 +317,16 @@ public final class CdumpExecutionTopComponent extends TopComponent {
}
}//GEN-LAST:event_jButton2ActionPerformed
private void checkPlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkPlotActionPerformed
// TODO add your handling code here:
comboNumberPoints.setEnabled(checkPlot.isSelected());
comboSubsampling.setEnabled(checkPlot.isSelected());
}//GEN-LAST:event_checkPlotActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox checkPlot;
private javax.swing.JComboBox comboNumberPoints;
private javax.swing.JComboBox comboSubsampling;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox jComboBox1;
@@ -267,6 +334,8 @@ public final class CdumpExecutionTopComponent extends TopComponent {
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
@@ -382,8 +451,31 @@ public final class CdumpExecutionTopComponent extends TopComponent {
}
}
public void startAcquisitionFdaq() {
final boolean showPlot = checkPlot.isSelected();
final int itemCount = Integer.valueOf(comboNumberPoints.getSelectedItem().toString());
final int subsamplingFactor = Integer.valueOf(comboSubsampling.getSelectedItem().toString());
final PlotVisualizerTopComponent tc = PlotVisualizerTopComponent.findInstance();
new Thread(new Runnable() {
@Override
public void run() {
try{
acquireFdaq(tc, showPlot, itemCount, subsamplingFactor);
}
catch (Exception ex){
Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.WARNING,null,ex);
}
}
}).start();
if (showPlot){
tc.requestVisible();
}
}
public void acquireFdaq(PlotVisualizerTopComponent tc, boolean showPlot, int itemCount, int subsamplingFactor) {
Preferences p = Lookup.getDefault().lookup(Preferences.class);
// TODO currently only the hardcoded configurations are supported
// The ch.psi.fda.fdaq.config.file configuration file is not set base on FDA_HOME ...
@@ -391,7 +483,7 @@ public final class CdumpExecutionTopComponent extends TopComponent {
FdaqConfiguration configuration = new FdaqConfiguration();
EventBus bus = new AsyncEventBus(Executors.newSingleThreadExecutor());
fdaqService = new Fdaq(bus, configuration);
fdaqService = new Fdaq(bus, configuration);
String fname = jTextField2.getText();
AcquisitionConfiguration config = ch.psi.fda.ui.ee.Configuration.getInstance().getConfiguration();
@@ -412,13 +504,30 @@ public final class CdumpExecutionTopComponent extends TopComponent {
} catch (InterruptedException e) {
e.printStackTrace();
}
Logger.getLogger(CdumpExecutionTopComponent.class.getName()).log(Level.INFO, "Start fdaq acquisition");
fdaqService.acquire();
if (showPlot) {
VDescriptor vd = new VDescriptor();
//LinePlot lineplot = new LinePlot();
for (String plot: new String[]{"ain1","ain2","ain3","ain4","enc1"}){
LinePlot lineplot = new LinePlot(plot);
XYSeries series = new XYSeries("counter", plot);
series.setMaxItemCount(itemCount);
lineplot.getData().add(series);
vd.getPlots().add(lineplot);
}
//vd.getPlots().add(lineplot);
String linePlotImpl=Lookup.getDefault().lookup(Preferences.class).getLinePlotImpl();
Visualizer visualizer = new Visualizer(vd,linePlotImpl);
visualizer.setSubsampling(subsamplingFactor);
bus.register(visualizer);
tc.updatePanel(visualizer.getPlotPanels());
}
fdaqService.acquire();
// // Calculate data file location/name
// String fname = jTextField2.getText();

View File

@@ -1,2 +1,2 @@
CTL_MainWindow_Title=FDA 3.1.3
CTL_MainWindow_Title_No_Project=FDA 3.1.3
CTL_MainWindow_Title=FDA 3.1.4
CTL_MainWindow_Title_No_Project=FDA 3.1.4

View File

@@ -14,3 +14,6 @@ CdumpExecutionTopComponent.jLabel3.text=Fdaq Testing
CdumpExecutionTopComponent.jLabel4.text=Scan Name
CdumpExecutionTopComponent.jTextField2.text=
CdumpExecutionTopComponent.jButton2.text=Start
CdumpExecutionTopComponent.jLabel5.text=Subsampling Factor:
CdumpExecutionTopComponent.jLabel6.text=Number of Points:
CdumpExecutionTopComponent.checkPlot.text=Show Plot

View File

@@ -4,7 +4,7 @@
<groupId>ch.psi</groupId>
<artifactId>fda.ui</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
<packaging>pom</packaging>
<name>ch.psi.fda.ui.parent</name>