Update
parent
cb729441ca
commit
78d12d7635
|
@ -3,5 +3,6 @@
|
||||||
<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.6"/>
|
||||||
<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="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
2
.project
2
.project
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>org.hwo.pulscounter</name>
|
<name>org.hwo.pulscounter2</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
public interface IPCController {
|
||||||
|
|
||||||
|
void shutdownService(int exitCode);
|
||||||
|
|
||||||
|
}
|
|
@ -1,24 +1,30 @@
|
||||||
package org.hwo.pulscounter;
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import org.hwo.bitfields.BitField;
|
||||||
|
import org.hwo.io.SerialPortExeption;
|
||||||
|
|
||||||
public interface IPulsCounter {
|
public interface IPulsCounter {
|
||||||
|
|
||||||
public String[] getDeviceName();
|
public String[] getDeviceName();
|
||||||
|
|
||||||
public int getChannels();
|
public void close();
|
||||||
|
|
||||||
public String getChannelName(Integer channel);
|
public int getChannels() throws SerialPortExeption;
|
||||||
public void setChannelName(Integer channel,String name);
|
|
||||||
|
public String getChannelName(Integer channel) throws SerialPortExeption;
|
||||||
|
public void setChannelName(Integer channel,String name) throws SerialPortExeption;
|
||||||
|
|
||||||
public int[] getChannelCounters();
|
public int[] getChannelCounters() throws SerialPortExeption;
|
||||||
public void setChannelCounter(Integer channel,Integer count);
|
public void setChannelCounter(Integer channel,Integer count) throws SerialPortExeption;
|
||||||
|
|
||||||
public int[] getChannelOffsets();
|
public int[] getChannelOffsets() throws SerialPortExeption;
|
||||||
public void setChannelOffset(Integer channel,Integer offset);
|
public void setChannelOffset(Integer channel,Integer offset) throws SerialPortExeption;
|
||||||
|
|
||||||
public String getPhysicalInterfaceName();
|
public String getPhysicalInterfaceName() throws SerialPortExeption;
|
||||||
public void setPhysicalInterfaceName(String interfaceName);
|
public void setPhysicalInterfaceName(String interfaceName) throws SerialPortExeption;
|
||||||
|
|
||||||
public String[] getPhysicalInterfaceNames();
|
public String[] getPhysicalInterfaceNames() throws SerialPortExeption;
|
||||||
|
|
||||||
|
public Integer getPhysicalInputs() throws SerialPortExeption;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.hwo.bitfields.BitField;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
|
import org.hwo.io.SerialPortExeption;
|
||||||
import org.hwo.io.servicelink.ServiceLink;
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
import org.hwo.io.servicelink.ServiceLinkException;
|
import org.hwo.io.servicelink.ServiceLinkException;
|
||||||
import org.hwo.io.servicelink.ServiceLinkRequestFailedException;
|
import org.hwo.io.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
@ -41,22 +43,12 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
|
|
||||||
setPhysicalInterfaceName(defaultPort);
|
setPhysicalInterfaceName(defaultPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void reset(int ch)
|
public void close(){
|
||||||
{
|
if (this.serviceLink != null)
|
||||||
|
this.serviceLink.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void reset()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
synchronized public void update()
|
|
||||||
{
|
|
||||||
System.err.println(String.format("BRKVAL: 0x%04x", serviceLink.getServiceRegisterCache().getCachedInteger((byte)0, (byte)0, (short)0x200)));
|
|
||||||
System.err.println(String.format("SPLIM : 0x%04x", serviceLink.getServiceRegisterCache().getCachedInteger((byte)0, (byte)0, (short)0x201)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveProps(){
|
private void saveProps(){
|
||||||
File pf = new File("chnames.prop");
|
File pf = new File("chnames.prop");
|
||||||
try {
|
try {
|
||||||
|
@ -72,6 +64,13 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
if (!serviceLink.isOpen())
|
if (!serviceLink.isOpen())
|
||||||
try {
|
try {
|
||||||
serviceLink.open();
|
serviceLink.open();
|
||||||
|
serviceLink.getSerialPort().setTimeout(250);
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} catch (ServiceLinkException e) {
|
} catch (ServiceLinkException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -101,16 +100,18 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
|
|
||||||
this.serviceLink.setSerialPort(serialPort);;
|
this.serviceLink.setSerialPort(serialPort);;
|
||||||
this.serviceLink.open();
|
this.serviceLink.open();
|
||||||
|
this.serviceLink.getSerialPort().setTimeout(500);
|
||||||
|
|
||||||
try {
|
/* try {
|
||||||
this.serviceLink.readInt((byte)0, (byte)0, 0);
|
this.serviceLink.readInt((byte)0, (byte)0, 0);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
System.err.println("BRKVAL: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020));
|
System.err.println("BRKVAL: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020));
|
||||||
System.err.println("SPLIM: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021));
|
System.err.println("SPLIM: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021));
|
||||||
|
System.err.println("tCounter: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0500));
|
||||||
|
System.err.println("tInterface:" + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0501));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,9 +136,13 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
int[] counters = new int[ nch ];
|
int[] counters = new int[ nch ];
|
||||||
|
|
||||||
for (int i=0;i<nch;i++) {
|
for (int i=0;i<nch;i++) {
|
||||||
counters[i] = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x1000 + i);
|
Integer v = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x1000 + i);
|
||||||
}
|
if (v != null) {
|
||||||
|
counters[i] = v;
|
||||||
|
} else {
|
||||||
|
counters[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return counters;
|
return counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,14 +201,14 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
System.err.println("BRKVAL: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020));
|
System.err.println("BRKVAL: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0020));
|
||||||
System.err.println("SPLIM: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021));
|
System.err.println("SPLIM: " + this.serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0021));
|
||||||
|
|
||||||
return serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0400 );
|
Integer r = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0400 );
|
||||||
|
if (r == null)
|
||||||
|
return 0;
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPhysicalInterfaceName() {
|
public String getPhysicalInterfaceName() {
|
||||||
|
|
||||||
checkOpen();
|
|
||||||
|
|
||||||
return serviceLink.getSerialPort().getPortName();
|
return serviceLink.getSerialPort().getPortName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,9 +218,14 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
chprop.setProperty("io.port", interfaceName);
|
chprop.setProperty("io.port", interfaceName);
|
||||||
saveProps();
|
saveProps();
|
||||||
|
|
||||||
SerialPort sport = SerialPort.newInstance();
|
if ((this.serviceLink == null) || (serviceLink.getSerialPort() == null)) {
|
||||||
sport.setPortName(interfaceName);
|
SerialPort sport = SerialPort.newInstance();
|
||||||
setSerialPort(sport);
|
sport.setPortName(interfaceName);
|
||||||
|
setSerialPort(sport);
|
||||||
|
} else {
|
||||||
|
serviceLink.getSerialPort().setPortName(interfaceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (ServiceLinkException sle){
|
} catch (ServiceLinkException sle){
|
||||||
sle.printStackTrace();
|
sle.printStackTrace();
|
||||||
|
@ -226,5 +236,14 @@ public class NewPulsCounterDevice implements IPulsCounter {
|
||||||
public String[] getPhysicalInterfaceNames() {
|
public String[] getPhysicalInterfaceNames() {
|
||||||
return SerialPort.getPortNames();
|
return SerialPort.getPortNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPhysicalInputs() throws SerialPortExeption {
|
||||||
|
Integer result;
|
||||||
|
|
||||||
|
result = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x0502);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,38 @@
|
||||||
package org.hwo.pulscounter;
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
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 java.util.prefs.Preferences;
|
||||||
|
|
||||||
import org.hwo.beacon.Beacon;
|
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;
|
||||||
import org.hwo.os.OsDetect.OsType;
|
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.json.RPCAdapter;
|
||||||
import org.hwo.rpc.simple.SimpleRPCServer;
|
import org.hwo.rpc.simple.SimpleRPCServer;
|
||||||
|
import org.hwo.rpc.simple.SimpleRPCService;
|
||||||
|
|
||||||
|
|
||||||
public class PulsCounter {
|
public class PulsCounter {
|
||||||
|
|
||||||
|
@ -21,37 +40,56 @@ public class PulsCounter {
|
||||||
public static Preferences getPrefs() {
|
public static Preferences getPrefs() {
|
||||||
return prefs;
|
return prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private IPulsCounter deviceConnection;
|
static private PulsCounterService localService;
|
||||||
public static IPulsCounter getDeviceConnection() {
|
public static PulsCounterService getLocalService(){
|
||||||
return deviceConnection;
|
return localService;
|
||||||
}
|
|
||||||
public static void setDeviceConnection(IPulsCounter deviceConnection) {
|
|
||||||
PulsCounter.deviceConnection = deviceConnection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Beacon beacon;
|
static private InspectorApplication inspectorApplication;
|
||||||
public static Beacon getBeacon() {
|
static public InspectorApplication getInspectorApplication() {
|
||||||
return beacon;
|
if (inspectorApplication == null)
|
||||||
|
inspectorApplication = new InspectorApplication();
|
||||||
|
return inspectorApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean serverMode;
|
|
||||||
|
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[])
|
public static void main(String args[])
|
||||||
{
|
{
|
||||||
File cwd = new File(".");
|
File cwd = new File(".");
|
||||||
|
|
||||||
System.err.println("Starting on OS: " + System.getProperty("os.name"));
|
/* System.err.println("Starting on OS: " + System.getProperty("os.name"));
|
||||||
System.err.println("Current Directory: " + cwd.getAbsolutePath());
|
System.err.println("Current Directory: " + cwd.getAbsolutePath());
|
||||||
System.err.println("Library Path: " + System.getProperty("java.library.path"));
|
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();
|
prefs = Preferences.userRoot();
|
||||||
|
|
||||||
if (OsDetect.getOperatingSystem() == OsType.LINUX)
|
if (OsDetect.getOperatingSystem() == OsType.LINUX)
|
||||||
{
|
{
|
||||||
System.err.println("Linux erkannt. Patche java.library.path");
|
// System.err.println("Linux erkannt. Patche java.library.path");
|
||||||
System.setProperty("java.library.path",String.format(".:%s",System.getProperty("java.library.path")));
|
// System.setProperty("java.library.path",String.format(".:%s",System.getProperty("java.library.path")));
|
||||||
Field fieldSysPath;
|
Field fieldSysPath;
|
||||||
try {
|
try {
|
||||||
fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
|
fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
|
||||||
|
@ -71,9 +109,14 @@ public class PulsCounter {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println("Library Path: " + System.getProperty("java.library.path"));
|
// 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();
|
Iterator<String> options = Arrays.asList(args).iterator();
|
||||||
|
|
||||||
while (options.hasNext()) {
|
while (options.hasNext()) {
|
||||||
|
@ -81,39 +124,181 @@ public class PulsCounter {
|
||||||
|
|
||||||
if (no.equals("-s")) {
|
if (no.equals("-s")) {
|
||||||
serverMode = true;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceConnection = null;
|
|
||||||
|
|
||||||
beacon = new Beacon(44556);
|
|
||||||
beacon.getProperties().setProperty("rpc.simple.interfaces", "org.hwo.pulsecounter");
|
|
||||||
beacon.getProperties().setProperty("rpc.simple.port", "44352");
|
|
||||||
beacon.setServerOnly(serverMode);
|
if (batchMode)
|
||||||
beacon.start();
|
guiMode = false;
|
||||||
|
|
||||||
try {
|
|
||||||
NewPulsCounterDevice device = new NewPulsCounterDevice();
|
|
||||||
|
localService = new PulsCounterService();
|
||||||
SimpleRPCServer rpcserver = new SimpleRPCServer(InetAddress.getByName("0.0.0.0"), 44352);
|
|
||||||
rpcserver.registerObject(IPulsCounter.class, device);
|
if (startLocalService){
|
||||||
rpcserver.start();
|
localService.start();
|
||||||
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!serverMode) {
|
if (batchMode) {
|
||||||
|
batchrun();
|
||||||
|
} else if (guiMode){
|
||||||
PulsCounterWindow window = new PulsCounterWindow();
|
PulsCounterWindow window = new PulsCounterWindow();
|
||||||
window.setVisible(true);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hwo.io.SerialPort;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.pulscounter.ui.AppSettingsListener;
|
||||||
|
|
||||||
|
public class PulsCounter2Application {
|
||||||
|
|
||||||
|
static PulsCounter2Application _application;
|
||||||
|
public static PulsCounter2Application getApplication(){
|
||||||
|
if (_application == null)
|
||||||
|
_application = new PulsCounter2Application();
|
||||||
|
|
||||||
|
return _application;
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialPort serialPort;
|
||||||
|
ServiceLink serviceLink;
|
||||||
|
|
||||||
|
List<AppSettingsListener> appSettingsListeners;
|
||||||
|
|
||||||
|
public PulsCounter2Application(){
|
||||||
|
appSettingsListeners = new LinkedList<AppSettingsListener>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAppSettingsListener(AppSettingsListener listener){
|
||||||
|
appSettingsListeners.add(listener);
|
||||||
|
}
|
||||||
|
public void removeAppSettingsListener(AppSettingsListener listener){
|
||||||
|
appSettingsListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireServiceLinkChanged(){
|
||||||
|
for (AppSettingsListener l: appSettingsListeners){
|
||||||
|
l.ServiceLinkChanged(serviceLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized SerialPort getSerialPort() {
|
||||||
|
return serialPort;
|
||||||
|
}
|
||||||
|
public synchronized void setSerialPort(SerialPort serialPort) {
|
||||||
|
if (serviceLink != null){
|
||||||
|
serviceLink.close();
|
||||||
|
serviceLink = null;
|
||||||
|
}
|
||||||
|
this.serialPort = serialPort;
|
||||||
|
|
||||||
|
fireServiceLinkChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized ServiceLink getServiceLink() {
|
||||||
|
if (serviceLink == null){
|
||||||
|
if (serialPort != null){
|
||||||
|
serviceLink = new ServiceLink(serialPort);
|
||||||
|
serviceLink.getSerialPort().setTimeout(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serviceLink;
|
||||||
|
}
|
||||||
|
public synchronized void setServiceLink(ServiceLink serviceLink) {
|
||||||
|
if (serviceLink != null){
|
||||||
|
serviceLink.close();
|
||||||
|
}
|
||||||
|
this.serviceLink = serviceLink;
|
||||||
|
|
||||||
|
fireServiceLinkChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ public class TimeBarrier {
|
||||||
CSV csv = new CSV();
|
CSV csv = new CSV();
|
||||||
for (CounterChannel channel: channels)
|
for (CounterChannel channel: channels)
|
||||||
{
|
{
|
||||||
csv.getCells().add(new String[]{channel.getChannel().toString(),channel.getValue().toString(),channel.getCorrect().toString(),channel.correctedValue().toString()});
|
// csv.getRecords().add(new String[]{channel.getChannel().toString(),channel.getValue().toString(),channel.getCorrect().toString(),channel.correctedValue().toString()});
|
||||||
}
|
}
|
||||||
csv.saveToStream(output);
|
csv.saveToStream(output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package org.hwo.pulscounter.application;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.elements.WorkShift;
|
||||||
|
|
||||||
|
public class InspectorApplication {
|
||||||
|
List<WorkShift> workShifts;
|
||||||
|
|
||||||
|
Connection db;
|
||||||
|
|
||||||
|
public InspectorApplication(){
|
||||||
|
workShifts = new LinkedList<WorkShift>();
|
||||||
|
/*
|
||||||
|
workShifts.add(new WorkShift());
|
||||||
|
workShifts.add(new WorkShift());
|
||||||
|
|
||||||
|
workShifts.get(0).setName("Frühschicht");
|
||||||
|
workShifts.get(0).getBegins().setHours(6);
|
||||||
|
workShifts.get(0).getBegins().setMinutes(0);
|
||||||
|
workShifts.get(0).getEnds().setHours(15);
|
||||||
|
workShifts.get(0).getEnds().setMinutes(0);
|
||||||
|
workShifts.get(1).setName("Frühschicht");
|
||||||
|
workShifts.get(1).getBegins().setHours(15);
|
||||||
|
workShifts.get(1).getBegins().setMinutes(0);
|
||||||
|
workShifts.get(1).getEnds().setHours(3);
|
||||||
|
workShifts.get(1).getEnds().setMinutes(0);
|
||||||
|
*/
|
||||||
|
connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Statement stat = db.createStatement();
|
||||||
|
ResultSet result = stat.executeQuery("SELECT * from workshifts");
|
||||||
|
|
||||||
|
while (result.next()){
|
||||||
|
WorkShift shift = new WorkShift();
|
||||||
|
shift.setName(result.getString("name"));
|
||||||
|
shift.getBegins().setTime( result.getTime("begins"));
|
||||||
|
shift.getEnds().setTime( result.getTime("ends"));
|
||||||
|
workShifts.add(shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.close();
|
||||||
|
stat.close();
|
||||||
|
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect(){
|
||||||
|
try {
|
||||||
|
Class.forName("org.postgresql.Driver");
|
||||||
|
|
||||||
|
db = DriverManager.getConnection("jdbc:postgresql://10.112.1.1/pulscounter", "haraldwolff","diekleinefeine");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkShift[] getWorkShifts(){
|
||||||
|
return workShifts.toArray(new WorkShift[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Connection getConnection() {
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
|
||||||
|
properties.put("hibernate.connection.driver", "org.postgresql.Driver");
|
||||||
|
properties.put("hibernate.connection.url", );
|
||||||
|
***/
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.hwo.pulscounter.elements;
|
||||||
|
|
||||||
|
import org.hwo.datetime.DateTime;
|
||||||
|
|
||||||
|
public class RawValueEntry {
|
||||||
|
|
||||||
|
int channel;
|
||||||
|
DateTime dateTime;
|
||||||
|
int value;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package org.hwo.pulscounter.elements;
|
||||||
|
|
||||||
|
import org.hwo.datetime.Date;
|
||||||
|
import org.hwo.datetime.TimeOfDay;
|
||||||
|
import org.hwo.datetime.DateTime;
|
||||||
|
|
||||||
|
|
||||||
|
public class WorkShift {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String comment;
|
||||||
|
|
||||||
|
private TimeOfDay begins;
|
||||||
|
private TimeOfDay ends;
|
||||||
|
|
||||||
|
public WorkShift(){
|
||||||
|
this.name = "";
|
||||||
|
this.comment = "";
|
||||||
|
this.begins = new TimeOfDay();
|
||||||
|
this.ends = new TimeOfDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOverMidnight(){
|
||||||
|
return ends.isEarlierThan(begins);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeOfDay getBegins() {
|
||||||
|
return begins;
|
||||||
|
}
|
||||||
|
public void setBegins(TimeOfDay begins) {
|
||||||
|
this.begins = begins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeOfDay getEnds() {
|
||||||
|
return ends;
|
||||||
|
}
|
||||||
|
public void setEnds(TimeOfDay ends) {
|
||||||
|
this.ends = ends;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime getShiftBegins(Date date){
|
||||||
|
DateTime dt = new DateTime(date, begins);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime getShiftEnds(Date date){
|
||||||
|
DateTime dt = new DateTime(date, ends);
|
||||||
|
if (isOverMidnight()){
|
||||||
|
dt.getDate().addDays(1);
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
package org.hwo.pulscounter.elements;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hwo.datetime.Date;
|
||||||
|
import org.hwo.datetime.DateTime;
|
||||||
|
import org.hwo.pulscounter.PulsCounter;
|
||||||
|
|
||||||
|
public class WorkShiftRecord {
|
||||||
|
|
||||||
|
public class ChannelRecords{
|
||||||
|
|
||||||
|
public class ChannelRecord
|
||||||
|
{
|
||||||
|
DateTime timestamp;
|
||||||
|
Integer value;
|
||||||
|
|
||||||
|
public ChannelRecord(DateTime timestamp,int value){
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
public void setTimestamp(DateTime timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
public void setValue(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int channel;
|
||||||
|
List<ChannelRecord> values;
|
||||||
|
|
||||||
|
public ChannelRecords(int channel){
|
||||||
|
this.channel = channel;
|
||||||
|
this.values = new LinkedList<WorkShiftRecord.ChannelRecords.ChannelRecord>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addValue(DateTime timestamp,int value){
|
||||||
|
this.values.add(new ChannelRecord(timestamp, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sort(){
|
||||||
|
/* List<ChannelRecord> sorted = new LinkedList<WorkShiftRecord.ChannelRecords.ChannelRecord>();
|
||||||
|
|
||||||
|
for (ChannelRecord r: values){
|
||||||
|
if (values.size() == 0)
|
||||||
|
sorted.add(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.values = sorted;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChannelRecord> getRecords(){
|
||||||
|
return this.values;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkShift workShift;
|
||||||
|
Date date;
|
||||||
|
|
||||||
|
Hashtable<Integer, ChannelRecords>
|
||||||
|
records;
|
||||||
|
|
||||||
|
public WorkShiftRecord(WorkShift shift,Date date){
|
||||||
|
workShift = shift;
|
||||||
|
this.date = date;
|
||||||
|
records = new Hashtable<Integer, WorkShiftRecord.ChannelRecords>();
|
||||||
|
|
||||||
|
loadRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadRecords(){
|
||||||
|
try {
|
||||||
|
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(2, workShift.getShiftEnds(date).getTimeStamp());
|
||||||
|
|
||||||
|
ResultSet result = stat.executeQuery();
|
||||||
|
|
||||||
|
while (result.next()){
|
||||||
|
int channel = result.getInt("channel");
|
||||||
|
|
||||||
|
if (!records.containsKey(channel)){
|
||||||
|
records.put(channel, new ChannelRecords(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.err.println("Record: " + result.getString("tstamp") + " [" + result.getString("channel") + "] " + result.getString("chvalue") );
|
||||||
|
|
||||||
|
records.get(channel).addValue(new DateTime(result.getTimestamp("tstamp")),result.getInt("chvalue"));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
result.close();
|
||||||
|
stat.close();
|
||||||
|
|
||||||
|
for (WorkShiftRecord.ChannelRecords record: records.values().toArray(new WorkShiftRecord.ChannelRecords[0])){
|
||||||
|
record.sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer[] getChannels(){
|
||||||
|
return (Integer[]) this.records.keySet().toArray(new Integer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelRecords getChannelRecords(int channel){
|
||||||
|
return records.get(channel);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package org.hwo.pulscounter.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import org.hwo.beacon.Beacon;
|
||||||
|
import org.hwo.pulscounter.IPulsCounter;
|
||||||
|
import org.hwo.pulscounter.NewPulsCounterDevice;
|
||||||
|
import org.hwo.rpc.simple.SimpleRPCServer;
|
||||||
|
|
||||||
|
public class PulsCounterService {
|
||||||
|
|
||||||
|
private NewPulsCounterDevice localDevice;
|
||||||
|
private SimpleRPCServer localRPCServer;
|
||||||
|
private Beacon serviceBeacon;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public PulsCounterService(){
|
||||||
|
|
||||||
|
serviceBeacon = new Beacon(44556);
|
||||||
|
serviceBeacon.getProperties().setProperty("rpc.simple.interfaces", "org.hwo.pulsecounter");
|
||||||
|
serviceBeacon.getProperties().setProperty("rpc.simple.port", "44352");
|
||||||
|
serviceBeacon.setServerOnly(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(){
|
||||||
|
|
||||||
|
if (localDevice == null){
|
||||||
|
localDevice = new NewPulsCounterDevice();
|
||||||
|
|
||||||
|
try {
|
||||||
|
localRPCServer = new SimpleRPCServer(InetAddress.getByName("0.0.0.0"), 44352);
|
||||||
|
localRPCServer.registerObject(IPulsCounter.class, localDevice);
|
||||||
|
localRPCServer.start();
|
||||||
|
|
||||||
|
serviceBeacon.start();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
localDevice = null;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(){
|
||||||
|
if (serviceBeacon.isAlive())
|
||||||
|
serviceBeacon.exit();
|
||||||
|
|
||||||
|
if (localDevice != null){
|
||||||
|
localRPCServer.exit();
|
||||||
|
localDevice.close();
|
||||||
|
localDevice = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return (serviceBeacon.isAlive());
|
||||||
|
}
|
||||||
|
|
||||||
|
public NewPulsCounterDevice getLocalDevice(){
|
||||||
|
return localDevice;
|
||||||
|
}
|
||||||
|
void setLocalDevice(NewPulsCounterDevice device){
|
||||||
|
localDevice = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
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.Dialog.ModalExclusionType;
|
||||||
|
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
import org.hwo.io.SerialPort;
|
||||||
|
import org.hwo.io.SerialPortChooser;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class AppSettingsFrame extends JFrame {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JTextField tfInterface;
|
||||||
|
|
||||||
|
private SerialPort selectedSerialPort;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public AppSettingsFrame() {
|
||||||
|
setTitle("Einstellungen");
|
||||||
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 603, 447);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
setContentPane(contentPane);
|
||||||
|
|
||||||
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
|
contentPane.add(tabbedPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
tabbedPane.addTab("Kommunikation", null, panel, null);
|
||||||
|
tabbedPane.setEnabledAt(0, true);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{0.0, 1.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 lblSchnittstelle = new JLabel("Schnittstelle:");
|
||||||
|
GridBagConstraints gbc_lblSchnittstelle = new GridBagConstraints();
|
||||||
|
gbc_lblSchnittstelle.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblSchnittstelle.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblSchnittstelle.gridx = 0;
|
||||||
|
gbc_lblSchnittstelle.gridy = 0;
|
||||||
|
panel.add(lblSchnittstelle, gbc_lblSchnittstelle);
|
||||||
|
|
||||||
|
tfInterface = new JTextField();
|
||||||
|
GridBagConstraints gbc_tfInterface = new GridBagConstraints();
|
||||||
|
gbc_tfInterface.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_tfInterface.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_tfInterface.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfInterface.gridx = 1;
|
||||||
|
gbc_tfInterface.gridy = 0;
|
||||||
|
panel.add(tfInterface, gbc_tfInterface);
|
||||||
|
tfInterface.setColumns(10);
|
||||||
|
|
||||||
|
JButton btnWhlen = new JButton("wählen...");
|
||||||
|
btnWhlen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
chooseSerialPort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnWhlen = new GridBagConstraints();
|
||||||
|
gbc_btnWhlen.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_btnWhlen.gridx = 2;
|
||||||
|
gbc_btnWhlen.gridy = 0;
|
||||||
|
panel.add(btnWhlen, gbc_btnWhlen);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
contentPane.add(panel_1, BorderLayout.SOUTH);
|
||||||
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
|
gbl_panel_1.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gbl_panel_1.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
|
JButton bCANCEL = new JButton("cancel");
|
||||||
|
bCANCEL.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_bCANCEL = new GridBagConstraints();
|
||||||
|
gbc_bCANCEL.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_bCANCEL.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_bCANCEL.gridx = 0;
|
||||||
|
gbc_bCANCEL.gridy = 0;
|
||||||
|
panel_1.add(bCANCEL, gbc_bCANCEL);
|
||||||
|
|
||||||
|
JButton bOK = new JButton("OK");
|
||||||
|
bOK.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
accept();
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_bOK = new GridBagConstraints();
|
||||||
|
gbc_bOK.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_bOK.gridx = 1;
|
||||||
|
gbc_bOK.gridy = 0;
|
||||||
|
panel_1.add(bOK, gbc_bOK);
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
|
||||||
|
selectedSerialPort = pc2a.getSerialPort();
|
||||||
|
|
||||||
|
if (selectedSerialPort != null)
|
||||||
|
tfInterface.setText(selectedSerialPort.getPortName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void accept(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
pc2a.setSerialPort(selectedSerialPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chooseSerialPort(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
|
||||||
|
SerialPortChooser spc = new SerialPortChooser();
|
||||||
|
|
||||||
|
String selectedPortName = null;
|
||||||
|
if (selectedSerialPort != null)
|
||||||
|
selectedPortName = selectedSerialPort.getPortName();
|
||||||
|
|
||||||
|
SerialPort sp = spc.execute(selectedPortName);
|
||||||
|
if (sp != null){
|
||||||
|
selectedSerialPort = sp;
|
||||||
|
tfInterface.setText(sp.getPortName());
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
|
||||||
|
public interface AppSettingsListener {
|
||||||
|
|
||||||
|
void ServiceLinkChanged(ServiceLink serviceLink);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,302 @@
|
||||||
|
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,122 @@
|
||||||
|
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,309 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.datetime.JTimeOfDay;
|
||||||
|
import org.hwo.io.servicelink.ServiceLink;
|
||||||
|
import org.hwo.io.servicelink.ServiceLinkException;
|
||||||
|
import org.hwo.io.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.pulscounter.PulsCounter2Application;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectOutputStream.PutField;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
|
||||||
|
public class LiveViewFrame extends JFrame implements AppSettingsListener {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
private Timer liveViewTimer;
|
||||||
|
private ServiceLink serviceLink;
|
||||||
|
|
||||||
|
private JToggleButton[] inputButtons;
|
||||||
|
private JToggleButton[] pullupButtons;
|
||||||
|
private JToggleButton[] outputButtons;
|
||||||
|
|
||||||
|
private JLabel[] analogLabels;
|
||||||
|
|
||||||
|
private JPanel pDisplay;
|
||||||
|
private JPanel pPullups;
|
||||||
|
private JPanel pAnalog;
|
||||||
|
private JPanel pOutputs;
|
||||||
|
|
||||||
|
private Integer inputs,
|
||||||
|
outputs,
|
||||||
|
pullups;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public LiveViewFrame() {
|
||||||
|
setTitle("Live Ansicht");
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 873, 530);
|
||||||
|
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, 0};
|
||||||
|
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};
|
||||||
|
contentPane.setLayout(gbl_contentPane);
|
||||||
|
|
||||||
|
pDisplay = new JPanel();
|
||||||
|
pDisplay.setBorder(new TitledBorder(null, "Eing\u00E4nge", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_pDisplay = new GridBagConstraints();
|
||||||
|
gbc_pDisplay.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_pDisplay.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_pDisplay.gridx = 0;
|
||||||
|
gbc_pDisplay.gridy = 0;
|
||||||
|
contentPane.add(pDisplay, gbc_pDisplay);
|
||||||
|
GridBagLayout gbl_pDisplay = new GridBagLayout();
|
||||||
|
gbl_pDisplay.columnWidths = new int[] {50, 50, 50, 50, 50, 50, 50, 50};
|
||||||
|
gbl_pDisplay.rowHeights = new int[] {25, 25, 25, 25};
|
||||||
|
gbl_pDisplay.columnWeights = new double[]{1.0, 1.0,1.0, 1.0,1.0, 1.0,1.0, 1.0};
|
||||||
|
gbl_pDisplay.rowWeights = new double[]{1.0, 1.0,1.0, 1.0};
|
||||||
|
pDisplay.setLayout(gbl_pDisplay);
|
||||||
|
|
||||||
|
pPullups = new JPanel();
|
||||||
|
pPullups.setBorder(new TitledBorder(null, "PullUPs", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_pPullups = new GridBagConstraints();
|
||||||
|
gbc_pPullups.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_pPullups.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_pPullups.gridx = 0;
|
||||||
|
gbc_pPullups.gridy = 1;
|
||||||
|
contentPane.add(pPullups, gbc_pPullups);
|
||||||
|
GridBagLayout gbl_pPullups = new GridBagLayout();
|
||||||
|
gbl_pPullups.columnWidths = new int[] {50, 50, 50, 50, 50, 50, 50, 50};
|
||||||
|
gbl_pPullups.rowHeights = new int[] {25, 25, 25, 25};
|
||||||
|
gbl_pPullups.columnWeights = new double[]{1.0, 1.0,1.0, 1.0,1.0, 1.0,1.0, 1.0};
|
||||||
|
gbl_pPullups.rowWeights = new double[]{1.0, 1.0,1.0, 1.0};
|
||||||
|
pPullups.setLayout(gbl_pPullups);
|
||||||
|
|
||||||
|
pOutputs = new JPanel();
|
||||||
|
pOutputs.setBorder(new TitledBorder(null, "Ausg\u00E4nge", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_pOutputs = new GridBagConstraints();
|
||||||
|
gbc_pOutputs.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_pOutputs.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_pOutputs.gridx = 0;
|
||||||
|
gbc_pOutputs.gridy = 2;
|
||||||
|
contentPane.add(pOutputs, gbc_pOutputs);
|
||||||
|
GridBagLayout gbl_pOutputs = new GridBagLayout();
|
||||||
|
gbl_pOutputs.columnWidths = new int[] {50, 50, 50, 50, 50, 50, 50, 50};
|
||||||
|
gbl_pOutputs.rowHeights = new int[] {25, 25, 25, 25};
|
||||||
|
gbl_pOutputs.columnWeights = new double[]{1.0, 1.0,1.0, 1.0,1.0, 1.0,1.0, 1.0};
|
||||||
|
gbl_pOutputs.rowWeights = new double[]{1.0, 1.0,1.0, 1.0};
|
||||||
|
pOutputs.setLayout(gbl_pOutputs);
|
||||||
|
|
||||||
|
pAnalog = new JPanel();
|
||||||
|
pAnalog.setBorder(new TitledBorder(null, "Analogkan\u00E4le", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
GridBagConstraints gbc_pAnalog = new GridBagConstraints();
|
||||||
|
gbc_pAnalog.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_pAnalog.gridx = 0;
|
||||||
|
gbc_pAnalog.gridy = 3;
|
||||||
|
contentPane.add(pAnalog, gbc_pAnalog);
|
||||||
|
pAnalog.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
pc2a.removeAppSettingsListener(this);
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
PulsCounter2Application pc2a = PulsCounter2Application.getApplication();
|
||||||
|
|
||||||
|
inputButtons = new JToggleButton[32];
|
||||||
|
outputButtons = new JToggleButton[32];
|
||||||
|
pullupButtons = new JToggleButton[32];
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
final int n = i;
|
||||||
|
|
||||||
|
inputButtons[i] = new JToggleButton(String.format("%d", i));
|
||||||
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(0, 0, 0, 0);
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc.gridx = i % 8;
|
||||||
|
gbc.gridy = (i / 8);
|
||||||
|
|
||||||
|
pDisplay.add(inputButtons[i], gbc);
|
||||||
|
|
||||||
|
outputButtons[i] = new JToggleButton(String.format("%d", i));
|
||||||
|
outputButtons[i].addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
setOutput(n, outputButtons[n].isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pOutputs.add(outputButtons[i], gbc);
|
||||||
|
|
||||||
|
pullupButtons[i] = new JToggleButton(String.format("%d", i));
|
||||||
|
pullupButtons[i].addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
setPullUp(n, pullupButtons[n].isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pPullups.add(pullupButtons[i],gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
analogLabels = new JLabel[8];
|
||||||
|
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
analogLabels[i] = new JLabel(String.format("---"));
|
||||||
|
analogLabels[i].setBorder(new TitledBorder(String.format("AN%d",i)));
|
||||||
|
pAnalog.add(analogLabels[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
liveViewTimer = new Timer();
|
||||||
|
liveViewTimer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateLiveView();
|
||||||
|
}
|
||||||
|
}, 200, 250);
|
||||||
|
|
||||||
|
pc2a.addAppSettingsListener(this);
|
||||||
|
|
||||||
|
serviceLink = pc2a.getServiceLink();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void updateLiveView(){
|
||||||
|
System.err.println("LiveView Update");
|
||||||
|
if (serviceLink != null){
|
||||||
|
System.err.println("ServiceLink exists.");
|
||||||
|
try {
|
||||||
|
serviceLink.open();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x84F0 );
|
||||||
|
outputs = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x81F9 );
|
||||||
|
pullups = serviceLink.getServiceRegisterCache().getCachedInteger(13, 0, 0x81FA );
|
||||||
|
|
||||||
|
if (inputs == null)
|
||||||
|
inputs = 0;
|
||||||
|
if (outputs == null)
|
||||||
|
outputs = 0;
|
||||||
|
if (pullups == null)
|
||||||
|
pullups = 0;
|
||||||
|
|
||||||
|
System.err.println(String.format("Inputs State: 0x%08x",inputs));
|
||||||
|
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++){
|
||||||
|
if ((inputs & (1<<i))!=0){
|
||||||
|
inputButtons[i].setBackground(Color.GREEN);
|
||||||
|
inputButtons[i].setSelected(true);
|
||||||
|
} else {
|
||||||
|
inputButtons[i].setBackground(Color.RED);
|
||||||
|
inputButtons[i].setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((outputs & (1<<i))!=0){
|
||||||
|
outputButtons[i].setBackground(Color.GREEN);
|
||||||
|
outputButtons[i].setSelected(true);
|
||||||
|
} else {
|
||||||
|
outputButtons[i].setBackground(Color.WHITE);
|
||||||
|
outputButtons[i].setSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pullups & (1<<i))!=0){
|
||||||
|
pullupButtons[i].setBackground(Color.BLUE);
|
||||||
|
pullupButtons[i].setSelected(true);
|
||||||
|
} else {
|
||||||
|
pullupButtons[i].setBackground(Color.WHITE);
|
||||||
|
pullupButtons[i].setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
float analog = serviceLink.getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i );
|
||||||
|
analogLabels[i].setText(String.format("%5.3fV", (analog * 10.0f)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void ServiceLinkChanged(ServiceLink serviceLink) {
|
||||||
|
this.serviceLink = serviceLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setOutput(int ch,boolean set){
|
||||||
|
if (this.serviceLink != null){
|
||||||
|
try {
|
||||||
|
if (set){
|
||||||
|
serviceLink.writeInt((byte)13, (byte)0, 0x8100 + ch, 1);
|
||||||
|
} else {
|
||||||
|
serviceLink.writeInt((byte)13, (byte)0, 0x8100 + ch, 0);
|
||||||
|
}
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setPullUp(int ch,boolean set){
|
||||||
|
if (this.serviceLink != null){
|
||||||
|
if (set){
|
||||||
|
pullups |= (1<<ch);
|
||||||
|
} else {
|
||||||
|
pullups &= ~(1<<ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt((byte)13, (byte)0, 0x81FA, pullups);
|
||||||
|
} catch (ServiceLinkRequestFailedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hwo.pulscounter;
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
@ -23,11 +23,18 @@ import javax.swing.JComboBox;
|
||||||
|
|
||||||
import org.hwo.beacon.Beacon;
|
import org.hwo.beacon.Beacon;
|
||||||
import org.hwo.beacon.Beacon.BeaconSender;
|
import org.hwo.beacon.Beacon.BeaconSender;
|
||||||
|
import org.hwo.bitfields.BitField;
|
||||||
import org.hwo.csv.CSV;
|
import org.hwo.csv.CSV;
|
||||||
import org.hwo.io.SerialPort;
|
import org.hwo.io.SerialPort;
|
||||||
|
import org.hwo.io.SerialPortExeption;
|
||||||
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
import org.hwo.models.TableMapper.AbstractTableMapperListener;
|
||||||
import org.hwo.models.TableMapper.TableMapper;
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
import org.hwo.pulscounter.ui.NetworkSelectorDialog;
|
import org.hwo.pulscounter.CounterChannel;
|
||||||
|
import org.hwo.pulscounter.IPulsCounter;
|
||||||
|
import org.hwo.pulscounter.NewPulsCounterDevice;
|
||||||
|
import org.hwo.pulscounter.PulsCounter;
|
||||||
|
import org.hwo.pulscounter.TimeBarrier;
|
||||||
|
import org.hwo.pulscounter.service.PulsCounterService;
|
||||||
import org.hwo.rpc.simple.SimpleRPCService;
|
import org.hwo.rpc.simple.SimpleRPCService;
|
||||||
import org.hwo.ui.JObjectSelector;
|
import org.hwo.ui.JObjectSelector;
|
||||||
import org.hwo.ui.MousePopupListener;
|
import org.hwo.ui.MousePopupListener;
|
||||||
|
@ -37,6 +44,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.prefs.BackingStoreException;
|
import java.util.prefs.BackingStoreException;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
@ -60,6 +68,7 @@ import javax.swing.BoxLayout;
|
||||||
|
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.Console;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -71,8 +80,19 @@ import java.net.UnknownHostException;
|
||||||
import org.hwo.datetime.JTimeOfDay;
|
import org.hwo.datetime.JTimeOfDay;
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JRadioButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
public class PulsCounterWindow extends JFrame{
|
public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
|
Beacon clientBeacon;
|
||||||
|
IPulsCounter connectedPulsCounter;
|
||||||
|
UUID selectedNetworkUUID;
|
||||||
|
|
||||||
|
boolean useUSB;
|
||||||
|
boolean useNetwork;
|
||||||
|
|
||||||
|
|
||||||
private JTable tCounter;
|
private JTable tCounter;
|
||||||
|
|
||||||
private TableMapper tmCounter;
|
private TableMapper tmCounter;
|
||||||
|
@ -90,7 +110,6 @@ public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
boolean applicationExiting;
|
boolean applicationExiting;
|
||||||
|
|
||||||
private PulsCounterDevice pulsCounterDevice;
|
|
||||||
private JComboBox cbTimeBarriers;
|
private JComboBox cbTimeBarriers;
|
||||||
private JTable tTBChannels;
|
private JTable tTBChannels;
|
||||||
private JTimeOfDay todTimebarrier;
|
private JTimeOfDay todTimebarrier;
|
||||||
|
@ -100,12 +119,24 @@ public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
private String workingDirectory;
|
private String workingDirectory;
|
||||||
private JTextField tfPhysicalInterface;
|
private JTextField tfPhysicalInterface;
|
||||||
|
private JTextField tfNetworkNode;
|
||||||
|
private JRadioButton rbNetwork;
|
||||||
|
private JRadioButton rbUSB;
|
||||||
|
private JCheckBox cbUSBEnabled;
|
||||||
|
private JButton btnNetzwerk;
|
||||||
|
private JLabel lInputs;
|
||||||
|
|
||||||
public PulsCounterWindow() {
|
public PulsCounterWindow() {
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent arg0) {
|
public void windowClosing(WindowEvent arg0) {
|
||||||
applicationExiting = true;
|
applicationExiting = true;
|
||||||
|
try {
|
||||||
|
prefs.sync();
|
||||||
|
} catch (Exception ex){
|
||||||
|
System.err.print("Preferences could not be saved.");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
@ -143,63 +174,77 @@ public class PulsCounterWindow extends JFrame{
|
||||||
panel.add(panel_1, gbc_panel_1);
|
panel.add(panel_1, gbc_panel_1);
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0};
|
gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0};
|
||||||
gbl_panel_1.rowHeights = new int[]{0, 0, 0};
|
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
gbl_panel_1.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_1.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
gbl_panel_1.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_1.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
panel_1.setLayout(gbl_panel_1);
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
JButton btnNetzwerk = new JButton("Netzwerk...");
|
rbUSB = new JRadioButton("USB");
|
||||||
|
rbUSB.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
selectUSBConnection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_rbUSB = new GridBagConstraints();
|
||||||
|
gbc_rbUSB.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_rbUSB.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_rbUSB.gridx = 0;
|
||||||
|
gbc_rbUSB.gridy = 0;
|
||||||
|
panel_1.add(rbUSB, gbc_rbUSB);
|
||||||
|
|
||||||
|
rbNetwork = new JRadioButton("Netzwerk");
|
||||||
|
rbNetwork.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
selectNetworkConnection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cbUSBEnabled = new JCheckBox("USB Verbindung aktiv");
|
||||||
|
cbUSBEnabled.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
switchUSBEnabled();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_cbUSBEnabled = new GridBagConstraints();
|
||||||
|
gbc_cbUSBEnabled.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_cbUSBEnabled.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_cbUSBEnabled.gridx = 1;
|
||||||
|
gbc_cbUSBEnabled.gridy = 0;
|
||||||
|
panel_1.add(cbUSBEnabled, gbc_cbUSBEnabled);
|
||||||
|
GridBagConstraints gbc_rbNetwork = new GridBagConstraints();
|
||||||
|
gbc_rbNetwork.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_rbNetwork.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_rbNetwork.gridx = 0;
|
||||||
|
gbc_rbNetwork.gridy = 1;
|
||||||
|
panel_1.add(rbNetwork, gbc_rbNetwork);
|
||||||
|
|
||||||
|
btnNetzwerk = new JButton("Netzwerk...");
|
||||||
btnNetzwerk.addActionListener(new ActionListener() {
|
btnNetzwerk.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
BeaconSender sender = NetworkSelectorDialog.show(PulsCounter.getBeacon());
|
|
||||||
if (sender != null){
|
|
||||||
|
|
||||||
int port = Integer.decode(sender.getProperties().getProperty("rpc.simple.port"));
|
|
||||||
|
|
||||||
SimpleRPCService service = new SimpleRPCService(sender.getInetAddress(), port);
|
|
||||||
IPulsCounter ipc = service.createProxy(IPulsCounter.class);
|
|
||||||
|
|
||||||
counterChannels.clear();
|
|
||||||
|
|
||||||
changeDeviceConnection(ipc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnNetzwerk = new GridBagConstraints();
|
|
||||||
gbc_btnNetzwerk.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_btnNetzwerk.gridx = 0;
|
|
||||||
gbc_btnNetzwerk.gridy = 0;
|
|
||||||
panel_1.add(btnNetzwerk, gbc_btnNetzwerk);
|
|
||||||
|
|
||||||
JButton btnLokal = new JButton("Lokal");
|
tfNetworkNode = new JTextField();
|
||||||
btnLokal.addActionListener(new ActionListener() {
|
tfNetworkNode.setEditable(false);
|
||||||
public void actionPerformed(ActionEvent e) {
|
GridBagConstraints gbc_tfNetworkNode = new GridBagConstraints();
|
||||||
try {
|
gbc_tfNetworkNode.insets = new Insets(0, 0, 5, 5);
|
||||||
SimpleRPCService service;
|
gbc_tfNetworkNode.fill = GridBagConstraints.HORIZONTAL;
|
||||||
service = new SimpleRPCService(InetAddress.getLocalHost(), 44352);
|
gbc_tfNetworkNode.gridx = 1;
|
||||||
IPulsCounter ipc = service.createProxy(IPulsCounter.class);
|
gbc_tfNetworkNode.gridy = 1;
|
||||||
|
panel_1.add(tfNetworkNode, gbc_tfNetworkNode);
|
||||||
counterChannels.clear();
|
tfNetworkNode.setColumns(10);
|
||||||
|
GridBagConstraints gbc_btnNetzwerk = new GridBagConstraints();
|
||||||
changeDeviceConnection(ipc);
|
gbc_btnNetzwerk.insets = new Insets(0, 0, 5, 0);
|
||||||
} catch (UnknownHostException e1) {
|
gbc_btnNetzwerk.gridx = 2;
|
||||||
// TODO Auto-generated catch block
|
gbc_btnNetzwerk.gridy = 1;
|
||||||
e1.printStackTrace();
|
panel_1.add(btnNetzwerk, gbc_btnNetzwerk);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnLokal = new GridBagConstraints();
|
|
||||||
gbc_btnLokal.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnLokal.gridx = 2;
|
|
||||||
gbc_btnLokal.gridy = 0;
|
|
||||||
panel_1.add(btnLokal, gbc_btnLokal);
|
|
||||||
|
|
||||||
JLabel lblNewLabel = new JLabel("Schnittstelle:");
|
JLabel lblNewLabel = new JLabel("Schnittstelle:");
|
||||||
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||||
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
|
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_lblNewLabel.gridx = 0;
|
gbc_lblNewLabel.gridx = 0;
|
||||||
gbc_lblNewLabel.gridy = 1;
|
gbc_lblNewLabel.gridy = 2;
|
||||||
panel_1.add(lblNewLabel, gbc_lblNewLabel);
|
panel_1.add(lblNewLabel, gbc_lblNewLabel);
|
||||||
|
|
||||||
tfPhysicalInterface = new JTextField();
|
tfPhysicalInterface = new JTextField();
|
||||||
|
@ -209,7 +254,7 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_tfPhysicalInterface.anchor = GridBagConstraints.NORTH;
|
gbc_tfPhysicalInterface.anchor = GridBagConstraints.NORTH;
|
||||||
gbc_tfPhysicalInterface.fill = GridBagConstraints.HORIZONTAL;
|
gbc_tfPhysicalInterface.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfPhysicalInterface.gridx = 1;
|
gbc_tfPhysicalInterface.gridx = 1;
|
||||||
gbc_tfPhysicalInterface.gridy = 1;
|
gbc_tfPhysicalInterface.gridy = 2;
|
||||||
panel_1.add(tfPhysicalInterface, gbc_tfPhysicalInterface);
|
panel_1.add(tfPhysicalInterface, gbc_tfPhysicalInterface);
|
||||||
tfPhysicalInterface.setColumns(10);
|
tfPhysicalInterface.setColumns(10);
|
||||||
|
|
||||||
|
@ -221,7 +266,7 @@ public class PulsCounterWindow extends JFrame{
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnWhlen = new GridBagConstraints();
|
GridBagConstraints gbc_btnWhlen = new GridBagConstraints();
|
||||||
gbc_btnWhlen.gridx = 2;
|
gbc_btnWhlen.gridx = 2;
|
||||||
gbc_btnWhlen.gridy = 1;
|
gbc_btnWhlen.gridy = 2;
|
||||||
panel_1.add(btnWhlen, gbc_btnWhlen);
|
panel_1.add(btnWhlen, gbc_btnWhlen);
|
||||||
|
|
||||||
JPanel panel_2 = new JPanel();
|
JPanel panel_2 = new JPanel();
|
||||||
|
@ -332,9 +377,9 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_panel_3.gridy = 3;
|
gbc_panel_3.gridy = 3;
|
||||||
panel.add(panel_3, gbc_panel_3);
|
panel.add(panel_3, gbc_panel_3);
|
||||||
GridBagLayout gbl_panel_3 = new GridBagLayout();
|
GridBagLayout gbl_panel_3 = new GridBagLayout();
|
||||||
gbl_panel_3.columnWidths = new int[]{0, 0, 0, 0, 0};
|
gbl_panel_3.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
gbl_panel_3.rowHeights = new int[]{0, 0};
|
gbl_panel_3.rowHeights = new int[]{0, 0};
|
||||||
gbl_panel_3.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_3.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
gbl_panel_3.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
gbl_panel_3.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
panel_3.setLayout(gbl_panel_3);
|
panel_3.setLayout(gbl_panel_3);
|
||||||
|
|
||||||
|
@ -357,9 +402,23 @@ public class PulsCounterWindow extends JFrame{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnAlle = new GridBagConstraints();
|
GridBagConstraints gbc_btnAlle = new GridBagConstraints();
|
||||||
|
gbc_btnAlle.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_btnAlle.gridx = 3;
|
gbc_btnAlle.gridx = 3;
|
||||||
gbc_btnAlle.gridy = 0;
|
gbc_btnAlle.gridy = 0;
|
||||||
panel_3.add(btnAlle, gbc_btnAlle);
|
panel_3.add(btnAlle, gbc_btnAlle);
|
||||||
|
|
||||||
|
JButton btnInspektor = new JButton("Inspektor");
|
||||||
|
btnInspektor.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
InspectionMainFrame f = new InspectionMainFrame();
|
||||||
|
f.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnInspektor = new GridBagConstraints();
|
||||||
|
gbc_btnInspektor.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnInspektor.gridx = 17;
|
||||||
|
gbc_btnInspektor.gridy = 0;
|
||||||
|
panel_3.add(btnInspektor, gbc_btnInspektor);
|
||||||
btnNewButton.addActionListener(new ActionListener() {
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
synchronized (threadUpdater) {
|
synchronized (threadUpdater) {
|
||||||
|
@ -487,9 +546,9 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_panel_4.gridy = 2;
|
gbc_panel_4.gridy = 2;
|
||||||
getContentPane().add(panel_4, gbc_panel_4);
|
getContentPane().add(panel_4, gbc_panel_4);
|
||||||
GridBagLayout gbl_panel_4 = new GridBagLayout();
|
GridBagLayout gbl_panel_4 = new GridBagLayout();
|
||||||
gbl_panel_4.columnWidths = new int[]{0, 0, 0, 0};
|
gbl_panel_4.columnWidths = new int[]{0, 0, 0, 0, 0};
|
||||||
gbl_panel_4.rowHeights = new int[]{0, 0};
|
gbl_panel_4.rowHeights = new int[]{0, 0};
|
||||||
gbl_panel_4.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_4.columnWeights = new double[]{1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
gbl_panel_4.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
gbl_panel_4.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
panel_4.setLayout(gbl_panel_4);
|
panel_4.setLayout(gbl_panel_4);
|
||||||
|
|
||||||
|
@ -518,20 +577,27 @@ public class PulsCounterWindow extends JFrame{
|
||||||
gbc_lActivity.gridy = 0;
|
gbc_lActivity.gridy = 0;
|
||||||
panel_6.add(lActivity, gbc_lActivity);
|
panel_6.add(lActivity, gbc_lActivity);
|
||||||
|
|
||||||
|
lInputs = new JLabel("Input State");
|
||||||
|
GridBagConstraints gbc_lInputs = new GridBagConstraints();
|
||||||
|
gbc_lInputs.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lInputs.gridx = 1;
|
||||||
|
gbc_lInputs.gridy = 0;
|
||||||
|
panel_4.add(lInputs, gbc_lInputs);
|
||||||
|
|
||||||
JPanel panel_5 = new JPanel();
|
JPanel panel_5 = new JPanel();
|
||||||
panel_5.setToolTipText("Angeschlossener Ger\u00E4tetyp");
|
panel_5.setToolTipText("Angeschlossener Ger\u00E4tetyp");
|
||||||
panel_5.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
panel_5.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||||
GridBagConstraints gbc_panel_5 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_5 = new GridBagConstraints();
|
||||||
gbc_panel_5.insets = new Insets(0, 0, 0, 5);
|
gbc_panel_5.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_panel_5.fill = GridBagConstraints.VERTICAL;
|
gbc_panel_5.fill = GridBagConstraints.VERTICAL;
|
||||||
gbc_panel_5.gridx = 1;
|
gbc_panel_5.gridx = 2;
|
||||||
gbc_panel_5.gridy = 0;
|
gbc_panel_5.gridy = 0;
|
||||||
panel_4.add(panel_5, gbc_panel_5);
|
panel_4.add(panel_5, gbc_panel_5);
|
||||||
|
|
||||||
lDeviceType = new JLabel("----");
|
lDeviceType = new JLabel("----");
|
||||||
panel_5.add(lDeviceType);
|
panel_5.add(lDeviceType);
|
||||||
GridBagConstraints gbc_panel_7 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_7 = new GridBagConstraints();
|
||||||
gbc_panel_7.gridx = 2;
|
gbc_panel_7.gridx = 3;
|
||||||
gbc_panel_7.gridy = 0;
|
gbc_panel_7.gridy = 0;
|
||||||
panel_7.setToolTipText("Ger\u00E4tezeit bei letztem Kontakt");
|
panel_7.setToolTipText("Ger\u00E4tezeit bei letztem Kontakt");
|
||||||
panel_4.add(panel_7, gbc_panel_7);
|
panel_4.add(panel_7, gbc_panel_7);
|
||||||
|
@ -545,6 +611,11 @@ public class PulsCounterWindow extends JFrame{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
|
||||||
|
clientBeacon = new Beacon(44556);
|
||||||
|
clientBeacon.setClientOnly(true);
|
||||||
|
clientBeacon.start();
|
||||||
|
|
||||||
applicationExiting = false;
|
applicationExiting = false;
|
||||||
|
|
||||||
prefs = Preferences.userRoot();
|
prefs = Preferences.userRoot();
|
||||||
|
@ -589,7 +660,12 @@ public class PulsCounterWindow extends JFrame{
|
||||||
CounterChannel cc = (CounterChannel)tmCounter.getSelectedRow();
|
CounterChannel cc = (CounterChannel)tmCounter.getSelectedRow();
|
||||||
if (cc != null)
|
if (cc != null)
|
||||||
{
|
{
|
||||||
PulsCounter.getDeviceConnection().setChannelCounter(cc.getChannel(), 0);
|
try {
|
||||||
|
connectedPulsCounter.setChannelCounter(cc.getChannel(), 0);
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println(sex);
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (threadUpdater) {
|
synchronized (threadUpdater) {
|
||||||
threadUpdater.notifyAll();
|
threadUpdater.notifyAll();
|
||||||
|
@ -645,7 +721,16 @@ public class PulsCounterWindow extends JFrame{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateTimer.setRepeats(true);
|
updateTimer.setRepeats(true);
|
||||||
updateTimer.start();
|
updateTimer.start();
|
||||||
|
|
||||||
|
|
||||||
|
useUSB = prefs.getBoolean("pulscounter.ui.useUSB", false);
|
||||||
|
useNetwork = prefs.getBoolean("pulscounter.ui.useNetwork", false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
updateUI();
|
||||||
|
setupDeviceConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCounter()
|
private void updateCounter()
|
||||||
|
@ -658,15 +743,27 @@ public class PulsCounterWindow extends JFrame{
|
||||||
tmCounter.setRows(counterChannels);
|
tmCounter.setRows(counterChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPulsCounter ipc = PulsCounter.getDeviceConnection();
|
IPulsCounter ipc = connectedPulsCounter;
|
||||||
|
|
||||||
if (ipc == null)
|
if (ipc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int nch = ipc.getChannels();
|
int nch = 0;
|
||||||
|
int[] counters = null;
|
||||||
|
Integer inputs = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
nch = ipc.getChannels();
|
||||||
|
counters = ipc.getChannelCounters();
|
||||||
|
inputs = ipc.getPhysicalInputs();
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: updateCounter(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
System.err.println(String.format("GUI: updateCounter(): Channel Array Size: %d / %d",nch,counterChannels.size()));
|
System.err.println(String.format("GUI: updateCounter(): Channel Array Size: %d / %d",nch,counterChannels.size()));
|
||||||
|
|
||||||
|
lInputs.setText(new BitField().toText(inputs));
|
||||||
|
|
||||||
if (nch != counterChannels.size()){
|
if (nch != counterChannels.size()){
|
||||||
counterChannels.clear();
|
counterChannels.clear();
|
||||||
|
@ -681,8 +778,6 @@ public class PulsCounterWindow extends JFrame{
|
||||||
tmCounter.setRows(counterChannels);
|
tmCounter.setRows(counterChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] counters = ipc.getChannelCounters();
|
|
||||||
|
|
||||||
for (CounterChannel channel: counterChannels){
|
for (CounterChannel channel: counterChannels){
|
||||||
channel.setValue(counters[channel.getChannel()]);
|
channel.setValue(counters[channel.getChannel()]);
|
||||||
}
|
}
|
||||||
|
@ -693,45 +788,66 @@ public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
private void saveCorrection(int row)
|
private void saveCorrection(int row)
|
||||||
{
|
{
|
||||||
System.err.println(String.format("Korrekturwert fŸr Kanal %d = %d",row + 1,tmCounter.getRow(row,CounterChannel.class).getCorrect()));
|
try {
|
||||||
PulsCounter.getDeviceConnection().setChannelOffset(row, tmCounter.getRow(row,CounterChannel.class).getCorrect());
|
System.err.println(String.format("Korrekturwert f<>r Kanal %d = %d",row + 1,tmCounter.getRow(row,CounterChannel.class).getCorrect()));
|
||||||
|
connectedPulsCounter.setChannelOffset(row, tmCounter.getRow(row,CounterChannel.class).getCorrect());
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: saveCorrection(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveChannelName(int channel)
|
private void saveChannelName(int channel)
|
||||||
{
|
{
|
||||||
PulsCounter.getDeviceConnection().setChannelName(channel, counterChannels.get(channel).getBezeichnung());
|
try {
|
||||||
|
connectedPulsCounter.setChannelName(channel, counterChannels.get(channel).getBezeichnung());
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: saveChannelName(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void loadChannelNames()
|
private void loadChannelNames()
|
||||||
{
|
{
|
||||||
for (CounterChannel channel: counterChannels){
|
for (CounterChannel channel: counterChannels){
|
||||||
channel.setBezeichnung(PulsCounter.getDeviceConnection().getChannelName(channel.getChannel()));
|
try {
|
||||||
|
channel.setBezeichnung(connectedPulsCounter.getChannelName(channel.getChannel()));
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: loadChannelNames(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadChannelOffsets() {
|
private void loadChannelOffsets() {
|
||||||
|
|
||||||
int[] offsets = PulsCounter.getDeviceConnection().getChannelOffsets();
|
try {
|
||||||
|
int[] offsets = connectedPulsCounter.getChannelOffsets();
|
||||||
if (offsets.length != counterChannels.size()) {
|
|
||||||
System.err.println(String.format("GUI: loadChannelOffsets(): offset list size differs: %d != %d",offsets.length,counterChannels.size()));
|
if (offsets.length != counterChannels.size()) {
|
||||||
}
|
System.err.println(String.format("GUI: loadChannelOffsets(): offset list size differs: %d != %d",offsets.length,counterChannels.size()));
|
||||||
for (CounterChannel channel: counterChannels){
|
}
|
||||||
channel.setCorrect(offsets[channel.getChannel()]);
|
for (CounterChannel channel: counterChannels){
|
||||||
|
channel.setCorrect(offsets[channel.getChannel()]);
|
||||||
|
}
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: loadChannelOffsets(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetAllChannels() {
|
private void resetAllChannels() {
|
||||||
for (CounterChannel channel: counterChannels){
|
for (CounterChannel channel: counterChannels){
|
||||||
PulsCounter.getDeviceConnection().setChannelCounter(channel.getChannel(), 0);
|
try {
|
||||||
|
connectedPulsCounter.setChannelCounter(channel.getChannel(), 0);
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: resetAllChannels(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeDeviceConnection(IPulsCounter ipc){
|
|
||||||
PulsCounter.setDeviceConnection(ipc);
|
|
||||||
|
|
||||||
tfPhysicalInterface.setText(ipc.getPhysicalInterfaceName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -751,7 +867,7 @@ public class PulsCounterWindow extends JFrame{
|
||||||
|
|
||||||
public void updateLiveFile()
|
public void updateLiveFile()
|
||||||
{
|
{
|
||||||
Date date = new Date();
|
/* Date date = new Date();
|
||||||
|
|
||||||
CSV csv = new CSV();
|
CSV csv = new CSV();
|
||||||
|
|
||||||
|
@ -768,12 +884,155 @@ public class PulsCounterWindow extends JFrame{
|
||||||
}
|
}
|
||||||
|
|
||||||
csv.saveToFile(String.format("%s/live.csv",workingDirectory));
|
csv.saveToFile(String.format("%s/live.csv",workingDirectory));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPhysicalInterface(){
|
private void selectPhysicalInterface(){
|
||||||
String pn = (String)JObjectSelector.execute(PulsCounter.getDeviceConnection().getPhysicalInterfaceNames());
|
try {
|
||||||
PulsCounter.getDeviceConnection().setPhysicalInterfaceName(pn);
|
String pn = (String)JObjectSelector.execute(connectedPulsCounter.getPhysicalInterfaceNames());
|
||||||
tfPhysicalInterface.setText(pn);
|
connectedPulsCounter.setPhysicalInterfaceName(pn);
|
||||||
|
tfPhysicalInterface.setText(pn);
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: setPhysicalInterface(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private synchronized void changeDeviceConnection(IPulsCounter ipc){
|
||||||
|
try {
|
||||||
|
counterChannels.clear();
|
||||||
|
connectedPulsCounter = ipc;
|
||||||
|
if (ipc != null){
|
||||||
|
tfPhysicalInterface.setText(ipc.getPhysicalInterfaceName());
|
||||||
|
} else {
|
||||||
|
tfPhysicalInterface.setText("");
|
||||||
|
}
|
||||||
|
} catch (SerialPortExeption sex){
|
||||||
|
System.err.println("GUI: changeDeviceConnection(): SerialPortException: " + sex.toString());
|
||||||
|
sex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void selectUSBConnection(){
|
||||||
|
useUSB = true;
|
||||||
|
useNetwork = false;
|
||||||
|
|
||||||
|
setupDeviceConnection();
|
||||||
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectNetworkConnection(){
|
||||||
|
useUSB = false;
|
||||||
|
useNetwork = true;
|
||||||
|
|
||||||
|
if (selectedNetworkUUID == null) {
|
||||||
|
|
||||||
|
selectedNetworkUUID = selectNetworkNode();
|
||||||
|
|
||||||
|
if (selectedNetworkUUID == null) {
|
||||||
|
useNetwork = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDeviceConnection();
|
||||||
|
updateUI();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchUSBEnabled(){
|
||||||
|
PulsCounterService localService = PulsCounter.getLocalService();
|
||||||
|
if (localService.isActive()){
|
||||||
|
useUSB = false;
|
||||||
|
localService.stop();
|
||||||
|
prefs.putBoolean("pulscounter.local.enabled", false);
|
||||||
|
} else {
|
||||||
|
localService.start();
|
||||||
|
prefs.putBoolean("pulscounter.local.enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDeviceConnection();
|
||||||
|
updateUI();
|
||||||
|
|
||||||
|
try {
|
||||||
|
prefs.sync();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private UUID selectNetworkNode(){
|
||||||
|
BeaconSender sender = NetworkSelectorDialog.show(clientBeacon);
|
||||||
|
if (sender != null){
|
||||||
|
return UUID.fromString(sender.getProperties().getProperty("beacon.uuid"));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupDeviceConnection(){
|
||||||
|
if (useUSB){
|
||||||
|
|
||||||
|
if (isUSBEnabled()) {
|
||||||
|
changeDeviceConnection( PulsCounter.getLocalService().getLocalDevice() );
|
||||||
|
} else {
|
||||||
|
changeDeviceConnection( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (selectedNetworkUUID != null) {
|
||||||
|
|
||||||
|
BeaconSender sender = clientBeacon.getSenderByUUID(selectedNetworkUUID);
|
||||||
|
if (sender != null) {
|
||||||
|
IPulsCounter ipc = PulsCounter.createProxyFromBeaconSender(sender);
|
||||||
|
|
||||||
|
changeDeviceConnection(ipc);
|
||||||
|
} else {
|
||||||
|
changeDeviceConnection(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
changeDeviceConnection(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isUSBEnabled(){
|
||||||
|
return PulsCounter.getLocalService().isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUI() {
|
||||||
|
updateUIUsbEnabled(isUSBEnabled());
|
||||||
|
rbUSB.setSelected(useUSB);
|
||||||
|
rbNetwork.setSelected(useNetwork);
|
||||||
|
btnNetzwerk.setEnabled(useNetwork);
|
||||||
|
|
||||||
|
tfNetworkNode.setText("");
|
||||||
|
if (useNetwork){
|
||||||
|
if (selectedNetworkUUID != null){
|
||||||
|
BeaconSender sender = clientBeacon.getSenderByUUID(selectedNetworkUUID);
|
||||||
|
if (sender != null){
|
||||||
|
tfNetworkNode.setText(sender.getProperties().getProperty("beacon.name"));
|
||||||
|
prefs.put("pulscounter.network.connect.hostname", sender.getProperties().getProperty("beacon.name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs.putBoolean("pulscounter.ui.useUSB", useUSB);
|
||||||
|
prefs.putBoolean("pulscounter.ui.useNetwork", useNetwork);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUIUsbEnabled(boolean enabled){
|
||||||
|
cbUSBEnabled.setSelected(enabled);
|
||||||
|
rbUSB.setEnabled(enabled);
|
||||||
|
if (enabled){
|
||||||
|
} else {
|
||||||
|
rbUSB.setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue