WIP161121
parent
4332bb8a14
commit
4624fa0903
|
@ -71,6 +71,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
private PulsCounterDatabase database;
|
private PulsCounterDatabase database;
|
||||||
|
|
||||||
|
private List<String> batchCommands;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +111,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
interfaceClasses = new ArrayList<>();
|
interfaceClasses = new ArrayList<>();
|
||||||
interfaces = new ArrayList<>();
|
interfaces = new ArrayList<>();
|
||||||
|
|
||||||
|
batchCommands = new ArrayList<>();
|
||||||
|
|
||||||
/* Prepare for Startup */
|
/* Prepare for Startup */
|
||||||
loadApplicationConfiguration();
|
loadApplicationConfiguration();
|
||||||
|
|
||||||
|
@ -134,6 +138,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
case "-G":
|
case "-G":
|
||||||
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
||||||
break;
|
break;
|
||||||
|
case "--batch-execute":
|
||||||
|
batchCommands.add( options.next() );
|
||||||
default:
|
default:
|
||||||
log(WARN,"Unknown command line parameter: %s", option);
|
log(WARN,"Unknown command line parameter: %s", option);
|
||||||
}
|
}
|
||||||
|
@ -208,6 +214,10 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
log("OS Search Path: %s", System.getenv("PATH"));
|
log("OS Search Path: %s", System.getenv("PATH"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getBatchCommands(){
|
||||||
|
return batchCommands.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(){
|
public void start(){
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,17 @@ import java.sql.SQLException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.hwo.csv.CSVRecord;
|
import org.hwo.csv.CSVRecord;
|
||||||
import org.hwo.models.TableMapper.TableColumn;
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
import org.hwo.servicelink.ServiceLink;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.ui.diagram.annotation.Plot;
|
||||||
|
|
||||||
public class SnapShot {
|
public class SnapShot {
|
||||||
|
UUID uuid;
|
||||||
|
|
||||||
Integer deviceSerial;
|
Integer deviceSerial;
|
||||||
|
|
||||||
Integer index;
|
Integer index;
|
||||||
|
@ -145,6 +149,7 @@ public class SnapShot {
|
||||||
this.values[ch] = value;
|
this.values[ch] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Plot(label="Zähler %d",instances=32)
|
||||||
public Integer getValue(Integer ch){
|
public Integer getValue(Integer ch){
|
||||||
if ((ch >= 0) && (ch<32)){
|
if ((ch >= 0) && (ch<32)){
|
||||||
return this.values[ch];
|
return this.values[ch];
|
||||||
|
|
|
@ -192,6 +192,12 @@ public class PulsCounterDatabase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteSnapshot(SnapShot snapShot){
|
||||||
|
log(INFO,"db delete snapshot [%d]",snapShot.getIndex());
|
||||||
|
executeVerySimpleQuery("DELETE FROM snapshots WHERE device=? AND snap_id=?", snapShot.getDeviceSerial(),snapShot.getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int highestSnapShot(int deviceSerial){
|
public int highestSnapShot(int deviceSerial){
|
||||||
Integer ind = (Integer)executeSimpleQueryObject("SELECT max(snap_id) FROM snapshots WHERE device=? GROUP BY device", deviceSerial);
|
Integer ind = (Integer)executeSimpleQueryObject("SELECT max(snap_id) FROM snapshots WHERE device=? GROUP BY device", deviceSerial);
|
||||||
if (ind == null){
|
if (ind == null){
|
||||||
|
|
|
@ -26,15 +26,42 @@ public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
|
|
||||||
PulsCounterApplication.getApplication().checkForSnapShots();
|
|
||||||
|
|
||||||
for (ExportSetting es: PulsCounterApplication.getApplication().getExportSettings()){
|
for (String cmd: pulsCounterApplication.getBatchCommands()){
|
||||||
if (es.getAutostart()){
|
String[] tokens = cmd.split(":");
|
||||||
es.export();
|
switch (tokens[0]){
|
||||||
|
case "output":
|
||||||
|
|
||||||
|
String[] s = tokens[1].split("=");
|
||||||
|
int outputno = Integer.decode(s[0]);
|
||||||
|
int state = Integer.decode(s[1]);
|
||||||
|
|
||||||
|
int outputs = pulsCounterApplication.getInterfaces().get(0).getOutputs();
|
||||||
|
if (state != 0){
|
||||||
|
outputs |= (1<<outputno);
|
||||||
|
} else {
|
||||||
|
outputs &= ~(1<<outputno);
|
||||||
|
}
|
||||||
|
|
||||||
|
log(INFO,"BatchCommand: set output %d = %d",outputno,state);
|
||||||
|
|
||||||
|
pulsCounterApplication.getInterfaces().get(0).setOutputs(outputs);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pulsCounterApplication.getBatchCommands().length == 0){
|
||||||
|
PulsCounterApplication.getApplication().checkForSnapShots();
|
||||||
|
|
||||||
|
for (ExportSetting es: PulsCounterApplication.getApplication().getExportSettings()){
|
||||||
|
if (es.getAutostart()){
|
||||||
|
es.export();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
pulsCounterApplication.notifyUiIsFinished(false);
|
pulsCounterApplication.notifyUiIsFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private Integer trimTicksOnConnect;
|
private Integer trimTicksOnConnect;
|
||||||
private Long trimTimeOnConnect;
|
private Long trimTimeOnConnect;
|
||||||
private Integer trimDeviceTimeSlice;
|
private Integer trimDeviceTimeSlice;
|
||||||
private JCheckBox cbTrimDevice;
|
|
||||||
|
|
||||||
private Smoother smoothTrim;
|
private Smoother smoothTrim;
|
||||||
private JList lInterfaces;
|
private JList lInterfaces;
|
||||||
|
@ -352,16 +351,15 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
panel_1.setBorder(new TitledBorder(null, "Verbindung", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel_1.setBorder(new TitledBorder(null, "Verbindung", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
||||||
gbc_panel_1.insets = new Insets(0, 0, 5, 0);
|
gbc_panel_1.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_panel_1.anchor = GridBagConstraints.NORTH;
|
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
||||||
gbc_panel_1.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_panel_1.gridx = 0;
|
gbc_panel_1.gridx = 0;
|
||||||
gbc_panel_1.gridy = 0;
|
gbc_panel_1.gridy = 0;
|
||||||
panel.add(panel_1, gbc_panel_1);
|
panel.add(panel_1, gbc_panel_1);
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
gbl_panel_1.columnWidths = new int[]{0, 0, 0};
|
gbl_panel_1.columnWidths = new int[]{0, 0, 0};
|
||||||
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0, 0};
|
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
gbl_panel_1.rowWeights = new double[]{0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_1.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
||||||
panel_1.setLayout(gbl_panel_1);
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
bIntfAdd = new JButton("+");
|
bIntfAdd = new JButton("+");
|
||||||
|
@ -419,22 +417,10 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
});
|
});
|
||||||
scrollPane_2.setViewportView(lInterfaces);
|
scrollPane_2.setViewportView(lInterfaces);
|
||||||
|
|
||||||
cbTrimDevice = new JCheckBox("Trimmung justieren");
|
|
||||||
cbTrimDevice.setToolTipText("<html>\n<b>Abgleich der Zeitmessung</b><br/>\n<br/>\nDiese Funktion gleicht die Geschwindigkeit der Echtzeituhr des<br/>\nSynololog mit der des Rechners ab und korrigiert diese Laufzeitdifferenz.<br/>\n<br/>\nHierdurch kann der Synololog auch ohne angeschlossenen Rechner über<br/>\nmehrere Tage hinweg eine genaue Systemzeit vorhalten.<br/>\n<br/>\nDie Trimmung sollte vor allem dann ausgeführt werden, wenn die durchschnittliche<br/>\nUmgebungstemperatur am Einsatzort des Synololog sich stark verändert.\n</html>");
|
|
||||||
cbTrimDevice.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
trimTicksOnConnect = null;
|
|
||||||
if (cbTrimDevice.isSelected()){
|
|
||||||
// trimDevice();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
panel_4 = new JPanel();
|
panel_4 = new JPanel();
|
||||||
panel_4.setBorder(new TitledBorder(null, "Anschlusseinstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel_4.setBorder(new TitledBorder(null, "Anschlusseinstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
||||||
gbc_panel_4.gridwidth = 2;
|
gbc_panel_4.gridwidth = 2;
|
||||||
gbc_panel_4.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
||||||
gbc_panel_4.gridx = 0;
|
gbc_panel_4.gridx = 0;
|
||||||
gbc_panel_4.gridy = 2;
|
gbc_panel_4.gridy = 2;
|
||||||
|
@ -454,13 +440,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
gbc_tfConnectionSettings.gridy = 0;
|
gbc_tfConnectionSettings.gridy = 0;
|
||||||
panel_4.add(tfConnectionSettings, gbc_tfConnectionSettings);
|
panel_4.add(tfConnectionSettings, gbc_tfConnectionSettings);
|
||||||
tfConnectionSettings.setColumns(10);
|
tfConnectionSettings.setColumns(10);
|
||||||
|
|
||||||
GridBagConstraints gbc_cbTrimDevice = new GridBagConstraints();
|
|
||||||
gbc_cbTrimDevice.gridwidth = 2;
|
|
||||||
gbc_cbTrimDevice.anchor = GridBagConstraints.WEST;
|
|
||||||
gbc_cbTrimDevice.gridx = 0;
|
|
||||||
gbc_cbTrimDevice.gridy = 3;
|
|
||||||
panel_1.add(cbTrimDevice, gbc_cbTrimDevice);
|
|
||||||
|
|
||||||
JPanel panel_2 = new JPanel();
|
JPanel panel_2 = new JPanel();
|
||||||
panel_2.setBackground(Color.WHITE);
|
panel_2.setBackground(Color.WHITE);
|
||||||
|
|
|
@ -23,7 +23,9 @@ import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
import org.hwo.ui.JMappedTable;
|
import org.hwo.ui.JMappedTable;
|
||||||
import org.hwo.ui.MousePopupListener;
|
import org.hwo.ui.MousePopupListener;
|
||||||
|
import org.hwo.ui.diagram.AnnotatedPlotProvider;
|
||||||
import org.hwo.ui.diagram.LinePlotPainter;
|
import org.hwo.ui.diagram.LinePlotPainter;
|
||||||
|
import org.hwo.ui.diagram.PlotLabeler;
|
||||||
import org.hwo.ui.diagram.SimplePlotProvider;
|
import org.hwo.ui.diagram.SimplePlotProvider;
|
||||||
|
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
@ -33,10 +35,14 @@ import javax.swing.JOptionPane;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.lang.management.GarbageCollectorMXBean;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.MenuItem;
|
||||||
|
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import org.hwo.ui.JDiagram;
|
import org.hwo.ui.JDiagram;
|
||||||
|
@ -66,10 +72,15 @@ public class SnapshotManager extends JDialog {
|
||||||
private JCheckBox cbDifferenzen;
|
private JCheckBox cbDifferenzen;
|
||||||
private JPanel paIndex;
|
private JPanel paIndex;
|
||||||
|
|
||||||
|
private JLabel[] graphLabels;
|
||||||
|
private AnnotatedPlotProvider
|
||||||
|
annotatedPlotProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dialog.
|
* Create the dialog.
|
||||||
*/
|
*/
|
||||||
public SnapshotManager() {
|
public SnapshotManager() {
|
||||||
|
setTitle("Aufgezeichnete Werte verwalten");
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
@ -176,10 +187,13 @@ public class SnapshotManager extends JDialog {
|
||||||
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
panel_2.setLayout(gbl_panel_2);
|
panel_2.setLayout(gbl_panel_2);
|
||||||
{
|
{
|
||||||
cbDifferenzen = new JCheckBox("Differenzen");
|
cbDifferenzen = new JCheckBox("Differenzieren");
|
||||||
cbDifferenzen.addActionListener(new ActionListener(){
|
cbDifferenzen.addActionListener(new ActionListener(){
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
updateDiagram();
|
for (int i=0;i<32;i++){
|
||||||
|
annotatedPlotProvider.setPlotDifferentiated(i, cbDifferenzen.isSelected());
|
||||||
|
}
|
||||||
|
diaSnapshots.repaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_cbDifferenzen = new GridBagConstraints();
|
GridBagConstraints gbc_cbDifferenzen = new GridBagConstraints();
|
||||||
|
@ -218,7 +232,10 @@ public class SnapshotManager extends JDialog {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(){
|
private void initializeDeviceList(){
|
||||||
|
initializeDeviceList(null);
|
||||||
|
}
|
||||||
|
private void initializeDeviceList(Integer preSelected){
|
||||||
Integer[] deviceSerials = PulsCounterApplication.getApplication().getDatabase().getKnownDevices();
|
Integer[] deviceSerials = PulsCounterApplication.getApplication().getDatabase().getKnownDevices();
|
||||||
DefaultListModel<Integer> lm = new DefaultListModel<>();
|
DefaultListModel<Integer> lm = new DefaultListModel<>();
|
||||||
|
|
||||||
|
@ -227,6 +244,13 @@ public class SnapshotManager extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
lDevices.setModel(lm);
|
lDevices.setModel(lm);
|
||||||
|
lDevices.setSelectedValue(preSelected, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
graphLabels = new JLabel[32];
|
||||||
|
|
||||||
|
initializeDeviceList();
|
||||||
|
|
||||||
mtSnapshots.getTableMapper().setReadOnly(true);
|
mtSnapshots.getTableMapper().setReadOnly(true);
|
||||||
mtSnapshots.getTableMapper().addListSelectionListener(new ListSelectionListener() {
|
mtSnapshots.getTableMapper().addListSelectionListener(new ListSelectionListener() {
|
||||||
|
@ -238,10 +262,66 @@ public class SnapshotManager extends JDialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
for (int i=0;i<32;i++){
|
||||||
|
final int ii = i;
|
||||||
|
|
||||||
JLabel l = new JLabel(String.format("#%02d", i));
|
JLabel l = new JLabel(String.format("#%02d", i));
|
||||||
l.setForeground(plotColors[i]);
|
l.setForeground(plotColors[i]);
|
||||||
|
l.addMouseListener(new MouseAdapter() {
|
||||||
|
public void mouseClicked(java.awt.event.MouseEvent e) {
|
||||||
|
if (l.isEnabled()){
|
||||||
|
l.setEnabled(false);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(ii, false);
|
||||||
|
} else {
|
||||||
|
l.setEnabled(true);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(ii, true);
|
||||||
|
}
|
||||||
|
diaSnapshots.repaint();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
l.addMouseListener(new MousePopupListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupTriggered(int x, int y) {
|
||||||
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
|
||||||
|
JMenuItem mi = new JMenuItem("Nur diesen Graph zeigen");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
for (int g=0;g<32;g++){
|
||||||
|
graphLabels[g].setEnabled(false);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(g, false);
|
||||||
|
}
|
||||||
|
graphLabels[ii].setEnabled(true);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(ii,true);
|
||||||
|
diaSnapshots.repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(mi);
|
||||||
|
|
||||||
|
mi = new JMenuItem("Alle ausser diesem Graph zeigen");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
for (int g=0;g<32;g++){
|
||||||
|
graphLabels[g].setEnabled(true);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(g, true);
|
||||||
|
}
|
||||||
|
graphLabels[ii].setEnabled(false);
|
||||||
|
annotatedPlotProvider.setPlotEnabled(ii, false);
|
||||||
|
diaSnapshots.repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(mi);
|
||||||
|
|
||||||
|
popup.show(l, x, y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
paIndex.add(l);
|
paIndex.add(l);
|
||||||
|
graphLabels[i] = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
mtSnapshots.addMouseListener(new MousePopupListener() {
|
mtSnapshots.addMouseListener(new MousePopupListener() {
|
||||||
|
@ -257,16 +337,37 @@ public class SnapshotManager extends JDialog {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
if (JOptionPane.showConfirmDialog(mtSnapshots, "Sollen die markierten Snapshots wirklich gelöscht werden?","Aufzeichnungen entfernen",JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
if (JOptionPane.showConfirmDialog(SnapshotManager.this, "Sollen die markierten Snapshots wirklich gelöscht werden?","Aufzeichnungen entfernen",JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
||||||
for (SnapShot ss: selRows){
|
for (SnapShot ss: selRows){
|
||||||
mtSnapshots.getTableMapper().removeRow(ss);
|
mtSnapshots.getTableMapper().removeRow(ss);
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().deleteSnapshot(ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mtSnapshots.getTableMapper().getRows().size()==0){
|
||||||
|
initializeDeviceList();
|
||||||
|
}
|
||||||
|
|
||||||
mtSnapshots.repaint();
|
mtSnapshots.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
popupMenu.add(mi);
|
popupMenu.add(mi);
|
||||||
|
|
||||||
|
mi = new JMenuItem("(Ent-)Parken");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
for (SnapShot ss: selRows){
|
||||||
|
mtSnapshots.getTableMapper().removeRow(ss);
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().deleteSnapshot(ss);
|
||||||
|
ss.setDeviceSerial(-ss.getDeviceSerial());
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().storeSnapshots(new SnapShot[]{ss});
|
||||||
|
}
|
||||||
|
initializeDeviceList((Integer)lDevices.getSelectedValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(mi);
|
||||||
|
|
||||||
popupMenu.show(mtSnapshots, x, y);
|
popupMenu.show(mtSnapshots, x, y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -274,6 +375,29 @@ public class SnapshotManager extends JDialog {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
annotatedPlotProvider = new AnnotatedPlotProvider(SnapShot.class);
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
annotatedPlotProvider.setColors(i, plotColors[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
diaSnapshots.setPlotProvider(annotatedPlotProvider);
|
||||||
|
diaSnapshots.setAbszissLabeler(new PlotLabeler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOrdinateLabel(JDiagram diagram, int ordinate, Double value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAbzisseLabel(JDiagram diagram, Double pos) {
|
||||||
|
return ((SnapShot)annotatedPlotProvider.getValues().get(pos.intValue())).getTimeStampFormated();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lDevices.getModel().getSize()>0)
|
||||||
|
lDevices.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSnapshots(){
|
private void showSnapshots(){
|
||||||
|
@ -288,45 +412,14 @@ public class SnapshotManager extends JDialog {
|
||||||
updateDiagram();
|
updateDiagram();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDiagram(){
|
private void updateDiagram(){
|
||||||
System.gc();
|
|
||||||
|
|
||||||
SnapShot[] rows = mtSnapshots.getTableMapper().getSelectedRows(new SnapShot[0]);
|
SnapShot[] rows = mtSnapshots.getTableMapper().getSelectedRows(new SnapShot[0]);
|
||||||
|
|
||||||
if ((rows == null)||(rows.length==0)){
|
if ((rows == null)||(rows.length==0)){
|
||||||
rows = mtSnapshots.getTableMapper().getRows(SnapShot.class).toArray(new SnapShot[0]);
|
rows = mtSnapshots.getTableMapper().getRows(SnapShot.class).toArray(new SnapShot[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int plotLength = rows.length;
|
annotatedPlotProvider.setValues(rows);
|
||||||
|
|
||||||
if (cbDifferenzen.isSelected()){
|
|
||||||
plotLength--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plotLength > 1024)
|
|
||||||
plotLength = 1024;
|
|
||||||
|
|
||||||
SimplePlotProvider pp = new SimplePlotProvider(32, plotLength);
|
|
||||||
diaSnapshots.setPlotProvider(pp);
|
|
||||||
|
|
||||||
for (int p=0;p<32;p++){
|
|
||||||
Float[] v = new Float[ plotLength ];
|
|
||||||
|
|
||||||
for (int i=0;i<plotLength;i++){
|
|
||||||
v[i] = (float)rows[i].getValue(p);
|
|
||||||
if (cbDifferenzen.isSelected()){
|
|
||||||
v[i] = ((float)rows[i+1].getValue(p)) - v[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pp.setPlot(p, v);
|
|
||||||
|
|
||||||
LinePlotPainter lpp = new LinePlotPainter();
|
|
||||||
lpp.setColor(plotColors[p]);
|
|
||||||
|
|
||||||
diaSnapshots.setPlotPainter(p, lpp);
|
|
||||||
}
|
|
||||||
|
|
||||||
diaSnapshots.repaint();
|
diaSnapshots.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue