2014-01-24 11:41:56 +01:00
|
|
|
|
package org.hwo.pulscounter;
|
|
|
|
|
|
|
|
|
|
import java.awt.EventQueue;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
|
import javax.swing.JPanel;
|
2014-02-03 10:52:19 +01:00
|
|
|
|
import javax.swing.Timer;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
|
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
|
import java.awt.GridBagConstraints;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JComboBox;
|
|
|
|
|
|
|
|
|
|
import org.hwo.csv.CSV;
|
|
|
|
|
import org.hwo.io.SerialPort;
|
2014-02-03 10:52:19 +01:00
|
|
|
|
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
import org.hwo.models.TableMapper.TableMapper;
|
|
|
|
|
|
|
|
|
|
import java.awt.Insets;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
2014-02-03 10:52:19 +01:00
|
|
|
|
import java.util.prefs.BackingStoreException;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
import java.util.prefs.Preferences;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JTable;
|
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
import javax.swing.border.TitledBorder;
|
|
|
|
|
import javax.swing.JSpinner;
|
|
|
|
|
import javax.swing.SpinnerNumberModel;
|
|
|
|
|
import javax.swing.border.BevelBorder;
|
|
|
|
|
import javax.swing.SwingConstants;
|
|
|
|
|
import javax.swing.event.ChangeListener;
|
|
|
|
|
import javax.swing.event.ChangeEvent;
|
|
|
|
|
import javax.swing.JTabbedPane;
|
|
|
|
|
import javax.swing.BoxLayout;
|
|
|
|
|
|
|
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
|
|
import java.awt.event.WindowEvent;
|
|
|
|
|
|
|
|
|
|
import org.hwo.datetime.JTimeOfDay;
|
|
|
|
|
|
2014-01-24 11:41:56 +01:00
|
|
|
|
public class PulsCounterWindow extends JFrame{
|
|
|
|
|
private JComboBox cbInterfaces;
|
|
|
|
|
private JTable tCounter;
|
|
|
|
|
|
|
|
|
|
private TableMapper tmCounter;
|
|
|
|
|
private Preferences prefs;
|
|
|
|
|
private List<CounterChannel> counterChannels;
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
private final JPanel panel_7 = new JPanel();
|
|
|
|
|
private JLabel lDeviceType;
|
|
|
|
|
private JLabel lDeviceTime;
|
|
|
|
|
private JLabel lActivity;
|
|
|
|
|
|
|
|
|
|
Thread threadUpdater;
|
|
|
|
|
Timer updateTimer;
|
|
|
|
|
private JSpinner spUpdateIntervall;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
boolean applicationExiting;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
private PulsCounterDevice pulsCounterDevice;
|
|
|
|
|
private JComboBox cbTimeBarriers;
|
|
|
|
|
private JTable tTBChannels;
|
|
|
|
|
private JTimeOfDay todTimebarrier;
|
|
|
|
|
|
|
|
|
|
private TableMapper tmTBChannels;
|
|
|
|
|
|
2014-01-24 11:41:56 +01:00
|
|
|
|
public PulsCounterWindow() {
|
2014-02-03 10:52:19 +01:00
|
|
|
|
addWindowListener(new WindowAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void windowClosing(WindowEvent arg0) {
|
|
|
|
|
applicationExiting = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-01-24 11:41:56 +01:00
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
2014-02-03 10:52:19 +01:00
|
|
|
|
setBounds(100, 100, 930, 592);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
setTitle("PulsCounter");
|
|
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0};
|
2014-02-03 10:52:19 +01:00
|
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
|
2014-01-24 11:41:56 +01:00
|
|
|
|
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
2014-02-03 10:52:19 +01:00
|
|
|
|
gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
2014-01-24 11:41:56 +01:00
|
|
|
|
getContentPane().setLayout(gridBagLayout);
|
|
|
|
|
|
|
|
|
|
JPanel panel = new JPanel();
|
|
|
|
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
|
|
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel.gridx = 0;
|
|
|
|
|
gbc_panel.gridy = 0;
|
|
|
|
|
getContentPane().add(panel, gbc_panel);
|
|
|
|
|
GridBagLayout gbl_panel = new GridBagLayout();
|
|
|
|
|
gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
2014-02-03 10:52:19 +01:00
|
|
|
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
|
|
|
|
gbl_panel.columnWeights = new double[]{1.0, 1.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel.rowWeights = new double[]{1.0, 1.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
2014-01-24 11:41:56 +01:00
|
|
|
|
panel.setLayout(gbl_panel);
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
JPanel panel_1 = new JPanel();
|
|
|
|
|
panel_1.setBorder(new TitledBorder(null, "Anschluss", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_1.gridwidth = 3;
|
|
|
|
|
gbc_panel_1.insets = new Insets(0, 0, 5, 5);
|
|
|
|
|
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_1.gridx = 0;
|
|
|
|
|
gbc_panel_1.gridy = 0;
|
|
|
|
|
panel.add(panel_1, gbc_panel_1);
|
|
|
|
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
|
|
|
|
gbl_panel_1.columnWidths = new int[]{0, 0, 0};
|
|
|
|
|
gbl_panel_1.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_1.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
|
|
panel_1.setLayout(gbl_panel_1);
|
|
|
|
|
|
2014-01-24 11:41:56 +01:00
|
|
|
|
JLabel lblNewLabel = new JLabel("Schnittstelle:");
|
|
|
|
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
2014-02-03 10:52:19 +01:00
|
|
|
|
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
gbc_lblNewLabel.gridx = 0;
|
|
|
|
|
gbc_lblNewLabel.gridy = 0;
|
2014-02-03 10:52:19 +01:00
|
|
|
|
panel_1.add(lblNewLabel, gbc_lblNewLabel);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
cbInterfaces = new JComboBox();
|
2014-02-03 10:52:19 +01:00
|
|
|
|
GridBagConstraints gbc_cbInterfaces = new GridBagConstraints();
|
|
|
|
|
gbc_cbInterfaces.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
gbc_cbInterfaces.gridx = 1;
|
|
|
|
|
gbc_cbInterfaces.gridy = 0;
|
|
|
|
|
panel_1.add(cbInterfaces, gbc_cbInterfaces);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
cbInterfaces.addActionListener(new ActionListener() {
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
|
|
|
|
|
|
System.err.println("Save Pref PORT");
|
|
|
|
|
|
|
|
|
|
prefs.put("io.port", cbInterfaces.getSelectedItem().toString());
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
prefs.sync();
|
|
|
|
|
} catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
System.err.println("Exception: " + e);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2014-02-03 10:52:19 +01:00
|
|
|
|
setSerialPort();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
JPanel panel_2 = new JPanel();
|
|
|
|
|
panel_2.setBorder(new TitledBorder(null, "Einstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_2 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_2.gridwidth = 2;
|
|
|
|
|
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_2.gridx = 3;
|
|
|
|
|
gbc_panel_2.gridy = 0;
|
|
|
|
|
panel.add(panel_2, gbc_panel_2);
|
|
|
|
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
|
|
|
|
gbl_panel_2.columnWidths = new int[]{0, 0, 0};
|
|
|
|
|
gbl_panel_2.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
|
|
panel_2.setLayout(gbl_panel_2);
|
|
|
|
|
|
|
|
|
|
JLabel lblAktualisierungsintervall = new JLabel("Aktualisierungsintervall:");
|
|
|
|
|
GridBagConstraints gbc_lblAktualisierungsintervall = new GridBagConstraints();
|
|
|
|
|
gbc_lblAktualisierungsintervall.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_lblAktualisierungsintervall.gridx = 0;
|
|
|
|
|
gbc_lblAktualisierungsintervall.gridy = 0;
|
|
|
|
|
panel_2.add(lblAktualisierungsintervall, gbc_lblAktualisierungsintervall);
|
|
|
|
|
|
|
|
|
|
spUpdateIntervall = new JSpinner();
|
|
|
|
|
spUpdateIntervall.addChangeListener(new ChangeListener() {
|
|
|
|
|
public void stateChanged(ChangeEvent arg0) {
|
|
|
|
|
if (updateTimer != null)
|
|
|
|
|
{
|
|
|
|
|
Integer updateIntervall = (Integer)spUpdateIntervall.getValue();
|
|
|
|
|
updateTimer.stop();
|
|
|
|
|
updateTimer.setDelay(updateIntervall * 1000);
|
|
|
|
|
updateTimer.start();
|
|
|
|
|
|
|
|
|
|
prefs.putInt("update.intervall", updateIntervall);
|
|
|
|
|
try {
|
|
|
|
|
prefs.flush();
|
|
|
|
|
} catch (BackingStoreException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-24 11:41:56 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-02-03 10:52:19 +01:00
|
|
|
|
spUpdateIntervall.setModel(new SpinnerNumberModel(15, 5, 3600, 1));
|
|
|
|
|
GridBagConstraints gbc_spUpdateIntervall = new GridBagConstraints();
|
|
|
|
|
gbc_spUpdateIntervall.anchor = GridBagConstraints.EAST;
|
|
|
|
|
gbc_spUpdateIntervall.gridx = 1;
|
|
|
|
|
gbc_spUpdateIntervall.gridy = 0;
|
|
|
|
|
panel_2.add(spUpdateIntervall, gbc_spUpdateIntervall);
|
|
|
|
|
|
|
|
|
|
JPanel panel_3 = new JPanel();
|
|
|
|
|
panel_3.setBorder(new TitledBorder(null, "Aktionen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_3.gridwidth = 5;
|
|
|
|
|
gbc_panel_3.insets = new Insets(0, 0, 5, 5);
|
|
|
|
|
gbc_panel_3.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_3.gridx = 0;
|
|
|
|
|
gbc_panel_3.gridy = 3;
|
|
|
|
|
panel.add(panel_3, gbc_panel_3);
|
|
|
|
|
GridBagLayout gbl_panel_3 = new GridBagLayout();
|
|
|
|
|
gbl_panel_3.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
|
|
|
gbl_panel_3.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_3.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_3.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
|
|
panel_3.setLayout(gbl_panel_3);
|
|
|
|
|
|
|
|
|
|
JButton btnNewButton = new JButton("Jetzt aktualisieren...");
|
2014-01-24 11:41:56 +01:00
|
|
|
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
2014-02-03 10:52:19 +01:00
|
|
|
|
gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_btnNewButton.gridx = 1;
|
2014-01-24 11:41:56 +01:00
|
|
|
|
gbc_btnNewButton.gridy = 0;
|
2014-02-03 10:52:19 +01:00
|
|
|
|
panel_3.add(btnNewButton, gbc_btnNewButton);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
JButton btnTagesdateiSchreiben = new JButton("Tagesdatei schreiben...");
|
2014-02-03 10:52:19 +01:00
|
|
|
|
GridBagConstraints gbc_btnTagesdateiSchreiben = new GridBagConstraints();
|
|
|
|
|
gbc_btnTagesdateiSchreiben.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_btnTagesdateiSchreiben.gridx = 2;
|
|
|
|
|
gbc_btnTagesdateiSchreiben.gridy = 0;
|
|
|
|
|
panel_3.add(btnTagesdateiSchreiben, gbc_btnTagesdateiSchreiben);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
btnTagesdateiSchreiben.addActionListener(new ActionListener() {
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
|
writeDayFile();
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-02-03 10:52:19 +01:00
|
|
|
|
btnNewButton.addActionListener(new ActionListener() {
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
|
synchronized (threadUpdater) {
|
|
|
|
|
threadUpdater.notifyAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
|
|
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
|
|
|
|
|
gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_tabbedPane.gridx = 0;
|
|
|
|
|
gbc_tabbedPane.gridy = 1;
|
|
|
|
|
getContentPane().add(tabbedPane, gbc_tabbedPane);
|
|
|
|
|
|
|
|
|
|
JPanel panel_8 = new JPanel();
|
|
|
|
|
tabbedPane.addTab("Aktuelle Werte", null, panel_8, null);
|
|
|
|
|
panel_8.setLayout(new BoxLayout(panel_8, BoxLayout.X_AXIS));
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
JScrollPane scrollPane = new JScrollPane();
|
2014-02-03 10:52:19 +01:00
|
|
|
|
panel_8.add(scrollPane);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
tCounter = new JTable();
|
|
|
|
|
scrollPane.setViewportView(tCounter);
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
JPanel panel_9 = new JPanel();
|
|
|
|
|
tabbedPane.addTab("Tageszeiterfassung", null, panel_9, null);
|
|
|
|
|
GridBagLayout gbl_panel_9 = new GridBagLayout();
|
|
|
|
|
gbl_panel_9.columnWidths = new int[]{0, 0, 0};
|
|
|
|
|
gbl_panel_9.rowHeights = new int[]{0, 0, 0, 0};
|
|
|
|
|
gbl_panel_9.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_9.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
panel_9.setLayout(gbl_panel_9);
|
|
|
|
|
|
|
|
|
|
JLabel lblNewLabel_1 = new JLabel("Speicher:");
|
|
|
|
|
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
|
|
|
|
gbc_lblNewLabel_1.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
|
|
|
|
|
gbc_lblNewLabel_1.gridx = 0;
|
|
|
|
|
gbc_lblNewLabel_1.gridy = 0;
|
|
|
|
|
panel_9.add(lblNewLabel_1, gbc_lblNewLabel_1);
|
|
|
|
|
|
|
|
|
|
cbTimeBarriers = new JComboBox();
|
|
|
|
|
cbTimeBarriers.addActionListener(new ActionListener() {
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
|
updateTimeBarrierView();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
GridBagConstraints gbc_cbTimeBarriers = new GridBagConstraints();
|
|
|
|
|
gbc_cbTimeBarriers.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
gbc_cbTimeBarriers.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
gbc_cbTimeBarriers.gridx = 1;
|
|
|
|
|
gbc_cbTimeBarriers.gridy = 0;
|
|
|
|
|
panel_9.add(cbTimeBarriers, gbc_cbTimeBarriers);
|
|
|
|
|
|
|
|
|
|
JPanel panel_10 = new JPanel();
|
|
|
|
|
panel_10.setBorder(new TitledBorder(null, "Einstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_10 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_10.insets = new Insets(0, 0, 5, 0);
|
|
|
|
|
gbc_panel_10.gridwidth = 2;
|
|
|
|
|
gbc_panel_10.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_10.gridx = 0;
|
|
|
|
|
gbc_panel_10.gridy = 1;
|
|
|
|
|
panel_9.add(panel_10, gbc_panel_10);
|
|
|
|
|
GridBagLayout gbl_panel_10 = new GridBagLayout();
|
|
|
|
|
gbl_panel_10.columnWidths = new int[]{0, 0, 0};
|
|
|
|
|
gbl_panel_10.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_10.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_10.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
panel_10.setLayout(gbl_panel_10);
|
|
|
|
|
|
|
|
|
|
JLabel lblDdd = new JLabel("Werte erfassen bis:");
|
|
|
|
|
GridBagConstraints gbc_lblDdd = new GridBagConstraints();
|
|
|
|
|
gbc_lblDdd.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbc_lblDdd.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_lblDdd.fill = GridBagConstraints.VERTICAL;
|
|
|
|
|
gbc_lblDdd.gridx = 0;
|
|
|
|
|
gbc_lblDdd.gridy = 0;
|
|
|
|
|
panel_10.add(lblDdd, gbc_lblDdd);
|
|
|
|
|
|
|
|
|
|
todTimebarrier = new JTimeOfDay();
|
|
|
|
|
todTimebarrier.setSecondsHidden(true);
|
|
|
|
|
todTimebarrier.addChangeListener(new ChangeListener() {
|
|
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
GridBagConstraints gbc_todTimebarrier = new GridBagConstraints();
|
|
|
|
|
gbc_todTimebarrier.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbc_todTimebarrier.fill = GridBagConstraints.VERTICAL;
|
|
|
|
|
gbc_todTimebarrier.gridx = 1;
|
|
|
|
|
gbc_todTimebarrier.gridy = 0;
|
|
|
|
|
panel_10.add(todTimebarrier, gbc_todTimebarrier);
|
|
|
|
|
|
|
|
|
|
JPanel panel_11 = new JPanel();
|
|
|
|
|
panel_11.setBorder(new TitledBorder(null, "Aktuelle Werte", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_11 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_11.gridwidth = 2;
|
|
|
|
|
gbc_panel_11.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_11.gridx = 0;
|
|
|
|
|
gbc_panel_11.gridy = 2;
|
|
|
|
|
panel_9.add(panel_11, gbc_panel_11);
|
|
|
|
|
GridBagLayout gbl_panel_11 = new GridBagLayout();
|
|
|
|
|
gbl_panel_11.columnWidths = new int[]{0, 0};
|
|
|
|
|
gbl_panel_11.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_11.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_11.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
panel_11.setLayout(gbl_panel_11);
|
|
|
|
|
|
|
|
|
|
JScrollPane scrollPane_1 = new JScrollPane();
|
|
|
|
|
GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
|
|
|
|
|
gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_scrollPane_1.gridx = 0;
|
|
|
|
|
gbc_scrollPane_1.gridy = 0;
|
|
|
|
|
panel_11.add(scrollPane_1, gbc_scrollPane_1);
|
|
|
|
|
|
|
|
|
|
tTBChannels = new JTable();
|
|
|
|
|
scrollPane_1.setViewportView(tTBChannels);
|
|
|
|
|
|
|
|
|
|
JPanel panel_4 = new JPanel();
|
|
|
|
|
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_4.gridx = 0;
|
|
|
|
|
gbc_panel_4.gridy = 2;
|
|
|
|
|
getContentPane().add(panel_4, gbc_panel_4);
|
|
|
|
|
GridBagLayout gbl_panel_4 = new GridBagLayout();
|
|
|
|
|
gbl_panel_4.columnWidths = new int[]{0, 0, 0, 0};
|
|
|
|
|
gbl_panel_4.rowHeights = new int[]{0, 0};
|
|
|
|
|
gbl_panel_4.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_4.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
|
|
panel_4.setLayout(gbl_panel_4);
|
|
|
|
|
|
|
|
|
|
JPanel panel_6 = new JPanel();
|
|
|
|
|
panel_6.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_6 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_6.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_panel_6.fill = GridBagConstraints.BOTH;
|
|
|
|
|
gbc_panel_6.gridx = 0;
|
|
|
|
|
gbc_panel_6.gridy = 0;
|
|
|
|
|
panel_4.add(panel_6, gbc_panel_6);
|
|
|
|
|
GridBagLayout gbl_panel_6 = new GridBagLayout();
|
|
|
|
|
gbl_panel_6.columnWidths = new int[]{348, 0};
|
|
|
|
|
gbl_panel_6.rowHeights = new int[]{16, 0};
|
|
|
|
|
gbl_panel_6.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
gbl_panel_6.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
|
|
panel_6.setLayout(gbl_panel_6);
|
|
|
|
|
|
|
|
|
|
lActivity = new JLabel("Verbindungsaktivit\u00E4t");
|
|
|
|
|
lActivity.setToolTipText("Aktuelle Aufgabe");
|
|
|
|
|
lActivity.setHorizontalAlignment(SwingConstants.LEFT);
|
|
|
|
|
GridBagConstraints gbc_lActivity = new GridBagConstraints();
|
|
|
|
|
gbc_lActivity.insets = new Insets(0, 5, 0, 0);
|
|
|
|
|
gbc_lActivity.anchor = GridBagConstraints.WEST;
|
|
|
|
|
gbc_lActivity.gridx = 0;
|
|
|
|
|
gbc_lActivity.gridy = 0;
|
|
|
|
|
panel_6.add(lActivity, gbc_lActivity);
|
|
|
|
|
|
|
|
|
|
JPanel panel_5 = new JPanel();
|
|
|
|
|
panel_5.setToolTipText("Angeschlossener Ger\u00E4tetyp");
|
|
|
|
|
panel_5.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
|
|
|
|
GridBagConstraints gbc_panel_5 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_5.insets = new Insets(0, 0, 0, 5);
|
|
|
|
|
gbc_panel_5.fill = GridBagConstraints.VERTICAL;
|
|
|
|
|
gbc_panel_5.gridx = 1;
|
|
|
|
|
gbc_panel_5.gridy = 0;
|
|
|
|
|
panel_4.add(panel_5, gbc_panel_5);
|
|
|
|
|
|
|
|
|
|
lDeviceType = new JLabel("----");
|
|
|
|
|
panel_5.add(lDeviceType);
|
|
|
|
|
GridBagConstraints gbc_panel_7 = new GridBagConstraints();
|
|
|
|
|
gbc_panel_7.gridx = 2;
|
|
|
|
|
gbc_panel_7.gridy = 0;
|
|
|
|
|
panel_7.setToolTipText("Ger\u00E4tezeit bei letztem Kontakt");
|
|
|
|
|
panel_4.add(panel_7, gbc_panel_7);
|
|
|
|
|
panel_7.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
|
|
|
|
|
|
|
|
|
lDeviceTime = new JLabel("----");
|
|
|
|
|
panel_7.add(lDeviceTime);
|
|
|
|
|
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
initialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initialize() {
|
2014-02-03 10:52:19 +01:00
|
|
|
|
applicationExiting = false;
|
|
|
|
|
pulsCounterDevice = new PulsCounterDevice();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
prefs = Preferences.userRoot();
|
|
|
|
|
|
|
|
|
|
String defaultPort = prefs.get("io.port", "COM1");
|
|
|
|
|
|
|
|
|
|
for (String portName:SerialPort.getPortNames())
|
|
|
|
|
cbInterfaces.addItem(portName);
|
2014-02-03 10:52:19 +01:00
|
|
|
|
|
|
|
|
|
// cbInterfaces.addItem("dummy:");
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
System.err.println("Default Port: " + defaultPort);
|
|
|
|
|
|
|
|
|
|
for (int i=0;i < cbInterfaces.getItemCount();i++)
|
|
|
|
|
{
|
|
|
|
|
if (cbInterfaces.getItemAt(i).equals(defaultPort))
|
|
|
|
|
cbInterfaces.setSelectedIndex(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tmCounter = new TableMapper(CounterChannel.class, tCounter);
|
2014-02-03 10:52:19 +01:00
|
|
|
|
tmCounter.setRows(pulsCounterDevice.getChannels());
|
2014-01-24 11:41:56 +01:00
|
|
|
|
tmCounter.getColumnInfo().get(0).setReadOnly(true);
|
|
|
|
|
tmCounter.getColumnInfo().get(1).setReadOnly(true);
|
|
|
|
|
tmCounter.getColumnInfo().get(3).setReadOnly(true);
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
tmCounter.addTableMapperListener(new AbstractTableMapperListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void ValueChanged(int row, int column) {
|
|
|
|
|
if (column == 2)
|
|
|
|
|
{
|
|
|
|
|
saveCorrection(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tmTBChannels = new TableMapper(CounterChannel.class, tTBChannels);
|
|
|
|
|
tmTBChannels.getColumnInfo().get(0).setReadOnly(true);
|
|
|
|
|
tmTBChannels.getColumnInfo().get(1).setReadOnly(true);
|
|
|
|
|
tmTBChannels.getColumnInfo().get(3).setReadOnly(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
threadUpdater = new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (applicationExiting)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
synchronized (threadUpdater) {
|
|
|
|
|
threadUpdater.wait();
|
|
|
|
|
}
|
|
|
|
|
updateCounter();
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
threadUpdater.start();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
spUpdateIntervall.setValue(prefs.getInt("update.intervall", 15));
|
|
|
|
|
updateTimer = new Timer(prefs.getInt("update.intervall", 15)*1000, new ActionListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
|
synchronized (threadUpdater) {
|
|
|
|
|
threadUpdater.notifyAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
updateTimer.setRepeats(true);
|
|
|
|
|
updateTimer.start();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateCounter()
|
|
|
|
|
{
|
2014-02-03 10:52:19 +01:00
|
|
|
|
lActivity.setText("Werte aktuelisieren...");
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
pulsCounterDevice.update();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
lDeviceType.setText(pulsCounterDevice.getDeviceName());
|
|
|
|
|
lDeviceTime.setText(pulsCounterDevice.getDeviceTime().toLocaleString());
|
2014-01-24 11:41:56 +01:00
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
if (cbTimeBarriers.getItemCount()==0)
|
2014-01-24 11:41:56 +01:00
|
|
|
|
{
|
2014-02-03 10:52:19 +01:00
|
|
|
|
for (TimeBarrier tb: pulsCounterDevice.getTimeBarriers())
|
|
|
|
|
{
|
|
|
|
|
cbTimeBarriers.addItem(tb);
|
|
|
|
|
}
|
2014-01-24 11:41:56 +01:00
|
|
|
|
}
|
2014-02-03 10:52:19 +01:00
|
|
|
|
|
|
|
|
|
lActivity.setText("warten...");
|
|
|
|
|
tCounter.repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveCorrection(int row)
|
|
|
|
|
{
|
|
|
|
|
System.err.println(String.format("Korrekturwert f<>r Kanal %d = %d",row + 1,tmCounter.getRow(row,CounterChannel.class).getCorrect()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setSerialPort()
|
|
|
|
|
{
|
|
|
|
|
String serialPortName = cbInterfaces.getSelectedItem().toString();
|
|
|
|
|
SerialPort sport = SerialPort.newInstance();
|
|
|
|
|
sport.setPortName(serialPortName);
|
|
|
|
|
pulsCounterDevice.setSerialPort(sport);
|
2014-01-24 11:41:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void writeDayFile()
|
|
|
|
|
{
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
2014-02-03 10:52:19 +01:00
|
|
|
|
/* CSV csv = new CSV();
|
2014-01-24 11:41:56 +01:00
|
|
|
|
String[] row = new String[this.timeBarriers.size() + 1];
|
|
|
|
|
|
|
|
|
|
row[0] = "";
|
|
|
|
|
for (int n=1;n<row.length;n++)
|
|
|
|
|
{
|
|
|
|
|
row[n] = String.format("%02d:%02d", (timeBarriers.get(n-1).timeOfDay / 60),(timeBarriers.get(n-1).timeOfDay % 60));
|
|
|
|
|
}
|
|
|
|
|
csv.getCells().add(row);
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<this.counterChannels.size();i++)
|
|
|
|
|
{
|
|
|
|
|
row = new String[this.timeBarriers.size() + 1];
|
|
|
|
|
row[0] = new Integer(i + 1).toString();
|
|
|
|
|
for (int n=1;n<row.length;n++)
|
|
|
|
|
row[n] = timeBarriers.get(n-1).values.get(i).toString();
|
|
|
|
|
csv.getCells().add(row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csv.saveToFile(String.format("daily-%d-%d-%d.csv",(date.getYear()+1900),date.getMonth()+1,date.getDate()+1));
|
2014-02-03 10:52:19 +01:00
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateTimeBarrierView()
|
|
|
|
|
{
|
|
|
|
|
TimeBarrier tb = (TimeBarrier)cbTimeBarriers.getSelectedItem();
|
|
|
|
|
if (tb == null)
|
|
|
|
|
{
|
|
|
|
|
todTimebarrier.setEnabled(false);
|
|
|
|
|
tTBChannels.setEnabled(false);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
todTimebarrier.setEnabled(true);
|
|
|
|
|
todTimebarrier.setTimeOfDay(tb.getTimeOfDay());
|
|
|
|
|
}
|
2014-01-24 11:41:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|