Updates
parent
ed0d5643c4
commit
d9a08dfeeb
|
@ -6,7 +6,11 @@ public class CounterChannel {
|
||||||
|
|
||||||
@TableColumn(label="Kanal",firstColumn=true)
|
@TableColumn(label="Kanal",firstColumn=true)
|
||||||
private Integer channel;
|
private Integer channel;
|
||||||
@TableColumn(label="ZŠhlerstand",after="Kanal")
|
|
||||||
|
@TableColumn(label="Bezeichnung",after="Kanal")
|
||||||
|
private String bezeichnung;
|
||||||
|
|
||||||
|
@TableColumn(label="ZŠhlerstand",after="Bezeichnung")
|
||||||
private Integer value;
|
private Integer value;
|
||||||
@TableColumn(label="Korrekturwert",after="ZŠhlerstand")
|
@TableColumn(label="Korrekturwert",after="ZŠhlerstand")
|
||||||
private Integer correct;
|
private Integer correct;
|
||||||
|
@ -22,6 +26,7 @@ public class CounterChannel {
|
||||||
channel = ch;
|
channel = ch;
|
||||||
value = 0;
|
value = 0;
|
||||||
correct = 0;
|
correct = 0;
|
||||||
|
bezeichnung = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getChannel() {
|
public Integer getChannel() {
|
||||||
|
@ -44,6 +49,14 @@ public class CounterChannel {
|
||||||
this.correct = correct;
|
this.correct = correct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBezeichnung() {
|
||||||
|
return bezeichnung;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBezeichnung(String bezeichnung) {
|
||||||
|
this.bezeichnung = bezeichnung;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
|
||||||
public class PulsCounterDevice {
|
public class PulsCounterDevice {
|
||||||
|
|
||||||
|
@ -38,39 +39,75 @@ public class PulsCounterDevice {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update()
|
synchronized public void reset(int ch)
|
||||||
{
|
{
|
||||||
if (serialPort == null)
|
if (serialPort == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!serialPort.open())
|
|
||||||
{
|
|
||||||
System.err.println("Fehler: Port konnte nicht gešffnet werden!");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DeviceControlChannel channel = new DeviceControlChannel(serialPort.getInputStream(), serialPort.getOutputStream());
|
ServiceLink sl = new ServiceLink(serialPort);
|
||||||
|
|
||||||
channel.noop();
|
sl.writeInt((byte)0, (byte)0, (short)(0x1000 + ch), 0);
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
System.err.println("Exception: " + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serialPort.isOpen())
|
||||||
|
serialPort.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void reset()
|
||||||
|
{
|
||||||
|
if (serialPort == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServiceLink sl = new ServiceLink(serialPort);
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++)
|
||||||
|
sl.writeInt((byte)0, (byte)0, (short)(0x1000 + i), 0);
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
System.err.println("Exception: " + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serialPort.isOpen())
|
||||||
|
serialPort.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
synchronized public void update()
|
||||||
|
{
|
||||||
|
if (serialPort == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServiceLink sl = new ServiceLink(serialPort);
|
||||||
|
|
||||||
|
System.err.println(String.format("BRKVAL: 0x%04x", sl.readInt((byte)0, (byte)0, (short)0x200)));
|
||||||
|
System.err.println(String.format("SPLIM : 0x%04x", sl.readInt((byte)0, (byte)0, (short)0x201)));
|
||||||
|
|
||||||
|
|
||||||
for (int i=0;i<32;i++)
|
for (int i=0;i<32;i++)
|
||||||
{
|
{
|
||||||
int inc = random.nextInt(15);
|
channels.get(i).setValue( sl.readInt((byte)0x0D, (byte)0, (short)(0x1000 + i)) );
|
||||||
if (inc > 4)
|
|
||||||
inc = 0;
|
|
||||||
|
|
||||||
channels.get(i).setValue(channels.get(i).getValue() + inc);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
System.err.println("Exception: " + e);
|
System.err.println("Exception: " + e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serialPort.isOpen())
|
if (serialPort.isOpen())
|
||||||
serialPort.close();
|
serialPort.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +138,4 @@ public class PulsCounterDevice {
|
||||||
public void setSerialPort(SerialPort serialPort) {
|
public void setSerialPort(SerialPort serialPort) {
|
||||||
this.serialPort = serialPort;
|
this.serialPort = serialPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@ import java.io.RandomAccessFile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
public class PulsCounterInterface {
|
public class PulsCounterInterface {
|
||||||
|
|
||||||
|
|
||||||
public PulsCounterInterface(String portName)
|
public PulsCounterInterface(String portName)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> readCounter()
|
public List<Integer> readCounter()
|
||||||
|
|
|
@ -2,8 +2,11 @@ package org.hwo.pulscounter;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
@ -20,11 +23,13 @@ import org.hwo.csv.CSV;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
||||||
import org.hwo.models.TableMapper.TableMapper;
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.ui.MousePopupListener;
|
||||||
|
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.prefs.BackingStoreException;
|
import java.util.prefs.BackingStoreException;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
@ -33,6 +38,8 @@ import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
@ -46,9 +53,16 @@ import javax.swing.BoxLayout;
|
||||||
|
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.hwo.datetime.JTimeOfDay;
|
import org.hwo.datetime.JTimeOfDay;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
public class PulsCounterWindow extends JFrame{
|
public class PulsCounterWindow extends JFrame{
|
||||||
private JComboBox cbInterfaces;
|
private JComboBox cbInterfaces;
|
||||||
private JTable tCounter;
|
private JTable tCounter;
|
||||||
|
@ -74,6 +88,9 @@ public class PulsCounterWindow extends JFrame{
|
||||||
private JTimeOfDay todTimebarrier;
|
private JTimeOfDay todTimebarrier;
|
||||||
|
|
||||||
private TableMapper tmTBChannels;
|
private TableMapper tmTBChannels;
|
||||||
|
private JTextField tfWorkDir;
|
||||||
|
|
||||||
|
private String workingDirectory;
|
||||||
|
|
||||||
public PulsCounterWindow() {
|
public PulsCounterWindow() {
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
|
@ -163,15 +180,16 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_panel_2.gridy = 0;
|
gbc_panel_2.gridy = 0;
|
||||||
panel.add(panel_2, gbc_panel_2);
|
panel.add(panel_2, gbc_panel_2);
|
||||||
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
||||||
gbl_panel_2.columnWidths = new int[]{0, 0, 0};
|
gbl_panel_2.columnWidths = new int[]{0, 0, 0, 0};
|
||||||
gbl_panel_2.rowHeights = new int[]{0, 0};
|
gbl_panel_2.rowHeights = new int[]{0, 0, 0};
|
||||||
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
||||||
panel_2.setLayout(gbl_panel_2);
|
panel_2.setLayout(gbl_panel_2);
|
||||||
|
|
||||||
JLabel lblAktualisierungsintervall = new JLabel("Aktualisierungsintervall:");
|
JLabel lblAktualisierungsintervall = new JLabel("Aktualisierungsintervall:");
|
||||||
GridBagConstraints gbc_lblAktualisierungsintervall = new GridBagConstraints();
|
GridBagConstraints gbc_lblAktualisierungsintervall = new GridBagConstraints();
|
||||||
gbc_lblAktualisierungsintervall.insets = new Insets(0, 0, 0, 5);
|
gbc_lblAktualisierungsintervall.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_lblAktualisierungsintervall.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblAktualisierungsintervall.gridx = 0;
|
gbc_lblAktualisierungsintervall.gridx = 0;
|
||||||
gbc_lblAktualisierungsintervall.gridy = 0;
|
gbc_lblAktualisierungsintervall.gridy = 0;
|
||||||
panel_2.add(lblAktualisierungsintervall, gbc_lblAktualisierungsintervall);
|
panel_2.add(lblAktualisierungsintervall, gbc_lblAktualisierungsintervall);
|
||||||
|
@ -198,11 +216,58 @@ public class PulsCounterWindow extends JFrame{
|
||||||
});
|
});
|
||||||
spUpdateIntervall.setModel(new SpinnerNumberModel(15, 5, 3600, 1));
|
spUpdateIntervall.setModel(new SpinnerNumberModel(15, 5, 3600, 1));
|
||||||
GridBagConstraints gbc_spUpdateIntervall = new GridBagConstraints();
|
GridBagConstraints gbc_spUpdateIntervall = new GridBagConstraints();
|
||||||
|
gbc_spUpdateIntervall.gridwidth = 2;
|
||||||
|
gbc_spUpdateIntervall.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_spUpdateIntervall.anchor = GridBagConstraints.EAST;
|
gbc_spUpdateIntervall.anchor = GridBagConstraints.EAST;
|
||||||
gbc_spUpdateIntervall.gridx = 1;
|
gbc_spUpdateIntervall.gridx = 1;
|
||||||
gbc_spUpdateIntervall.gridy = 0;
|
gbc_spUpdateIntervall.gridy = 0;
|
||||||
panel_2.add(spUpdateIntervall, gbc_spUpdateIntervall);
|
panel_2.add(spUpdateIntervall, gbc_spUpdateIntervall);
|
||||||
|
|
||||||
|
JLabel lblArbeitsverzeichnis = new JLabel("Arbeitsverzeichnis:");
|
||||||
|
GridBagConstraints gbc_lblArbeitsverzeichnis = new GridBagConstraints();
|
||||||
|
gbc_lblArbeitsverzeichnis.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblArbeitsverzeichnis.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblArbeitsverzeichnis.gridx = 0;
|
||||||
|
gbc_lblArbeitsverzeichnis.gridy = 1;
|
||||||
|
panel_2.add(lblArbeitsverzeichnis, gbc_lblArbeitsverzeichnis);
|
||||||
|
|
||||||
|
tfWorkDir = new JTextField();
|
||||||
|
tfWorkDir.setEditable(false);
|
||||||
|
GridBagConstraints gbc_tfWorkDir = new GridBagConstraints();
|
||||||
|
gbc_tfWorkDir.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_tfWorkDir.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_tfWorkDir.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfWorkDir.gridx = 1;
|
||||||
|
gbc_tfWorkDir.gridy = 1;
|
||||||
|
panel_2.add(tfWorkDir, gbc_tfWorkDir);
|
||||||
|
tfWorkDir.setColumns(10);
|
||||||
|
|
||||||
|
JButton btnDurchsuchen = new JButton("durchsuchen...");
|
||||||
|
btnDurchsuchen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
|
||||||
|
JFileChooser jfc = new JFileChooser();
|
||||||
|
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
|
||||||
|
if (jfc.showOpenDialog(PulsCounterWindow.this)==JFileChooser.APPROVE_OPTION)
|
||||||
|
{
|
||||||
|
workingDirectory = jfc.getSelectedFile().getAbsolutePath();
|
||||||
|
tfWorkDir.setText(workingDirectory);
|
||||||
|
prefs.put("file.directory",workingDirectory);
|
||||||
|
try {
|
||||||
|
prefs.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnDurchsuchen = new GridBagConstraints();
|
||||||
|
gbc_btnDurchsuchen.gridx = 2;
|
||||||
|
gbc_btnDurchsuchen.gridy = 1;
|
||||||
|
panel_2.add(btnDurchsuchen, gbc_btnDurchsuchen);
|
||||||
|
|
||||||
JPanel panel_3 = new JPanel();
|
JPanel panel_3 = new JPanel();
|
||||||
panel_3.setBorder(new TitledBorder(null, "Aktionen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel_3.setBorder(new TitledBorder(null, "Aktionen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
||||||
|
@ -226,15 +291,30 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_btnNewButton.gridy = 0;
|
gbc_btnNewButton.gridy = 0;
|
||||||
panel_3.add(btnNewButton, gbc_btnNewButton);
|
panel_3.add(btnNewButton, gbc_btnNewButton);
|
||||||
|
|
||||||
JButton btnTagesdateiSchreiben = new JButton("Tagesdatei schreiben...");
|
JButton btnTagesdateiSchreiben = new JButton("Kanalbezeichnungen speichern...");
|
||||||
GridBagConstraints gbc_btnTagesdateiSchreiben = new GridBagConstraints();
|
GridBagConstraints gbc_btnTagesdateiSchreiben = new GridBagConstraints();
|
||||||
gbc_btnTagesdateiSchreiben.insets = new Insets(0, 0, 0, 5);
|
gbc_btnTagesdateiSchreiben.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_btnTagesdateiSchreiben.gridx = 2;
|
gbc_btnTagesdateiSchreiben.gridx = 2;
|
||||||
gbc_btnTagesdateiSchreiben.gridy = 0;
|
gbc_btnTagesdateiSchreiben.gridy = 0;
|
||||||
panel_3.add(btnTagesdateiSchreiben, gbc_btnTagesdateiSchreiben);
|
panel_3.add(btnTagesdateiSchreiben, gbc_btnTagesdateiSchreiben);
|
||||||
|
|
||||||
|
JButton btnAlle = new JButton("Alle 0");
|
||||||
|
btnAlle.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
pulsCounterDevice.reset();
|
||||||
|
|
||||||
|
synchronized (threadUpdater) {
|
||||||
|
threadUpdater.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnAlle = new GridBagConstraints();
|
||||||
|
gbc_btnAlle.gridx = 3;
|
||||||
|
gbc_btnAlle.gridy = 0;
|
||||||
|
panel_3.add(btnAlle, gbc_btnAlle);
|
||||||
btnTagesdateiSchreiben.addActionListener(new ActionListener() {
|
btnTagesdateiSchreiben.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
writeDayFile();
|
saveChannelNames();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
|
@ -429,6 +509,9 @@ public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
String defaultPort = prefs.get("io.port", "COM1");
|
String defaultPort = prefs.get("io.port", "COM1");
|
||||||
|
|
||||||
|
workingDirectory = prefs.get("file.directory", (new File(".")).getAbsolutePath());
|
||||||
|
tfWorkDir.setText(workingDirectory);
|
||||||
|
|
||||||
for (String portName:SerialPort.getPortNames())
|
for (String portName:SerialPort.getPortNames())
|
||||||
cbInterfaces.addItem(portName);
|
cbInterfaces.addItem(portName);
|
||||||
|
|
||||||
|
@ -445,8 +528,8 @@ public class PulsCounterWindow extends JFrame{
|
||||||
tmCounter = new TableMapper(CounterChannel.class, tCounter);
|
tmCounter = new TableMapper(CounterChannel.class, tCounter);
|
||||||
tmCounter.setRows(pulsCounterDevice.getChannels());
|
tmCounter.setRows(pulsCounterDevice.getChannels());
|
||||||
tmCounter.getColumnInfo().get(0).setReadOnly(true);
|
tmCounter.getColumnInfo().get(0).setReadOnly(true);
|
||||||
tmCounter.getColumnInfo().get(1).setReadOnly(true);
|
tmCounter.getColumnInfo().get(2).setReadOnly(true);
|
||||||
tmCounter.getColumnInfo().get(3).setReadOnly(true);
|
tmCounter.getColumnInfo().get(4).setReadOnly(true);
|
||||||
|
|
||||||
tmCounter.addTableMapperListener(new AbstractTableMapperListener() {
|
tmCounter.addTableMapperListener(new AbstractTableMapperListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -456,8 +539,37 @@ public class PulsCounterWindow extends JFrame{
|
||||||
saveCorrection(row);
|
saveCorrection(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tCounter.addMouseListener(new MousePopupListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupTriggered(int x, int y) {
|
||||||
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
JMenuItem mi = new JMenuItem();
|
||||||
|
mi.setText("RESET");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
CounterChannel cc = (CounterChannel)tmCounter.getSelectedRow();
|
||||||
|
if (cc != null)
|
||||||
|
{
|
||||||
|
pulsCounterDevice.reset(cc.getChannel()-1);
|
||||||
|
synchronized (threadUpdater) {
|
||||||
|
threadUpdater.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(mi);
|
||||||
|
|
||||||
|
popup.show(tCounter, x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tmTBChannels = new TableMapper(CounterChannel.class, tTBChannels);
|
tmTBChannels = new TableMapper(CounterChannel.class, tTBChannels);
|
||||||
tmTBChannels.getColumnInfo().get(0).setReadOnly(true);
|
tmTBChannels.getColumnInfo().get(0).setReadOnly(true);
|
||||||
|
@ -479,6 +591,7 @@ public class PulsCounterWindow extends JFrame{
|
||||||
threadUpdater.wait();
|
threadUpdater.wait();
|
||||||
}
|
}
|
||||||
updateCounter();
|
updateCounter();
|
||||||
|
updateLiveFile();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -502,11 +615,13 @@ public class PulsCounterWindow extends JFrame{
|
||||||
updateTimer.setRepeats(true);
|
updateTimer.setRepeats(true);
|
||||||
updateTimer.start();
|
updateTimer.start();
|
||||||
|
|
||||||
|
loadChannelNames();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCounter()
|
private void updateCounter()
|
||||||
{
|
{
|
||||||
lActivity.setText("Werte aktuelisieren...");
|
lActivity.setText("Werte aktualisieren...");
|
||||||
|
|
||||||
pulsCounterDevice.update();
|
pulsCounterDevice.update();
|
||||||
|
|
||||||
|
@ -538,31 +653,48 @@ public class PulsCounterWindow extends JFrame{
|
||||||
pulsCounterDevice.setSerialPort(sport);
|
pulsCounterDevice.setSerialPort(sport);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDayFile()
|
private void saveChannelNames()
|
||||||
{
|
{
|
||||||
Date date = new Date();
|
Properties chprop = new Properties();
|
||||||
|
|
||||||
|
for (CounterChannel ch:pulsCounterDevice.getChannels())
|
||||||
|
chprop.put(String.format("channel.%d", ch.getChannel()), ch.getBezeichnung());
|
||||||
|
|
||||||
|
File pf = new File("chnames.prop");
|
||||||
|
|
||||||
|
try {
|
||||||
|
chprop.store(new FileOutputStream(pf), "");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
private void loadChannelNames()
|
||||||
|
{
|
||||||
|
Properties chprop = new Properties();
|
||||||
|
|
||||||
|
File pf = new File("chnames.prop");
|
||||||
|
|
||||||
|
try {
|
||||||
|
chprop.load(new FileInputStream(pf));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CSV csv = new CSV();
|
for (CounterChannel ch:pulsCounterDevice.getChannels())
|
||||||
String[] row = new String[this.timeBarriers.size() + 1];
|
ch.setBezeichnung( chprop.getProperty(String.format("channel.%d", ch.getChannel())));
|
||||||
|
|
||||||
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));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTimeBarrierView()
|
public void updateTimeBarrierView()
|
||||||
|
@ -579,4 +711,25 @@ public class PulsCounterWindow extends JFrame{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateLiveFile()
|
||||||
|
{
|
||||||
|
Date date = new Date();
|
||||||
|
|
||||||
|
CSV csv = new CSV();
|
||||||
|
|
||||||
|
for (int n=0;n<pulsCounterDevice.getChannels().size();n++)
|
||||||
|
{
|
||||||
|
String[] row = new String[4];
|
||||||
|
|
||||||
|
row[0] = (new Integer(n+1)).toString();
|
||||||
|
row[1] = pulsCounterDevice.getChannels().get(n).getValue().toString();
|
||||||
|
row[2] = pulsCounterDevice.getChannels().get(n).getCorrect().toString();
|
||||||
|
row[3] = pulsCounterDevice.getChannels().get(n).correctedValue().toString();
|
||||||
|
|
||||||
|
csv.getCells().add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
csv.saveToFile(String.format("%s/live.csv",workingDirectory));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue