WIP / Beta 161006

WIP-PC2
Harald Wolff 2016-10-06 10:57:31 +02:00
parent 88c7073dcb
commit 756f0f2d4d
9 changed files with 506 additions and 365 deletions

View File

@ -279,6 +279,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
Integer nProfiles = new Integer(sProfiles);
for (int n=0;n<nProfiles;n++){
String profileConf = database.getProperty(String.format("export.profiles.%d",n));
log(INFO,"Export Profile %d: %s",n,profileConf);
if (profileConf != null){
ExportSetting es = new ExportSetting();
ConfigurableObjects.setConfiguration(es, profileConf);

View File

@ -231,8 +231,8 @@ public class SnapShot {
record.appendValue(df.format(new Date(((long)timestamp)*1000)));
if (extended){
record.appendValue("TRIGGER");
record.appendValue("QUELLE");
record.appendValue(field0 & 0x000000FF);
record.appendValue((field0 >> 8) & 0xff);
}
for (int n=0;n<32;n++)

View File

@ -3,7 +3,10 @@ package org.hwo.pulscounter.device;
import org.hwo.pulscounter.SnapShot;
public interface IDeviceConnector {
public static int ESC_DEBUG_MASK = 0xFFFF0000;
public static int ESC_DEBUG_SCHEDULER_BUG = 0x00010000;
public Integer getDeviceSerial();
public boolean showConnctionSetup();
@ -60,6 +63,7 @@ public interface IDeviceConnector {
readSnapShots(int startIndex);
public void reset(int flags);
public int escape(int escape,int parm);
public void syncConfigToLive();

View File

@ -1,8 +1,10 @@
package org.hwo.pulscounter.device;
import java.io.IOException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@ -20,9 +22,10 @@ import static org.hwo.logging.LogLevel.*;
public class ServiceLinkDeviceConnector implements IDeviceConnector {
private ServiceLink serviceLink;
private Integer deviceSerial;
private int debugMode;
public ServiceLinkDeviceConnector() {
serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
@ -45,6 +48,10 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
return String.format("Serial [%s]", this.serviceLink.getSerialPort().getPortName());
}
public ServiceLink getServiceLink() {
return serviceLink;
}
private Integer readDeviceSerial(){
checkOpen();
@ -313,6 +320,15 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
Integer id;
try {
Integer sbrk,stacklimit,cycletime;
sbrk = serviceLink.readInt(13, 0, 0x0020);
stacklimit = serviceLink.readInt(13, 0, 0x0021);
cycletime = serviceLink.readInt(13, 0, 0x1310);
log(INFO,"HEAP END: 0x%04x SYS-STACK: 0x%04x",sbrk,stacklimit);
log(INFO,"I/O cycle time: %dus",cycletime);
newest = serviceLink.readInt(13, 0, 0x0581);
sssize = serviceLink.readInt(13, 0, 0x0582);
@ -397,6 +413,8 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
log(e);
}
checkForAssertions();
}
return snapshots.toArray(new SnapShot[0]);
}
@ -561,7 +579,7 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
checkOpen();
try {
serviceLink.writeInt(13, 0, 0x0581, -1 );
serviceLink.writeInt(13, 0, 0x0581, flags );
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
@ -654,13 +672,17 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
try {
Integer deviceTime = serviceLink.readInt(13, 0, 0x001C);
Long delta = deviceTime - (System.currentTimeMillis()/1000);
if ((delta < -1) || (delta > 1)){
log(INFO,"realtime clock has a %d seconds shift",delta);
serviceLink.writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
log(INFO,"realtime clock has been corrected.");
Long currentTime = (System.currentTimeMillis()/1000);
if (debugMode != ESC_DEBUG_SCHEDULER_BUG){
Long delta = deviceTime - currentTime;
if ((delta < -1) || (delta > 1)){
log(INFO,"realtime clock has a %d seconds shift",delta);
serviceLink.writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
log(INFO,"realtime clock has been corrected.");
}
} else {
log(DEBUG,"SCHEDULER_DEBUG: DeviceTime is %s",DateFormat.getInstance().format(new Date(((long)deviceTime)*1000)));
}
} catch (ServiceLinkRequestFailedException e) {
e.printStackTrace();
@ -671,7 +693,55 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
}
}
private void checkForAssertions(){
Integer assert_error,assert_code;
try
{
assert_error = -1;
for (int i=0;i<8;i++){
assert_error = serviceLink.readInt(13, 0, 0x0026);
assert_code = serviceLink.readInt(13, 0, 0x0025);
if (assert_error >= 0)
break;
log(WARN,"Assertion: Error: 0x%08x (%d) Position: 0x%04x Mark: %d", assert_error,assert_error, assert_code & 0xffff, (assert_code >> 16) & 0xffff);
serviceLink.writeInt(13, 0, 0x0025, -1);
};
} catch (Exception ex){
System.err.println("Exception while checking for assertions...");
ex.printStackTrace();
}
}
@Override
public int escape(int escape, int parm) {
if ((escape & ESC_DEBUG_MASK)!=0){
debugMode = escape;
}
switch (escape){
case ESC_DEBUG_SCHEDULER_BUG:
try {
Long currentTime = (System.currentTimeMillis()/1000);
currentTime -= currentTime % 86400;
currentTime += -920;
log(DEBUG,"ESC_DEBUG_SCHEDULER_BUG");
serviceLink.writeInt((byte)13, (byte)0, 0x001C, (currentTime.intValue()));
} catch (ServiceLinkRequestFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceLinkException e) {
e.printStackTrace();
}
return 0;
}
return 0;
}
}

View File

@ -282,4 +282,10 @@ public class SimulatedCounter implements IDeviceConnector {
};
@Override
public int escape(int escape, int parm) {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -100,9 +100,9 @@ public class DeviceConfiguration extends JFrame {
tabbedPane.addTab("Intervalle", null, panel_2, null);
GridBagLayout gbl_panel_2 = new GridBagLayout();
gbl_panel_2.columnWidths = new int[]{0, 0, 0};
gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
panel_2.setLayout(gbl_panel_2);
bfeIntervall = new BitFieldEditor();
@ -233,7 +233,7 @@ public class DeviceConfiguration extends JFrame {
GridBagConstraints gbc_btnSnapshotSpeicherZurcksetzen = new GridBagConstraints();
gbc_btnSnapshotSpeicherZurcksetzen.gridwidth = 2;
gbc_btnSnapshotSpeicherZurcksetzen.fill = GridBagConstraints.HORIZONTAL;
gbc_btnSnapshotSpeicherZurcksetzen.insets = new Insets(0, 0, 5, 5);
gbc_btnSnapshotSpeicherZurcksetzen.insets = new Insets(0, 0, 5, 0);
gbc_btnSnapshotSpeicherZurcksetzen.gridx = 0;
gbc_btnSnapshotSpeicherZurcksetzen.gridy = 5;
panel_2.add(btnSnapshotSpeicherZurcksetzen, gbc_btnSnapshotSpeicherZurcksetzen);
@ -244,12 +244,25 @@ public class DeviceConfiguration extends JFrame {
resetCounters();
}
});
JButton btnSnapshotSpeicherAuf = new JButton("SnapShot Speicher auf letzten bekannten SnapShot setzen");
btnSnapshotSpeicherAuf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resetSnapShots(true);
}
});
GridBagConstraints gbc_btnSnapshotSpeicherAuf = new GridBagConstraints();
gbc_btnSnapshotSpeicherAuf.fill = GridBagConstraints.HORIZONTAL;
gbc_btnSnapshotSpeicherAuf.gridwidth = 2;
gbc_btnSnapshotSpeicherAuf.insets = new Insets(0, 0, 5, 0);
gbc_btnSnapshotSpeicherAuf.gridx = 0;
gbc_btnSnapshotSpeicherAuf.gridy = 6;
panel_2.add(btnSnapshotSpeicherAuf, gbc_btnSnapshotSpeicherAuf);
GridBagConstraints gbc_btnAlleZhlerLschen = new GridBagConstraints();
gbc_btnAlleZhlerLschen.gridwidth = 2;
gbc_btnAlleZhlerLschen.fill = GridBagConstraints.HORIZONTAL;
gbc_btnAlleZhlerLschen.insets = new Insets(0, 0, 0, 5);
gbc_btnAlleZhlerLschen.gridx = 0;
gbc_btnAlleZhlerLschen.gridy = 6;
gbc_btnAlleZhlerLschen.gridy = 7;
panel_2.add(btnAlleZhlerLschen, gbc_btnAlleZhlerLschen);
JPanel panel_1 = new JPanel();
@ -331,7 +344,11 @@ public class DeviceConfiguration extends JFrame {
}
private void resetSnapShots(){
deviceConnector.reset(0);
resetSnapShots(false);
}
private void resetSnapShots(boolean toLastKnown){
deviceConnector.reset(toLastKnown ? PulsCounterApplication.getApplication().getDatabase().highestSnapShot(deviceConnector.getDeviceSerial()) : -1);
}
private void resetCounters(){

View File

@ -8,8 +8,12 @@ import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import org.hwo.datetime.DateTime;
import org.hwo.logging.Logging;
import org.hwo.logging.LoggingListener;
import org.hwo.pulscounter.PulsCounterApplication;
import org.hwo.pulscounter.PulsCounterApplicationListener;
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
import org.hwo.servicelink.ServiceLink;
import org.hwo.servicelink.ServiceLinkException;
import java.awt.GridBagLayout;
@ -26,352 +30,369 @@ import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JScrollPane;
public class DeviceTestFrame extends JFrame { //implements PulsCounterApplicationListener {
import static org.hwo.logging.Logging.*;
import static org.hwo.logging.LogLevel.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class DeviceTestFrame extends JFrame implements LoggingListener{
private JPanel contentPane;
private JTextField tfCommunication;
private JTextField tfEEPROM;
private JTextField tfIO;
private JTextField tfAD;
private JTextField tfSerial;
private Timer reconnectTimer;
private DeviceChecker deviceChecker;
private JList lMessages;
private DefaultListModel<String> messageListModel;
private PulsCounterApplication pulsCounterApplication;
/**
* Create the frame.
*/
public DeviceTestFrame(PulsCounterApplication pulsCounterApplication) {
this.pulsCounterApplication = pulsCounterApplication;
setTitle("Device Test Frame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 701, 464);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[]{0, 0, 0};
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
contentPane.setLayout(gbl_contentPane);
JLabel lblKommunikation = new JLabel("Communication:");
GridBagConstraints gbc_lblKommunikation = new GridBagConstraints();
gbc_lblKommunikation.anchor = GridBagConstraints.EAST;
gbc_lblKommunikation.insets = new Insets(0, 0, 5, 5);
gbc_lblKommunikation.gridx = 0;
gbc_lblKommunikation.gridy = 0;
contentPane.add(lblKommunikation, gbc_lblKommunikation);
tfCommunication = new JTextField();
GridBagConstraints gbc_tfCommunication = new GridBagConstraints();
gbc_tfCommunication.insets = new Insets(0, 0, 5, 0);
gbc_tfCommunication.fill = GridBagConstraints.HORIZONTAL;
gbc_tfCommunication.gridx = 1;
gbc_tfCommunication.gridy = 0;
contentPane.add(tfCommunication, gbc_tfCommunication);
tfCommunication.setColumns(10);
JLabel lblLeds = new JLabel("LEDs:");
GridBagConstraints gbc_lblLeds = new GridBagConstraints();
gbc_lblLeds.insets = new Insets(0, 0, 5, 5);
gbc_lblLeds.gridx = 0;
gbc_lblLeds.gridy = 1;
contentPane.add(lblLeds, gbc_lblLeds);
JLabel lblEeprom = new JLabel("EEPROM:");
GridBagConstraints gbc_lblEeprom = new GridBagConstraints();
gbc_lblEeprom.anchor = GridBagConstraints.EAST;
gbc_lblEeprom.insets = new Insets(0, 0, 5, 5);
gbc_lblEeprom.gridx = 0;
gbc_lblEeprom.gridy = 2;
contentPane.add(lblEeprom, gbc_lblEeprom);
tfEEPROM = new JTextField();
GridBagConstraints gbc_tfEEPROM = new GridBagConstraints();
gbc_tfEEPROM.insets = new Insets(0, 0, 5, 0);
gbc_tfEEPROM.fill = GridBagConstraints.HORIZONTAL;
gbc_tfEEPROM.gridx = 1;
gbc_tfEEPROM.gridy = 2;
contentPane.add(tfEEPROM, gbc_tfEEPROM);
tfEEPROM.setColumns(10);
JLabel lblIoCircuit = new JLabel("I/O Circuit:");
GridBagConstraints gbc_lblIoCircuit = new GridBagConstraints();
gbc_lblIoCircuit.anchor = GridBagConstraints.EAST;
gbc_lblIoCircuit.insets = new Insets(0, 0, 5, 5);
gbc_lblIoCircuit.gridx = 0;
gbc_lblIoCircuit.gridy = 3;
contentPane.add(lblIoCircuit, gbc_lblIoCircuit);
tfIO = new JTextField();
GridBagConstraints gbc_tfIO = new GridBagConstraints();
gbc_tfIO.insets = new Insets(0, 0, 5, 0);
gbc_tfIO.fill = GridBagConstraints.HORIZONTAL;
gbc_tfIO.gridx = 1;
gbc_tfIO.gridy = 3;
contentPane.add(tfIO, gbc_tfIO);
tfIO.setColumns(10);
JLabel lblAdConverters = new JLabel("A/D Converters:");
GridBagConstraints gbc_lblAdConverters = new GridBagConstraints();
gbc_lblAdConverters.anchor = GridBagConstraints.EAST;
gbc_lblAdConverters.insets = new Insets(0, 0, 5, 5);
gbc_lblAdConverters.gridx = 0;
gbc_lblAdConverters.gridy = 4;
contentPane.add(lblAdConverters, gbc_lblAdConverters);
tfAD = new JTextField();
GridBagConstraints gbc_tfAD = new GridBagConstraints();
gbc_tfAD.insets = new Insets(0, 0, 5, 0);
gbc_tfAD.fill = GridBagConstraints.HORIZONTAL;
gbc_tfAD.gridx = 1;
gbc_tfAD.gridy = 4;
contentPane.add(tfAD, gbc_tfAD);
tfAD.setColumns(10);
JLabel lblSerial = new JLabel("Serial:");
GridBagConstraints gbc_lblSerial = new GridBagConstraints();
gbc_lblSerial.anchor = GridBagConstraints.EAST;
gbc_lblSerial.insets = new Insets(0, 0, 5, 5);
gbc_lblSerial.gridx = 0;
gbc_lblSerial.gridy = 5;
contentPane.add(lblSerial, gbc_lblSerial);
tfSerial = new JTextField();
GridBagConstraints gbc_tfSerial = new GridBagConstraints();
gbc_tfSerial.insets = new Insets(0, 0, 5, 0);
gbc_tfSerial.fill = GridBagConstraints.HORIZONTAL;
gbc_tfSerial.gridx = 1;
gbc_tfSerial.gridy = 5;
contentPane.add(tfSerial, gbc_tfSerial);
tfSerial.setColumns(10);
JButton btnStart = new JButton("Start");
btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
startTest();
}
});
GridBagConstraints gbc_btnStart = new GridBagConstraints();
gbc_btnStart.insets = new Insets(0, 0, 5, 5);
gbc_btnStart.gridx = 0;
gbc_btnStart.gridy = 6;
contentPane.add(btnStart, gbc_btnStart);
JButton btnSetDevice = new JButton("Confirm Device");
GridBagConstraints gbc_btnSetDevice = new GridBagConstraints();
gbc_btnSetDevice.insets = new Insets(0, 0, 5, 0);
gbc_btnSetDevice.gridx = 1;
gbc_btnSetDevice.gridy = 6;
contentPane.add(btnSetDevice, gbc_btnSetDevice);
JScrollPane scrollPane = new JScrollPane();
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.gridwidth = 2;
gbc_scrollPane.gridx = 0;
gbc_scrollPane.gridy = 7;
contentPane.add(scrollPane, gbc_scrollPane);
lMessages = new JList();
scrollPane.setViewportView(lMessages);
this.initialize();
}
private PulsCounterApplication application(){
return this.pulsCounterApplication;
}
private void initialize(){
this.reconnectTimer = new Timer("Reconnection Timer");
messageListModel = new DefaultListModel<String>();
lMessages.setModel(messageListModel);
Logging.getInstance().addLoggingListener(this);
setVisible(true);
}
ServiceLink getServiceLink(){
return ((ServiceLinkDeviceConnector)(application().getInterfaces().get(0))).getServiceLink();
}
/*
@Override
public void connectionStateChanged(Boolean connected) {
if (!connected){
tfCommunication.setText("NO CONNECTION");
if (this.deviceChecker != null){
this.deviceChecker.cancel();
}
reconnectTimer.schedule(new TimerTask() {
@Override
public void run() {
if (!getServiceLink().isOpen()){
try {
getServiceLink().open();
} catch (ServiceLinkException e) {
e.printStackTrace();
}
}
}
}, 3000);
} else {
}
}
*/
private void startTest(){
if (this.deviceChecker != null){
while (this.deviceChecker.isAlive()){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
this.deviceChecker = new DeviceChecker();
this.deviceChecker.start();
}
@Override
public void logMessageArrived(String message) {
if (EventQueue.isDispatchThread()){
int pos = messageListModel.size();
messageListModel.addElement(message);
lMessages.ensureIndexIsVisible(messageListModel.size()-1);
} else {
final String msg = message;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
logMessageArrived(msg);
}
});
}
}
class DeviceChecker extends Thread {
private boolean cancel;
public DeviceChecker(){
cancel = false;
}
public void cancel(){
this.cancel = true;
}
@Override
public void run() {
try {
getServiceLink().open();
} catch (ServiceLinkException e) {
log(e);
}
checkCommunication();
checkEEPROM();
checkIO();
checkADC();
while (!cancel){
checkCommunication();
}
}
private void checkCommunication(){
if (!this.cancel){
Integer version = getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001A);
Integer uptime = getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0022);
if ((version != null)&&(uptime != null)){
tfCommunication.setText(String.format("OK (V: %d.%d.%d) Up: %d:%d:%d",version >> 16, (version >> 8) & 0xff, version & 0xff, uptime / 3600, (uptime / 60)%60, uptime % 60));
}
}
}
private void checkEEPROM(){
if (!this.cancel){
Integer eesize = getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x9000);
if (eesize != null){
tfEEPROM.setText(String.format("EEPROM Size Detected: 0x%08x Bytes (%d kBytes)", eesize, (eesize >> 10)));
} else {
tfEEPROM.setText("EEPROM failed.");
}
}
}
private void checkIO(){
if (!this.cancel){
log(INFO,"I/O test begins...");
log(INFO,"I/O reset...");
try {
getServiceLink().writeInt(13, 0, 0x0682, 0);
getServiceLink().writeInt(13, 0, 0x0683, 0);
getServiceLink().writeInt(13, 0, 0x0684, 0);
getServiceLink().writeInt(13, 0, 0x0685, 0);
log(INFO,"counter reset.");
for (int i=0;i<32;i++){
getServiceLink().writeInt(13, 0, 0x0600 + i, 0);
}
log(INFO,"PullUP-Counter test.");
for (int i=0;i<12;i++){
Thread.sleep(250);
getServiceLink().writeInt(13, 0, 0x0683, -1);
Thread.sleep(250);
getServiceLink().writeInt(13, 0, 0x0683, 0);
}
for (int i=0;i<32;i++){
Thread.sleep(100);
Integer c = getServiceLink().readInt(13, 0, 0x0600 + i);
if ((c != null) && (c.equals(12))){
log(INFO,String.format("OK: Channel %d counted %d events.", i, c));
} else {
log(INFO,String.format("FAILED: Channel %d counted %d events.", i, c));
}
}
log(INFO,"I/O test finished!");
} catch (IOException | ServiceLinkException e) {
e.printStackTrace();
log(INFO,"I/O test FAILED!");
} catch (InterruptedException iex){
iex.printStackTrace();
log(INFO,"I/O test FAILED!");
}
}
}
private void checkADC(){
if (!this.cancel){
}
}
}
// private JPanel contentPane;
// private JTextField tfCommunication;
// private JTextField tfEEPROM;
// private JTextField tfIO;
// private JTextField tfAD;
// private JTextField tfSerial;
//
// private Timer reconnectTimer;
//
// private DeviceChecker deviceChecker;
// private JList lMessages;
// private DefaultListModel<String> messageListModel;
//
// private PulsCounterApplication pulsCounterApplication;
//
// /**
// * Create the frame.
// */
// public DeviceTestFrame(PulsCounterApplication pulsCounterApplication) {
// this.pulsCounterApplication = pulsCounterApplication;
//
// setTitle("Device Test Frame");
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// setBounds(100, 100, 701, 464);
// contentPane = new JPanel();
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
// setContentPane(contentPane);
// GridBagLayout gbl_contentPane = new GridBagLayout();
// gbl_contentPane.columnWidths = new int[]{0, 0, 0};
// gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
// gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
// gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
// contentPane.setLayout(gbl_contentPane);
//
// JLabel lblKommunikation = new JLabel("Communication:");
// GridBagConstraints gbc_lblKommunikation = new GridBagConstraints();
// gbc_lblKommunikation.anchor = GridBagConstraints.EAST;
// gbc_lblKommunikation.insets = new Insets(0, 0, 5, 5);
// gbc_lblKommunikation.gridx = 0;
// gbc_lblKommunikation.gridy = 0;
// contentPane.add(lblKommunikation, gbc_lblKommunikation);
//
// tfCommunication = new JTextField();
// GridBagConstraints gbc_tfCommunication = new GridBagConstraints();
// gbc_tfCommunication.insets = new Insets(0, 0, 5, 0);
// gbc_tfCommunication.fill = GridBagConstraints.HORIZONTAL;
// gbc_tfCommunication.gridx = 1;
// gbc_tfCommunication.gridy = 0;
// contentPane.add(tfCommunication, gbc_tfCommunication);
// tfCommunication.setColumns(10);
//
// JLabel lblLeds = new JLabel("LEDs:");
// GridBagConstraints gbc_lblLeds = new GridBagConstraints();
// gbc_lblLeds.insets = new Insets(0, 0, 5, 5);
// gbc_lblLeds.gridx = 0;
// gbc_lblLeds.gridy = 1;
// contentPane.add(lblLeds, gbc_lblLeds);
//
// JLabel lblEeprom = new JLabel("EEPROM:");
// GridBagConstraints gbc_lblEeprom = new GridBagConstraints();
// gbc_lblEeprom.anchor = GridBagConstraints.EAST;
// gbc_lblEeprom.insets = new Insets(0, 0, 5, 5);
// gbc_lblEeprom.gridx = 0;
// gbc_lblEeprom.gridy = 2;
// contentPane.add(lblEeprom, gbc_lblEeprom);
//
// tfEEPROM = new JTextField();
// GridBagConstraints gbc_tfEEPROM = new GridBagConstraints();
// gbc_tfEEPROM.insets = new Insets(0, 0, 5, 0);
// gbc_tfEEPROM.fill = GridBagConstraints.HORIZONTAL;
// gbc_tfEEPROM.gridx = 1;
// gbc_tfEEPROM.gridy = 2;
// contentPane.add(tfEEPROM, gbc_tfEEPROM);
// tfEEPROM.setColumns(10);
//
// JLabel lblIoCircuit = new JLabel("I/O Circuit:");
// GridBagConstraints gbc_lblIoCircuit = new GridBagConstraints();
// gbc_lblIoCircuit.anchor = GridBagConstraints.EAST;
// gbc_lblIoCircuit.insets = new Insets(0, 0, 5, 5);
// gbc_lblIoCircuit.gridx = 0;
// gbc_lblIoCircuit.gridy = 3;
// contentPane.add(lblIoCircuit, gbc_lblIoCircuit);
//
// tfIO = new JTextField();
// GridBagConstraints gbc_tfIO = new GridBagConstraints();
// gbc_tfIO.insets = new Insets(0, 0, 5, 0);
// gbc_tfIO.fill = GridBagConstraints.HORIZONTAL;
// gbc_tfIO.gridx = 1;
// gbc_tfIO.gridy = 3;
// contentPane.add(tfIO, gbc_tfIO);
// tfIO.setColumns(10);
//
// JLabel lblAdConverters = new JLabel("A/D Converters:");
// GridBagConstraints gbc_lblAdConverters = new GridBagConstraints();
// gbc_lblAdConverters.anchor = GridBagConstraints.EAST;
// gbc_lblAdConverters.insets = new Insets(0, 0, 5, 5);
// gbc_lblAdConverters.gridx = 0;
// gbc_lblAdConverters.gridy = 4;
// contentPane.add(lblAdConverters, gbc_lblAdConverters);
//
// tfAD = new JTextField();
// GridBagConstraints gbc_tfAD = new GridBagConstraints();
// gbc_tfAD.insets = new Insets(0, 0, 5, 0);
// gbc_tfAD.fill = GridBagConstraints.HORIZONTAL;
// gbc_tfAD.gridx = 1;
// gbc_tfAD.gridy = 4;
// contentPane.add(tfAD, gbc_tfAD);
// tfAD.setColumns(10);
//
// JLabel lblSerial = new JLabel("Serial:");
// GridBagConstraints gbc_lblSerial = new GridBagConstraints();
// gbc_lblSerial.anchor = GridBagConstraints.EAST;
// gbc_lblSerial.insets = new Insets(0, 0, 5, 5);
// gbc_lblSerial.gridx = 0;
// gbc_lblSerial.gridy = 5;
// contentPane.add(lblSerial, gbc_lblSerial);
//
// tfSerial = new JTextField();
// GridBagConstraints gbc_tfSerial = new GridBagConstraints();
// gbc_tfSerial.insets = new Insets(0, 0, 5, 0);
// gbc_tfSerial.fill = GridBagConstraints.HORIZONTAL;
// gbc_tfSerial.gridx = 1;
// gbc_tfSerial.gridy = 5;
// contentPane.add(tfSerial, gbc_tfSerial);
// tfSerial.setColumns(10);
//
// JButton btnSetDevice = new JButton("Confirm Device");
// GridBagConstraints gbc_btnSetDevice = new GridBagConstraints();
// gbc_btnSetDevice.insets = new Insets(0, 0, 5, 0);
// gbc_btnSetDevice.gridx = 1;
// gbc_btnSetDevice.gridy = 6;
// contentPane.add(btnSetDevice, gbc_btnSetDevice);
//
// JScrollPane scrollPane = new JScrollPane();
// GridBagConstraints gbc_scrollPane = new GridBagConstraints();
// gbc_scrollPane.fill = GridBagConstraints.BOTH;
// gbc_scrollPane.gridwidth = 2;
// gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
// gbc_scrollPane.gridx = 0;
// gbc_scrollPane.gridy = 7;
// contentPane.add(scrollPane, gbc_scrollPane);
//
// lMessages = new JList();
// scrollPane.setViewportView(lMessages);
//
// this.initialize();
// }
//
// private PulsCounterApplication application(){
// return this.pulsCounterApplication;
// }
//
// private void initialize(){
// this.reconnectTimer = new Timer("Reconnection Timer");
//
// messageListModel = new DefaultListModel<String>();
// lMessages.setModel(messageListModel);
//
// application().addPulsCounterApplicationListener(this);
//
// setVisible(true);
// }
//
// /*
// @Override
// public void connectionStateChanged(Boolean connected) {
//
// if (!connected){
// tfCommunication.setText("NO CONNECTION");
// if (this.deviceChecker != null){
// this.deviceChecker.cancel();
// }
// reconnectTimer.schedule(new TimerTask() {
//
// @Override
// public void run() {
// if (!application().getServiceLink().isOpen()){
// try {
// application().getServiceLink().open();
// } catch (ServiceLinkException e) {
// e.printStackTrace();
// }
// }
// }
// }, 3000);
//
// } else {
// if (this.deviceChecker != null){
// while (this.deviceChecker.isAlive()){
// try {
// Thread.sleep(100);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// }
// this.deviceChecker = new DeviceChecker();
// this.deviceChecker.start();
// }
//
// }
// */
//
// @Override
// public synchronized void messageArrived(String message) {
// if (EventQueue.isDispatchThread()){
// int pos = messageListModel.size();
// String t = String.format("%s: %s",DateTime.NOW().getSQLDateTime(),message);
// messageListModel.addElement(t);
// lMessages.ensureIndexIsVisible(messageListModel.size()-1);
// } else {
// final String msg = message;
// EventQueue.invokeLater(new Runnable() {
//
// @Override
// public void run() {
// messageArrived(msg);
// }
// });
// }
// }
//
//
// class DeviceChecker extends Thread {
//
// private boolean cancel;
//
// public DeviceChecker(){
// cancel = false;
// }
//
// public void cancel(){
// this.cancel = true;
// }
//
// @Override
// public void run() {
//
// checkCommunication();
// checkEEPROM();
// checkIO();
// checkADC();
//
// while (!cancel){
// checkCommunication();
// }
//
// }
//
// private void checkCommunication(){
// if (!this.cancel){
// Integer version = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001A);
// Integer uptime = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0022);
//
// if ((version != null)&&(uptime != null)){
// tfCommunication.setText(String.format("OK (V: %d.%d.%d) Up: %d:%d:%d",version >> 16, (version >> 8) & 0xff, version & 0xff, uptime / 3600, (uptime / 60)%60, uptime % 60));
// }
// }
// }
//
// private void checkEEPROM(){
// if (!this.cancel){
// Integer eesize = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x9000);
// if (eesize != null){
// tfEEPROM.setText(String.format("EEPROM Size Detected: 0x%08x Bytes (%d kBytes)", eesize, (eesize >> 10)));
// } else {
// tfEEPROM.setText("EEPROM failed.");
// }
// }
// }
//
// private void checkIO(){
// if (!this.cancel){
//
// application().message("I/O test begins...");
// application().message("I/O reset...");
//
// try {
// application().getServiceLink().writeInt(13, 0, 0x0682, 0);
// application().getServiceLink().writeInt(13, 0, 0x0683, 0);
// application().getServiceLink().writeInt(13, 0, 0x0684, 0);
// application().getServiceLink().writeInt(13, 0, 0x0685, 0);
//
// application().message("counter reset.");
// for (int i=0;i<32;i++){
// application().getServiceLink().writeInt(13, 0, 0x0600 + i, 0);
// }
//
// application().message("PullUP-Counter test.");
// for (int i=0;i<12;i++){
// Thread.sleep(250);
// application().getServiceLink().writeInt(13, 0, 0x0683, -1);
// Thread.sleep(250);
// application().getServiceLink().writeInt(13, 0, 0x0683, 0);
// }
//
// for (int i=0;i<32;i++){
// Thread.sleep(100);
//
// Integer c = application().getServiceLink().readInt(13, 0, 0x0600 + i);
// if ((c != null) && (c.equals(12))){
// application().message(String.format("OK: Channel %d counted %d events.", i, c));
// } else {
// application().message(String.format("FAILED: Channel %d counted %d events.", i, c));
// }
// }
//
//
//
// application().message("I/O test finished!");
// } catch (IOException | ServiceLinkException e) {
// e.printStackTrace();
//
// application().message("I/O test FAILED!");
// } catch (InterruptedException iex){
// iex.printStackTrace();
//
// application().message("I/O test FAILED!");
// }
//
//
//
// }
// }
//
// private void checkADC(){
// if (!this.cancel){
// }
// }
//
// }
//
//
// @Override
// public void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
// // TODO Auto-generated method stub
//
// }
}

View File

@ -41,6 +41,7 @@ public class ExportFilesFrame extends JFrame {
private ExportSetting selectedExportSetting;
private JSeparator separator;
private JButton btnExec;
private JButton btnBatch;
/**
* Create the frame.
@ -118,6 +119,14 @@ public class ExportFilesFrame extends JFrame {
doExport();
}
});
btnBatch = new JButton("BATCH");
btnBatch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doBatchExport();
}
});
toolBar.add(btnBatch);
toolBar.add(btnExec);
JScrollPane scrollPane = new JScrollPane();
@ -176,5 +185,12 @@ public class ExportFilesFrame extends JFrame {
((ExportSetting)tmExportSettings.getSelectedRow()).export();
}
public void doBatchExport(){
for (ExportSetting es: PulsCounterApplication.getApplication().getExportSettings()){
if (es.getAutostart()){
es.export();
}
}
}
}

View File

@ -274,7 +274,12 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
if (selectedDeviceInterface != null){
if (ServiceLinkDeviceConnector.class.isInstance(selectedDeviceInterface)){
ServiceLinkDeviceConnector dc = (ServiceLinkDeviceConnector)selectedDeviceInterface;
dc.setDeviceSerial(Integer.parseInt(descriptionText.substring(5)));
if (descriptionText.startsWith("!\"§$%&")){
Integer escape = Integer.decode(descriptionText.substring(6));
dc.escape(escape, 0);
} else {
dc.setDeviceSerial(Integer.parseInt(descriptionText.substring(5)));
}
}
}
}