Alpha für 16/C
|
@ -1,8 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo"/>
|
||||||
<classpathentry kind="lib" path="postgresql-9.1-901.jdbc4.jar"/>
|
<classpathentry kind="lib" path="postgresql-9.1-901.jdbc4.jar"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.ui"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.servicelink"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.platform"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -2,4 +2,7 @@
|
||||||
bin/**
|
bin/**
|
||||||
/bin
|
/bin
|
||||||
live.csv
|
live.csv
|
||||||
chnames.prop
|
chnames.prop
|
||||||
|
*.dat
|
||||||
|
*.log
|
||||||
|
*.old
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
public abstract class AbstractPulsCounterApplicationListener implements PulsCounterApplicationListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialPortChanged() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,203 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.hwo.configuration.ConfigurableAttribute;
|
||||||
|
import org.hwo.configuration.ConfigurableObject;
|
||||||
|
import org.hwo.csv.CSV;
|
||||||
|
import org.hwo.csv.CSVRecord;
|
||||||
|
import org.hwo.interactiveobjects.InteractiveObject;
|
||||||
|
import org.hwo.interactiveobjects.ObjectEditorUI;
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
import org.hwo.pulscounter.ui.ExportSettingsEditorDialog;
|
||||||
|
|
||||||
|
@ObjectEditorUI(editor=ExportSettingsEditorDialog.class)
|
||||||
|
@ConfigurableObject
|
||||||
|
public class ExportSetting {
|
||||||
|
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private String name;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private TriggerType triggerType;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private Integer triggerSource;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private String fileName;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private String path;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private Boolean extended;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private Boolean autostart;
|
||||||
|
@ConfigurableAttribute
|
||||||
|
private Boolean recordDelta;
|
||||||
|
|
||||||
|
private SimpleDateFormat dateFormat;
|
||||||
|
|
||||||
|
public ExportSetting() {
|
||||||
|
this.dateFormat = new SimpleDateFormat();
|
||||||
|
this.name = "unbenannt";
|
||||||
|
this.path = ".";
|
||||||
|
this.fileName = "synololog.csv";
|
||||||
|
this.triggerType = triggerType.ALL;
|
||||||
|
this.triggerSource = 0;
|
||||||
|
this.extended = false;
|
||||||
|
this.autostart = false;
|
||||||
|
this.recordDelta = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Benennung",firstColumn=true)
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Auslöser")
|
||||||
|
public TriggerType getTriggerType() {
|
||||||
|
return triggerType;
|
||||||
|
}
|
||||||
|
public void setTriggerType(TriggerType triggerType) {
|
||||||
|
this.triggerType = triggerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Dateiname")
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Verzeichnis")
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTriggerSource() {
|
||||||
|
return triggerSource;
|
||||||
|
}
|
||||||
|
public void setTriggerSource(Integer triggerSource) {
|
||||||
|
this.triggerSource = triggerSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getExtended() {
|
||||||
|
return extended;
|
||||||
|
}
|
||||||
|
public void setExtended(Boolean extended) {
|
||||||
|
this.extended = extended;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Autostart",after="Auslöser")
|
||||||
|
public Boolean getAutostart() {
|
||||||
|
return autostart;
|
||||||
|
}
|
||||||
|
public void setAutostart(Boolean autostart) {
|
||||||
|
this.autostart = autostart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRecordDelta() {
|
||||||
|
return recordDelta;
|
||||||
|
}
|
||||||
|
public void setRecordDelta(Boolean recordDelta) {
|
||||||
|
this.recordDelta = recordDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateFileName(String filename,SnapShot ss){
|
||||||
|
Date d = new Date(((long)ss.getTimestamp())*1000);
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(d);
|
||||||
|
|
||||||
|
return filename
|
||||||
|
.replaceAll("\\%Y", String.format("%04d", new Integer(c.get(Calendar.YEAR))))
|
||||||
|
.replaceAll("\\%M", String.format("%02d", new Integer(c.get(Calendar.MONTH)+1)))
|
||||||
|
.replaceAll("\\%D", String.format("%02d", new Integer(c.get(Calendar.DAY_OF_MONTH))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void export(){
|
||||||
|
SnapshotManager ssm = PulsCounter2Application.getApplication().getSnapshotManager();
|
||||||
|
|
||||||
|
Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
|
||||||
|
|
||||||
|
for (int n=0;n<ssm.size();n++){
|
||||||
|
SnapShot ss = ssm.loadSnapShot(n);
|
||||||
|
String fn = calculateFileName(fileName, ss);
|
||||||
|
|
||||||
|
if ((triggerType==TriggerType.ALL)||(ss.getTriggerType()==triggerType)){
|
||||||
|
if (triggerSource.equals(-1) || triggerSource.equals(ss.getSource())){
|
||||||
|
|
||||||
|
if (!hash.containsKey(fn)){
|
||||||
|
hash.put(fn, new CSV());
|
||||||
|
if (extended){
|
||||||
|
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
|
"Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
|
||||||
|
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
|
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
|
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
|
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
|
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
|
} else {
|
||||||
|
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
|
"Datum/Zeit",
|
||||||
|
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
|
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
|
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
|
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
|
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hash.get(fn).getRecords().add(ss.getCSVRecord(extended));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fn: hash.keySet()){
|
||||||
|
if (recordDelta){
|
||||||
|
CSV csv = hash.get(fn);
|
||||||
|
if (!csv.getRecords().isEmpty()){
|
||||||
|
Iterator<CSVRecord> iter = csv.getRecords().iterator();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
|
||||||
|
CSVRecord n = iter.next();
|
||||||
|
Integer[] vals = new Integer[32];
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
vals[i] = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
while (iter.hasNext()){
|
||||||
|
n = iter.next();
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
||||||
|
n.setValue(extended ? i + 4 : i + 1 , v - vals[i]);
|
||||||
|
vals[i] = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
csv.getRecords().remove(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
hash.get(fn).saveToFile(new File(path,fn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -17,9 +17,10 @@ import java.util.Random;
|
||||||
import org.hwo.bitfields.BitField;
|
import org.hwo.bitfields.BitField;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
import org.hwo.io.SerialPortExeption;
|
import org.hwo.io.SerialPortExeption;
|
||||||
import org.hwo.io.servicelink.ServiceLink;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
import org.hwo.io.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.io.servicelink.ServiceLinkRequestFailedException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
|
||||||
public class NewPulsCounterDevice implements IPulsCounter {
|
public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
private ServiceLink serviceLink;
|
private ServiceLink serviceLink;
|
||||||
|
@ -64,7 +65,7 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
if (!serviceLink.isOpen())
|
if (!serviceLink.isOpen())
|
||||||
try {
|
try {
|
||||||
serviceLink.open();
|
serviceLink.open();
|
||||||
serviceLink.getSerialPort().setTimeout(250);
|
serviceLink.getSerialPort().setTimeOut(250);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -86,11 +87,11 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerialPort getSerialPort() {
|
public NewSerialPort getSerialPort() {
|
||||||
return serviceLink.getSerialPort();
|
return serviceLink.getSerialPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSerialPort(SerialPort serialPort) throws ServiceLinkException {
|
public void setSerialPort(NewSerialPort serialPort) throws ServiceLinkException {
|
||||||
|
|
||||||
if (this.serviceLink == null)
|
if (this.serviceLink == null)
|
||||||
this.serviceLink = new ServiceLink(serialPort);
|
this.serviceLink = new ServiceLink(serialPort);
|
||||||
|
@ -100,7 +101,7 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
|
|
||||||
this.serviceLink.setSerialPort(serialPort);;
|
this.serviceLink.setSerialPort(serialPort);;
|
||||||
this.serviceLink.open();
|
this.serviceLink.open();
|
||||||
this.serviceLink.getSerialPort().setTimeout(500);
|
this.serviceLink.getSerialPort().setTimeOut(500);
|
||||||
|
|
||||||
/* try {
|
/* try {
|
||||||
this.serviceLink.readInt((byte)0, (byte)0, 0);
|
this.serviceLink.readInt((byte)0, (byte)0, 0);
|
||||||
|
@ -219,9 +220,8 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
saveProps();
|
saveProps();
|
||||||
|
|
||||||
if ((this.serviceLink == null) || (serviceLink.getSerialPort() == null)) {
|
if ((this.serviceLink == null) || (serviceLink.getSerialPort() == null)) {
|
||||||
SerialPort sport = SerialPort.newInstance();
|
NewSerialPort nsp = new NewSerialPort(interfaceName);
|
||||||
sport.setPortName(interfaceName);
|
setSerialPort(nsp);
|
||||||
setSerialPort(sport);
|
|
||||||
} else {
|
} else {
|
||||||
serviceLink.getSerialPort().setPortName(interfaceName);
|
serviceLink.getSerialPort().setPortName(interfaceName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,305 +0,0 @@
|
||||||
package org.hwo.pulscounter;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.LogManager;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.util.prefs.Preferences;
|
|
||||||
|
|
||||||
import org.hwo.beacon.Beacon;
|
|
||||||
import org.hwo.beacon.Beacon.BeaconSender;
|
|
||||||
import org.hwo.csv.CSV;
|
|
||||||
import org.hwo.io.SerialPortExeption;
|
|
||||||
import org.hwo.os.OsDetect;
|
|
||||||
import org.hwo.os.OsDetect.OsType;
|
|
||||||
import org.hwo.pulscounter.application.InspectorApplication;
|
|
||||||
import org.hwo.pulscounter.service.PulsCounterService;
|
|
||||||
import org.hwo.pulscounter.ui.PulsCounterWindow;
|
|
||||||
import org.hwo.rpc.json.RPCAdapter;
|
|
||||||
import org.hwo.rpc.simple.SimpleRPCServer;
|
|
||||||
import org.hwo.rpc.simple.SimpleRPCService;
|
|
||||||
|
|
||||||
|
|
||||||
public class PulsCounter {
|
|
||||||
|
|
||||||
static private Preferences prefs;
|
|
||||||
public static Preferences getPrefs() {
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
static private PulsCounterService localService;
|
|
||||||
public static PulsCounterService getLocalService(){
|
|
||||||
return localService;
|
|
||||||
}
|
|
||||||
|
|
||||||
static private InspectorApplication inspectorApplication;
|
|
||||||
static public InspectorApplication getInspectorApplication() {
|
|
||||||
if (inspectorApplication == null)
|
|
||||||
inspectorApplication = new InspectorApplication();
|
|
||||||
return inspectorApplication;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static String logFile;
|
|
||||||
|
|
||||||
static boolean serverMode = false;
|
|
||||||
static boolean guiMode = true;
|
|
||||||
static boolean batchMode = false;
|
|
||||||
static boolean batchConvert = false;
|
|
||||||
|
|
||||||
static boolean startLocalService = false;
|
|
||||||
|
|
||||||
static String batchFilename = null;
|
|
||||||
static String networkName = null;
|
|
||||||
static String batchConvertTarget = null;
|
|
||||||
|
|
||||||
static boolean debugMode = false;
|
|
||||||
|
|
||||||
|
|
||||||
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"));
|
|
||||||
*/
|
|
||||||
|
|
||||||
Logger rootLogger = LogManager.getLogManager().getLogger("");
|
|
||||||
if (rootLogger != null){
|
|
||||||
rootLogger.setLevel(Level.SEVERE);
|
|
||||||
}
|
|
||||||
|
|
||||||
prefs = Preferences.userRoot();
|
|
||||||
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Load serverMode default from local preferences */
|
|
||||||
|
|
||||||
startLocalService = prefs.getBoolean("pulscounter.local.enabled", false);
|
|
||||||
|
|
||||||
Iterator<String> options = Arrays.asList(args).iterator();
|
|
||||||
|
|
||||||
while (options.hasNext()) {
|
|
||||||
String no = options.next();
|
|
||||||
|
|
||||||
if (no.equals("-s")) {
|
|
||||||
serverMode = true;
|
|
||||||
guiMode = false;
|
|
||||||
} else if (no.equals("-bo")) {
|
|
||||||
serverMode = false;
|
|
||||||
startLocalService = false;
|
|
||||||
} else if (no.equals("-b")) {
|
|
||||||
batchMode = true;
|
|
||||||
} else if (no.equals("-c")) {
|
|
||||||
batchConvert = true;
|
|
||||||
batchConvertTarget = options.next();
|
|
||||||
} else if (no.equals("-f")){
|
|
||||||
batchFilename = options.next();
|
|
||||||
} else if (no.equals("-n")){
|
|
||||||
networkName = options.next();
|
|
||||||
startLocalService = false;
|
|
||||||
} else if (no.equals("-l")){
|
|
||||||
logFile = options.next();
|
|
||||||
} else if (no.equals("-u")){
|
|
||||||
startLocalService = true;
|
|
||||||
} else if (no.equals("-d")){
|
|
||||||
debugMode = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logFile != null){
|
|
||||||
try {
|
|
||||||
PrintStream logStream = new PrintStream(new FileOutputStream(logFile, true));
|
|
||||||
System.setErr(logStream);
|
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (batchMode)
|
|
||||||
guiMode = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
localService = new PulsCounterService();
|
|
||||||
|
|
||||||
if (startLocalService){
|
|
||||||
localService.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (batchMode) {
|
|
||||||
batchrun();
|
|
||||||
} else if (guiMode){
|
|
||||||
PulsCounterWindow window = new PulsCounterWindow();
|
|
||||||
window.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (batchConvert) {
|
|
||||||
batchConvert(batchFilename,batchConvertTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void batchrun(){
|
|
||||||
|
|
||||||
if (networkName == null) {
|
|
||||||
// TODO: Use UUID from preferences to select network service
|
|
||||||
} else {
|
|
||||||
Beacon clientBeacon = new Beacon(44556);
|
|
||||||
clientBeacon.setClientOnly(true);
|
|
||||||
clientBeacon.start();
|
|
||||||
|
|
||||||
for (int i=0;i<120;i++){
|
|
||||||
if (clientBeacon.getSenderByName(networkName) != null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BeaconSender sender = clientBeacon.getSenderByName(networkName);
|
|
||||||
if (sender == null) {
|
|
||||||
System.err.println("Networknode: " + networkName + " is offline.");
|
|
||||||
clientBeacon.exit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPulsCounter ipc = createProxyFromBeaconSender(sender);
|
|
||||||
|
|
||||||
Date d = new Date();
|
|
||||||
String time = String.format("%04d-%02d-%02d %02d:%02d:%02d",d.getYear()+1900,d.getMonth()+1,d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds());
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
CounterChannel[] channels = new CounterChannel[ ipc.getChannels() ];
|
|
||||||
int[] values = ipc.getChannelCounters();
|
|
||||||
|
|
||||||
try {
|
|
||||||
File csvfile = new File(batchFilename);
|
|
||||||
boolean newfile = !csvfile.exists();
|
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(csvfile,true));
|
|
||||||
|
|
||||||
if (newfile){
|
|
||||||
|
|
||||||
writer.write("Zeitpunkt");
|
|
||||||
|
|
||||||
for (int i=0;i<values.length;i++){
|
|
||||||
writer.write("\t");
|
|
||||||
writer.write(ipc.getChannelName(i));
|
|
||||||
}
|
|
||||||
writer.write("\r\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.write(time + "\t");
|
|
||||||
for (int i=0;i<values.length;i++){
|
|
||||||
if (i>0)
|
|
||||||
writer.write("\t");
|
|
||||||
|
|
||||||
writer.write(String.format("%d",values[i]));
|
|
||||||
}
|
|
||||||
writer.write("\r\n");
|
|
||||||
writer.flush();
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (SerialPortExeption sex){
|
|
||||||
System.err.println(sex);
|
|
||||||
sex.printStackTrace();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println(e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
clientBeacon.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void batchConvert(String source,String target){
|
|
||||||
|
|
||||||
CSV csv = new CSV();
|
|
||||||
csv.setSeparator('\t');
|
|
||||||
csv.readFromFile(source);
|
|
||||||
|
|
||||||
for (int i=csv.getRecords().size()-1;i>1;--i){
|
|
||||||
for (int j=1;j<csv.getRecord(i).size();j++){
|
|
||||||
int last = csv.getRecord(i-1).getIntegerValue(j);
|
|
||||||
int actual = csv.getRecord(i).getIntegerValue(j);
|
|
||||||
|
|
||||||
csv.getRecord(i).setValue(j, actual - last);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
csv.getRecords().remove(1);
|
|
||||||
|
|
||||||
csv.saveToFile(batchConvertTarget);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static IPulsCounter createProxyFromBeaconSender(BeaconSender sender){
|
|
||||||
int port = Integer.decode(sender.getProperties().getProperty("rpc.simple.port"));
|
|
||||||
SimpleRPCService service = new SimpleRPCService(sender.getInetAddress(), port);
|
|
||||||
IPulsCounter ipc = service.createProxy(IPulsCounter.class);
|
|
||||||
return ipc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +1,23 @@
|
||||||
package org.hwo.pulscounter;
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.prefs.BackingStoreException;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
import org.hwo.configuration.ConfigurableObjects;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
import org.hwo.io.servicelink.ServiceLink;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
|
import org.hwo.servicelink.ServiceLink;
|
||||||
|
import org.hwo.servicelink.ServiceLinkListener;
|
||||||
|
import org.hwo.tasklet.TaskletManager;
|
||||||
|
import org.hwo.pulscounter.SnapshotManager.Notification;
|
||||||
import org.hwo.pulscounter.ui.AppSettingsListener;
|
import org.hwo.pulscounter.ui.AppSettingsListener;
|
||||||
|
import org.hwo.scheduler.Scheduler;
|
||||||
|
|
||||||
public class PulsCounter2Application {
|
public class PulsCounter2Application implements ServiceLinkListener{
|
||||||
|
|
||||||
static PulsCounter2Application _application;
|
static PulsCounter2Application _application;
|
||||||
public static PulsCounter2Application getApplication(){
|
public static PulsCounter2Application getApplication(){
|
||||||
|
@ -17,14 +27,42 @@ public class PulsCounter2Application {
|
||||||
return _application;
|
return _application;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialPort serialPort;
|
private NewSerialPort serialPort;
|
||||||
ServiceLink serviceLink;
|
private ServiceLink serviceLink;
|
||||||
|
|
||||||
List<AppSettingsListener> appSettingsListeners;
|
private List<AppSettingsListener> appSettingsListeners;
|
||||||
|
private List<PulsCounterApplicationListener> applicationListeners;
|
||||||
|
|
||||||
public PulsCounter2Application(){
|
private boolean snapshotLock;
|
||||||
|
|
||||||
|
private Vector<String> unseenMessages;
|
||||||
|
|
||||||
|
private SnapshotManager snapshotManager;
|
||||||
|
|
||||||
|
private List<ExportSetting> exportSettings;
|
||||||
|
|
||||||
|
private Scheduler scheduler;
|
||||||
|
|
||||||
|
public PulsCounter2Application() {
|
||||||
appSettingsListeners = new LinkedList<AppSettingsListener>();
|
appSettingsListeners = new LinkedList<AppSettingsListener>();
|
||||||
|
applicationListeners = new LinkedList<PulsCounterApplicationListener>();
|
||||||
|
unseenMessages = new Vector<String>();
|
||||||
|
exportSettings = new LinkedList<ExportSetting>();
|
||||||
|
scheduler = new Scheduler();
|
||||||
|
|
||||||
|
loadPrefs();
|
||||||
|
|
||||||
|
try {
|
||||||
|
snapshotManager = new SnapshotManager();
|
||||||
|
snapshotManager.notify(Notification.INITIALIZE);
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void addAppSettingsListener(AppSettingsListener listener){
|
public void addAppSettingsListener(AppSettingsListener listener){
|
||||||
appSettingsListeners.add(listener);
|
appSettingsListeners.add(listener);
|
||||||
|
@ -33,31 +71,78 @@ public class PulsCounter2Application {
|
||||||
appSettingsListeners.remove(listener);
|
appSettingsListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireServiceLinkChanged(){
|
public void addPulsCounterApplicationListener(PulsCounterApplicationListener listener){
|
||||||
|
applicationListeners.add(listener);
|
||||||
|
}
|
||||||
|
public void removePulsCounterApplicationListener(PulsCounterApplicationListener listener){
|
||||||
|
applicationListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void fireServiceLinkChanged(){
|
||||||
for (AppSettingsListener l: appSettingsListeners){
|
for (AppSettingsListener l: appSettingsListeners){
|
||||||
l.ServiceLinkChanged(serviceLink);
|
l.ServiceLinkChanged(serviceLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized SerialPort getSerialPort() {
|
public void fireSerialPortChanged(){
|
||||||
|
for (PulsCounterApplicationListener listener: applicationListeners){
|
||||||
|
listener.serialPortChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireConnectionStateChanged(){
|
||||||
|
fireConnectionStateChanged(getServiceLink().isOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fireConnectionStateChanged(Boolean connected){
|
||||||
|
for (PulsCounterApplicationListener listener: applicationListeners){
|
||||||
|
listener.connectionStateChanged(connected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void message(String message){
|
||||||
|
|
||||||
|
if (applicationListeners.size() == 0){
|
||||||
|
unseenMessages.addElement(message);
|
||||||
|
} else {
|
||||||
|
while (!unseenMessages.isEmpty()){
|
||||||
|
String msg = unseenMessages.remove(0);
|
||||||
|
for (PulsCounterApplicationListener listener: applicationListeners){
|
||||||
|
listener.messageArrived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PulsCounterApplicationListener listener: applicationListeners){
|
||||||
|
listener.messageArrived(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized NewSerialPort getSerialPort() {
|
||||||
|
if (serialPort == null){
|
||||||
|
serialPort = new NewSerialPort("COM1:");
|
||||||
|
}
|
||||||
return serialPort;
|
return serialPort;
|
||||||
}
|
}
|
||||||
public synchronized void setSerialPort(SerialPort serialPort) {
|
public synchronized void setSerialPort(NewSerialPort serialPort) {
|
||||||
if (serviceLink != null){
|
if (serviceLink != null){
|
||||||
serviceLink.close();
|
serviceLink.close();
|
||||||
serviceLink = null;
|
serviceLink = null;
|
||||||
}
|
}
|
||||||
this.serialPort = serialPort;
|
this.serialPort = serialPort;
|
||||||
|
|
||||||
|
getServiceLink();
|
||||||
|
|
||||||
fireServiceLinkChanged();
|
fireServiceLinkChanged();
|
||||||
|
fireSerialPortChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ServiceLink getServiceLink() {
|
public synchronized ServiceLink getServiceLink() {
|
||||||
if (serviceLink == null){
|
if (serviceLink == null){
|
||||||
if (serialPort != null){
|
serviceLink = new ServiceLink(getSerialPort());
|
||||||
serviceLink = new ServiceLink(serialPort);
|
serviceLink.getSerialPort().setTimeOut(200);
|
||||||
serviceLink.getSerialPort().setTimeout(200);
|
serviceLink.addServiceLinkListener(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return serviceLink;
|
return serviceLink;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +155,77 @@ public class PulsCounter2Application {
|
||||||
fireServiceLinkChanged();
|
fireServiceLinkChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Preferences getPreferencesNode(){
|
||||||
|
return Preferences.userNodeForPackage(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePrefs(){
|
||||||
|
Preferences prefs = getPreferencesNode();
|
||||||
|
|
||||||
|
if (serialPort != null)
|
||||||
|
prefs.put("io.port", serialPort.getPortName());
|
||||||
|
|
||||||
|
System.out.println(String.format("savePrefs(): %d exportSettings werden gesichert.", exportSettings.size()));
|
||||||
|
if (exportSettings.size()>0)
|
||||||
|
{
|
||||||
|
for (int n=0;n<exportSettings.size();n++){
|
||||||
|
prefs.put(String.format("export.configuration.%d", n), ConfigurableObjects.getConfiguration(exportSettings.get(n)));
|
||||||
|
}
|
||||||
|
prefs.putInt("export.configurations", exportSettings.size());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
prefs.flush();
|
||||||
|
} catch (BackingStoreException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPrefs(){
|
||||||
|
Preferences prefs = getPreferencesNode();
|
||||||
|
|
||||||
|
String sn = prefs.get("io.port", null);
|
||||||
|
|
||||||
|
if (sn != null){
|
||||||
|
NewSerialPort nsp = new NewSerialPort(sn);
|
||||||
|
setSerialPort(nsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
exportSettings.clear();
|
||||||
|
int nESC = prefs.getInt("export.configurations", 0);
|
||||||
|
for (int n=0;n<nESC;n++){
|
||||||
|
ExportSetting es = new ExportSetting();
|
||||||
|
ConfigurableObjects.setConfiguration(es, prefs.get(String.format("export.configuration.%d", n), ""));
|
||||||
|
exportSettings.add(es);
|
||||||
|
}
|
||||||
|
System.out.println(String.format("loadPrefs(): %d exportSettings geladen.", nESC));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionStateChanged(Boolean connected) {
|
||||||
|
fireConnectionStateChanged(connected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnapshotManager getSnapshotManager() {
|
||||||
|
return snapshotManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExportSetting> getExportSettings() {
|
||||||
|
return exportSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
System.err.println("Shutting down...");
|
||||||
|
this.scheduler.shutdown();
|
||||||
|
this.snapshotManager.doShutdown();
|
||||||
|
TaskletManager.instance().shutdown();
|
||||||
|
|
||||||
|
this.getServiceLink().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
public interface PulsCounterApplicationListener {
|
||||||
|
|
||||||
|
void serialPortChanged();
|
||||||
|
void connectionStateChanged(Boolean connected);
|
||||||
|
|
||||||
|
void messageArrived(String message);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.hwo.csv.CSVRecord;
|
||||||
|
import org.hwo.servicelink.ServiceLink;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
|
public class SnapShot {
|
||||||
|
Integer timestamp;
|
||||||
|
Integer field0;
|
||||||
|
|
||||||
|
Integer[] values;
|
||||||
|
Integer[] analog;
|
||||||
|
|
||||||
|
Integer inputmask,
|
||||||
|
outputmask,
|
||||||
|
pullupmask,
|
||||||
|
invertmask,
|
||||||
|
triggermask;
|
||||||
|
|
||||||
|
public SnapShot(){
|
||||||
|
this.values = new Integer[32];
|
||||||
|
this.analog = new Integer[8];
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnapShot(byte[] bytes){
|
||||||
|
this.values = new Integer[32];
|
||||||
|
this.analog = new Integer[8];
|
||||||
|
|
||||||
|
fromBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField0(Integer field0) {
|
||||||
|
this.field0 = field0;
|
||||||
|
}
|
||||||
|
public Integer getField0() {
|
||||||
|
return field0;
|
||||||
|
}
|
||||||
|
public void setTimestamp(Integer timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
public Integer getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
public Integer getInputmask() {
|
||||||
|
return inputmask;
|
||||||
|
}
|
||||||
|
public void setInputmask(Integer inputmask) {
|
||||||
|
this.inputmask = inputmask;
|
||||||
|
}
|
||||||
|
public Integer getOutputmask() {
|
||||||
|
return outputmask;
|
||||||
|
}
|
||||||
|
public void setOutputmask(Integer outputmask) {
|
||||||
|
this.outputmask = outputmask;
|
||||||
|
}
|
||||||
|
public Integer getPullupmask() {
|
||||||
|
return pullupmask;
|
||||||
|
}
|
||||||
|
public void setPullupmask(Integer pullupmask) {
|
||||||
|
this.pullupmask = pullupmask;
|
||||||
|
}
|
||||||
|
public Integer getInvertmask() {
|
||||||
|
return invertmask;
|
||||||
|
}
|
||||||
|
public void setInvertmask(Integer invertmask) {
|
||||||
|
this.invertmask = invertmask;
|
||||||
|
}
|
||||||
|
public Integer getTriggermask() {
|
||||||
|
return triggermask;
|
||||||
|
}
|
||||||
|
public void setTriggermask(Integer triggermask) {
|
||||||
|
this.triggermask = triggermask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Integer ch,Integer value){
|
||||||
|
if ((ch >= 0) && (ch<32)){
|
||||||
|
this.values[ch] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Integer getValue(Integer ch){
|
||||||
|
if ((ch >= 0) && (ch<32)){
|
||||||
|
return this.values[ch];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Integer[] getValues(){
|
||||||
|
return Arrays.copyOf(this.values, this.values.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalog(Integer ch,Integer value){
|
||||||
|
if ((ch >= 0) && (ch<8)){
|
||||||
|
this.analog[ch] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Integer getAnalog(Integer ch){
|
||||||
|
if ((ch >= 0) && (ch<8)){
|
||||||
|
return this.analog[ch];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public Integer[] getAnalog(){
|
||||||
|
return Arrays.copyOf(this.analog, this.analog.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getHashCode(){
|
||||||
|
return ((long)timestamp << 32) | field0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriggerType getTriggerType(){
|
||||||
|
return TriggerType.get(this.field0 & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSource(){
|
||||||
|
return (field0 >> 8) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] toBytes(){
|
||||||
|
byte[] buffer = new byte[256];
|
||||||
|
ByteBuffer bb = ByteBuffer.wrap(buffer);
|
||||||
|
|
||||||
|
Arrays.fill(buffer, (byte)0);
|
||||||
|
|
||||||
|
bb.putInt(0, timestamp);
|
||||||
|
bb.putInt(4, field0);
|
||||||
|
bb.putInt(8, inputmask);
|
||||||
|
bb.putInt(12, outputmask);
|
||||||
|
bb.putInt(16, pullupmask);
|
||||||
|
bb.putInt(20, invertmask);
|
||||||
|
bb.putInt(24, triggermask);
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
bb.putInt(32 + (i<<2), values[i]);
|
||||||
|
}
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
bb.putInt(160 + (i<<2), analog[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fromBytes(byte[] bytes){
|
||||||
|
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||||
|
|
||||||
|
timestamp = bb.getInt(0);
|
||||||
|
field0 = bb.getInt(4);
|
||||||
|
inputmask = bb.getInt(8);
|
||||||
|
outputmask = bb.getInt(12);
|
||||||
|
pullupmask = bb.getInt(16);
|
||||||
|
invertmask = bb.getInt(20);
|
||||||
|
triggermask = bb.getInt(24);
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
values[i] = bb.getInt(32 + (i<<2));
|
||||||
|
}
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
analog[i] = bb.getInt(160 + (i<<2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CSVRecord getCSVRecord(){
|
||||||
|
return getCSVRecord(false);
|
||||||
|
}
|
||||||
|
public CSVRecord getCSVRecord(Boolean extended){
|
||||||
|
CSVRecord record = new CSVRecord();
|
||||||
|
|
||||||
|
if (extended)
|
||||||
|
record.appendValue(timestamp);
|
||||||
|
|
||||||
|
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
record.appendValue(df.format(new Date(((long)timestamp)*1000)));
|
||||||
|
|
||||||
|
if (extended){
|
||||||
|
record.appendValue("TRIGGER");
|
||||||
|
record.appendValue("QUELLE");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int n=0;n<32;n++)
|
||||||
|
record.appendValue( values[n]);
|
||||||
|
for (int n=0;n<8;n++)
|
||||||
|
record.appendValue( analog[n]);
|
||||||
|
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append("SnapShot(");
|
||||||
|
sb.append(this.timestamp);
|
||||||
|
sb.append(":");
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
if (i>0)
|
||||||
|
sb.append(",");
|
||||||
|
sb.append(this.values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(")");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,321 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.tasklet.Tasklet;
|
||||||
|
import org.hwo.tasklet.TaskletManager;
|
||||||
|
|
||||||
|
public class SnapshotManager {
|
||||||
|
|
||||||
|
public enum Notification { INITIALIZE, SHUTDOWN, SYNC, FULLSYNC };
|
||||||
|
|
||||||
|
private RandomAccessFile file;
|
||||||
|
|
||||||
|
private Hashtable<Long,Integer> hashList;
|
||||||
|
|
||||||
|
private Integer lastNewest,
|
||||||
|
snapshotSize;
|
||||||
|
|
||||||
|
|
||||||
|
public SnapshotManager() throws FileNotFoundException {
|
||||||
|
this.file = new RandomAccessFile("snapshots.dat", "rws");
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnapshotManager(File file) throws FileNotFoundException {
|
||||||
|
this.file = new RandomAccessFile(file, "rws");
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void initialize(){
|
||||||
|
hashList = new Hashtable<Long, Integer>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PulsCounter2Application application(){
|
||||||
|
return PulsCounter2Application.getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void notify(Notification notification){
|
||||||
|
switch (notification){
|
||||||
|
case INITIALIZE:
|
||||||
|
TaskletManager.instance().enqueue(new Tasklet("SnapShot Manager initialisieren") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doInitialize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case SHUTDOWN:
|
||||||
|
doShutdown();
|
||||||
|
return;
|
||||||
|
case FULLSYNC:
|
||||||
|
TaskletManager.instance().enqueue(new Tasklet("Volle Synchronisation") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doFullSync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case SYNC:
|
||||||
|
TaskletManager.instance().enqueue(new Tasklet("Schnelle Synchronisation") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doSync();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public synchronized void doInitialize(){
|
||||||
|
try {
|
||||||
|
byte[] buffer = new byte[256];
|
||||||
|
ByteBuffer bb = ByteBuffer.wrap(buffer);
|
||||||
|
Integer ind = 0;
|
||||||
|
|
||||||
|
application().message("SnapShotManager: Initialisieren");
|
||||||
|
|
||||||
|
hashList.clear();
|
||||||
|
file.seek(0);
|
||||||
|
|
||||||
|
while (file.read(buffer)==256){
|
||||||
|
Integer timestamp,field0;
|
||||||
|
Long hash;
|
||||||
|
|
||||||
|
timestamp = bb.getInt(0);
|
||||||
|
field0 = bb.getInt(4);
|
||||||
|
|
||||||
|
hash = ((long)timestamp << 32) | field0;
|
||||||
|
|
||||||
|
hashList.put(hash, ind++);
|
||||||
|
}
|
||||||
|
|
||||||
|
application().message(String.format("SnapShotManager: %d SnapShots lokal", hashList.size()));
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
application().message("SnapShotManager meldet Fehler: " + e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void doShutdown(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void doFullSync(){
|
||||||
|
Integer ind_oldest,ind_newest,ind;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
application().message("SnapShotManager: Beginne volle synchronisation");
|
||||||
|
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
snapshotSize = application().getServiceLink().readInt(13, 0, 0x0582);
|
||||||
|
} catch (ServiceLinkRequestFailedException e){
|
||||||
|
snapshotSize = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
ind_oldest = application().getServiceLink().readInt(13, 0, 0x0580);
|
||||||
|
ind_newest = application().getServiceLink().readInt(13, 0, 0x0581);
|
||||||
|
lastNewest = ind_newest;
|
||||||
|
|
||||||
|
System.out.println(String.format("ind_oldest: %d", ind_oldest));
|
||||||
|
System.out.println(String.format("ind_newest: %d", ind_newest));
|
||||||
|
|
||||||
|
ind = ind_oldest;
|
||||||
|
|
||||||
|
do {
|
||||||
|
TaskletManager.instance().setProgress(String.format("%d / %d", n++, snapshotSize));
|
||||||
|
|
||||||
|
Integer id;
|
||||||
|
try {
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x0500, ind);
|
||||||
|
id = application().getServiceLink().readInt(13, 0, 0x0500);
|
||||||
|
if (!id.equals(ind)){
|
||||||
|
System.out.println(String.format("bus_snapshot_id: %d != %d",ind,id));
|
||||||
|
} else {
|
||||||
|
Integer ts,f0;
|
||||||
|
|
||||||
|
ts = application().getServiceLink().readInt(13, 0, 0x0501);
|
||||||
|
f0 = application().getServiceLink().readInt(13, 0, 0x0502);
|
||||||
|
|
||||||
|
Long hash = ((long)ts<<32) | f0;
|
||||||
|
|
||||||
|
if (!hashList.containsKey(hash)){
|
||||||
|
SnapShot snap = snapshotFromDevice(ind);
|
||||||
|
if (snap != null){
|
||||||
|
Integer find = snapshotToFile(snap);
|
||||||
|
if (find != -1){
|
||||||
|
hashList.put(snap.getHashCode(), find);
|
||||||
|
} else {
|
||||||
|
application().message("Snapshot konnte nicht gespeichert werden!");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ind.equals(ind_newest))
|
||||||
|
break;
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException failed){
|
||||||
|
failed.printStackTrace();
|
||||||
|
};
|
||||||
|
|
||||||
|
ind++;
|
||||||
|
if (ind > snapshotSize){
|
||||||
|
ind = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (!ind.equals(ind_oldest));
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
application().message(String.format("SnapShotManager: %d bekannte Snapshots nach FullSync", hashList.size()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void doSync(){
|
||||||
|
Integer ind_oldest,ind_newest,ind;
|
||||||
|
int n,c;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ind_newest = application().getServiceLink().readInt(13, 0, 0x0581);
|
||||||
|
|
||||||
|
if (ind_newest == lastNewest)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ind = lastNewest;
|
||||||
|
|
||||||
|
c = ind_newest - lastNewest;
|
||||||
|
if (c < 0)
|
||||||
|
c+=snapshotSize;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
|
||||||
|
if (c == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
TaskletManager.instance().setProgress(String.format("%d / %d", n,c));
|
||||||
|
|
||||||
|
ind ++;
|
||||||
|
ind &= 0x1FF;
|
||||||
|
n++;
|
||||||
|
|
||||||
|
SnapShot snap = snapshotFromDevice(ind);
|
||||||
|
if (snap != null){
|
||||||
|
Integer ind_file = snapshotToFile(snap);
|
||||||
|
|
||||||
|
hashList.put(snap.getHashCode(), ind_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (!ind.equals(ind_newest));
|
||||||
|
|
||||||
|
lastNewest = ind_newest;
|
||||||
|
|
||||||
|
application().message(String.format("%d neue Snapshots", n));
|
||||||
|
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized SnapShot loadSnapShot(int ind){
|
||||||
|
byte[] bytes = new byte[256];
|
||||||
|
|
||||||
|
try {
|
||||||
|
file.seek(ind * 256);
|
||||||
|
file.read(bytes);
|
||||||
|
return new SnapShot(bytes);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized Integer size(){
|
||||||
|
try {
|
||||||
|
return ((int)(file.length())/256);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized Integer snapshotToFile(SnapShot snap){
|
||||||
|
Long find;
|
||||||
|
try {
|
||||||
|
|
||||||
|
find = file.length()/256;
|
||||||
|
|
||||||
|
file.seek(find * 256);
|
||||||
|
file.write(snap.toBytes());
|
||||||
|
|
||||||
|
|
||||||
|
return find.intValue();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SnapShot snapshotFromDevice(Integer ind){
|
||||||
|
SnapShot ss = new SnapShot();
|
||||||
|
Integer id;
|
||||||
|
try {
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x0500, ind);
|
||||||
|
id = application().getServiceLink().readInt(13, 0, 0x0500);
|
||||||
|
if (!id.equals(ind)){
|
||||||
|
System.out.println(String.format("bus_snapshot_id: %d != %d",ind,id));
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
ss.setTimestamp( application().getServiceLink().readInt(13, 0, 0x0501));
|
||||||
|
ss.setField0( application().getServiceLink().readInt(13, 0, 0x0502));
|
||||||
|
ss.setInputmask( application().getServiceLink().readInt(13, 0, 0x0503));
|
||||||
|
ss.setOutputmask( application().getServiceLink().readInt(13, 0, 0x0504));
|
||||||
|
ss.setPullupmask( application().getServiceLink().readInt(13, 0, 0x0505));
|
||||||
|
ss.setInvertmask( application().getServiceLink().readInt(13, 0, 0x0506));
|
||||||
|
ss.setTriggermask( application().getServiceLink().readInt(13, 0, 0x0507));
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
ss.setValue(i, application().getServiceLink().readInt(13, 0, 0x0510 + i));
|
||||||
|
}
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
ss.setAnalog(i, application().getServiceLink().readInt(13, 0, 0x0508 + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print(String.format("Snapshot from Device: %s\n", ss.toString()));
|
||||||
|
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
public enum TriggerType {
|
||||||
|
|
||||||
|
Intervall(1),Trigger(2),Timer(4),Manual(8),ALL(-1),UNKOWN(-2);
|
||||||
|
|
||||||
|
TriggerType(int n){
|
||||||
|
this.n = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TriggerType get(int n){
|
||||||
|
switch (n){
|
||||||
|
case 1:
|
||||||
|
return TriggerType.Intervall;
|
||||||
|
case 2:
|
||||||
|
return TriggerType.Trigger;
|
||||||
|
case 4:
|
||||||
|
return TriggerType.Timer;
|
||||||
|
case 8:
|
||||||
|
return TriggerType.Manual;
|
||||||
|
default:
|
||||||
|
return TriggerType.UNKOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer n;
|
||||||
|
|
||||||
|
public Integer getValue(){
|
||||||
|
return this.n;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.hwo.datetime.Date;
|
import org.hwo.datetime.Date;
|
||||||
import org.hwo.datetime.DateTime;
|
import org.hwo.datetime.DateTime;
|
||||||
import org.hwo.pulscounter.PulsCounter;
|
|
||||||
|
|
||||||
public class WorkShiftRecord {
|
public class WorkShiftRecord {
|
||||||
|
|
||||||
|
@ -86,7 +85,7 @@ public class WorkShiftRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadRecords(){
|
void loadRecords(){
|
||||||
try {
|
/* try {
|
||||||
PreparedStatement stat = PulsCounter.getInspectorApplication().getConnection().prepareStatement("SELECT tstamp,channel,chvalue FROM rawvalues WHERE tstamp >= ? AND tstamp < ? ORDER BY channel,tstamp");
|
PreparedStatement stat = PulsCounter.getInspectorApplication().getConnection().prepareStatement("SELECT tstamp,channel,chvalue FROM rawvalues WHERE tstamp >= ? AND tstamp < ? ORDER BY channel,tstamp");
|
||||||
|
|
||||||
stat.setTimestamp(1, workShift.getShiftBegins(date).getTimeStamp());
|
stat.setTimestamp(1, workShift.getShiftBegins(date).getTimeStamp());
|
||||||
|
@ -119,6 +118,7 @@ public class WorkShiftRecord {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer[] getChannels(){
|
public Integer[] getChannels(){
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.hwo.pulscounter.ui;
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
@ -21,27 +23,65 @@ import java.awt.Insets;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
import org.hwo.csv.CSV;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
import org.hwo.io.SerialPortChooser;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
import org.hwo.pulscounter.PulsCounter2Application;
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
import org.hwo.pulscounter.SnapshotManager;
|
||||||
|
import org.hwo.servicelink.ServiceLink;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.ui.dialog.SerialPortChooser;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
public class AppSettingsFrame extends JFrame {
|
public class AppSettingsFrame extends JDialog {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JTextField tfInterface;
|
private JTextField tfInterface;
|
||||||
|
|
||||||
private SerialPort selectedSerialPort;
|
private NewSerialPort selectedSerialPort,formerSerialPort;
|
||||||
|
private JTextField timeComputer;
|
||||||
|
private JTextField timeSynololog;
|
||||||
|
private JSpinner spTrimm;
|
||||||
|
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
|
private Calendar calendar = Calendar.getInstance();
|
||||||
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
private JTabbedPane tabbedPane;
|
||||||
|
private JPanel debugPanel;
|
||||||
|
private JLabel lHeapDec;
|
||||||
|
private JLabel lHeapHex;
|
||||||
|
private JLabel lSStackDec;
|
||||||
|
private JLabel lSStackHex;
|
||||||
|
private JEditorPane msgExc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public AppSettingsFrame() {
|
public AppSettingsFrame() {
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
setModal(true);
|
||||||
setTitle("Einstellungen");
|
setTitle("Einstellungen");
|
||||||
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 603, 447);
|
setBounds(100, 100, 603, 447);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
|
@ -49,7 +89,7 @@ public class AppSettingsFrame extends JFrame {
|
||||||
contentPane.setLayout(new BorderLayout(0, 0));
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
|
|
||||||
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
contentPane.add(tabbedPane, BorderLayout.CENTER);
|
contentPane.add(tabbedPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
|
@ -71,6 +111,7 @@ public class AppSettingsFrame extends JFrame {
|
||||||
panel.add(lblSchnittstelle, gbc_lblSchnittstelle);
|
panel.add(lblSchnittstelle, gbc_lblSchnittstelle);
|
||||||
|
|
||||||
tfInterface = new JTextField();
|
tfInterface = new JTextField();
|
||||||
|
tfInterface.setToolTipText("<html>\n<b>Aktuell eingstellte Schnittstelle</b><br/>\n<br/>\nDiese Schnittstelle wird wür die Kommunikation mit dem Synololog verwendet.\n</html>");
|
||||||
GridBagConstraints gbc_tfInterface = new GridBagConstraints();
|
GridBagConstraints gbc_tfInterface = new GridBagConstraints();
|
||||||
gbc_tfInterface.anchor = GridBagConstraints.NORTH;
|
gbc_tfInterface.anchor = GridBagConstraints.NORTH;
|
||||||
gbc_tfInterface.insets = new Insets(0, 0, 5, 5);
|
gbc_tfInterface.insets = new Insets(0, 0, 5, 5);
|
||||||
|
@ -92,6 +133,235 @@ public class AppSettingsFrame extends JFrame {
|
||||||
gbc_btnWhlen.gridy = 0;
|
gbc_btnWhlen.gridy = 0;
|
||||||
panel.add(btnWhlen, gbc_btnWhlen);
|
panel.add(btnWhlen, gbc_btnWhlen);
|
||||||
|
|
||||||
|
JPanel panel_3 = new JPanel();
|
||||||
|
tabbedPane.addTab("Inbetriebnahme", null, panel_3, null);
|
||||||
|
GridBagLayout gbl_panel_3 = new GridBagLayout();
|
||||||
|
gbl_panel_3.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_panel_3.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_panel_3.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_3.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel_3.setLayout(gbl_panel_3);
|
||||||
|
|
||||||
|
JPanel panel_4 = new JPanel();
|
||||||
|
panel_4.setBorder(new TitledBorder(null, "Echtzeituhr", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
||||||
|
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_4.gridx = 0;
|
||||||
|
gbc_panel_4.gridy = 0;
|
||||||
|
panel_3.add(panel_4, gbc_panel_4);
|
||||||
|
GridBagLayout gbl_panel_4 = new GridBagLayout();
|
||||||
|
gbl_panel_4.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gbl_panel_4.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_panel_4.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_4.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel_4.setLayout(gbl_panel_4);
|
||||||
|
|
||||||
|
JLabel lblAktuelleUhrzeitcomputer = new JLabel("Aktuelle Uhrzeit (Computer):");
|
||||||
|
GridBagConstraints gbc_lblAktuelleUhrzeitcomputer = new GridBagConstraints();
|
||||||
|
gbc_lblAktuelleUhrzeitcomputer.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAktuelleUhrzeitcomputer.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAktuelleUhrzeitcomputer.gridx = 0;
|
||||||
|
gbc_lblAktuelleUhrzeitcomputer.gridy = 0;
|
||||||
|
panel_4.add(lblAktuelleUhrzeitcomputer, gbc_lblAktuelleUhrzeitcomputer);
|
||||||
|
|
||||||
|
timeComputer = new JTextField();
|
||||||
|
GridBagConstraints gbc_timeComputer = new GridBagConstraints();
|
||||||
|
gbc_timeComputer.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_timeComputer.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_timeComputer.gridx = 1;
|
||||||
|
gbc_timeComputer.gridy = 0;
|
||||||
|
panel_4.add(timeComputer, gbc_timeComputer);
|
||||||
|
timeComputer.setColumns(10);
|
||||||
|
|
||||||
|
JLabel lblAktuelleUhrzeitsynololog = new JLabel("Aktuelle Uhrzeit (Synololog):");
|
||||||
|
GridBagConstraints gbc_lblAktuelleUhrzeitsynololog = new GridBagConstraints();
|
||||||
|
gbc_lblAktuelleUhrzeitsynololog.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAktuelleUhrzeitsynololog.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAktuelleUhrzeitsynololog.gridx = 0;
|
||||||
|
gbc_lblAktuelleUhrzeitsynololog.gridy = 1;
|
||||||
|
panel_4.add(lblAktuelleUhrzeitsynololog, gbc_lblAktuelleUhrzeitsynololog);
|
||||||
|
|
||||||
|
timeSynololog = new JTextField();
|
||||||
|
GridBagConstraints gbc_timeSynololog = new GridBagConstraints();
|
||||||
|
gbc_timeSynololog.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_timeSynololog.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_timeSynololog.gridx = 1;
|
||||||
|
gbc_timeSynololog.gridy = 1;
|
||||||
|
panel_4.add(timeSynololog, gbc_timeSynololog);
|
||||||
|
timeSynololog.setColumns(10);
|
||||||
|
|
||||||
|
JLabel lblTrimmungsynololog = new JLabel("Trimmung (Synololog):");
|
||||||
|
GridBagConstraints gbc_lblTrimmungsynololog = new GridBagConstraints();
|
||||||
|
gbc_lblTrimmungsynololog.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblTrimmungsynololog.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblTrimmungsynololog.gridx = 0;
|
||||||
|
gbc_lblTrimmungsynololog.gridy = 2;
|
||||||
|
panel_4.add(lblTrimmungsynololog, gbc_lblTrimmungsynololog);
|
||||||
|
|
||||||
|
spTrimm = new JSpinner();
|
||||||
|
spTrimm.setToolTipText("<html>\n<b>Trimmung</b><br/>\n<br/>\nDieser Wert korrigiert die Echtzeituhr des Synololog.<br/>\nPositive Werte beschleunigen, negative Werte verlangsamen die Echtzeituhr des Synololog.<br/>\n<br/>\nEinheit: <b>us / 1004ms</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_spTrimm = new GridBagConstraints();
|
||||||
|
gbc_spTrimm.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_spTrimm.gridx = 1;
|
||||||
|
gbc_spTrimm.gridy = 2;
|
||||||
|
panel_4.add(spTrimm, gbc_spTrimm);
|
||||||
|
|
||||||
|
debugPanel = new JPanel();
|
||||||
|
GridBagLayout gbl_debugPanel = new GridBagLayout();
|
||||||
|
gbl_debugPanel.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_debugPanel.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_debugPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_debugPanel.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
debugPanel.setLayout(gbl_debugPanel);
|
||||||
|
|
||||||
|
JPanel panel_5 = new JPanel();
|
||||||
|
GridBagConstraints gbc_panel_5 = new GridBagConstraints();
|
||||||
|
gbc_panel_5.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel_5.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_5.gridx = 0;
|
||||||
|
gbc_panel_5.gridy = 0;
|
||||||
|
debugPanel.add(panel_5, gbc_panel_5);
|
||||||
|
GridBagLayout gbl_panel_5 = new GridBagLayout();
|
||||||
|
gbl_panel_5.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
||||||
|
gbl_panel_5.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_panel_5.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_5.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel_5.setLayout(gbl_panel_5);
|
||||||
|
|
||||||
|
JButton btnUpdate = new JButton("Update...");
|
||||||
|
btnUpdate.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
readDebug();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
|
||||||
|
gbc_btnUpdate.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnUpdate.gridx = 0;
|
||||||
|
gbc_btnUpdate.gridy = 0;
|
||||||
|
panel_5.add(btnUpdate, gbc_btnUpdate);
|
||||||
|
|
||||||
|
JButton btnRamImage = new JButton("RAM Image...");
|
||||||
|
GridBagConstraints gbc_btnRamImage = new GridBagConstraints();
|
||||||
|
gbc_btnRamImage.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnRamImage.gridx = 1;
|
||||||
|
gbc_btnRamImage.gridy = 0;
|
||||||
|
panel_5.add(btnRamImage, gbc_btnRamImage);
|
||||||
|
|
||||||
|
JButton btnDumpSnapshots = new JButton("Dump Snapshots");
|
||||||
|
btnDumpSnapshots.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dumpSnapshots();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnDumpSnapshots = new GridBagConstraints();
|
||||||
|
gbc_btnDumpSnapshots.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnDumpSnapshots.gridx = 2;
|
||||||
|
gbc_btnDumpSnapshots.gridy = 0;
|
||||||
|
panel_5.add(btnDumpSnapshots, gbc_btnDumpSnapshots);
|
||||||
|
|
||||||
|
JButton btnResetDevice = new JButton("Reset Device");
|
||||||
|
btnResetDevice.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
doRESETDevice();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnResetDevice = new GridBagConstraints();
|
||||||
|
gbc_btnResetDevice.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnResetDevice.gridx = 3;
|
||||||
|
gbc_btnResetDevice.gridy = 0;
|
||||||
|
panel_5.add(btnResetDevice, gbc_btnResetDevice);
|
||||||
|
|
||||||
|
JButton btnRckDump = new JButton("RCK Dump");
|
||||||
|
btnRckDump.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
doRCKDump();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnRckDump = new GridBagConstraints();
|
||||||
|
gbc_btnRckDump.gridx = 4;
|
||||||
|
gbc_btnRckDump.gridy = 0;
|
||||||
|
panel_5.add(btnRckDump, gbc_btnRckDump);
|
||||||
|
btnRamImage.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
doRAMImage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tabbedPane.addTab("DEBUG", null, debugPanel, null);
|
||||||
|
|
||||||
|
JPanel panel_2 = new JPanel();
|
||||||
|
panel_2.setBorder(new TitledBorder(null, "Live Stats", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel_2 = new GridBagConstraints();
|
||||||
|
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_2.gridx = 0;
|
||||||
|
gbc_panel_2.gridy = 1;
|
||||||
|
debugPanel.add(panel_2, gbc_panel_2);
|
||||||
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
||||||
|
gbl_panel_2.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
||||||
|
gbl_panel_2.rowHeights = new int[]{0, 0, 0};
|
||||||
|
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel_2.setLayout(gbl_panel_2);
|
||||||
|
|
||||||
|
JLabel lblHeapEnd = new JLabel("HEAP END:");
|
||||||
|
GridBagConstraints gbc_lblHeapEnd = new GridBagConstraints();
|
||||||
|
gbc_lblHeapEnd.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblHeapEnd.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblHeapEnd.gridx = 0;
|
||||||
|
gbc_lblHeapEnd.gridy = 0;
|
||||||
|
panel_2.add(lblHeapEnd, gbc_lblHeapEnd);
|
||||||
|
|
||||||
|
lHeapDec = new JLabel("Heap Dec");
|
||||||
|
GridBagConstraints gbc_lHeapDec = new GridBagConstraints();
|
||||||
|
gbc_lHeapDec.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lHeapDec.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lHeapDec.gridx = 1;
|
||||||
|
gbc_lHeapDec.gridy = 0;
|
||||||
|
panel_2.add(lHeapDec, gbc_lHeapDec);
|
||||||
|
|
||||||
|
lHeapHex = new JLabel("HeapHex");
|
||||||
|
GridBagConstraints gbc_lHeapHex = new GridBagConstraints();
|
||||||
|
gbc_lHeapHex.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lHeapHex.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lHeapHex.gridx = 2;
|
||||||
|
gbc_lHeapHex.gridy = 0;
|
||||||
|
panel_2.add(lHeapHex, gbc_lHeapHex);
|
||||||
|
|
||||||
|
JLabel lblSysStackBottom = new JLabel("SYS STACK BOTTOM:");
|
||||||
|
GridBagConstraints gbc_lblSysStackBottom = new GridBagConstraints();
|
||||||
|
gbc_lblSysStackBottom.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblSysStackBottom.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblSysStackBottom.gridx = 0;
|
||||||
|
gbc_lblSysStackBottom.gridy = 1;
|
||||||
|
panel_2.add(lblSysStackBottom, gbc_lblSysStackBottom);
|
||||||
|
|
||||||
|
lSStackDec = new JLabel("Stack Dec");
|
||||||
|
GridBagConstraints gbc_lSStackDec = new GridBagConstraints();
|
||||||
|
gbc_lSStackDec.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lSStackDec.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lSStackDec.gridx = 1;
|
||||||
|
gbc_lSStackDec.gridy = 1;
|
||||||
|
panel_2.add(lSStackDec, gbc_lSStackDec);
|
||||||
|
|
||||||
|
lSStackHex = new JLabel("StackHex");
|
||||||
|
GridBagConstraints gbc_lSStackHex = new GridBagConstraints();
|
||||||
|
gbc_lSStackHex.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lSStackHex.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lSStackHex.gridx = 2;
|
||||||
|
gbc_lSStackHex.gridy = 1;
|
||||||
|
panel_2.add(lSStackHex, gbc_lSStackHex);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 2;
|
||||||
|
debugPanel.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
msgExc = new JEditorPane();
|
||||||
|
scrollPane.setViewportView(msgExc);
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
JPanel panel_1 = new JPanel();
|
||||||
contentPane.add(panel_1, BorderLayout.SOUTH);
|
contentPane.add(panel_1, BorderLayout.SOUTH);
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
|
@ -119,6 +389,7 @@ public class AppSettingsFrame extends JFrame {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
accept();
|
accept();
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
application().savePrefs();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_bOK = new GridBagConstraints();
|
GridBagConstraints gbc_bOK = new GridBagConstraints();
|
||||||
|
@ -134,14 +405,75 @@ public class AppSettingsFrame extends JFrame {
|
||||||
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
|
||||||
selectedSerialPort = pc2a.getSerialPort();
|
selectedSerialPort = pc2a.getSerialPort();
|
||||||
|
formerSerialPort = selectedSerialPort;
|
||||||
|
|
||||||
if (selectedSerialPort != null)
|
if (selectedSerialPort != null)
|
||||||
tfInterface.setText(selectedSerialPort.getPortName());
|
tfInterface.setText(selectedSerialPort.getPortName());
|
||||||
|
|
||||||
|
Integer trimmung = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x1002);
|
||||||
|
if (trimmung == null){
|
||||||
|
System.err.println("Trimmung konnte nicht gelesen werden!");
|
||||||
|
trimmung = 0;
|
||||||
|
spTrimm.setEnabled(false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
spTrimm.setValue(trimmung);
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = new Timer();
|
||||||
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Long deviceTimestamp;
|
||||||
|
Integer i;
|
||||||
|
i = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001C);
|
||||||
|
if (i != null){
|
||||||
|
deviceTimestamp = new Long(i);
|
||||||
|
|
||||||
|
calendar.setTimeInMillis(deviceTimestamp * 1000L);
|
||||||
|
timeSynololog.setText( sdf.format( calendar.getTime() ));
|
||||||
|
timeComputer.setText(sdf.format(new Date()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 500, 500);
|
||||||
|
|
||||||
|
for (int i=0;i<tabbedPane.getTabCount();i++){
|
||||||
|
Component c = tabbedPane.getComponentAt(i);
|
||||||
|
if (debugPanel.equals(c)){
|
||||||
|
tabbedPane.removeTabAt(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debugging(){
|
||||||
|
tabbedPane.addTab("DEBUG", null, debugPanel, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void accept(){
|
private PulsCounter2Application application(){
|
||||||
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
return PulsCounter2Application.getApplication();
|
||||||
pc2a.setSerialPort(selectedSerialPort);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void accept(){
|
||||||
|
try {
|
||||||
|
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x1002, (Integer)spTrimm.getValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formerSerialPort != selectedSerialPort){
|
||||||
|
application().setSerialPort(selectedSerialPort);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseSerialPort(){
|
private void chooseSerialPort(){
|
||||||
|
@ -153,7 +485,7 @@ public class AppSettingsFrame extends JFrame {
|
||||||
if (selectedSerialPort != null)
|
if (selectedSerialPort != null)
|
||||||
selectedPortName = selectedSerialPort.getPortName();
|
selectedPortName = selectedSerialPort.getPortName();
|
||||||
|
|
||||||
SerialPort sp = spc.execute(selectedPortName);
|
NewSerialPort sp = spc.execute(selectedPortName);
|
||||||
if (sp != null){
|
if (sp != null){
|
||||||
selectedSerialPort = sp;
|
selectedSerialPort = sp;
|
||||||
tfInterface.setText(sp.getPortName());
|
tfInterface.setText(sp.getPortName());
|
||||||
|
@ -161,5 +493,143 @@ public class AppSettingsFrame extends JFrame {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doRESETDevice(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
ServiceLink sl = pc2a.getServiceLink();
|
||||||
|
|
||||||
|
try {
|
||||||
|
sl.open();
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1001, 3);
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doRAMImage(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
ServiceLink sl = pc2a.getServiceLink();
|
||||||
|
|
||||||
|
try {
|
||||||
|
sl.open();
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x0004, 0xFF00A3);
|
||||||
|
|
||||||
|
Integer sp = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x0004);
|
||||||
|
System.err.println(String.format("SP readback: 0x%08x",sp));
|
||||||
|
|
||||||
|
File dump = new File("ram.bin");
|
||||||
|
FileOutputStream o = new FileOutputStream(dump);
|
||||||
|
|
||||||
|
for (int p=0;p<0x2100;p++){
|
||||||
|
if (p % 0x0010 == 0){
|
||||||
|
System.err.println(String.format("P: 0x%04x",p));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x00eb, (p));
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(2);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer i32 = sl.readInt(13, 0, 0x00ee);
|
||||||
|
|
||||||
|
o.write(i32 & 0xff);
|
||||||
|
/* o.write((i32>>8) & 0xff);
|
||||||
|
o.write((i32>>16) & 0xff);
|
||||||
|
o.write((i32>>24) & 0xff);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
o.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void readDebug(){
|
||||||
|
Integer v;
|
||||||
|
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
ServiceLink sl = pc2a.getServiceLink();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020);
|
||||||
|
if (v != null){
|
||||||
|
lHeapDec.setText(v.toString());
|
||||||
|
lHeapHex.setText(Integer.toHexString(v));
|
||||||
|
}
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021);
|
||||||
|
if (v != null){
|
||||||
|
lSStackDec.setText(v.toString());
|
||||||
|
lSStackHex.setText(Integer.toHexString(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
sb.append(e.toString());
|
||||||
|
e.printStackTrace(new PrintStream(out));
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
sb.append(out.toString());
|
||||||
|
|
||||||
|
msgExc.setText(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dumpSnapshots(){
|
||||||
|
SnapshotManager ssm = PulsCounter2Application.getApplication().getSnapshotManager();
|
||||||
|
|
||||||
|
for (int n=0;n<ssm.size();n++){
|
||||||
|
SnapShot ss = ssm.loadSnapShot(n);
|
||||||
|
System.err.println(ss.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void doRCKDump(){
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
ServiceLink sl = application().getServiceLink();
|
||||||
|
|
||||||
|
sb.append("Dumpink RCK EEPROM:\n");
|
||||||
|
|
||||||
|
for (int i=0x0004000;i<0x0005000;i+=4){
|
||||||
|
try {
|
||||||
|
sl.writeInt(13, 0, 0x9010, i);
|
||||||
|
} catch (Exception e){
|
||||||
|
sb.append(String.format("0x%08x failed [index] (%s).\n",i,e.toString()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Integer v = sl.readInt(13, 0, 0x9011);
|
||||||
|
sb.append(String.format("0x%08x: 0x%08x\n",i,v));
|
||||||
|
} catch (Exception e){
|
||||||
|
sb.append(String.format("0x%08x failed [read] (%s).\n",i,e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msgExc.setText(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.hwo.pulscounter.ui;
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
import org.hwo.io.servicelink.ServiceLink;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
|
|
||||||
public interface AppSettingsListener {
|
public interface AppSettingsListener {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.ExportSetting;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
|
import org.hwo.pulscounter.SnapshotManager.Notification;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
|
public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
|
|
||||||
|
public PulsCounter2Application application(){
|
||||||
|
return PulsCounter2Application.getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BatchRunner(){
|
||||||
|
|
||||||
|
application().addPulsCounterApplicationListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(){
|
||||||
|
try {
|
||||||
|
application().getServiceLink().open();
|
||||||
|
|
||||||
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
application().getSnapshotManager().doFullSync();
|
||||||
|
|
||||||
|
for (ExportSetting es: application().getExportSettings()){
|
||||||
|
if (es.getAutostart()){
|
||||||
|
es.export();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
application().shutdown();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialPortChanged() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionStateChanged(Boolean connected) {
|
||||||
|
if (connected){
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String message) {
|
||||||
|
System.err.println(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,278 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.InputVerifier;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFormattedTextField;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import java.awt.Font;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
public class ChannelDisplay extends JPanel {
|
||||||
|
private JTextField tfCounter;
|
||||||
|
private JTextField tfAnalog;
|
||||||
|
|
||||||
|
|
||||||
|
private ImageIcon iconEactive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_e_aktiv.png"));
|
||||||
|
private ImageIcon iconEpassive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_e_passiv.png"));
|
||||||
|
private ImageIcon iconAactive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_a_aktiv.png"));
|
||||||
|
private ImageIcon iconApassive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_a_passiv.png"));
|
||||||
|
private ImageIcon iconPactive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_p2_aktiv.png"));
|
||||||
|
private ImageIcon iconPpassive = new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_p2_passiv.png"));
|
||||||
|
|
||||||
|
private boolean input,output,pullup;
|
||||||
|
private Integer counter;
|
||||||
|
private Double voltage;
|
||||||
|
|
||||||
|
private boolean isAnalog;
|
||||||
|
private JLabel lblP;
|
||||||
|
private JLabel lblA;
|
||||||
|
private JLabel lblE;
|
||||||
|
private JLabel lblChannelName;
|
||||||
|
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
private JPopupMenu popupMenu;
|
||||||
|
private List<ChannelDisplayListener> channelDisplayListeners;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
public ChannelDisplay() {
|
||||||
|
setBackground(Color.GRAY);
|
||||||
|
setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||||
|
setSize(260, 64);
|
||||||
|
setMinimumSize(new Dimension(160,64));
|
||||||
|
|
||||||
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
|
||||||
|
gridBagLayout.rowHeights = new int[]{0, 0, 0};
|
||||||
|
gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gridBagLayout.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
|
lblChannelName = new JLabel("XXX");
|
||||||
|
lblChannelName.setToolTipText("<html>\n<b>Kanal</b><br/>\n<br/>\nDies ist die Nummer des Kanals\n</html>");
|
||||||
|
lblChannelName.setFont(new Font("DejaVu Sans", Font.PLAIN, 20));
|
||||||
|
lblChannelName.setSize(new Dimension(48, 24));
|
||||||
|
GridBagConstraints gbc_lblChannelName = new GridBagConstraints();
|
||||||
|
gbc_lblChannelName.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblChannelName.gridx = 0;
|
||||||
|
gbc_lblChannelName.gridy = 0;
|
||||||
|
add(lblChannelName, gbc_lblChannelName);
|
||||||
|
|
||||||
|
lblE = new JLabel("");
|
||||||
|
lblE.setToolTipText("<html>\n<b>Eingang</b><br/>\n<br/>\nzeigt den digitalen Status der Eingangsmessung\n</html>");
|
||||||
|
lblE.setMinimumSize(new Dimension(24, 24));
|
||||||
|
lblE.setMaximumSize(new Dimension(24, 24));
|
||||||
|
lblE.setIcon(new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_e_passiv.png")));
|
||||||
|
lblE.setPreferredSize(new Dimension(24, 24));
|
||||||
|
GridBagConstraints gbc_lblE = new GridBagConstraints();
|
||||||
|
gbc_lblE.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblE.gridx = 1;
|
||||||
|
gbc_lblE.gridy = 0;
|
||||||
|
add(lblE, gbc_lblE);
|
||||||
|
|
||||||
|
lblP = new JLabel("");
|
||||||
|
lblP.setToolTipText("<html>\n<b>PullUp Widerstand</b><br/>\n<br/>\nZeigt an, ob der PullUp-Widerstand für diesen Kanal eingeschaltet ist.\n</html>");
|
||||||
|
lblP.setMaximumSize(new Dimension(24, 24));
|
||||||
|
lblP.setMinimumSize(new Dimension(24, 24));
|
||||||
|
lblP.setIcon(new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_p_passiv.png")));
|
||||||
|
lblP.setPreferredSize(new Dimension(24, 24));
|
||||||
|
GridBagConstraints gbc_lblP = new GridBagConstraints();
|
||||||
|
gbc_lblP.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblP.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblP.gridx = 2;
|
||||||
|
gbc_lblP.gridy = 0;
|
||||||
|
add(lblP, gbc_lblP);
|
||||||
|
|
||||||
|
tfCounter = new JTextField();
|
||||||
|
tfCounter.setToolTipText("<html>\n<b>Zählerstand</b><br/>\n<br/>\nZeigt den aktuellen Zählerstand dieses Kanals.\n</html>");
|
||||||
|
tfCounter.setEditable(false);
|
||||||
|
tfCounter.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||||
|
tfCounter.setMinimumSize(new Dimension(100, 19));
|
||||||
|
tfCounter.setFont(new Font("DejaVu Sans", Font.PLAIN, 12));
|
||||||
|
tfCounter.setInheritsPopupMenu(true);
|
||||||
|
GridBagConstraints gbc_tfCounter = new GridBagConstraints();
|
||||||
|
gbc_tfCounter.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tfCounter.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfCounter.gridx = 3;
|
||||||
|
gbc_tfCounter.gridy = 0;
|
||||||
|
add(tfCounter, gbc_tfCounter);
|
||||||
|
tfCounter.setColumns(10);
|
||||||
|
|
||||||
|
lblA = new JLabel("");
|
||||||
|
lblA.setToolTipText("<html>\n<b>Ausgang</b><br/>\n<br/>\nZeigt, ob die Ausgangsschaltung für diesen Kanal aktiv ist.\n</html>");
|
||||||
|
lblA.setIcon(new ImageIcon(ChannelDisplay.class.getResource("/org/hwo/pulscounter/ui/sym_a_passiv.png")));
|
||||||
|
lblA.setPreferredSize(new Dimension(24, 24));
|
||||||
|
GridBagConstraints gbc_lblA = new GridBagConstraints();
|
||||||
|
gbc_lblA.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblA.gridx = 2;
|
||||||
|
gbc_lblA.gridy = 1;
|
||||||
|
add(lblA, gbc_lblA);
|
||||||
|
|
||||||
|
tfAnalog = new JTextField();
|
||||||
|
tfAnalog.setToolTipText("<html>\n<b>Analog Messwert</b><br/>\n<br/>\nZeigt die an diesem Kanal gemessene Spannung.\n</html>");
|
||||||
|
tfAnalog.setEditable(false);
|
||||||
|
tfAnalog.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||||
|
tfAnalog.setInheritsPopupMenu(true);
|
||||||
|
GridBagConstraints gbc_tfAnalog = new GridBagConstraints();
|
||||||
|
gbc_tfAnalog.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfAnalog.gridx = 3;
|
||||||
|
gbc_tfAnalog.gridy = 1;
|
||||||
|
add(tfAnalog, gbc_tfAnalog);
|
||||||
|
tfAnalog.setColumns(10);
|
||||||
|
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
|
||||||
|
channelDisplayListeners = new LinkedList<ChannelDisplayListener>();
|
||||||
|
|
||||||
|
popupMenu = new JPopupMenu("");
|
||||||
|
setComponentPopupMenu(popupMenu);
|
||||||
|
|
||||||
|
JMenuItem mi = new JMenuItem("Zurücksetzen");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
fireChannelDisplayReset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(mi);
|
||||||
|
popupMenu.addSeparator();
|
||||||
|
|
||||||
|
JLabel l = new JLabel("Setzen:");
|
||||||
|
popupMenu.add(l);
|
||||||
|
|
||||||
|
final JFormattedTextField tf = new JFormattedTextField(NumberFormat.getIntegerInstance());
|
||||||
|
tf.setText("0");
|
||||||
|
tf.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
fireChannelDisplaySet(((Long)tf.getValue()).intValue());
|
||||||
|
popupMenu.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
popupMenu.add(tf);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setToolTipText(String text) {
|
||||||
|
super.setToolTipText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addChannelDisplayListener(ChannelDisplayListener listener){
|
||||||
|
channelDisplayListeners.add(listener);
|
||||||
|
}
|
||||||
|
public void removeChannelDisplayListener(ChannelDisplayListener listener){
|
||||||
|
channelDisplayListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireChannelDisplayReset(){
|
||||||
|
for (ChannelDisplayListener l:channelDisplayListeners){
|
||||||
|
l.reset(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void fireChannelDisplaySet(int setValue){
|
||||||
|
for (ChannelDisplayListener l:channelDisplayListeners){
|
||||||
|
l.set(this, setValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalog(boolean isAnalog) {
|
||||||
|
this.isAnalog = isAnalog;
|
||||||
|
tfAnalog.setVisible(isAnalog);
|
||||||
|
}
|
||||||
|
public boolean isAnalog() {
|
||||||
|
return isAnalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPullup(boolean pullup) {
|
||||||
|
this.pullup = pullup;
|
||||||
|
if (pullup){
|
||||||
|
lblP.setIcon(iconPactive);
|
||||||
|
} else {
|
||||||
|
lblP.setIcon(iconPpassive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean isPullup() {
|
||||||
|
return pullup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(boolean input) {
|
||||||
|
this.input = input;
|
||||||
|
if (input){
|
||||||
|
lblE.setIcon(iconEactive);
|
||||||
|
} else {
|
||||||
|
lblE.setIcon(iconEpassive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean isInput() {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutput(boolean output) {
|
||||||
|
this.output = output;
|
||||||
|
if (output){
|
||||||
|
lblA.setIcon(iconAactive);
|
||||||
|
} else {
|
||||||
|
lblA.setIcon(iconApassive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean isOutput() {
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCounter() {
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
public void setCounter(Integer counter) {
|
||||||
|
this.counter = counter;
|
||||||
|
tfCounter.setText(String.format("%d", counter));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getVoltage() {
|
||||||
|
return voltage;
|
||||||
|
}
|
||||||
|
public void setVoltage(Double voltage) {
|
||||||
|
this.voltage = voltage;
|
||||||
|
tfAnalog.setText(String.format("%.02f V",voltage));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelName(String channelName) {
|
||||||
|
this.channelName = channelName;
|
||||||
|
lblChannelName.setText(channelName);
|
||||||
|
}
|
||||||
|
public String getChannelName() {
|
||||||
|
return channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
public interface ChannelDisplayListener {
|
||||||
|
|
||||||
|
public void reset (ChannelDisplay sender);
|
||||||
|
public void set (ChannelDisplay sender,int setValue);
|
||||||
|
|
||||||
|
}
|
|
@ -1,302 +0,0 @@
|
||||||
package org.hwo.pulscounter.ui;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
|
|
||||||
import javax.swing.border.TitledBorder;
|
|
||||||
|
|
||||||
import java.awt.Insets;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
|
|
||||||
import org.hwo.datetime.Date;
|
|
||||||
import org.hwo.pulscounter.PulsCounter;
|
|
||||||
import org.hwo.pulscounter.elements.WorkShift;
|
|
||||||
import org.hwo.pulscounter.elements.WorkShiftRecord;
|
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
import javax.swing.JTable;
|
|
||||||
|
|
||||||
import org.hwo.ui.FlexibleJTable;
|
|
||||||
import org.hwo.ui.JComboBoxEx;
|
|
||||||
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
|
|
||||||
public class CheckWorkshiftRecords extends JFrame {
|
|
||||||
|
|
||||||
private Date selectedDate;
|
|
||||||
private WorkShiftRecord selectedWorkShift;
|
|
||||||
|
|
||||||
|
|
||||||
private JPanel contentPane;
|
|
||||||
private JTextField tfDatum;
|
|
||||||
private JComboBox cbWorkShift;
|
|
||||||
private JTextField tfBegins;
|
|
||||||
private JTextField tfEnds;
|
|
||||||
private FlexibleJTable<WorkShiftRecord.ChannelRecords.ChannelRecord> flexibleJTable;
|
|
||||||
private JComboBoxEx cbChannel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
CheckWorkshiftRecords frame = new CheckWorkshiftRecords();
|
|
||||||
frame.setVisible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the frame.
|
|
||||||
*/
|
|
||||||
public CheckWorkshiftRecords() {
|
|
||||||
setTitle("Schichtdaten prüfen");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setBounds(100, 100, 938, 686);
|
|
||||||
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};
|
|
||||||
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0};
|
|
||||||
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
||||||
contentPane.setLayout(gbl_contentPane);
|
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setBorder(new TitledBorder(null, "Auswahl", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
||||||
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;
|
|
||||||
contentPane.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, 0};
|
|
||||||
gbl_panel.columnWeights = new double[]{0.0, 1.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
||||||
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
||||||
panel.setLayout(gbl_panel);
|
|
||||||
|
|
||||||
JLabel lblDatum = new JLabel("Datum:");
|
|
||||||
GridBagConstraints gbc_lblDatum = new GridBagConstraints();
|
|
||||||
gbc_lblDatum.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_lblDatum.anchor = GridBagConstraints.EAST;
|
|
||||||
gbc_lblDatum.gridx = 0;
|
|
||||||
gbc_lblDatum.gridy = 0;
|
|
||||||
panel.add(lblDatum, gbc_lblDatum);
|
|
||||||
|
|
||||||
tfDatum = new JTextField();
|
|
||||||
tfDatum.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Date d = new Date();
|
|
||||||
d.fromSQLDate(tfDatum.getText());
|
|
||||||
selectDatum(d);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_tfDatum = new GridBagConstraints();
|
|
||||||
gbc_tfDatum.gridwidth = 2;
|
|
||||||
gbc_tfDatum.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_tfDatum.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_tfDatum.gridx = 1;
|
|
||||||
gbc_tfDatum.gridy = 0;
|
|
||||||
panel.add(tfDatum, gbc_tfDatum);
|
|
||||||
tfDatum.setColumns(10);
|
|
||||||
|
|
||||||
JButton btnGestern = new JButton("GESTERN");
|
|
||||||
btnGestern.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Date d = new Date();
|
|
||||||
d.addDays(-1);
|
|
||||||
selectDatum(d);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JButton btnHeute = new JButton("HEUTE");
|
|
||||||
btnHeute.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
selectDatum(new Date());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnHeute = new GridBagConstraints();
|
|
||||||
gbc_btnHeute.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_btnHeute.gridx = 3;
|
|
||||||
gbc_btnHeute.gridy = 0;
|
|
||||||
panel.add(btnHeute, gbc_btnHeute);
|
|
||||||
GridBagConstraints gbc_btnGestern = new GridBagConstraints();
|
|
||||||
gbc_btnGestern.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnGestern.gridx = 4;
|
|
||||||
gbc_btnGestern.gridy = 0;
|
|
||||||
panel.add(btnGestern, gbc_btnGestern);
|
|
||||||
|
|
||||||
JLabel lblSchicht = new JLabel("Schicht:");
|
|
||||||
GridBagConstraints gbc_lblSchicht = new GridBagConstraints();
|
|
||||||
gbc_lblSchicht.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_lblSchicht.gridx = 0;
|
|
||||||
gbc_lblSchicht.gridy = 1;
|
|
||||||
panel.add(lblSchicht, gbc_lblSchicht);
|
|
||||||
|
|
||||||
cbWorkShift = new JComboBox();
|
|
||||||
cbWorkShift.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
selectionChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_cbWorkShift = new GridBagConstraints();
|
|
||||||
gbc_cbWorkShift.gridwidth = 2;
|
|
||||||
gbc_cbWorkShift.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_cbWorkShift.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_cbWorkShift.gridx = 1;
|
|
||||||
gbc_cbWorkShift.gridy = 1;
|
|
||||||
panel.add(cbWorkShift, gbc_cbWorkShift);
|
|
||||||
|
|
||||||
JLabel lblSchichtgrenzen = new JLabel("Schichtgrenzen:");
|
|
||||||
GridBagConstraints gbc_lblSchichtgrenzen = new GridBagConstraints();
|
|
||||||
gbc_lblSchichtgrenzen.anchor = GridBagConstraints.EAST;
|
|
||||||
gbc_lblSchichtgrenzen.insets = new Insets(0, 0, 0, 5);
|
|
||||||
gbc_lblSchichtgrenzen.gridx = 0;
|
|
||||||
gbc_lblSchichtgrenzen.gridy = 2;
|
|
||||||
panel.add(lblSchichtgrenzen, gbc_lblSchichtgrenzen);
|
|
||||||
|
|
||||||
tfBegins = new JTextField();
|
|
||||||
GridBagConstraints gbc_tfBegins = new GridBagConstraints();
|
|
||||||
gbc_tfBegins.insets = new Insets(0, 0, 0, 5);
|
|
||||||
gbc_tfBegins.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_tfBegins.gridx = 1;
|
|
||||||
gbc_tfBegins.gridy = 2;
|
|
||||||
panel.add(tfBegins, gbc_tfBegins);
|
|
||||||
tfBegins.setColumns(10);
|
|
||||||
|
|
||||||
tfEnds = new JTextField();
|
|
||||||
tfEnds.setColumns(10);
|
|
||||||
GridBagConstraints gbc_tfEnds = new GridBagConstraints();
|
|
||||||
gbc_tfEnds.insets = new Insets(0, 0, 0, 5);
|
|
||||||
gbc_tfEnds.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_tfEnds.gridx = 2;
|
|
||||||
gbc_tfEnds.gridy = 2;
|
|
||||||
panel.add(tfEnds, gbc_tfEnds);
|
|
||||||
|
|
||||||
JPanel panel_2 = new JPanel();
|
|
||||||
panel_2.setBorder(new TitledBorder(null, "Kanal", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
||||||
GridBagConstraints gbc_panel_2 = new GridBagConstraints();
|
|
||||||
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_panel_2.gridx = 0;
|
|
||||||
gbc_panel_2.gridy = 1;
|
|
||||||
contentPane.add(panel_2, gbc_panel_2);
|
|
||||||
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
|
||||||
gbl_panel_2.columnWidths = new int[]{0, 0};
|
|
||||||
gbl_panel_2.rowHeights = new int[]{0, 0};
|
|
||||||
gbl_panel_2.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
||||||
panel_2.setLayout(gbl_panel_2);
|
|
||||||
|
|
||||||
cbChannel = new JComboBoxEx();
|
|
||||||
cbChannel.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
selectChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
GridBagConstraints gbc_cbChannel = new GridBagConstraints();
|
|
||||||
gbc_cbChannel.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_cbChannel.gridx = 0;
|
|
||||||
gbc_cbChannel.gridy = 0;
|
|
||||||
panel_2.add(cbChannel, gbc_cbChannel);
|
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
|
||||||
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
|
||||||
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_panel_1.gridx = 0;
|
|
||||||
gbc_panel_1.gridy = 2;
|
|
||||||
contentPane.add(panel_1, gbc_panel_1);
|
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
|
||||||
gbl_panel_1.columnWidths = new int[]{0, 0};
|
|
||||||
gbl_panel_1.rowHeights = new int[]{0, 0};
|
|
||||||
gbl_panel_1.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
gbl_panel_1.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
panel_1.setLayout(gbl_panel_1);
|
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_scrollPane.gridx = 0;
|
|
||||||
gbc_scrollPane.gridy = 0;
|
|
||||||
panel_1.add(scrollPane, gbc_scrollPane);
|
|
||||||
|
|
||||||
flexibleJTable = new FlexibleJTable(WorkShiftRecord.ChannelRecords.ChannelRecord.class);
|
|
||||||
scrollPane.setViewportView(flexibleJTable);
|
|
||||||
|
|
||||||
this.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void initialize(){
|
|
||||||
for (WorkShift shift: PulsCounter.getInspectorApplication().getWorkShifts()){
|
|
||||||
cbWorkShift.addItem(shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
flexibleJTable.addColumn("timestamp");
|
|
||||||
flexibleJTable.addColumn("value");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
selectDatum(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectDatum(Date date){
|
|
||||||
tfDatum.setText(date.getSQLDate());
|
|
||||||
selectedDate = date;
|
|
||||||
|
|
||||||
selectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectionChanged(){
|
|
||||||
if (cbWorkShift.getSelectedItem()==null)
|
|
||||||
return;
|
|
||||||
if (selectedDate == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
WorkShift shift = (WorkShift)cbWorkShift.getSelectedItem();
|
|
||||||
|
|
||||||
tfBegins.setText(shift.getShiftBegins(selectedDate).getSQLDateTime());
|
|
||||||
tfEnds.setText(shift.getShiftEnds(selectedDate).getSQLDateTime());
|
|
||||||
|
|
||||||
WorkShiftRecord workShiftRecord = new WorkShiftRecord(shift, selectedDate);
|
|
||||||
|
|
||||||
selectedWorkShift = null;
|
|
||||||
|
|
||||||
flexibleJTable.setRows(new LinkedList<WorkShiftRecord.ChannelRecords.ChannelRecord>());
|
|
||||||
cbChannel.setItems(workShiftRecord.getChannels());
|
|
||||||
|
|
||||||
selectedWorkShift = workShiftRecord;
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectChannel(){
|
|
||||||
if (selectedWorkShift != null){
|
|
||||||
Integer ch = (Integer)cbChannel.getSelectedItem();
|
|
||||||
flexibleJTable.setRows(selectedWorkShift.getChannelRecords(ch).getRecords());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,508 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.hwo.servicelink.ServiceLink;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
import org.hwo.bitfields.BitField;
|
||||||
|
import org.hwo.bitfields.Field;
|
||||||
|
import org.hwo.bitfields.ui.BitFieldEditor;
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.ui.JTimeSpanEditor;
|
||||||
|
import java.awt.event.FocusAdapter;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
|
||||||
|
public class DeviceConfiguration extends JFrame {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
|
||||||
|
int currentChannel;
|
||||||
|
private BitFieldEditor bfeIntervall;
|
||||||
|
private JTimeSpanEditor tseI3;
|
||||||
|
private JTimeSpanEditor tseI2;
|
||||||
|
private JTimeSpanEditor tseI1;
|
||||||
|
private JTimeSpanEditor tseI0;
|
||||||
|
|
||||||
|
private TableMapper tmSettings;
|
||||||
|
|
||||||
|
int outputs,
|
||||||
|
pullups,
|
||||||
|
inverts,
|
||||||
|
trigger;
|
||||||
|
|
||||||
|
int[] filter,
|
||||||
|
windows;
|
||||||
|
private JTable tSettings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public DeviceConfiguration() {
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 860, 498);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
setContentPane(contentPane);
|
||||||
|
GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||||
|
gbl_contentPane.columnWidths = new int[] {30, 0, 0};
|
||||||
|
gbl_contentPane.rowHeights = new int[] {183, 0};
|
||||||
|
gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0};
|
||||||
|
gbl_contentPane.rowWeights = new double[]{1.0, 0.0};
|
||||||
|
contentPane.setLayout(gbl_contentPane);
|
||||||
|
|
||||||
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
|
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
|
||||||
|
gbc_tabbedPane.gridwidth = 3;
|
||||||
|
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tabbedPane.gridx = 0;
|
||||||
|
gbc_tabbedPane.gridy = 0;
|
||||||
|
contentPane.add(tabbedPane, gbc_tabbedPane);
|
||||||
|
|
||||||
|
JPanel panel_2 = new JPanel();
|
||||||
|
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};
|
||||||
|
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, Double.MIN_VALUE};
|
||||||
|
panel_2.setLayout(gbl_panel_2);
|
||||||
|
|
||||||
|
bfeIntervall = new BitFieldEditor();
|
||||||
|
bfeIntervall.setToolTipText("<html>\n<b>Tagesbasierte Intervalle</b><br/>\n<br/>\nTagesbasierte Intervalle werden immer auf 0:00:00 Uhr des aktuellen Tages bezogen ausgeführt.<br/>\nDies ermöglicht nicht nur eine Regelmäßige Aufzeichnung, sondern erzwingt auch eine Aufzeichnung<br/>\nin einem festgelegten immer gleichen Raster.<br/>\n<br/>\nNicht tageszeitbasierte Intervalle werden mit Bezug auf den 1.1.1970 0:00:00 Uhr ausgeführt.<br/>\nDiese ermöglichen eine stete regelmäßige Aufzeichnung bei der die tageszeit ignoriert wird.\n</html>");
|
||||||
|
bfeIntervall.addChangeListener(new ChangeListener() {
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
int v = bfeIntervall.getIntValue();
|
||||||
|
tseI0.setDaysEnabled(((v & 0x01)==0));
|
||||||
|
tseI1.setDaysEnabled(((v & 0x02)==0));
|
||||||
|
tseI2.setDaysEnabled(((v & 0x04)==0));
|
||||||
|
tseI3.setDaysEnabled(((v & 0x08)==0));
|
||||||
|
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JLabel lblTageszeitabhngigkeit = new JLabel("Tageszeitabhängigkeit:");
|
||||||
|
GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints();
|
||||||
|
gbc_lblTageszeitabhngigkeit.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblTageszeitabhngigkeit.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblTageszeitabhngigkeit.gridx = 0;
|
||||||
|
gbc_lblTageszeitabhngigkeit.gridy = 0;
|
||||||
|
panel_2.add(lblTageszeitabhngigkeit, gbc_lblTageszeitabhngigkeit);
|
||||||
|
GridBagConstraints gbc_bfeIntervall = new GridBagConstraints();
|
||||||
|
gbc_bfeIntervall.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_bfeIntervall.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_bfeIntervall.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_bfeIntervall.gridx = 1;
|
||||||
|
gbc_bfeIntervall.gridy = 0;
|
||||||
|
panel_2.add(bfeIntervall, gbc_bfeIntervall);
|
||||||
|
|
||||||
|
JLabel lblIntervall = new JLabel("Intervall 0:");
|
||||||
|
lblIntervall.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_lblIntervall = new GridBagConstraints();
|
||||||
|
gbc_lblIntervall.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblIntervall.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblIntervall.gridx = 0;
|
||||||
|
gbc_lblIntervall.gridy = 1;
|
||||||
|
panel_2.add(lblIntervall, gbc_lblIntervall);
|
||||||
|
|
||||||
|
tseI0 = new JTimeSpanEditor();
|
||||||
|
tseI0.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
tseI0.addFocusListener(new FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
System.err.println("FOCUS LOST 0");
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1010, (Integer)tseI0.getValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_tseI0 = new GridBagConstraints();
|
||||||
|
gbc_tseI0.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_tseI0.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tseI0.gridx = 1;
|
||||||
|
gbc_tseI0.gridy = 1;
|
||||||
|
panel_2.add(tseI0, gbc_tseI0);
|
||||||
|
|
||||||
|
JLabel lblIntervall_1 = new JLabel("Intervall 1:");
|
||||||
|
lblIntervall_1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints();
|
||||||
|
gbc_lblIntervall_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblIntervall_1.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblIntervall_1.gridx = 0;
|
||||||
|
gbc_lblIntervall_1.gridy = 2;
|
||||||
|
panel_2.add(lblIntervall_1, gbc_lblIntervall_1);
|
||||||
|
|
||||||
|
tseI1 = new JTimeSpanEditor();
|
||||||
|
tseI1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
tseI1.addFocusListener(new FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1011, (Integer)tseI1.getValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_tseI1 = new GridBagConstraints();
|
||||||
|
gbc_tseI1.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_tseI1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tseI1.gridx = 1;
|
||||||
|
gbc_tseI1.gridy = 2;
|
||||||
|
panel_2.add(tseI1, gbc_tseI1);
|
||||||
|
|
||||||
|
JLabel lblIntervall_2 = new JLabel("Intervall 2:");
|
||||||
|
lblIntervall_2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_lblIntervall_2 = new GridBagConstraints();
|
||||||
|
gbc_lblIntervall_2.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblIntervall_2.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblIntervall_2.gridx = 0;
|
||||||
|
gbc_lblIntervall_2.gridy = 3;
|
||||||
|
panel_2.add(lblIntervall_2, gbc_lblIntervall_2);
|
||||||
|
|
||||||
|
tseI2 = new JTimeSpanEditor();
|
||||||
|
tseI2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
tseI2.addFocusListener(new FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1012, (Integer)tseI2.getValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_tseI2 = new GridBagConstraints();
|
||||||
|
gbc_tseI2.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_tseI2.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tseI2.gridx = 1;
|
||||||
|
gbc_tseI2.gridy = 3;
|
||||||
|
panel_2.add(tseI2, gbc_tseI2);
|
||||||
|
|
||||||
|
JLabel lblIntervall_3 = new JLabel("Intervall 3:");
|
||||||
|
lblIntervall_3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_lblIntervall_3 = new GridBagConstraints();
|
||||||
|
gbc_lblIntervall_3.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblIntervall_3.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblIntervall_3.gridx = 0;
|
||||||
|
gbc_lblIntervall_3.gridy = 4;
|
||||||
|
panel_2.add(lblIntervall_3, gbc_lblIntervall_3);
|
||||||
|
|
||||||
|
tseI3 = new JTimeSpanEditor();
|
||||||
|
tseI3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
|
tseI3.addFocusListener(new FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1013, (Integer)tseI3.getValue());
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_tseI3 = new GridBagConstraints();
|
||||||
|
gbc_tseI3.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_tseI3.gridx = 1;
|
||||||
|
gbc_tseI3.gridy = 4;
|
||||||
|
panel_2.add(tseI3, gbc_tseI3);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
tabbedPane.addTab("Kanäle", null, panel_1, null);
|
||||||
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
|
gbl_panel_1.columnWidths = new int[] {100};
|
||||||
|
gbl_panel_1.rowHeights = new int[] {30};
|
||||||
|
gbl_panel_1.columnWeights = new double[]{1.0};
|
||||||
|
gbl_panel_1.rowWeights = new double[]{1.0};
|
||||||
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 0;
|
||||||
|
panel_1.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
tSettings = new JTable();
|
||||||
|
tSettings.setRowHeight(32);
|
||||||
|
tSettings.setFillsViewportHeight(true);
|
||||||
|
tSettings.setCellSelectionEnabled(true);
|
||||||
|
scrollPane.setViewportView(tSettings);
|
||||||
|
|
||||||
|
JButton btnSchliessen = new JButton("abbrechen");
|
||||||
|
btnSchliessen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton btnOk = new JButton("OK");
|
||||||
|
btnOk.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
writeDevice();
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnOk = new GridBagConstraints();
|
||||||
|
gbc_btnOk.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_btnOk.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnOk.gridx = 1;
|
||||||
|
gbc_btnOk.gridy = 1;
|
||||||
|
contentPane.add(btnOk, gbc_btnOk);
|
||||||
|
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
||||||
|
gbc_btnSchliessen.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_btnSchliessen.gridx = 2;
|
||||||
|
gbc_btnSchliessen.gridy = 1;
|
||||||
|
contentPane.add(btnSchliessen, gbc_btnSchliessen);
|
||||||
|
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer intOr0(Integer i){
|
||||||
|
if (i==null)
|
||||||
|
return 0;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
currentChannel = -1;
|
||||||
|
filter = new int[32];
|
||||||
|
windows = new int[32];
|
||||||
|
tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
|
||||||
|
|
||||||
|
BitField bf = new BitField();
|
||||||
|
bf.clear();
|
||||||
|
bf.addField(new Field(bf, 0, 1, "Intervall 0 basiert auf Tageszeit"));
|
||||||
|
bf.addField(new Field(bf, 1, 1, "Intervall 1 basiert auf Tageszeit"));
|
||||||
|
bf.addField(new Field(bf, 2, 1, "Intervall 2 basiert auf Tageszeit"));
|
||||||
|
bf.addField(new Field(bf, 3, 1, "Intervall 3 basiert auf Tageszeit"));
|
||||||
|
bfeIntervall.setBitField(bf);
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
tmSettings.addRow(new ChannelConfiguration(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
readDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readDevice(){
|
||||||
|
Integer v;
|
||||||
|
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
|
||||||
|
outputs = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1008));
|
||||||
|
pullups = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1009));
|
||||||
|
inverts = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100A));
|
||||||
|
trigger = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100B));
|
||||||
|
|
||||||
|
bfeIntervall.setIntValue(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1003));
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
filter[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1020 + i));
|
||||||
|
windows[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1280 + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1010);
|
||||||
|
if (v!=null){
|
||||||
|
tseI0.setValue(v);
|
||||||
|
}
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1011);
|
||||||
|
if (v!=null){
|
||||||
|
tseI1.setValue(v);
|
||||||
|
}
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1012);
|
||||||
|
if (v!=null){
|
||||||
|
tseI2.setValue(v);
|
||||||
|
}
|
||||||
|
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1013);
|
||||||
|
if (v!=null){
|
||||||
|
tseI3.setValue(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeDevice(){
|
||||||
|
ServiceLink sl = PulsCounter2Application.getApplication().getServiceLink();
|
||||||
|
try {
|
||||||
|
sl.writeInt(13, 0, 0x1008, outputs);
|
||||||
|
sl.writeInt(13, 0, 0x1009, pullups);
|
||||||
|
sl.writeInt(13, 0, 0x100A, inverts);
|
||||||
|
sl.writeInt(13, 0, 0x100B, trigger);
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
sl.writeInt(13, 0, 0x1020 + i, filter[i]);
|
||||||
|
sl.writeInt(13, 0, 0x1280 + i, windows[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sl.writeInt(13, 0, 0x1010, tseI0.getValue());
|
||||||
|
sl.writeInt(13, 0, 0x1011, tseI1.getValue());
|
||||||
|
sl.writeInt(13, 0, 0x1012, tseI2.getValue());
|
||||||
|
sl.writeInt(13, 0, 0x1013, tseI3.getValue());
|
||||||
|
|
||||||
|
/* Konfiguration auf Live-System übertragen */
|
||||||
|
sl.writeInt(13, 0, 0x1001, 1);
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChannelConfiguration{
|
||||||
|
|
||||||
|
int channel;
|
||||||
|
|
||||||
|
public ChannelConfiguration(int channel) {
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Channel",width=80,order=0)
|
||||||
|
public int getChannel(){
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Ausgang",width=80,order=10)
|
||||||
|
public Boolean getOutput(){
|
||||||
|
return (outputs & 1<<channel) == 0 ? false : true;
|
||||||
|
}
|
||||||
|
public void setOutput(Boolean value){
|
||||||
|
outputs &= ~(1<<channel);
|
||||||
|
if (value){
|
||||||
|
outputs |= (1<<channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Passiver Schalter",width=80,order=20)
|
||||||
|
public Boolean getPullup(){
|
||||||
|
return (pullups & 1<<channel) == 0 ? false : true;
|
||||||
|
}
|
||||||
|
public void setPullup(Boolean value){
|
||||||
|
pullups &= ~(1<<channel);
|
||||||
|
if (value){
|
||||||
|
pullups |= (1<<channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Invertiert",width=80,order=30)
|
||||||
|
public Boolean getInvert(){
|
||||||
|
return (inverts & 1<<channel) == 0 ? false : true;
|
||||||
|
}
|
||||||
|
public void setInvert(Boolean value){
|
||||||
|
inverts &= ~(1<<channel);
|
||||||
|
if (value){
|
||||||
|
inverts |= (1<<channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Löst Snapshot aus",width=80,order=40)
|
||||||
|
public Boolean getTrigger(){
|
||||||
|
return (trigger & 1<<channel) == 0 ? false : true;
|
||||||
|
}
|
||||||
|
public void setTrigger(Boolean value){
|
||||||
|
trigger &= ~(1<<channel);
|
||||||
|
if (value){
|
||||||
|
trigger |= (1<<channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Signalfenster",width=80,order=200)
|
||||||
|
public Integer getWindow(){
|
||||||
|
return windows[channel];
|
||||||
|
}
|
||||||
|
public void setWindow(Integer value){
|
||||||
|
windows[channel] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Signalfilter",width=80,order=210)
|
||||||
|
public Integer getFilter(){
|
||||||
|
return filter[channel];
|
||||||
|
}
|
||||||
|
public void setFilter(Integer value){
|
||||||
|
filter[channel] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,366 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.datetime.DateTime;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
|
import org.hwo.pulscounter.SnapshotManager.Notification;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
public class DeviceTestFrame extends JFrame implements PulsCounterApplicationListener {
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public DeviceTestFrame() {
|
||||||
|
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 PulsCounter2Application application(){
|
||||||
|
return PulsCounter2Application.getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
this.reconnectTimer = new Timer("Reconnection Timer");
|
||||||
|
|
||||||
|
messageListModel = new DefaultListModel<String>();
|
||||||
|
lMessages.setModel(messageListModel);
|
||||||
|
|
||||||
|
application().addPulsCounterApplicationListener(this);
|
||||||
|
application().fireConnectionStateChanged(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialPortChanged() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import org.hwo.interactiveobjects.ObjectEditorUI;
|
||||||
|
import org.hwo.interactiveobjects.ObjectEditorUIHelper;
|
||||||
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.pulscounter.ExportSetting;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
public class ExportFilesFrame extends JFrame {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JTable tExportSettings;
|
||||||
|
|
||||||
|
private TableMapper tmExportSettings;
|
||||||
|
private JButton bRemove;
|
||||||
|
private JButton bEdit;
|
||||||
|
private JButton bAdd;
|
||||||
|
|
||||||
|
|
||||||
|
private ExportSetting selectedExportSetting;
|
||||||
|
private JSeparator separator;
|
||||||
|
private JButton btnExec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public ExportFilesFrame() {
|
||||||
|
setTitle("Export Einstellungen...");
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 825, 433);
|
||||||
|
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, 0};
|
||||||
|
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPane.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
contentPane.setLayout(gbl_contentPane);
|
||||||
|
|
||||||
|
JToolBar toolBar = new JToolBar();
|
||||||
|
toolBar.setFloatable(false);
|
||||||
|
GridBagConstraints gbc_toolBar = new GridBagConstraints();
|
||||||
|
gbc_toolBar.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_toolBar.gridwidth = 3;
|
||||||
|
gbc_toolBar.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_toolBar.gridx = 0;
|
||||||
|
gbc_toolBar.gridy = 0;
|
||||||
|
contentPane.add(toolBar, gbc_toolBar);
|
||||||
|
|
||||||
|
bAdd = new JButton("+");
|
||||||
|
bAdd.setToolTipText("<html>\n<b>Neue Exportkonfiguration hinzufügen</b><br/>\n</html>");
|
||||||
|
bAdd.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
ExportSetting es = new ExportSetting();
|
||||||
|
tmExportSettings.addRow(es);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(bAdd);
|
||||||
|
|
||||||
|
bEdit = new JButton("e");
|
||||||
|
bEdit.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration bearbeiten</b>\n</html>");
|
||||||
|
bEdit.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
ExportSetting es = (ExportSetting)tmExportSettings.getSelectedRow();
|
||||||
|
if (es != null){
|
||||||
|
if (ObjectEditorUIHelper.edit(es)){
|
||||||
|
tmExportSettings.fireTableDataChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bEdit.setEnabled(false);
|
||||||
|
toolBar.add(bEdit);
|
||||||
|
|
||||||
|
bRemove = new JButton("-");
|
||||||
|
bRemove.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration entfernen</b>\n</html>");
|
||||||
|
bRemove.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (selectedExportSetting != null){
|
||||||
|
ExportSetting es = selectedExportSetting;
|
||||||
|
tmExportSettings.removeRow(es);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bRemove.setEnabled(false);
|
||||||
|
toolBar.add(bRemove);
|
||||||
|
|
||||||
|
separator = new JSeparator();
|
||||||
|
toolBar.add(separator);
|
||||||
|
|
||||||
|
btnExec = new JButton("EXEC");
|
||||||
|
btnExec.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration jetzt ausführen</b><br/>\n</html>");
|
||||||
|
btnExec.setEnabled(false);
|
||||||
|
btnExec.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
doExport();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnExec);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
scrollPane.setToolTipText("<html>\n<b>Exportkonfigurationen</b><br/>\nZeigt eine Übersicht über die aktuell vorhandenen Exportkonfigurationen\n</html>");
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.gridwidth = 3;
|
||||||
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 1;
|
||||||
|
contentPane.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
tExportSettings = new JTable();
|
||||||
|
tExportSettings.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
tmExportSettings = new TableMapper(ExportSetting.class, tExportSettings);
|
||||||
|
tmExportSettings.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
ExportSetting es = (ExportSetting)tmExportSettings.getSelectedRow();
|
||||||
|
setSelectedExportSetting(es);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tmExportSettings.setRows(PulsCounter2Application.getApplication().getExportSettings());
|
||||||
|
scrollPane.setViewportView(tExportSettings);
|
||||||
|
|
||||||
|
JButton btnSchliessen = new JButton("schliessen");
|
||||||
|
btnSchliessen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
PulsCounter2Application.getApplication().savePrefs();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
||||||
|
gbc_btnSchliessen.gridx = 2;
|
||||||
|
gbc_btnSchliessen.gridy = 2;
|
||||||
|
contentPane.add(btnSchliessen, gbc_btnSchliessen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportSetting getSelectedExportSetting() {
|
||||||
|
return selectedExportSetting;
|
||||||
|
}
|
||||||
|
public void setSelectedExportSetting(ExportSetting selectedExportSetting) {
|
||||||
|
this.selectedExportSetting = selectedExportSetting;
|
||||||
|
if (this.selectedExportSetting != null){
|
||||||
|
bEdit.setEnabled(true);
|
||||||
|
bRemove.setEnabled(true);
|
||||||
|
btnExec.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
bEdit.setEnabled(false);
|
||||||
|
bRemove.setEnabled(false);
|
||||||
|
btnExec.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doExport(){
|
||||||
|
((ExportSetting)tmExportSettings.getSelectedRow()).export();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,346 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.configuration.ConfigurableObject;
|
||||||
|
import org.hwo.configuration.ConfigurableObjects;
|
||||||
|
import org.hwo.interactiveobjects.IInteractiveObjectEditor;
|
||||||
|
import org.hwo.interactiveobjects.IObjectEditorUI;
|
||||||
|
import org.hwo.pulscounter.ExportSetting;
|
||||||
|
import org.hwo.pulscounter.TriggerType;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
|
public class ExportSettingsEditorDialog extends JDialog implements IObjectEditorUI {
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
|
||||||
|
private ExportSetting exportSetting;
|
||||||
|
private JTextField tfBenennung;
|
||||||
|
private JComboBox<TriggerType> cbTriggerType;
|
||||||
|
private JSpinner spSource;
|
||||||
|
private JTextField tfPath;
|
||||||
|
private JTextField tfFilename;
|
||||||
|
|
||||||
|
private boolean accepted;
|
||||||
|
private JCheckBox cbExtended;
|
||||||
|
private JCheckBox cbAutostart;
|
||||||
|
private JCheckBox cbRecordDeltas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*/
|
||||||
|
public ExportSettingsEditorDialog() {
|
||||||
|
setBounds(100, 100, 620, 386);
|
||||||
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
||||||
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JLabel lblBenennung = new JLabel("Benennung:");
|
||||||
|
GridBagConstraints gbc_lblBenennung = new GridBagConstraints();
|
||||||
|
gbc_lblBenennung.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblBenennung.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblBenennung.gridx = 0;
|
||||||
|
gbc_lblBenennung.gridy = 0;
|
||||||
|
contentPanel.add(lblBenennung, gbc_lblBenennung);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tfBenennung = new JTextField();
|
||||||
|
tfBenennung.setToolTipText("<html>\n<b>Bezeichnung dieser Exportkonfiguration</b>\n</html>");
|
||||||
|
GridBagConstraints gbc_tfBenennung = new GridBagConstraints();
|
||||||
|
gbc_tfBenennung.gridwidth = 2;
|
||||||
|
gbc_tfBenennung.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tfBenennung.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfBenennung.gridx = 1;
|
||||||
|
gbc_tfBenennung.gridy = 0;
|
||||||
|
contentPanel.add(tfBenennung, gbc_tfBenennung);
|
||||||
|
tfBenennung.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblAuslser = new JLabel("Auslöser:");
|
||||||
|
GridBagConstraints gbc_lblAuslser = new GridBagConstraints();
|
||||||
|
gbc_lblAuslser.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAuslser.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAuslser.gridx = 0;
|
||||||
|
gbc_lblAuslser.gridy = 1;
|
||||||
|
contentPanel.add(lblAuslser, gbc_lblAuslser);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cbTriggerType = new JComboBox<TriggerType>();
|
||||||
|
cbTriggerType.setToolTipText("<html>\n<b>Auslöser</b><br/>\n<br/>\nWählt aus, welche Snapshots in diesem Export übernommen werden sollen.<br/>\n<br/>\n<b>ALL</b> alle Snapshots<br/>\n<b>INTERVALL</b> alle Snapshots, welche aufgrund eines abgelaufenen Intervall aufgezeichnet wurden.<br/>\n<i>(nähere Auswahl durch <u>Quelle</u></i>)<br/>\n<b>TRIGGER</b> alle Snapshots, welche aufgrund eines Impulses auf einem als Trigger konfigurierten Kanal aufgezeichnet wurden.<br/>\n<i>(nähere Auswahl durch <u>Quelle</u></i>)<br/>\n</html>");
|
||||||
|
cbTriggerType.addItemListener(new ItemListener() {
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
if (exportSetting != null){
|
||||||
|
exportSetting.setTriggerType((TriggerType)cbTriggerType.getSelectedItem());
|
||||||
|
updateSourceEditor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cbTriggerType.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cbTriggerType.addItem(TriggerType.ALL);
|
||||||
|
cbTriggerType.addItem(TriggerType.Intervall);
|
||||||
|
cbTriggerType.addItem(TriggerType.Timer);
|
||||||
|
cbTriggerType.addItem(TriggerType.Manual);
|
||||||
|
|
||||||
|
GridBagConstraints gbc_cbTriggerType = new GridBagConstraints();
|
||||||
|
gbc_cbTriggerType.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_cbTriggerType.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_cbTriggerType.gridx = 1;
|
||||||
|
gbc_cbTriggerType.gridy = 1;
|
||||||
|
contentPanel.add(cbTriggerType, gbc_cbTriggerType);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblQuelle = new JLabel("Quelle:");
|
||||||
|
GridBagConstraints gbc_lblQuelle = new GridBagConstraints();
|
||||||
|
gbc_lblQuelle.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblQuelle.gridx = 0;
|
||||||
|
gbc_lblQuelle.gridy = 2;
|
||||||
|
contentPanel.add(lblQuelle, gbc_lblQuelle);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
spSource = new JSpinner();
|
||||||
|
spSource.setToolTipText("<html>\n<b>Quelle</b><br/>\n<br/>\nSchränkt den eingestellten Auslöser weiter ein.<br/>\n<br/>\nFür den Auslöser <u>INTERVALL</u> bezeichnet Quelle die Nummer des Intervalls. 0 bedeutet alle Intervalle.<br/>\nFür den Auslöser <u>TRIGGER</u> bezeichnet Quelle die Nummer des Kanals. 0 bedeutet alle Kanäle.<br/>\n</html>");
|
||||||
|
spSource.setModel(new SpinnerNumberModel(0, -1, 255, 1));
|
||||||
|
GridBagConstraints gbc_spSource = new GridBagConstraints();
|
||||||
|
gbc_spSource.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_spSource.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_spSource.gridx = 1;
|
||||||
|
gbc_spSource.gridy = 2;
|
||||||
|
contentPanel.add(spSource, gbc_spSource);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblNewLabel = new JLabel("Verzeichnis:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel.gridx = 0;
|
||||||
|
gbc_lblNewLabel.gridy = 3;
|
||||||
|
contentPanel.add(lblNewLabel, gbc_lblNewLabel);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tfPath = new JTextField();
|
||||||
|
tfPath.setToolTipText("<html>\n<b>Exportverzeichnis</b><br/>\n<br/>\nWählen Sie ein Verzeichnis, in dem die exportierten Dateien erstellt werden sollen.\n</html>");
|
||||||
|
tfPath.setEditable(false);
|
||||||
|
GridBagConstraints gbc_tfPath = new GridBagConstraints();
|
||||||
|
gbc_tfPath.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_tfPath.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfPath.gridx = 1;
|
||||||
|
gbc_tfPath.gridy = 3;
|
||||||
|
contentPanel.add(tfPath, gbc_tfPath);
|
||||||
|
tfPath.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton btnDurchsuchen = new JButton("durchsuchen...");
|
||||||
|
btnDurchsuchen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
fc.setCurrentDirectory(new File(tfPath.getText()));
|
||||||
|
if (fc.showOpenDialog(ExportSettingsEditorDialog.this)==JFileChooser.APPROVE_OPTION){
|
||||||
|
tfPath.setText( fc.getSelectedFile().getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnDurchsuchen = new GridBagConstraints();
|
||||||
|
gbc_btnDurchsuchen.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_btnDurchsuchen.gridx = 2;
|
||||||
|
gbc_btnDurchsuchen.gridy = 3;
|
||||||
|
contentPanel.add(btnDurchsuchen, gbc_btnDurchsuchen);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JLabel lblDateiname = new JLabel("Dateiname:");
|
||||||
|
GridBagConstraints gbc_lblDateiname = new GridBagConstraints();
|
||||||
|
gbc_lblDateiname.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblDateiname.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblDateiname.gridx = 0;
|
||||||
|
gbc_lblDateiname.gridy = 4;
|
||||||
|
contentPanel.add(lblDateiname, gbc_lblDateiname);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tfFilename = new JTextField();
|
||||||
|
tfFilename.setToolTipText("<html>\n<b>Dateiname</b><br/>\n<br/>\nGibt den Dateinamen an, unter welchem die Daten gespeichert werden sollen.<br/>\nHier können auch einige Platzhalter verwendet werden:<br/>\n<br/>\n<b>%Y</b> Die Jahreszahl des Snapshotdatums.<br/>\n<b>%M</b> Der Monat des Snapshotdatums.<br/>\n<b>%D</b> Das Tagesdatum des Snapshotdatums.<br/>\n<br/>\nDie Platzhalter werden beim exportieren durch die entsprechenden Werte ersetzt. Dadurch kann eine Exportkonfiguration<br/>\ndie Daten auf mehrer Dateien verteilen.\n</html>");
|
||||||
|
GridBagConstraints gbc_tfFilename = new GridBagConstraints();
|
||||||
|
gbc_tfFilename.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_tfFilename.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfFilename.gridx = 1;
|
||||||
|
gbc_tfFilename.gridy = 4;
|
||||||
|
contentPanel.add(tfFilename, gbc_tfFilename);
|
||||||
|
tfFilename.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cbRecordDeltas = new JCheckBox("Veränderungen berechnen");
|
||||||
|
cbRecordDeltas.setToolTipText("<html>\n<b>Veränderungen berechnen</b><br/>\n<br/>\nIn den Exportdateien wird die Differenz der Zählerstände zum jeweils davor liegenden Wert ausgegeben.\n</html>");
|
||||||
|
GridBagConstraints gbc_dbRecordDeltas = new GridBagConstraints();
|
||||||
|
gbc_dbRecordDeltas.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_dbRecordDeltas.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_dbRecordDeltas.gridx = 1;
|
||||||
|
gbc_dbRecordDeltas.gridy = 5;
|
||||||
|
contentPanel.add(cbRecordDeltas, gbc_dbRecordDeltas);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cbExtended = new JCheckBox("Erweitertes Dateiformat");
|
||||||
|
cbExtended.setToolTipText("<html>\n<b>Erweitertes Dateiformat</b><br/>\n<br/>\nEs werden zusätzliche Spalten mit Momentandaten bei der Aufzeichnung des Zählerstandes ausgegeben.\n</html>");
|
||||||
|
GridBagConstraints gbc_cbExtended = new GridBagConstraints();
|
||||||
|
gbc_cbExtended.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_cbExtended.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_cbExtended.gridx = 1;
|
||||||
|
gbc_cbExtended.gridy = 6;
|
||||||
|
contentPanel.add(cbExtended, gbc_cbExtended);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cbAutostart = new JCheckBox("Im Batch-Modus ausführen");
|
||||||
|
cbAutostart.setToolTipText("<html>\n<b>Im Batch- Modus ausführen</b><br/>\n<br/>\nDieses Exportkonfiguration soll automatisch ausgeführt werden, wenn die Software<br/>\nmit dem Kommandozeilenargument <i>-b</i> gestartet wurde.\n</html>");
|
||||||
|
GridBagConstraints gbc_cbAutostart = new GridBagConstraints();
|
||||||
|
gbc_cbAutostart.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_cbAutostart.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_cbAutostart.gridx = 1;
|
||||||
|
gbc_cbAutostart.gridy = 7;
|
||||||
|
contentPanel.add(cbAutostart, gbc_cbAutostart);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
updateObject();
|
||||||
|
accepted = true;
|
||||||
|
setVisible(false);
|
||||||
|
getParent().invalidate();
|
||||||
|
|
||||||
|
System.err.println(String.format("Configuration: %s",ConfigurableObjects.getConfiguration(exportSetting)));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
okButton.setActionCommand("OK");
|
||||||
|
buttonPane.add(okButton);
|
||||||
|
getRootPane().setDefaultButton(okButton);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editObject(Object o) {
|
||||||
|
setExportSetting((ExportSetting)o);
|
||||||
|
setModal(true);
|
||||||
|
setVisible(true);
|
||||||
|
setModal(false);
|
||||||
|
|
||||||
|
return accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExportSetting getExportSetting() {
|
||||||
|
return exportSetting;
|
||||||
|
}
|
||||||
|
public void setExportSetting(ExportSetting exportSetting) {
|
||||||
|
this.exportSetting = exportSetting;
|
||||||
|
updateEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccepted() {
|
||||||
|
return accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateObject(){
|
||||||
|
exportSetting.setPath(tfPath.getText());
|
||||||
|
exportSetting.setName(tfBenennung.getText());
|
||||||
|
exportSetting.setFileName(tfFilename.getText());
|
||||||
|
exportSetting.setTriggerSource((Integer)spSource.getValue());
|
||||||
|
exportSetting.setTriggerType((TriggerType)cbTriggerType.getSelectedItem());
|
||||||
|
exportSetting.setExtended(cbExtended.isSelected());
|
||||||
|
exportSetting.setAutostart(cbAutostart.isSelected());
|
||||||
|
exportSetting.setRecordDelta(cbRecordDeltas.isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEditor(){
|
||||||
|
if (exportSetting == null){
|
||||||
|
tfBenennung.setEnabled(false);
|
||||||
|
tfBenennung.setText("");
|
||||||
|
cbTriggerType.setEnabled(false);
|
||||||
|
cbTriggerType.setSelectedIndex(-1);
|
||||||
|
spSource.setEnabled(false);
|
||||||
|
spSource.setValue(0);
|
||||||
|
tfPath.setEnabled(false);
|
||||||
|
tfPath.setText("");
|
||||||
|
tfFilename.setEnabled(false);
|
||||||
|
tfFilename.setText("");
|
||||||
|
cbExtended.setEnabled(false);
|
||||||
|
cbAutostart.setEnabled(false);
|
||||||
|
cbRecordDeltas.setEnabled(false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tfBenennung.setEnabled(true);
|
||||||
|
tfBenennung.setText(exportSetting.getName());
|
||||||
|
cbTriggerType.setEnabled(true);
|
||||||
|
cbTriggerType.setSelectedItem(exportSetting.getTriggerType());
|
||||||
|
|
||||||
|
updateSourceEditor();
|
||||||
|
|
||||||
|
tfPath.setEnabled(true);
|
||||||
|
tfPath.setText(exportSetting.getPath());
|
||||||
|
tfFilename.setEnabled(true);
|
||||||
|
tfFilename.setText(exportSetting.getFileName());
|
||||||
|
|
||||||
|
cbExtended.setEnabled(true);
|
||||||
|
cbExtended.setSelected(exportSetting.getExtended());
|
||||||
|
|
||||||
|
cbAutostart.setEnabled(true);
|
||||||
|
cbAutostart.setSelected(exportSetting.getAutostart());
|
||||||
|
|
||||||
|
cbRecordDeltas.setEnabled(true);
|
||||||
|
cbRecordDeltas.setSelected(exportSetting.getRecordDelta());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSourceEditor(){
|
||||||
|
if ((exportSetting.getTriggerType()==TriggerType.ALL)||(exportSetting.getTriggerType()==TriggerType.Manual)){
|
||||||
|
spSource.setValue(-1);
|
||||||
|
spSource.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
spSource.setEnabled(true);
|
||||||
|
spSource.setValue(exportSetting.getTriggerSource());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,122 +0,0 @@
|
||||||
package org.hwo.pulscounter.ui;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.Insets;
|
|
||||||
|
|
||||||
import javax.swing.border.TitledBorder;
|
|
||||||
|
|
||||||
import org.hwo.datetime.Date;
|
|
||||||
import org.hwo.pulscounter.PulsCounter;
|
|
||||||
import org.hwo.pulscounter.elements.WorkShift;
|
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
|
|
||||||
public class InspectionMainFrame extends JFrame {
|
|
||||||
|
|
||||||
private JPanel contentPane;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
InspectionMainFrame frame = new InspectionMainFrame();
|
|
||||||
frame.setVisible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the frame.
|
|
||||||
*/
|
|
||||||
public InspectionMainFrame() {
|
|
||||||
setTitle("Inspektor");
|
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
setBounds(100, 100, 841, 607);
|
|
||||||
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};
|
|
||||||
gbl_contentPane.rowHeights = new int[]{0, 0, 0};
|
|
||||||
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
||||||
gbl_contentPane.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
||||||
contentPane.setLayout(gbl_contentPane);
|
|
||||||
|
|
||||||
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;
|
|
||||||
contentPane.add(panel, gbc_panel);
|
|
||||||
GridBagLayout gbl_panel = new GridBagLayout();
|
|
||||||
gbl_panel.columnWidths = new int[]{0, 0};
|
|
||||||
gbl_panel.rowHeights = new int[]{0, 0};
|
|
||||||
gbl_panel.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
||||||
gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
||||||
panel.setLayout(gbl_panel);
|
|
||||||
|
|
||||||
JButton btnNewButton = new JButton("Schichtdaten prüfen...");
|
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
WorkShift[] shifts = PulsCounter.getInspectorApplication().getWorkShifts();
|
|
||||||
Date d = new Date();
|
|
||||||
d.addDays(10);
|
|
||||||
for (int i=0;i<40;i++){
|
|
||||||
|
|
||||||
for (int s = 0;s<shifts.length;s++){
|
|
||||||
System.out.println(shifts[s].getName() + ": " + shifts[s].getShiftBegins(d).getSQLDateTime() + " - " + shifts[s].getShiftEnds(d).getSQLDateTime() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
|
||||||
gbc_btnNewButton.gridx = 0;
|
|
||||||
gbc_btnNewButton.gridy = 0;
|
|
||||||
panel.add(btnNewButton, gbc_btnNewButton);
|
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
|
||||||
panel_1.setBorder(new TitledBorder(null, "Einstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
|
||||||
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
|
||||||
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_panel_1.gridx = 0;
|
|
||||||
gbc_panel_1.gridy = 1;
|
|
||||||
contentPane.add(panel_1, gbc_panel_1);
|
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
|
||||||
gbl_panel_1.columnWidths = new int[]{0, 0};
|
|
||||||
gbl_panel_1.rowHeights = new int[]{0, 0};
|
|
||||||
gbl_panel_1.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
||||||
gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
||||||
panel_1.setLayout(gbl_panel_1);
|
|
||||||
|
|
||||||
JButton btnSchichten = new JButton("Schichten");
|
|
||||||
btnSchichten.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnSchichten = new GridBagConstraints();
|
|
||||||
gbc_btnSchichten.gridx = 0;
|
|
||||||
gbc_btnSchichten.gridy = 0;
|
|
||||||
panel_1.add(btnSchichten, gbc_btnSchichten);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.MenuItem;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JBitSetter extends JPanel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
JCheckBox[] checkboxes;
|
||||||
|
|
||||||
|
JPopupMenu contextMenu;
|
||||||
|
|
||||||
|
List<ActionListener> actionListeners;
|
||||||
|
|
||||||
|
|
||||||
|
public JBitSetter() {
|
||||||
|
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
|
||||||
|
|
||||||
|
this.checkboxes = new JCheckBox[32];
|
||||||
|
this.actionListeners = new LinkedList<ActionListener>();
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
this.checkboxes[i] = new JCheckBox();
|
||||||
|
// this.checkboxes[i].setText(String.format("%d", i));
|
||||||
|
this.checkboxes[i].setInheritsPopupMenu(true);
|
||||||
|
this.checkboxes[i].setToolTipText(String.format("%d", i));
|
||||||
|
/* this.checkboxes[i].addChangeListener(new ChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
fireAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
this.checkboxes[i].addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
fireAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.add(this.checkboxes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu = new JPopupMenu();
|
||||||
|
JMenuItem mi = new JMenuItem("Keins");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
checkboxes[i].setSelected(false);
|
||||||
|
}
|
||||||
|
fireAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenu.add(mi);
|
||||||
|
mi = new JMenuItem("Alle");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
checkboxes[i].setSelected(true);
|
||||||
|
}
|
||||||
|
fireAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenu.add(mi);
|
||||||
|
|
||||||
|
setComponentPopupMenu(contextMenu);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addActionListener(ActionListener listener){
|
||||||
|
this.actionListeners.add(listener);
|
||||||
|
}
|
||||||
|
public void removeActionListener(ActionListener listener){
|
||||||
|
this.actionListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireAction(){
|
||||||
|
for (ActionListener listener: this.actionListeners){
|
||||||
|
listener.actionPerformed(new ActionEvent(this, 0, ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Integer value){
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
this.checkboxes[i].setSelected( (value & (1<<i))!=0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue(){
|
||||||
|
Integer n = 0;
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
if (this.checkboxes[i].isSelected())
|
||||||
|
n |= 1<<i;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,35 +4,52 @@ import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import org.hwo.datetime.JTimeOfDay;
|
import org.hwo.datetime.JTimeOfDay;
|
||||||
import org.hwo.io.servicelink.ServiceLink;
|
import org.hwo.io.SerialPortExeption;
|
||||||
import org.hwo.io.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.io.servicelink.ServiceLinkRequestFailedException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.ui.MousePopupListener;
|
||||||
|
import org.hwo.pulscounter.CounterChannel;
|
||||||
import org.hwo.pulscounter.PulsCounter2Application;
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.postgresql.util.UnixCrypt;
|
||||||
|
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectOutputStream.PutField;
|
import java.io.ObjectOutputStream.PutField;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
|
@ -40,7 +57,7 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
private Timer liveViewTimer;
|
private Timer liveViewTimer;
|
||||||
private ServiceLink serviceLink;
|
private ServiceLink serviceLink;
|
||||||
|
|
||||||
private JToggleButton[] inputButtons;
|
private JLabel[] inputButtons;
|
||||||
private JToggleButton[] pullupButtons;
|
private JToggleButton[] pullupButtons;
|
||||||
private JToggleButton[] outputButtons;
|
private JToggleButton[] outputButtons;
|
||||||
|
|
||||||
|
@ -51,9 +68,23 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
private JPanel pAnalog;
|
private JPanel pAnalog;
|
||||||
private JPanel pOutputs;
|
private JPanel pOutputs;
|
||||||
|
|
||||||
private Integer inputs,
|
private Integer pinputs,
|
||||||
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
pullups;
|
pullups;
|
||||||
|
private JPanel pDateTime;
|
||||||
|
private JLabel lblUnixZeitstempel;
|
||||||
|
private JTextField tfUnixTime;
|
||||||
|
private JLabel lblAktuellesDatum;
|
||||||
|
private JTextField tfHumanDateTime;
|
||||||
|
private JButton btnSynchronisieren;
|
||||||
|
private JPanel panel;
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
private JList lMessages;
|
||||||
|
private JPanel panel_1;
|
||||||
|
private JButton btnSnapshot;
|
||||||
|
private JButton btnLeeren;
|
||||||
|
private JButton btnLaufzeitKorrigieren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
|
@ -61,15 +92,15 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
public LiveViewFrame() {
|
public LiveViewFrame() {
|
||||||
setTitle("Live Ansicht");
|
setTitle("Live Ansicht");
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 873, 530);
|
setBounds(100, 100, 1037, 875);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
GridBagLayout gbl_contentPane = new GridBagLayout();
|
GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||||
gbl_contentPane.columnWidths = new int[]{0, 0};
|
gbl_contentPane.columnWidths = new int[]{0, 0};
|
||||||
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0};
|
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
gbl_contentPane.rowWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
|
gbl_contentPane.rowWeights = new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
contentPane.setLayout(gbl_contentPane);
|
contentPane.setLayout(gbl_contentPane);
|
||||||
|
|
||||||
pDisplay = new JPanel();
|
pDisplay = new JPanel();
|
||||||
|
@ -120,12 +151,147 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
pAnalog = new JPanel();
|
pAnalog = new JPanel();
|
||||||
pAnalog.setBorder(new TitledBorder(null, "Analogkan\u00E4le", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
pAnalog.setBorder(new TitledBorder(null, "Analogkan\u00E4le", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
GridBagConstraints gbc_pAnalog = new GridBagConstraints();
|
GridBagConstraints gbc_pAnalog = new GridBagConstraints();
|
||||||
|
gbc_pAnalog.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_pAnalog.fill = GridBagConstraints.BOTH;
|
gbc_pAnalog.fill = GridBagConstraints.BOTH;
|
||||||
gbc_pAnalog.gridx = 0;
|
gbc_pAnalog.gridx = 0;
|
||||||
gbc_pAnalog.gridy = 3;
|
gbc_pAnalog.gridy = 3;
|
||||||
contentPane.add(pAnalog, gbc_pAnalog);
|
contentPane.add(pAnalog, gbc_pAnalog);
|
||||||
pAnalog.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
pAnalog.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||||
|
|
||||||
|
pDateTime = new JPanel();
|
||||||
|
pDateTime.setBorder(new TitledBorder(null, "Datum und Zeit", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_pDateTime = new GridBagConstraints();
|
||||||
|
gbc_pDateTime.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_pDateTime.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_pDateTime.gridx = 0;
|
||||||
|
gbc_pDateTime.gridy = 4;
|
||||||
|
contentPane.add(pDateTime, gbc_pDateTime);
|
||||||
|
GridBagLayout gbl_pDateTime = new GridBagLayout();
|
||||||
|
gbl_pDateTime.columnWidths = new int[]{0, 0, 0, 0, 0};
|
||||||
|
gbl_pDateTime.rowHeights = new int[]{0, 0, 0};
|
||||||
|
gbl_pDateTime.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_pDateTime.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
pDateTime.setLayout(gbl_pDateTime);
|
||||||
|
|
||||||
|
lblUnixZeitstempel = new JLabel("Unix Zeitstempel:");
|
||||||
|
GridBagConstraints gbc_lblUnixZeitstempel = new GridBagConstraints();
|
||||||
|
gbc_lblUnixZeitstempel.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblUnixZeitstempel.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblUnixZeitstempel.gridx = 0;
|
||||||
|
gbc_lblUnixZeitstempel.gridy = 0;
|
||||||
|
pDateTime.add(lblUnixZeitstempel, gbc_lblUnixZeitstempel);
|
||||||
|
|
||||||
|
tfUnixTime = new JTextField();
|
||||||
|
GridBagConstraints gbc_tfUnixTime = new GridBagConstraints();
|
||||||
|
gbc_tfUnixTime.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_tfUnixTime.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfUnixTime.gridx = 1;
|
||||||
|
gbc_tfUnixTime.gridy = 0;
|
||||||
|
pDateTime.add(tfUnixTime, gbc_tfUnixTime);
|
||||||
|
tfUnixTime.setColumns(10);
|
||||||
|
|
||||||
|
lblAktuellesDatum = new JLabel("Aktuelles Datum:");
|
||||||
|
GridBagConstraints gbc_lblAktuellesDatum = new GridBagConstraints();
|
||||||
|
gbc_lblAktuellesDatum.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAktuellesDatum.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAktuellesDatum.gridx = 2;
|
||||||
|
gbc_lblAktuellesDatum.gridy = 0;
|
||||||
|
pDateTime.add(lblAktuellesDatum, gbc_lblAktuellesDatum);
|
||||||
|
|
||||||
|
tfHumanDateTime = new JTextField();
|
||||||
|
GridBagConstraints gbc_tfHumanDateTime = new GridBagConstraints();
|
||||||
|
gbc_tfHumanDateTime.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tfHumanDateTime.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfHumanDateTime.gridx = 3;
|
||||||
|
gbc_tfHumanDateTime.gridy = 0;
|
||||||
|
pDateTime.add(tfHumanDateTime, gbc_tfHumanDateTime);
|
||||||
|
tfHumanDateTime.setColumns(10);
|
||||||
|
|
||||||
|
btnSynchronisieren = new JButton("Synchronisieren");
|
||||||
|
btnSynchronisieren.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
syncUnixTime();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnSynchronisieren = new GridBagConstraints();
|
||||||
|
gbc_btnSynchronisieren.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnSynchronisieren.gridx = 1;
|
||||||
|
gbc_btnSynchronisieren.gridy = 1;
|
||||||
|
pDateTime.add(btnSynchronisieren, gbc_btnSynchronisieren);
|
||||||
|
|
||||||
|
btnLaufzeitKorrigieren = new JButton("Laufzeit korrigieren");
|
||||||
|
btnLaufzeitKorrigieren.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
quartzCorrect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnLaufzeitKorrigieren = new GridBagConstraints();
|
||||||
|
gbc_btnLaufzeitKorrigieren.gridx = 3;
|
||||||
|
gbc_btnLaufzeitKorrigieren.gridy = 1;
|
||||||
|
pDateTime.add(btnLaufzeitKorrigieren, gbc_btnLaufzeitKorrigieren);
|
||||||
|
|
||||||
|
panel_1 = new JPanel();
|
||||||
|
panel_1.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Kommandos", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
||||||
|
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel_1.gridx = 0;
|
||||||
|
gbc_panel_1.gridy = 5;
|
||||||
|
contentPane.add(panel_1, gbc_panel_1);
|
||||||
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
|
gbl_panel_1.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_panel_1.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_panel_1.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
|
btnSnapshot = new JButton("SnapShot");
|
||||||
|
btnSnapshot.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
manualSnapshot();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnSnapshot = new GridBagConstraints();
|
||||||
|
gbc_btnSnapshot.gridx = 0;
|
||||||
|
gbc_btnSnapshot.gridy = 0;
|
||||||
|
panel_1.add(btnSnapshot, gbc_btnSnapshot);
|
||||||
|
|
||||||
|
panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(null, "Meldungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 6;
|
||||||
|
contentPane.add(panel, gbc_panel);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{383, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{0, 131, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
|
||||||
|
scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 1;
|
||||||
|
panel.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
lMessages = new JList();
|
||||||
|
scrollPane.setViewportView(lMessages);
|
||||||
|
|
||||||
|
btnLeeren = new JButton("leeren");
|
||||||
|
btnLeeren.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
((DefaultListModel)lMessages.getModel()).clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnLeeren = new GridBagConstraints();
|
||||||
|
gbc_btnLeeren.gridx = 0;
|
||||||
|
gbc_btnLeeren.gridy = 2;
|
||||||
|
panel.add(btnLeeren, gbc_btnLeeren);
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,20 +301,56 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
pc2a.removeAppSettingsListener(this);
|
pc2a.removeAppSettingsListener(this);
|
||||||
|
|
||||||
|
liveViewTimer.cancel();
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
|
||||||
inputButtons = new JToggleButton[32];
|
lMessages.setModel(new DefaultListModel<String>());
|
||||||
|
|
||||||
|
inputButtons = new JLabel[32];
|
||||||
outputButtons = new JToggleButton[32];
|
outputButtons = new JToggleButton[32];
|
||||||
pullupButtons = new JToggleButton[32];
|
pullupButtons = new JToggleButton[32];
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
for (int i=0;i<32;i++){
|
||||||
final int n = i;
|
final int n = i;
|
||||||
|
|
||||||
inputButtons[i] = new JToggleButton(String.format("%d", i));
|
inputButtons[i] = new JLabel(String.format("%d", i));
|
||||||
|
inputButtons[i].setOpaque(true);
|
||||||
|
inputButtons[i].setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
inputButtons[i].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) {
|
||||||
|
if (serviceLink != null){
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0600 + n, 0);
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(mi);
|
||||||
|
|
||||||
|
popup.show(inputButtons[n], x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.insets = new Insets(0, 0, 0, 0);
|
gbc.insets = new Insets(0, 0, 0, 0);
|
||||||
|
@ -196,7 +398,7 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
public void run() {
|
public void run() {
|
||||||
updateLiveView();
|
updateLiveView();
|
||||||
}
|
}
|
||||||
}, 200, 250);
|
}, 200, 500);
|
||||||
|
|
||||||
pc2a.addAppSettingsListener(this);
|
pc2a.addAppSettingsListener(this);
|
||||||
|
|
||||||
|
@ -206,6 +408,8 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
|
|
||||||
private synchronized void updateLiveView(){
|
private synchronized void updateLiveView(){
|
||||||
System.err.println("LiveView Update");
|
System.err.println("LiveView Update");
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
if (serviceLink != null){
|
if (serviceLink != null){
|
||||||
System.err.println("ServiceLink exists.");
|
System.err.println("ServiceLink exists.");
|
||||||
try {
|
try {
|
||||||
|
@ -214,10 +418,43 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x84F0 );
|
Integer brkval,heapend;
|
||||||
outputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x81F9 );
|
|
||||||
pullups = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x81FA );
|
brkval = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020 );
|
||||||
|
if (brkval == null)
|
||||||
|
brkval = 0;
|
||||||
|
|
||||||
|
heapend = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021 );
|
||||||
|
if (heapend == null)
|
||||||
|
heapend = 0;
|
||||||
|
|
||||||
|
System.err.println(String.format("PC2-BRKVAL: 0x%04x",brkval));
|
||||||
|
System.err.println(String.format("PC2-HEAPEND: 0x%04x",heapend));
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
Integer deviceUnixTime = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x001C);
|
||||||
|
if (deviceUnixTime != null){
|
||||||
|
calendar.setTimeInMillis(deviceUnixTime * 1000L);
|
||||||
|
|
||||||
|
tfUnixTime.setText(String.format("%d",deviceUnixTime));
|
||||||
|
tfHumanDateTime.setText(sdf.format(calendar.getTime()));
|
||||||
|
};
|
||||||
|
|
||||||
|
pinputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0680 );
|
||||||
|
inputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0681 );
|
||||||
|
outputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0682 );
|
||||||
|
pullups = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0683 );
|
||||||
|
|
||||||
|
Integer[] values = new Integer[32];
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
values[i] = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0600 + i);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (pinputs == null)
|
||||||
|
pinputs = 0;
|
||||||
if (inputs == null)
|
if (inputs == null)
|
||||||
inputs = 0;
|
inputs = 0;
|
||||||
if (outputs == null)
|
if (outputs == null)
|
||||||
|
@ -225,19 +462,25 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
if (pullups == null)
|
if (pullups == null)
|
||||||
pullups = 0;
|
pullups = 0;
|
||||||
|
|
||||||
System.err.println(String.format("Inputs State: 0x%08x",inputs));
|
System.err.println(String.format("Inputs State (Phys.): 0x%08x",pinputs));
|
||||||
System.err.println(String.format("Outputs State: 0x%08x",outputs));
|
System.err.println(String.format("Inputs State: 0x%08x",inputs));
|
||||||
System.err.println(String.format("PullUP State: 0x%08x",pullups));
|
System.err.println(String.format("Outputs State: 0x%08x",outputs));
|
||||||
|
System.err.println(String.format("PullUP State: 0x%08x",pullups));
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
for (int i=0;i<32;i++){
|
||||||
if ((inputs & (1<<i))!=0){
|
if ((inputs & (1<<i))!=0){
|
||||||
inputButtons[i].setBackground(Color.GREEN);
|
inputButtons[i].setBackground(Color.GREEN);
|
||||||
inputButtons[i].setSelected(true);
|
|
||||||
} else {
|
} else {
|
||||||
inputButtons[i].setBackground(Color.RED);
|
inputButtons[i].setBackground(Color.WHITE);
|
||||||
inputButtons[i].setSelected(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values[i] != null){
|
||||||
|
inputButtons[i].setText(String.format("<html><center>%d<br/>[%d]</center></html>", i, values[i]));
|
||||||
|
} else {
|
||||||
|
inputButtons[i].setText(String.format("<html><center>%d<br/>N.A.</center></html>", i));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
if ((outputs & (1<<i))!=0){
|
if ((outputs & (1<<i))!=0){
|
||||||
outputButtons[i].setBackground(Color.GREEN);
|
outputButtons[i].setBackground(Color.GREEN);
|
||||||
outputButtons[i].setSelected(true);
|
outputButtons[i].setSelected(true);
|
||||||
|
@ -256,10 +499,44 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0;i<8;i++){
|
for (int i=0;i<8;i++){
|
||||||
float analog = serviceLink.getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i );
|
Float analog = serviceLink.getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i );
|
||||||
analogLabels[i].setText(String.format("%5.3fV", (analog * 10.0f)));
|
if (analog != null){
|
||||||
|
analogLabels[i].setText(String.format("%5.3fV", (analog * 10.0f)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
DefaultListModel<String> lm = (DefaultListModel<String>)lMessages.getModel();
|
||||||
|
lm.addElement(String.format("Assertion: Error: 0x%08x (%d) Position: 0x%04x Mark: %d", assert_error,assert_error, assert_code & 0xffff, (assert_code >> 16) & 0xffff));
|
||||||
|
lMessages.ensureIndexIsVisible(lm.size()-1);
|
||||||
|
|
||||||
|
serviceLink.writeInt(13, 0, 0x0025, -1);
|
||||||
|
};
|
||||||
|
} catch (Exception ex){
|
||||||
|
System.err.println("Exception while checking for assertions...");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.err.println(String.format("updateLiveView(): Time needed: %d", (endTime - startTime)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -294,7 +571,7 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serviceLink.writeInt((byte)13, (byte)0, 0x81FA, pullups);
|
serviceLink.writeInt((byte)13, (byte)0, 0x0683, pullups);
|
||||||
} catch (ServiceLinkRequestFailedException e) {
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -305,5 +582,83 @@ public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void syncUnixTime(){
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
if (this.serviceLink != null){
|
||||||
|
try {
|
||||||
|
this.serviceLink.writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void manualSnapshot(){
|
||||||
|
if (this.serviceLink != null){
|
||||||
|
try {
|
||||||
|
Integer emask = this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x9001);
|
||||||
|
|
||||||
|
System.err.println(String.format("EMASK: 0x%08x", emask));
|
||||||
|
|
||||||
|
|
||||||
|
this.serviceLink.writeInt((byte)13, (byte)0, 0x1001, 2);
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void message(String msg){
|
||||||
|
((DefaultListModel<String>)lMessages.getModel()).addElement(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void quartzCorrect(){
|
||||||
|
long lStart,lEnd;
|
||||||
|
long rStart,rEnd;
|
||||||
|
long lDelta,rDelta;
|
||||||
|
long delta;
|
||||||
|
|
||||||
|
if (this.serviceLink != null){
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
lStart = System.currentTimeMillis();
|
||||||
|
rStart = serviceLink.readInt(13, 0, 0x0027);
|
||||||
|
|
||||||
|
Thread.sleep(30000);
|
||||||
|
|
||||||
|
lEnd = System.currentTimeMillis();
|
||||||
|
rEnd = serviceLink.readInt(13, 0, 0x0027);
|
||||||
|
|
||||||
|
lDelta = (lEnd - lStart)*1000;
|
||||||
|
rDelta = rEnd - rStart;
|
||||||
|
|
||||||
|
delta = lDelta - rDelta;
|
||||||
|
|
||||||
|
message(String.format("Local: %d Remote: %d Delta: %d", lDelta,rDelta,delta));
|
||||||
|
|
||||||
|
delta /= 30;
|
||||||
|
|
||||||
|
message(String.format("Korrektur: %d", delta));
|
||||||
|
|
||||||
|
serviceLink.writeInt(13, 0, 0x1002, (int)delta);
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
package org.hwo.pulscounter.ui;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
|
|
||||||
public class MainWindow {
|
|
||||||
|
|
||||||
private JFrame frame;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
MainWindow window = new MainWindow();
|
|
||||||
window.frame.setVisible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the application.
|
|
||||||
*/
|
|
||||||
public MainWindow() {
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the contents of the frame.
|
|
||||||
*/
|
|
||||||
private void initialize() {
|
|
||||||
frame = new JFrame();
|
|
||||||
frame.setBounds(100, 100, 655, 444);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
||||||
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0, 0};
|
|
||||||
gridBagLayout.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
||||||
gridBagLayout.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
||||||
frame.getContentPane().setLayout(gridBagLayout);
|
|
||||||
|
|
||||||
JButton btnNewButton = new JButton("Live Ansicht");
|
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
LiveViewFrame lvf = new LiveViewFrame();
|
|
||||||
lvf.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
|
||||||
gbc_btnNewButton.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_btnNewButton.gridx = 0;
|
|
||||||
gbc_btnNewButton.gridy = 0;
|
|
||||||
frame.getContentPane().add(btnNewButton, gbc_btnNewButton);
|
|
||||||
|
|
||||||
JButton btnAuswertung = new JButton("Auswertung");
|
|
||||||
GridBagConstraints gbc_btnAuswertung = new GridBagConstraints();
|
|
||||||
gbc_btnAuswertung.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_btnAuswertung.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnAuswertung.gridx = 1;
|
|
||||||
gbc_btnAuswertung.gridy = 0;
|
|
||||||
frame.getContentPane().add(btnAuswertung, gbc_btnAuswertung);
|
|
||||||
|
|
||||||
JButton btnZhlerKonfigurieren = new JButton("Zähler konfigurieren");
|
|
||||||
GridBagConstraints gbc_btnZhlerKonfigurieren = new GridBagConstraints();
|
|
||||||
gbc_btnZhlerKonfigurieren.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_btnZhlerKonfigurieren.insets = new Insets(0, 0, 0, 5);
|
|
||||||
gbc_btnZhlerKonfigurieren.gridx = 0;
|
|
||||||
gbc_btnZhlerKonfigurieren.gridy = 1;
|
|
||||||
frame.getContentPane().add(btnZhlerKonfigurieren, gbc_btnZhlerKonfigurieren);
|
|
||||||
|
|
||||||
JButton btnEinstellungen = new JButton("Einstellungen");
|
|
||||||
btnEinstellungen.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
AppSettingsFrame asf = new AppSettingsFrame();
|
|
||||||
asf.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnEinstellungen = new GridBagConstraints();
|
|
||||||
gbc_btnEinstellungen.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc_btnEinstellungen.gridx = 1;
|
|
||||||
gbc_btnEinstellungen.gridy = 1;
|
|
||||||
frame.getContentPane().add(btnEinstellungen, gbc_btnEinstellungen);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,913 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
|
import org.hwo.Smoother;
|
||||||
|
import org.hwo.datetime.DateTime;
|
||||||
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
|
import org.hwo.logging.Logging;
|
||||||
|
import org.hwo.platform.Platform;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
|
import org.hwo.pulscounter.SnapshotManager.Notification;
|
||||||
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.tasklet.Tasklet;
|
||||||
|
import org.hwo.tasklet.TaskletListener;
|
||||||
|
import org.hwo.tasklet.TaskletManager;
|
||||||
|
import org.hwo.ui.dialog.SerialPortChooser;
|
||||||
|
import org.omg.CORBA.Environment;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
|
import java.awt.event.WindowStateListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import java.awt.Font;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.ToolTipManager;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
import javax.swing.plaf.metal.MetalBorders.ToolBarBorder;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import static org.hwo.logging.Logging.log;
|
||||||
|
|
||||||
|
public class NewMainWindow implements PulsCounterApplicationListener, TaskletListener{
|
||||||
|
|
||||||
|
private JFrame frmSynolog;
|
||||||
|
private JTextField tfSerialPortName;
|
||||||
|
private JSplitPane splitter;
|
||||||
|
private JButton btnNewButton;
|
||||||
|
private JTextField tfConnection;
|
||||||
|
private JButton btnSetup;
|
||||||
|
|
||||||
|
private DefaultListModel<String> messageListModel;
|
||||||
|
private JList lMessages;
|
||||||
|
|
||||||
|
private Timer timerReconnect;
|
||||||
|
private JPanel pChannels;
|
||||||
|
|
||||||
|
private ChannelDisplay[] channelDisplays;
|
||||||
|
private JButton btnC;
|
||||||
|
private JPanel panel_3;
|
||||||
|
private JScrollPane scrollPane_1;
|
||||||
|
private JList lTasklets;
|
||||||
|
|
||||||
|
private DefaultListModel<Tasklet> knownTasklets;
|
||||||
|
|
||||||
|
private Boolean connected;
|
||||||
|
private JButton btnDatenExportieren;
|
||||||
|
|
||||||
|
private Integer trimTicksOnConnect;
|
||||||
|
private Long trimTimeOnConnect;
|
||||||
|
private Integer trimDeviceTimeSlice;
|
||||||
|
private JCheckBox cbTrimDevice;
|
||||||
|
|
||||||
|
private Smoother smoothTrim;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the application.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
boolean batchRun = false;
|
||||||
|
boolean deviceSetup = false;
|
||||||
|
String logFileName = "synololog.log";
|
||||||
|
|
||||||
|
Iterator<String> aiter = Arrays.asList(args).iterator();
|
||||||
|
|
||||||
|
while (aiter.hasNext()){
|
||||||
|
String opt = aiter.next();
|
||||||
|
|
||||||
|
switch (opt){
|
||||||
|
case "-b":
|
||||||
|
batchRun = true;
|
||||||
|
break;
|
||||||
|
case "--device-setup":
|
||||||
|
deviceSetup = true;
|
||||||
|
batchRun = false;
|
||||||
|
break;
|
||||||
|
case "--log":
|
||||||
|
logFileName = aiter.next();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logging.setLogFileName(logFileName);
|
||||||
|
|
||||||
|
logStartup();
|
||||||
|
|
||||||
|
if (deviceSetup){
|
||||||
|
startDeviceSetup();
|
||||||
|
} else if (batchRun){
|
||||||
|
startBATCH();
|
||||||
|
} else {
|
||||||
|
startGUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void logStartup(){
|
||||||
|
log("%s.logStartup()",NewMainWindow.class.getCanonicalName());
|
||||||
|
log("Synololog Java Software startup");
|
||||||
|
|
||||||
|
log("JAVA Environment: %s (%s)", System.getProperty("java.version"),
|
||||||
|
System.getProperty("java.vendor"));
|
||||||
|
|
||||||
|
log("Operating System: %s [%s] %s", System.getProperty("os.name"),
|
||||||
|
System.getProperty("os.arch"),
|
||||||
|
System.getProperty("os.version"));
|
||||||
|
|
||||||
|
log("User Environment: %s (%s) (CWD:%s)", System.getProperty("user.name"),
|
||||||
|
System.getProperty("user.home"),
|
||||||
|
System.getProperty("user.dir"));
|
||||||
|
|
||||||
|
log("Hostname: %s",Platform.getHostName());
|
||||||
|
log("OS Search Path: %s", System.getenv("PATH"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startGUI(){
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Set cross-platform Java L&F (also called "Metal")
|
||||||
|
UIManager.setLookAndFeel(
|
||||||
|
UIManager.getCrossPlatformLookAndFeelClassName());
|
||||||
|
}
|
||||||
|
catch (UnsupportedLookAndFeelException e) {
|
||||||
|
// handle exception
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e) {
|
||||||
|
// handle exception
|
||||||
|
}
|
||||||
|
catch (InstantiationException e) {
|
||||||
|
// handle exception
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e) {
|
||||||
|
// handle exception
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTipManager.sharedInstance().setDismissDelay( 20000 );
|
||||||
|
ToolTipManager.sharedInstance().setInitialDelay( 1250 );
|
||||||
|
ToolTipManager.sharedInstance().setReshowDelay( 500 );
|
||||||
|
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
NewMainWindow window = new NewMainWindow();
|
||||||
|
window.frmSynolog.setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startBATCH(){
|
||||||
|
|
||||||
|
BatchRunner batchRunner = new BatchRunner();
|
||||||
|
batchRunner.run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startDeviceSetup(){
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
DeviceTestFrame deviceTestFrame = new DeviceTestFrame();
|
||||||
|
deviceTestFrame.setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @wbp.parser.entryPoint
|
||||||
|
*/
|
||||||
|
public NewMainWindow() {
|
||||||
|
initialize();
|
||||||
|
|
||||||
|
this.connected = false;
|
||||||
|
|
||||||
|
knownTasklets = new DefaultListModel<Tasklet>();
|
||||||
|
lTasklets.setModel(knownTasklets);
|
||||||
|
TaskletManager.instance().addTaskletListener(this);
|
||||||
|
|
||||||
|
messageListModel = new DefaultListModel<String>();
|
||||||
|
lMessages.setModel(messageListModel);
|
||||||
|
|
||||||
|
timerReconnect = new Timer("ReconnectThread",true);
|
||||||
|
|
||||||
|
application().addPulsCounterApplicationListener(this);
|
||||||
|
|
||||||
|
application().fireConnectionStateChanged();
|
||||||
|
application().fireSerialPortChanged();
|
||||||
|
|
||||||
|
application().message("Synololog Applikation wurde gestartet.");
|
||||||
|
|
||||||
|
channelDisplays = new ChannelDisplay[32];
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
channelDisplays[i] = new ChannelDisplay();
|
||||||
|
channelDisplays[i].setChannelName(String.format("%02d",i));
|
||||||
|
if (i > 7){
|
||||||
|
channelDisplays[i].setAnalog(false);
|
||||||
|
}
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.weighty = 1;
|
||||||
|
gbc.gridx = i & 0x03;
|
||||||
|
gbc.gridy = i >> 2;
|
||||||
|
|
||||||
|
channelDisplays[i].addChannelDisplayListener(new ChannelDisplayListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(ChannelDisplay sender, int setValue) {
|
||||||
|
channelSet(sender, setValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(ChannelDisplay sender) {
|
||||||
|
channelReset(sender);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pChannels.add(channelDisplays[i], gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
timerReconnect.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateChannelView();
|
||||||
|
}
|
||||||
|
}, 5000, 500);
|
||||||
|
|
||||||
|
timerReconnect.schedule(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (application().getServiceLink().isOpen()){
|
||||||
|
application().getSnapshotManager().notify(Notification.SYNC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 15000, 15000);
|
||||||
|
|
||||||
|
timerReconnect.schedule(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (application().getServiceLink().isOpen()){
|
||||||
|
if (cbTrimDevice.isSelected()){
|
||||||
|
trimDevice();
|
||||||
|
}
|
||||||
|
syncClock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 52000, 15000);
|
||||||
|
|
||||||
|
frmSynolog.addWindowListener(new WindowListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowOpened(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowIconified(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowDeiconified(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowDeactivated(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowActivated(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the contents of the frame.
|
||||||
|
*/
|
||||||
|
private void initialize() {
|
||||||
|
frmSynolog = new JFrame();
|
||||||
|
frmSynolog.setTitle("Synololog");
|
||||||
|
frmSynolog.setBounds(100, 100, 1000, 580);
|
||||||
|
frmSynolog.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frmSynolog.getContentPane().setLayout(new BorderLayout(0, 0));
|
||||||
|
frmSynolog.setBackground(Color.WHITE);
|
||||||
|
|
||||||
|
JToolBar toolBar = new JToolBar();
|
||||||
|
toolBar.setBorder(new EmptyBorder(3, 3, 3, 3));
|
||||||
|
toolBar.setBackground(Color.WHITE);
|
||||||
|
toolBar.setFloatable(false);
|
||||||
|
frmSynolog.getContentPane().add(toolBar, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
btnSetup = new JButton("S");
|
||||||
|
btnSetup.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
AppSettingsFrame asf = new AppSettingsFrame();
|
||||||
|
asf.setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
|
if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
|
||||||
|
asf.debugging();
|
||||||
|
|
||||||
|
asf.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnSetup.setToolTipText("<html>\n<b>Einstellungen</b><br/>\n<br/>\nEinstellungen der Synololog PC Software ändern.\n</html>");
|
||||||
|
toolBar.add(btnSetup);
|
||||||
|
|
||||||
|
btnC = new JButton("C");
|
||||||
|
btnC.setToolTipText("<html>\n<b>Konfiguration</b><br/>\n<br/>\nKonfiguration des Synololog bearbeiten.\n</html>");
|
||||||
|
btnC.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
DeviceConfiguration cc = new DeviceConfiguration();
|
||||||
|
cc.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnC);
|
||||||
|
|
||||||
|
btnDatenExportieren = new JButton("Daten exportieren...");
|
||||||
|
btnDatenExportieren.setToolTipText("<html>\n<b>Daten exportieren</b><br/>\n<br/>\nExport definitionen bearbeiten und ausführen.<br/>\nHiermit können die Aufzeichnungsdaten in Textdateien exportiert werden.<br/>\n</html>");
|
||||||
|
btnDatenExportieren.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
ExportFilesFrame eff = new ExportFilesFrame();
|
||||||
|
eff.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnDatenExportieren);
|
||||||
|
|
||||||
|
splitter = new JSplitPane();
|
||||||
|
splitter.setBorder(null);
|
||||||
|
splitter.setOneTouchExpandable(true);
|
||||||
|
splitter.setResizeWeight(0.6);
|
||||||
|
frmSynolog.getContentPane().add(splitter, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBackground(Color.WHITE);
|
||||||
|
splitter.setRightComponent(panel);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
panel_1.setBackground(Color.WHITE);
|
||||||
|
panel_1.setBorder(new TitledBorder(null, "Verbindung", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
||||||
|
gbc_panel_1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel_1.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_panel_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
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, 0};
|
||||||
|
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
||||||
|
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_1.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
|
JLabel lblAnschluss = new JLabel("Anschluss:");
|
||||||
|
GridBagConstraints gbc_lblAnschluss = new GridBagConstraints();
|
||||||
|
gbc_lblAnschluss.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblAnschluss.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_lblAnschluss.gridx = 0;
|
||||||
|
gbc_lblAnschluss.gridy = 0;
|
||||||
|
panel_1.add(lblAnschluss, gbc_lblAnschluss);
|
||||||
|
|
||||||
|
tfSerialPortName = new JTextField();
|
||||||
|
tfSerialPortName.setToolTipText("<html>\n<b>Ausgewählter Anschluss</b><br/>\n<br/>\nHier wird der momentan gewählte Anschluss gezeigt,<br/>\ndurch den die Software mit dem Synololog kommuniziert.\n</html>");
|
||||||
|
tfSerialPortName.setEditable(false);
|
||||||
|
GridBagConstraints gbc_tfSerialPortName = new GridBagConstraints();
|
||||||
|
gbc_tfSerialPortName.gridwidth = 3;
|
||||||
|
gbc_tfSerialPortName.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_tfSerialPortName.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfSerialPortName.gridx = 0;
|
||||||
|
gbc_tfSerialPortName.gridy = 1;
|
||||||
|
panel_1.add(tfSerialPortName, gbc_tfSerialPortName);
|
||||||
|
tfSerialPortName.setColumns(10);
|
||||||
|
|
||||||
|
btnNewButton = new JButton("auswählen...");
|
||||||
|
btnNewButton.setToolTipText("<html>\n<b>Auswahl eines anderen Anschlusses</b>\n</html>");
|
||||||
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
chooseSerialPort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cbTrimDevice = new JCheckBox("Trimmung justieren");
|
||||||
|
cbTrimDevice.setToolTipText("<html>\n<b>Abgleich der Zeitmessung</b><br/>\n<br/>\nDiese Funktion gleicht die Geschwindigkeit der Echtzeituhr des<br/>\nSynololog mit der des Rechners ab und korrigiert diese Laufzeitdifferenz.<br/>\n<br/>\nHierdurch kann der Synololog auch ohne angeschlossenen Rechner über<br/>\nmehrere Tage hinweg eine genaue Systemzeit vorhalten.<br/>\n<br/>\nDie Trimmung sollte vor allem dann ausgeführt werden, wenn die durchschnittliche<br/>\nUmgebungstemperatur am Einsatzort des Synololog sich stark verändert.\n</html>");
|
||||||
|
cbTrimDevice.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
trimTicksOnConnect = null;
|
||||||
|
if (cbTrimDevice.isSelected()){
|
||||||
|
trimDevice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GridBagConstraints gbc_cbTrimDevice = new GridBagConstraints();
|
||||||
|
gbc_cbTrimDevice.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_cbTrimDevice.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_cbTrimDevice.gridx = 0;
|
||||||
|
gbc_cbTrimDevice.gridy = 2;
|
||||||
|
panel_1.add(cbTrimDevice, gbc_cbTrimDevice);
|
||||||
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
||||||
|
gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_btnNewButton.gridx = 2;
|
||||||
|
gbc_btnNewButton.gridy = 2;
|
||||||
|
panel_1.add(btnNewButton, gbc_btnNewButton);
|
||||||
|
|
||||||
|
tfConnection = new JTextField();
|
||||||
|
tfConnection.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
tfConnection.setText("...");
|
||||||
|
tfConnection.setBackground(Color.WHITE);
|
||||||
|
tfConnection.setEditable(false);
|
||||||
|
GridBagConstraints gbc_tfConnection = new GridBagConstraints();
|
||||||
|
gbc_tfConnection.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfConnection.gridwidth = 3;
|
||||||
|
gbc_tfConnection.gridx = 0;
|
||||||
|
gbc_tfConnection.gridy = 4;
|
||||||
|
panel_1.add(tfConnection, gbc_tfConnection);
|
||||||
|
tfConnection.setColumns(10);
|
||||||
|
|
||||||
|
JPanel panel_2 = new JPanel();
|
||||||
|
panel_2.setBackground(Color.WHITE);
|
||||||
|
panel_2.setBorder(new TitledBorder(null, "Meldungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel_2 = new GridBagConstraints();
|
||||||
|
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_2.gridx = 0;
|
||||||
|
gbc_panel_2.gridy = 4;
|
||||||
|
panel.add(panel_2, gbc_panel_2);
|
||||||
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
||||||
|
gbl_panel_2.columnWidths = new int[]{142, 0};
|
||||||
|
gbl_panel_2.rowHeights = new int[]{3, 0};
|
||||||
|
gbl_panel_2.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_2.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel_2.setLayout(gbl_panel_2);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 0;
|
||||||
|
panel_2.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
lMessages = new JList();
|
||||||
|
lMessages.setFont(new Font("Cantarell", Font.PLAIN, 10));
|
||||||
|
scrollPane.setViewportView(lMessages);
|
||||||
|
|
||||||
|
panel_3 = new JPanel();
|
||||||
|
panel_3.setBackground(Color.WHITE);
|
||||||
|
panel_3.setBorder(new TitledBorder(null, "Aktive Aufgaben", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
||||||
|
gbc_panel_3.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_3.gridx = 0;
|
||||||
|
gbc_panel_3.gridy = 5;
|
||||||
|
panel.add(panel_3, gbc_panel_3);
|
||||||
|
panel_3.setLayout(new BoxLayout(panel_3, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
scrollPane_1 = new JScrollPane();
|
||||||
|
panel_3.add(scrollPane_1);
|
||||||
|
|
||||||
|
lTasklets = new JList();
|
||||||
|
scrollPane_1.setViewportView(lTasklets);
|
||||||
|
|
||||||
|
pChannels = new JPanel();
|
||||||
|
pChannels.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||||
|
pChannels.setBackground(Color.WHITE);
|
||||||
|
pChannels.setMinimumSize(new Dimension(600, 10));
|
||||||
|
splitter.setLeftComponent(pChannels);
|
||||||
|
GridBagLayout gbl_pChannels = new GridBagLayout();
|
||||||
|
gbl_pChannels.columnWidths = new int[]{0};
|
||||||
|
gbl_pChannels.rowHeights = new int[]{0};
|
||||||
|
gbl_pChannels.columnWeights = new double[]{Double.MIN_VALUE};
|
||||||
|
gbl_pChannels.rowWeights = new double[]{Double.MIN_VALUE};
|
||||||
|
pChannels.setLayout(gbl_pChannels);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PulsCounter2Application application(){
|
||||||
|
return PulsCounter2Application.getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chooseSerialPort(){
|
||||||
|
SerialPortChooser spc = new SerialPortChooser();
|
||||||
|
NewSerialPort nsp = spc.execute( application().getSerialPort().getPortName() );
|
||||||
|
if (nsp != null)
|
||||||
|
setSerialPort(nsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSerialPort(NewSerialPort serialPort){
|
||||||
|
PulsCounter2Application.getApplication().setSerialPort(serialPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialPortChanged() {
|
||||||
|
tfSerialPortName.setText(application().getSerialPort().getPortName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionStateChanged(Boolean connected) {
|
||||||
|
if (connected){
|
||||||
|
Integer version = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001A);
|
||||||
|
Integer uptime = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0022);
|
||||||
|
Integer eesize = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x9000);
|
||||||
|
|
||||||
|
if (version != null){
|
||||||
|
tfConnection.setText(String.format("Version %d.%d.%d", version >> 16, (version >> 8) & 0xff, version & 0xff));
|
||||||
|
tfConnection.setBackground(Color.GREEN);
|
||||||
|
tfConnection.setForeground(Color.BLACK);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
application().message(String.format("Synololog verbunden (Version %d.%d.%d) (Uptime: %d:%d:%d)", version >> 16, (version >> 8) & 0xff, version & 0xff, uptime / 3600, (uptime / 60)%60, uptime % 60));
|
||||||
|
application().message(String.format("EEPROM Size: 0x%08x Bytes", eesize));
|
||||||
|
|
||||||
|
trimDeviceTimeSlice = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x1302);
|
||||||
|
|
||||||
|
/* Trim helper initialisieren */
|
||||||
|
trimTicksOnConnect = null;
|
||||||
|
|
||||||
|
application().getSnapshotManager().notify(Notification.FULLSYNC);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
tfConnection.setText("Version unbekannt");
|
||||||
|
tfConnection.setBackground(Color.YELLOW);
|
||||||
|
tfConnection.setForeground(Color.BLACK);
|
||||||
|
|
||||||
|
application().getServiceLink().close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tfConnection.setText("Nicht verbunden");
|
||||||
|
tfConnection.setBackground(Color.RED);
|
||||||
|
tfConnection.setForeground(Color.WHITE);
|
||||||
|
|
||||||
|
trimTicksOnConnect = null;
|
||||||
|
|
||||||
|
if (timerReconnect != null){
|
||||||
|
timerReconnect.schedule(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!application().getServiceLink().isOpen()){
|
||||||
|
try {
|
||||||
|
application().getServiceLink().open();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.connected)
|
||||||
|
application().message("Verbindung getrennt");
|
||||||
|
}
|
||||||
|
this.connected = connected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateChannelView(){
|
||||||
|
Integer inputs,outputs,pullups;
|
||||||
|
|
||||||
|
if (application().getServiceLink().isOpen()){
|
||||||
|
|
||||||
|
inputs = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0681 );
|
||||||
|
outputs = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0682 );
|
||||||
|
pullups = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0683 );
|
||||||
|
|
||||||
|
if (inputs == null)
|
||||||
|
inputs = 0;
|
||||||
|
if (outputs == null)
|
||||||
|
outputs = 0;
|
||||||
|
if (pullups == null)
|
||||||
|
pullups = 0;
|
||||||
|
|
||||||
|
Integer[] values = new Integer[32];
|
||||||
|
Float[] analog = new Float[8];
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
values[i] = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0600 + i);
|
||||||
|
|
||||||
|
if (i<8){
|
||||||
|
analog[i] = application().getServiceLink().getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i ) * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
channelDisplays[i].setInput( (inputs & 1<<i) != 0 );
|
||||||
|
channelDisplays[i].setOutput( (outputs & 1<<i) != 0);
|
||||||
|
channelDisplays[i].setPullup( (pullups & 1<<i) != 0);
|
||||||
|
channelDisplays[i].setCounter(values[i]);
|
||||||
|
|
||||||
|
if (i<8){
|
||||||
|
channelDisplays[i].setVoltage(new Double(analog[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer deviceTime = application().getServiceLink().readInt(13, 0, 0x001C);
|
||||||
|
Long delta = deviceTime - (System.currentTimeMillis()/1000);
|
||||||
|
|
||||||
|
if ((delta < -1) || (delta > 1)){
|
||||||
|
application().message(String.format("Abweichung ist %d Sekunde(-n)",delta));
|
||||||
|
application().getServiceLink().writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
|
||||||
|
application().message("Uhr der Elektronik wurde korrigiert.");
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
checkForAssertions();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer syncClock(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer trimDevice(){
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (trimTicksOnConnect != null){
|
||||||
|
long s1,s2,T;
|
||||||
|
Integer device_us;
|
||||||
|
|
||||||
|
|
||||||
|
s1 = System.currentTimeMillis();
|
||||||
|
device_us = application().getServiceLink().readInt(13, 0, 0x1300);
|
||||||
|
s2 = System.currentTimeMillis();
|
||||||
|
T = (s1+s2)>>1;
|
||||||
|
|
||||||
|
if (device_us < 0){
|
||||||
|
trimTicksOnConnect = null;
|
||||||
|
} else {
|
||||||
|
long elapsed_us;
|
||||||
|
long diff_us;
|
||||||
|
long trim_ns_per_slice;
|
||||||
|
|
||||||
|
elapsed_us = (T - trimTimeOnConnect) * 1000;
|
||||||
|
diff_us = elapsed_us - device_us;
|
||||||
|
|
||||||
|
System.err.println(String.format("Device Triming: Elapsed us: Dev: %d PC %d Diff: %d", device_us,elapsed_us,diff_us));
|
||||||
|
|
||||||
|
trim_ns_per_slice = (diff_us * 1000) * trimDeviceTimeSlice / elapsed_us;
|
||||||
|
|
||||||
|
smoothTrim.cycle((int)trim_ns_per_slice);
|
||||||
|
|
||||||
|
System.err.println(String.format("Device Triming: Trim %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
||||||
|
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x1002, smoothTrim.getWert());
|
||||||
|
|
||||||
|
application().message(String.format("Trimmung wurde korrigiert auf %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long s1,s2,T;
|
||||||
|
|
||||||
|
try {
|
||||||
|
trimTicksOnConnect = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0027);
|
||||||
|
s1 = System.currentTimeMillis();
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x1301, 0);
|
||||||
|
s2 = System.currentTimeMillis();
|
||||||
|
trimTimeOnConnect = (s1+s2)>>1;
|
||||||
|
|
||||||
|
smoothTrim = new Smoother();
|
||||||
|
smoothTrim.setTn( 10 );
|
||||||
|
smoothTrim.setWert( application().getServiceLink().readInt(13, 0, 0x1002) );
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
System.err.println("trimDevice(): init failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
trimTicksOnConnect = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void checkForAssertions(){
|
||||||
|
Integer assert_error,assert_code;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assert_error = -1;
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
assert_error = application().getServiceLink().readInt(13, 0, 0x0026);
|
||||||
|
assert_code = application().getServiceLink().readInt(13, 0, 0x0025);
|
||||||
|
|
||||||
|
if (assert_error >= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
application().message(String.format("Assertion: Error: 0x%08x (%d) Position: 0x%04x Mark: %d", assert_error,assert_error, assert_code & 0xffff, (assert_code >> 16) & 0xffff));
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x0025, -1);
|
||||||
|
};
|
||||||
|
} catch (Exception ex){
|
||||||
|
System.err.println("Exception while checking for assertions...");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void taskletQueued(final TaskletManager manager, final Tasklet tasklet) {
|
||||||
|
if (EventQueue.isDispatchThread())
|
||||||
|
knownTasklets.addElement(tasklet);
|
||||||
|
else {
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
taskletQueued(manager, tasklet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void taskletStarted(final TaskletManager manager, final Tasklet tasklet) {
|
||||||
|
if (EventQueue.isDispatchThread())
|
||||||
|
lTasklets.repaint();
|
||||||
|
else
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
taskletStarted(manager, tasklet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void taskletFinished(final TaskletManager manager, final Tasklet tasklet) {
|
||||||
|
if (EventQueue.isDispatchThread())
|
||||||
|
knownTasklets.removeElement(tasklet);
|
||||||
|
else
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
taskletFinished(manager, tasklet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public synchronized void taskletProgressChanged(final TaskletManager manager, final Tasklet tasklet) {
|
||||||
|
if (EventQueue.isDispatchThread())
|
||||||
|
lTasklets.repaint();
|
||||||
|
else
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
taskletProgressChanged(manager, tasklet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void channelReset(ChannelDisplay display){
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
if (display == channelDisplays[n]){
|
||||||
|
channelReset(n,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void channelReset(int channel,int setValue){
|
||||||
|
try {
|
||||||
|
|
||||||
|
application().getServiceLink().writeInt(13, 0, 0x0600 + channel, setValue);
|
||||||
|
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void channelSet(ChannelDisplay display,int setValue){
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
if (display == channelDisplays[n]){
|
||||||
|
channelReset(n,setValue);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 662 B |
After Width: | Height: | Size: 659 B |
After Width: | Height: | Size: 422 B |
After Width: | Height: | Size: 430 B |
After Width: | Height: | Size: 380 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 421 B |
After Width: | Height: | Size: 431 B |