DeviceControlChannel, Serial Interfaces
parent
44e67585ed
commit
80981debd8
|
@ -7,12 +7,12 @@ public class CounterChannel {
|
|||
@TableColumn(label="Kanal",firstColumn=true)
|
||||
private Integer channel;
|
||||
@TableColumn(label="ZŠhlerstand",after="Kanal")
|
||||
public Integer value;
|
||||
private Integer value;
|
||||
@TableColumn(label="Korrekturwert",after="ZŠhlerstand")
|
||||
public Integer correct;
|
||||
private Integer correct;
|
||||
|
||||
@TableColumn(label="Ergebnis",after="Korrekturwert")
|
||||
private Integer correctedValue()
|
||||
public Integer correctedValue()
|
||||
{
|
||||
return value + correct;
|
||||
}
|
||||
|
@ -23,7 +23,27 @@ public class CounterChannel {
|
|||
value = 0;
|
||||
correct = 0;
|
||||
}
|
||||
|
||||
|
||||
public Integer getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getCorrect() {
|
||||
return correct;
|
||||
}
|
||||
|
||||
public void setCorrect(Integer correct) {
|
||||
this.correct = correct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
package org.hwo.pulscounter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* DeviceControlChannel
|
||||
*
|
||||
* Binary Serial Protocol based on telegrams
|
||||
*
|
||||
* telegram:
|
||||
*
|
||||
* byte length of next telegram
|
||||
* byte request
|
||||
* byte options
|
||||
* byte reserve
|
||||
* int32 parameter1
|
||||
* int32 parameter2
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class DeviceControlChannel {
|
||||
|
||||
public class Telegram
|
||||
{
|
||||
private byte[] buffer;
|
||||
|
||||
private byte request;
|
||||
private byte options;
|
||||
|
||||
private Integer parameter1;
|
||||
private Integer parameter2;
|
||||
|
||||
public Telegram()
|
||||
{
|
||||
buffer = new byte[12];
|
||||
request = 0;
|
||||
options = 0;
|
||||
parameter1 = 0;
|
||||
parameter2 = 0;
|
||||
}
|
||||
|
||||
public Telegram(byte request)
|
||||
{
|
||||
this.request = request;
|
||||
options = 0;
|
||||
parameter1 = 0;
|
||||
parameter2 = 0;
|
||||
}
|
||||
public Telegram(byte request,byte options)
|
||||
{
|
||||
this.request = request;
|
||||
this.options = options;
|
||||
parameter1 = 0;
|
||||
parameter2 = 0;
|
||||
}
|
||||
public Telegram(byte request,byte options,int parameter1,int parameter2)
|
||||
{
|
||||
this.request = request;
|
||||
this.options = options;
|
||||
this.parameter1 = parameter1;
|
||||
this.parameter2 = parameter2;
|
||||
}
|
||||
|
||||
public byte[] getBuffer()
|
||||
{
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
public void decodeBuffer()
|
||||
{
|
||||
ByteBuffer bb = ByteBuffer.wrap(buffer);
|
||||
bb.get();
|
||||
request = bb.get();
|
||||
options = bb.get();
|
||||
bb.get();
|
||||
parameter1 = bb.getInt();
|
||||
parameter2 = bb.getInt();
|
||||
}
|
||||
|
||||
public Telegram(byte[] buffer)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
decodeBuffer();
|
||||
}
|
||||
|
||||
public byte[] toArray()
|
||||
{
|
||||
return ByteBuffer.allocate(12)
|
||||
.put((byte)11)
|
||||
.put(request)
|
||||
.put(options)
|
||||
.put((byte)0)
|
||||
.putInt(parameter1)
|
||||
.putInt(parameter2)
|
||||
.array();
|
||||
}
|
||||
|
||||
public byte getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(byte request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public byte getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(byte options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public Integer getParameter1() {
|
||||
return parameter1;
|
||||
}
|
||||
|
||||
public void setParameter1(Integer parameter1) {
|
||||
this.parameter1 = parameter1;
|
||||
}
|
||||
|
||||
public Integer getParameter2() {
|
||||
return parameter2;
|
||||
}
|
||||
|
||||
public void setParameter2(Integer parameter2) {
|
||||
this.parameter2 = parameter2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static byte NOOP = 0;
|
||||
public static byte READ = 1;
|
||||
public static byte WRITE = 2;
|
||||
public static byte COMMAND = 3;
|
||||
public static byte REPLY = 8;
|
||||
|
||||
private InputStream inputStream;
|
||||
private OutputStream outputStream;
|
||||
|
||||
public DeviceControlChannel(InputStream input,OutputStream output)
|
||||
{
|
||||
this.inputStream = input;
|
||||
this.outputStream = output;
|
||||
}
|
||||
|
||||
public Telegram sendRequest(Telegram request)
|
||||
{
|
||||
Telegram response = new Telegram();
|
||||
|
||||
try {
|
||||
outputStream.write(request.toArray());
|
||||
inputStream.read(response.getBuffer());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (request.getRequest() != response.getRequest())
|
||||
System.err.println("DDC Error!");
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public void noop()
|
||||
{
|
||||
sendRequest(new Telegram());
|
||||
}
|
||||
|
||||
public int readInteger()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +1,48 @@
|
|||
package org.hwo.pulscounter;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hwo.os.OsDetect;
|
||||
import org.hwo.os.OsDetect.OsType;
|
||||
|
||||
public class PulsCounter {
|
||||
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
File cwd = new File(".");
|
||||
|
||||
System.err.println("Starting on OS: " + System.getProperty("os.name"));
|
||||
System.err.println("Current Directory: " + cwd.getAbsolutePath());
|
||||
System.err.println("Library Path: " + System.getProperty("java.library.path"));
|
||||
|
||||
if (OsDetect.getOperatingSystem() == OsType.LINUX)
|
||||
{
|
||||
System.err.println("Linux erkannt. Patche java.library.path");
|
||||
System.setProperty("java.library.path",String.format(".:%s",System.getProperty("java.library.path")));
|
||||
Field fieldSysPath;
|
||||
try {
|
||||
fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
|
||||
fieldSysPath.setAccessible( true );
|
||||
fieldSysPath.set( null, null );
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.err.println("Library Path: " + System.getProperty("java.library.path"));
|
||||
}
|
||||
|
||||
|
||||
PulsCounterWindow window = new PulsCounterWindow();
|
||||
window.setVisible(true);
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
package org.hwo.pulscounter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.hwo.io.SerialPort;
|
||||
|
||||
public class PulsCounterDevice {
|
||||
|
||||
private List<CounterChannel> channels; // Aktuelle ZŠhlerstŠnde
|
||||
private List<TimeBarrier> timeBarriers; // TageszeitabhŠngige Wertespeicher
|
||||
|
||||
private Random random;
|
||||
|
||||
private SerialPort serialPort;
|
||||
|
||||
public PulsCounterDevice()
|
||||
{
|
||||
random = new Random();
|
||||
|
||||
channels = new ArrayList<CounterChannel>();
|
||||
timeBarriers = new ArrayList<TimeBarrier>();
|
||||
|
||||
for (int n=0;n<32;n++)
|
||||
{
|
||||
channels.add(new CounterChannel(n + 1));
|
||||
}
|
||||
|
||||
for (int n=0;n<10;n++)
|
||||
{
|
||||
timeBarriers.add(new TimeBarrier(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (serialPort == null)
|
||||
return;
|
||||
|
||||
if (!serialPort.open())
|
||||
{
|
||||
System.err.println("Fehler: Port konnte nicht gešffnet werden!");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DeviceControlChannel channel = new DeviceControlChannel(serialPort.getInputStream(), serialPort.getOutputStream());
|
||||
|
||||
channel.noop();
|
||||
|
||||
|
||||
for (int i=0;i<32;i++)
|
||||
{
|
||||
int inc = random.nextInt(15);
|
||||
if (inc > 4)
|
||||
inc = 0;
|
||||
|
||||
channels.get(i).setValue(channels.get(i).getValue() + inc);
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (serialPort.isOpen())
|
||||
serialPort.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getDeviceName()
|
||||
{
|
||||
return "PulsCounter Board";
|
||||
}
|
||||
|
||||
public Date getDeviceTime()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public List<CounterChannel> getChannels()
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
|
||||
public List<TimeBarrier> getTimeBarriers()
|
||||
{
|
||||
return timeBarriers;
|
||||
}
|
||||
|
||||
public SerialPort getSerialPort() {
|
||||
return serialPort;
|
||||
}
|
||||
|
||||
public void setSerialPort(SerialPort serialPort) {
|
||||
this.serialPort = serialPort;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,17 +2,14 @@ package org.hwo.pulscounter;
|
|||
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hwo.io.SerialPort;
|
||||
|
||||
public class PulsCounterInterface {
|
||||
|
||||
SerialPort port;
|
||||
|
||||
public PulsCounterInterface(String portName)
|
||||
{
|
||||
port = new SerialPort(portName);
|
||||
}
|
||||
|
||||
public List<Integer> readCounter()
|
||||
|
@ -31,7 +28,7 @@ public class PulsCounterInterface {
|
|||
return counter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.awt.EventQueue;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
|
@ -17,12 +18,14 @@ import javax.swing.JComboBox;
|
|||
|
||||
import org.hwo.csv.CSV;
|
||||
import org.hwo.io.SerialPort;
|
||||
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
||||
import org.hwo.models.TableMapper.TableMapper;
|
||||
|
||||
import java.awt.Insets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.JTable;
|
||||
|
@ -31,6 +34,21 @@ import javax.swing.JScrollPane;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
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;
|
||||
|
||||
public class PulsCounterWindow extends JFrame{
|
||||
private JComboBox cbInterfaces;
|
||||
private JTable tCounter;
|
||||
|
@ -39,18 +57,39 @@ public class PulsCounterWindow extends JFrame{
|
|||
private Preferences prefs;
|
||||
private List<CounterChannel> counterChannels;
|
||||
|
||||
List<TimeBarrier> timeBarriers;
|
||||
private final JPanel panel_7 = new JPanel();
|
||||
private JLabel lDeviceType;
|
||||
private JLabel lDeviceTime;
|
||||
private JLabel lActivity;
|
||||
|
||||
Thread threadUpdater;
|
||||
Timer updateTimer;
|
||||
private JSpinner spUpdateIntervall;
|
||||
|
||||
boolean applicationExiting;
|
||||
|
||||
private PulsCounterDevice pulsCounterDevice;
|
||||
private JComboBox cbTimeBarriers;
|
||||
private JTable tTBChannels;
|
||||
private JTimeOfDay todTimebarrier;
|
||||
|
||||
private TableMapper tmTBChannels;
|
||||
|
||||
public PulsCounterWindow() {
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent arg0) {
|
||||
applicationExiting = true;
|
||||
}
|
||||
});
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 732, 350);
|
||||
setBounds(100, 100, 930, 592);
|
||||
setTitle("PulsCounter");
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
gridBagLayout.columnWidths = new int[]{0, 0};
|
||||
gridBagLayout.rowHeights = new int[]{0, 0, 0};
|
||||
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
|
||||
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||
gridBagLayout.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||
gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||
getContentPane().setLayout(gridBagLayout);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
|
@ -62,20 +101,40 @@ public class PulsCounterWindow extends JFrame{
|
|||
getContentPane().add(panel, gbc_panel);
|
||||
GridBagLayout gbl_panel = new GridBagLayout();
|
||||
gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
||||
gbl_panel.rowHeights = new int[]{0, 0, 0};
|
||||
gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||
gbl_panel.rowWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||
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};
|
||||
panel.setLayout(gbl_panel);
|
||||
|
||||
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);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Schnittstelle:");
|
||||
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
|
||||
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
||||
gbc_lblNewLabel.gridx = 0;
|
||||
gbc_lblNewLabel.gridy = 0;
|
||||
panel.add(lblNewLabel, gbc_lblNewLabel);
|
||||
panel_1.add(lblNewLabel, gbc_lblNewLabel);
|
||||
|
||||
cbInterfaces = new JComboBox();
|
||||
GridBagConstraints gbc_cbInterfaces = new GridBagConstraints();
|
||||
gbc_cbInterfaces.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_cbInterfaces.gridx = 1;
|
||||
gbc_cbInterfaces.gridy = 0;
|
||||
panel_1.add(cbInterfaces, gbc_cbInterfaces);
|
||||
cbInterfaces.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
|
||||
|
@ -90,61 +149,281 @@ public class PulsCounterWindow extends JFrame{
|
|||
System.err.println("Exception: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
setSerialPort();
|
||||
}
|
||||
});
|
||||
GridBagConstraints gbc_cbInterfaces = new GridBagConstraints();
|
||||
gbc_cbInterfaces.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_cbInterfaces.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc_cbInterfaces.gridx = 1;
|
||||
gbc_cbInterfaces.gridy = 0;
|
||||
panel.add(cbInterfaces, gbc_cbInterfaces);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
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...");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
updateCounter();
|
||||
}
|
||||
});
|
||||
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
||||
gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_btnNewButton.gridx = 2;
|
||||
gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
|
||||
gbc_btnNewButton.gridx = 1;
|
||||
gbc_btnNewButton.gridy = 0;
|
||||
panel.add(btnNewButton, gbc_btnNewButton);
|
||||
panel_3.add(btnNewButton, gbc_btnNewButton);
|
||||
|
||||
JButton btnTagesdateiSchreiben = new JButton("Tagesdatei schreiben...");
|
||||
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);
|
||||
btnTagesdateiSchreiben.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
writeDayFile();
|
||||
}
|
||||
});
|
||||
GridBagConstraints gbc_btnTagesdateiSchreiben = new GridBagConstraints();
|
||||
gbc_btnTagesdateiSchreiben.insets = new Insets(0, 0, 5, 5);
|
||||
gbc_btnTagesdateiSchreiben.gridx = 3;
|
||||
gbc_btnTagesdateiSchreiben.gridy = 0;
|
||||
panel.add(btnTagesdateiSchreiben, gbc_btnTagesdateiSchreiben);
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
synchronized (threadUpdater) {
|
||||
threadUpdater.notifyAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JButton btnNewButton_1 = new JButton("New button");
|
||||
GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
|
||||
gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 0);
|
||||
gbc_btnNewButton_1.gridx = 4;
|
||||
gbc_btnNewButton_1.gridy = 0;
|
||||
panel.add(btnNewButton_1, gbc_btnNewButton_1);
|
||||
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));
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||
gbc_scrollPane.gridx = 0;
|
||||
gbc_scrollPane.gridy = 1;
|
||||
getContentPane().add(scrollPane, gbc_scrollPane);
|
||||
panel_8.add(scrollPane);
|
||||
|
||||
tCounter = new JTable();
|
||||
scrollPane.setViewportView(tCounter);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
applicationExiting = false;
|
||||
pulsCounterDevice = new PulsCounterDevice();
|
||||
|
||||
prefs = Preferences.userRoot();
|
||||
|
||||
|
@ -152,6 +431,8 @@ public class PulsCounterWindow extends JFrame{
|
|||
|
||||
for (String portName:SerialPort.getPortNames())
|
||||
cbInterfaces.addItem(portName);
|
||||
|
||||
// cbInterfaces.addItem("dummy:");
|
||||
|
||||
System.err.println("Default Port: " + defaultPort);
|
||||
|
||||
|
@ -161,49 +442,107 @@ public class PulsCounterWindow extends JFrame{
|
|||
cbInterfaces.setSelectedIndex(i);
|
||||
}
|
||||
|
||||
counterChannels = new ArrayList<CounterChannel>();
|
||||
for (int i=0;i<32;i++)
|
||||
counterChannels.add(new CounterChannel( i + 1) );
|
||||
|
||||
tmCounter = new TableMapper(CounterChannel.class, tCounter);
|
||||
tmCounter.setRows(counterChannels);
|
||||
tmCounter.setRows(pulsCounterDevice.getChannels());
|
||||
tmCounter.getColumnInfo().get(0).setReadOnly(true);
|
||||
tmCounter.getColumnInfo().get(1).setReadOnly(true);
|
||||
tmCounter.getColumnInfo().get(3).setReadOnly(true);
|
||||
|
||||
timeBarriers = new ArrayList<TimeBarrier>();
|
||||
tmCounter.addTableMapperListener(new AbstractTableMapperListener() {
|
||||
@Override
|
||||
public void ValueChanged(int row, int column) {
|
||||
if (column == 2)
|
||||
{
|
||||
saveCorrection(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
timeBarriers.add(new TimeBarrier(01,00));
|
||||
timeBarriers.add(new TimeBarrier(03,00));
|
||||
timeBarriers.add(new TimeBarrier(06,00));
|
||||
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
private void updateCounter()
|
||||
{
|
||||
PulsCounterInterface intf = new PulsCounterInterface(cbInterfaces.getSelectedItem().toString());
|
||||
lActivity.setText("Werte aktuelisieren...");
|
||||
|
||||
List<Integer> values = intf.readCounter();
|
||||
for (int i=0;i<values.size();i++)
|
||||
{
|
||||
counterChannels.get(i).value = values.get(i);
|
||||
values.set(i, values.get(i) + counterChannels.get(i).correct);
|
||||
}
|
||||
pulsCounterDevice.update();
|
||||
|
||||
tCounter.repaint();
|
||||
lDeviceType.setText(pulsCounterDevice.getDeviceName());
|
||||
lDeviceTime.setText(pulsCounterDevice.getDeviceTime().toLocaleString());
|
||||
|
||||
for (TimeBarrier tb:timeBarriers)
|
||||
if (cbTimeBarriers.getItemCount()==0)
|
||||
{
|
||||
tb.update(values);
|
||||
tb.save();
|
||||
for (TimeBarrier tb: pulsCounterDevice.getTimeBarriers())
|
||||
{
|
||||
cbTimeBarriers.addItem(tb);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void writeDayFile()
|
||||
{
|
||||
CSV csv = new CSV();
|
||||
Date date = new Date();
|
||||
|
||||
/* CSV csv = new CSV();
|
||||
String[] row = new String[this.timeBarriers.size() + 1];
|
||||
|
||||
row[0] = "";
|
||||
|
@ -223,7 +562,21 @@ public class PulsCounterWindow extends JFrame{
|
|||
}
|
||||
|
||||
csv.saveToFile(String.format("daily-%d-%d-%d.csv",(date.getYear()+1900),date.getMonth()+1,date.getDate()+1));
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,64 +1,61 @@
|
|||
package org.hwo.pulscounter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hwo.csv.CSV;
|
||||
import org.hwo.datetime.TimeOfDay;
|
||||
|
||||
public class TimeBarrier {
|
||||
|
||||
Integer timeOfDay;
|
||||
List<Integer> values;
|
||||
ArrayList<CounterChannel> channels;
|
||||
private TimeOfDay timeOfDay;
|
||||
|
||||
public TimeBarrier(Integer timeOfDay)
|
||||
public TimeBarrier(int timeOfDay)
|
||||
{
|
||||
this.timeOfDay = timeOfDay;
|
||||
values = new ArrayList<Integer>();
|
||||
load();
|
||||
this.timeOfDay = new TimeOfDay(timeOfDay);
|
||||
this.channels = new ArrayList<CounterChannel>();
|
||||
}
|
||||
|
||||
public TimeBarrier(Integer HourOfDay,Integer MinuteOfDay)
|
||||
{
|
||||
this.timeOfDay = (HourOfDay * 60) + MinuteOfDay;
|
||||
values = new ArrayList<Integer>();
|
||||
load();
|
||||
this.timeOfDay = new TimeOfDay(HourOfDay,MinuteOfDay,0);
|
||||
this.channels = new ArrayList<CounterChannel>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void update(List<Integer> values)
|
||||
{
|
||||
Date date = new Date();
|
||||
int now = (date.getHours() * 60) + date.getMinutes();
|
||||
|
||||
if (now < timeOfDay)
|
||||
{
|
||||
this.values.clear();
|
||||
for (Integer v: values)
|
||||
this.values.add(v);
|
||||
public void save()
|
||||
{
|
||||
try {
|
||||
save(new FileOutputStream(String.format("day-%d.csv", timeOfDay)));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
public void save(OutputStream output)
|
||||
{
|
||||
CSV csv = new CSV();
|
||||
for (Integer i:values)
|
||||
csv.getCells().add(new String[]{i.toString()});
|
||||
|
||||
|
||||
csv.saveToFile(String.format("day-%d.csv", timeOfDay));
|
||||
for (CounterChannel channel: channels)
|
||||
{
|
||||
csv.getCells().add(new String[]{channel.getChannel().toString(),channel.getValue().toString(),channel.getCorrect().toString(),channel.correctedValue().toString()});
|
||||
}
|
||||
csv.saveToStream(output);
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
CSV csv = new CSV();
|
||||
csv.readFromFile(String.format("day-%d.csv", timeOfDay));
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Werte bis %02d:%02d", timeOfDay.getHours(), timeOfDay.getMinutes());
|
||||
}
|
||||
|
||||
for (String[] row: csv.getCells())
|
||||
this.values.add(Integer.parseInt(row[0]));
|
||||
|
||||
public TimeOfDay getTimeOfDay() {
|
||||
return timeOfDay;
|
||||
}
|
||||
|
||||
public void setTimeOfDay(TimeOfDay timeOfDay) {
|
||||
this.timeOfDay = timeOfDay;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue