WIP
parent
e903133b95
commit
610b7637f1
|
@ -12,6 +12,7 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.InvalidPropertiesFormatException;
|
import java.util.InvalidPropertiesFormatException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -48,7 +49,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
return _application;
|
return _application;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties applicationConfiguration;
|
private Properties applicationConfiguration,
|
||||||
|
defaultConfiguration;
|
||||||
private List<IDeviceConnector> deviceConnectors;
|
private List<IDeviceConnector> deviceConnectors;
|
||||||
|
|
||||||
private Object uiSynchronization;
|
private Object uiSynchronization;
|
||||||
|
@ -143,22 +145,30 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Properties createDefaultApplicationConfiguration(){
|
||||||
|
|
||||||
|
defaultConfiguration = new Properties();
|
||||||
|
|
||||||
|
defaultConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
||||||
|
defaultConfiguration.setProperty("interface.classes", StringHelper.join(new String[]{
|
||||||
|
ServiceLinkDeviceConnector.class.getCanonicalName(),
|
||||||
|
SimulatedCounter.class.getCanonicalName()
|
||||||
|
}, ","));
|
||||||
|
|
||||||
|
return defaultConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadApplicationConfiguration(){
|
private void loadApplicationConfiguration(){
|
||||||
applicationConfiguration = new Properties();
|
createDefaultApplicationConfiguration();
|
||||||
|
|
||||||
/* Initialize default configuration */
|
applicationConfiguration = new Properties(defaultConfiguration);
|
||||||
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
|
||||||
applicationConfiguration.setProperty("interface.classes", StringHelper.join(new String[]{
|
|
||||||
ServiceLinkDeviceConnector.class.getCanonicalName(),
|
|
||||||
SimulatedCounter.class.getCanonicalName()
|
|
||||||
}, ","));
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Try to load configuration from file */
|
/* Try to load configuration from file */
|
||||||
FileInputStream fis = new FileInputStream("synololog.cfg");
|
FileInputStream fis = new FileInputStream("synololog.cfg");
|
||||||
applicationConfiguration.loadFromXML(fis);
|
applicationConfiguration.loadFromXML(fis);
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
} catch (InvalidPropertiesFormatException e) {
|
} catch (InvalidPropertiesFormatException e) {
|
||||||
log(WARN,"synololog.cfg is misformated");
|
log(WARN,"synololog.cfg is misformated");
|
||||||
|
@ -228,8 +238,17 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
|
|
||||||
|
/* Interface Classes should be merged with application well known*/
|
||||||
|
HashSet<String> interfaceClassNames = new HashSet<>();
|
||||||
|
for (String icn: applicationConfiguration.getProperty("interface.classes").split(",")){
|
||||||
|
interfaceClassNames.add(icn);
|
||||||
|
}
|
||||||
|
for (String icn: defaultConfiguration.getProperty("interface.classes").split(",")){
|
||||||
|
interfaceClassNames.add(icn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String[] interfaceClassNames = applicationConfiguration.getProperty("interface.classes").split(",");
|
|
||||||
for (String interfaceClassName: interfaceClassNames){
|
for (String interfaceClassName: interfaceClassNames){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,6 +11,8 @@ import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
public class SnapShot {
|
public class SnapShot {
|
||||||
|
Integer deviceSerial;
|
||||||
|
|
||||||
Integer timestamp;
|
Integer timestamp;
|
||||||
Integer field0;
|
Integer field0;
|
||||||
|
|
||||||
|
@ -23,6 +25,16 @@ public class SnapShot {
|
||||||
invertmask,
|
invertmask,
|
||||||
triggermask;
|
triggermask;
|
||||||
|
|
||||||
|
|
||||||
|
public SnapShot(int deviceSerial){
|
||||||
|
this.deviceSerial = deviceSerial;
|
||||||
|
|
||||||
|
this.values = new Integer[32];
|
||||||
|
this.analog = new Integer[8];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SnapShot(){
|
public SnapShot(){
|
||||||
this.values = new Integer[32];
|
this.values = new Integer[32];
|
||||||
this.analog = new Integer[8];
|
this.analog = new Integer[8];
|
||||||
|
@ -35,6 +47,13 @@ public class SnapShot {
|
||||||
fromBytes(bytes);
|
fromBytes(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getDeviceSerial() {
|
||||||
|
return deviceSerial;
|
||||||
|
}
|
||||||
|
public void setDeviceSerial(Integer deviceSerial) {
|
||||||
|
this.deviceSerial = deviceSerial;
|
||||||
|
}
|
||||||
|
|
||||||
public void setField0(Integer field0) {
|
public void setField0(Integer field0) {
|
||||||
this.field0 = field0;
|
this.field0 = field0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
|
||||||
public interface IDeviceConnector {
|
public interface IDeviceConnector {
|
||||||
|
|
||||||
public String getDeviceSerial();
|
public Integer getDeviceSerial();
|
||||||
|
|
||||||
public boolean showConnctionSetup();
|
public boolean showConnctionSetup();
|
||||||
public String getConnectionSettings();
|
public String getConnectionSettings();
|
||||||
|
@ -29,5 +31,9 @@ public interface IDeviceConnector {
|
||||||
public int getInverts();
|
public int getInverts();
|
||||||
public void setInverts(int inverts);
|
public void setInverts(int inverts);
|
||||||
|
|
||||||
|
public int getAvailableSnapshots();
|
||||||
|
public SnapShot[]
|
||||||
|
readSnapShots();
|
||||||
|
public SnapShot readSnapShot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.hwo.pulscounter.device;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.hwo.io.NewSerialPort.NewSerialPort;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
|
import org.hwo.pulscounter.SnapShot;
|
||||||
import org.hwo.pulscounter.ui.DeviceConfiguration;
|
import org.hwo.pulscounter.ui.DeviceConfiguration;
|
||||||
import org.hwo.servicelink.ServiceLink;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
@ -16,6 +17,9 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
private ServiceLink serviceLink;
|
private ServiceLink serviceLink;
|
||||||
|
|
||||||
|
private Integer deviceSerial;
|
||||||
|
private Integer indSnapshotOldest;
|
||||||
|
|
||||||
public ServiceLinkDeviceConnector() {
|
public ServiceLinkDeviceConnector() {
|
||||||
serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
|
serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
|
||||||
|
|
||||||
|
@ -38,13 +42,35 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
return String.format("Serial [%s]", this.serviceLink.getSerialPort().getPortName());
|
return String.format("Serial [%s]", this.serviceLink.getSerialPort().getPortName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Integer readDeviceSerial(){
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer v = serviceLink.readInt(13, 0, 0x0001 );
|
||||||
|
return v;
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDeviceSerial() {
|
public Integer getDeviceSerial() {
|
||||||
return null;
|
Integer serial = readDeviceSerial();
|
||||||
|
deviceSerial = serial;
|
||||||
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceSerial(int serial) {
|
public void setDeviceSerial(int serial) {
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0004, -1895890944);
|
||||||
|
serviceLink.writeInt(13, 0, 0x0001, serial );
|
||||||
|
serviceLink.writeInt(13, 0, 0x0004, 0x0);
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,20 +105,8 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
public int[] getCounters() {
|
public int[] getCounters() {
|
||||||
int[] values = new int[32];
|
int[] values = new int[32];
|
||||||
|
|
||||||
checkOpen();
|
|
||||||
|
|
||||||
for (int n=0;n<32;n++){
|
for (int n=0;n<32;n++){
|
||||||
Integer v = null;
|
values[n] = getCounter(n);
|
||||||
try {
|
|
||||||
v = serviceLink.readInt(13, 0, 0x600 + n );
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new NoDeviceConnectionException();
|
|
||||||
}
|
|
||||||
if (v != null){
|
|
||||||
values[n] = v;
|
|
||||||
} else {
|
|
||||||
values[n] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
|
@ -100,20 +114,37 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCounters(int[] values) {
|
public void setCounters(int[] values) {
|
||||||
// TODO Auto-generated method stub
|
for (int n=0;n<32;n++){
|
||||||
|
setCounter(n, values[n]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCounter(int channel) {
|
public int getCounter(int channel) {
|
||||||
// TODO Auto-generated method stub
|
Integer v = null;
|
||||||
return 0;
|
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
try {
|
||||||
|
v = serviceLink.readInt(13, 0, 0x600 + channel );
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
|
if (v != null){
|
||||||
|
return v;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCounter(int channel, int counter) {
|
public void setCounter(int channel, int counter) {
|
||||||
// TODO Auto-generated method stub
|
checkOpen();
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0600 + channel, counter);
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,32 +161,56 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInputs() {
|
public int getInputs() {
|
||||||
// TODO Auto-generated method stub
|
checkOpen();
|
||||||
return 0;
|
|
||||||
|
try {
|
||||||
|
Integer v = serviceLink.readInt(13, 0, 0x0681 );
|
||||||
|
return v;
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOutputs() {
|
public int getOutputs() {
|
||||||
// TODO Auto-generated method stub
|
checkOpen();
|
||||||
return 0;
|
|
||||||
|
try {
|
||||||
|
Integer v = serviceLink.readInt(13, 0, 0x0682 );
|
||||||
|
return v;
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOutputs(int outputs) {
|
public void setOutputs(int outputs) {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0682, outputs);
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPullups() {
|
public int getPullups() {
|
||||||
// TODO Auto-generated method stub
|
checkOpen();
|
||||||
return 0;
|
|
||||||
|
try {
|
||||||
|
Integer v = serviceLink.readInt(13, 0, 0x0683 );
|
||||||
|
return v;
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPullups(int pullups) {
|
public void setPullups(int pullups) {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0683, pullups);
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,16 +227,154 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] getAnalogs() {
|
public float[] getAnalogs() {
|
||||||
// TODO Auto-generated method stub
|
float[] values = new float[32];
|
||||||
return null;
|
|
||||||
|
for (int n=0;n<8;n++){
|
||||||
|
values[n] = getAnalog(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getAnalog(int channel) {
|
public float getAnalog(int channel) {
|
||||||
// TODO Auto-generated method stub
|
Integer v = null;
|
||||||
|
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
v = serviceLink.readInt(13, 0, 0x8000 + channel );
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
|
if (v != null){
|
||||||
|
return (v / 6553.60f);
|
||||||
|
} else {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableSnapshots() {
|
||||||
|
Integer s = readDeviceSerial();
|
||||||
|
|
||||||
|
if (s != null){
|
||||||
|
Integer oldest,newest,sssize;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (s.equals(deviceSerial) && (indSnapshotOldest != null)){
|
||||||
|
oldest = indSnapshotOldest;
|
||||||
|
} else {
|
||||||
|
oldest = serviceLink.readInt(13, 0, 0x0580);
|
||||||
|
}
|
||||||
|
|
||||||
|
newest = serviceLink.readInt(13, 0, 0x0581);
|
||||||
|
sssize = serviceLink.readInt(13, 0, 0x0582);
|
||||||
|
|
||||||
|
Integer avail = newest - oldest;
|
||||||
|
if (avail < 0){
|
||||||
|
avail += sssize;
|
||||||
|
}
|
||||||
|
return avail;
|
||||||
|
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SnapShot[] readSnapShots() {
|
||||||
|
Integer s = readDeviceSerial();
|
||||||
|
|
||||||
|
if (s != null){
|
||||||
|
Integer oldest,newest,sssize;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (s.equals(deviceSerial) && (indSnapshotOldest != null)){
|
||||||
|
oldest = indSnapshotOldest;
|
||||||
|
} else {
|
||||||
|
oldest = serviceLink.readInt(13, 0, 0x0580);
|
||||||
|
}
|
||||||
|
|
||||||
|
newest = serviceLink.readInt(13, 0, 0x0581);
|
||||||
|
sssize = serviceLink.readInt(13, 0, 0x0582);
|
||||||
|
|
||||||
|
while (!oldest.equals(newest)){
|
||||||
|
|
||||||
|
Integer id;
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0500, oldest);
|
||||||
|
id = serviceLink.readInt(13, 0, 0x0500);
|
||||||
|
if (!id.equals(oldest)){
|
||||||
|
log(WARN,"Snapshot could not be selected [%d]",oldest);
|
||||||
|
} else {
|
||||||
|
Integer timestamp,
|
||||||
|
flags,
|
||||||
|
in,
|
||||||
|
out,
|
||||||
|
pu,
|
||||||
|
inv,
|
||||||
|
trigger;
|
||||||
|
|
||||||
|
Integer[] counters,
|
||||||
|
analogs;
|
||||||
|
|
||||||
|
timestamp = serviceLink.readInt(13, 0, 0x0501);
|
||||||
|
flags = serviceLink.readInt(13, 0, 0x0502);
|
||||||
|
in = serviceLink.readInt(13, 0, 0x0503);
|
||||||
|
out = serviceLink.readInt(13, 0, 0x0504);
|
||||||
|
pu = serviceLink.readInt(13, 0, 0x0505);
|
||||||
|
inv = serviceLink.readInt(13, 0, 0x0506);
|
||||||
|
trigger = serviceLink.readInt(13, 0, 0x0507);
|
||||||
|
|
||||||
|
counters = new Integer[32];
|
||||||
|
analogs = new Integer[8];
|
||||||
|
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
counters[n] = serviceLink.readInt(13, 0, 0x0510 + n);
|
||||||
|
}
|
||||||
|
for (int n=0;n<8;n++){
|
||||||
|
analogs[n] = serviceLink.readInt(13, 0, 0x0508 + n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SnapShot ss = new SnapShot(s);
|
||||||
|
ss.setTimestamp(timestamp);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
} catch (ServiceLinkRequestFailedException e){
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SnapShot readSnapShot() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
|
||||||
import static org.hwo.logging.Logging.*;
|
import static org.hwo.logging.Logging.*;
|
||||||
import static org.hwo.logging.LogLevel.*;
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
@ -37,8 +40,8 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDeviceSerial() {
|
public Integer getDeviceSerial() {
|
||||||
return String.format("%d", serial);
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,4 +160,22 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
return analogs[channel];
|
return analogs[channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailableSnapshots() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SnapShot[] readSnapShots() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SnapShot readSnapShot() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ import javax.swing.border.TitledBorder;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JEditorPane;
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
public class AppSettingsFrame extends JDialog {
|
public class AppSettingsFrame extends JDialog {
|
||||||
|
|
||||||
|
@ -79,6 +81,12 @@ public class AppSettingsFrame extends JDialog {
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public AppSettingsFrame() {
|
public AppSettingsFrame() {
|
||||||
|
addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
timer.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setTitle("Einstellungen");
|
setTitle("Einstellungen");
|
||||||
|
|
|
@ -204,7 +204,10 @@ public class ChannelDisplay extends JPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setDescriptionText(tf2.getText());
|
|
||||||
|
if (!tf2.getText().startsWith("!\"§$%")){
|
||||||
|
setDescriptionText(tf2.getText());
|
||||||
|
};
|
||||||
fireChannelDisplayDescriptionSet(tf2.getText());
|
fireChannelDisplayDescriptionSet(tf2.getText());
|
||||||
popupMenu.setVisible(false);
|
popupMenu.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
import org.hwo.pulscounter.SnapshotManager.Notification;
|
import org.hwo.pulscounter.SnapshotManager.Notification;
|
||||||
import org.hwo.pulscounter.device.IDeviceConnector;
|
import org.hwo.pulscounter.device.IDeviceConnector;
|
||||||
import org.hwo.pulscounter.device.NoDeviceConnectionException;
|
import org.hwo.pulscounter.device.NoDeviceConnectionException;
|
||||||
|
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
import org.hwo.tasklet.Tasklet;
|
import org.hwo.tasklet.Tasklet;
|
||||||
|
@ -272,6 +273,14 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDescriptionText(ChannelDisplay sender, String descriptionText) {
|
public void setDescriptionText(ChannelDisplay sender, String descriptionText) {
|
||||||
|
if (descriptionText.startsWith("!\"§$%")){
|
||||||
|
if (selectedDeviceInterface != null){
|
||||||
|
if (ServiceLinkDeviceConnector.class.isInstance(selectedDeviceInterface)){
|
||||||
|
ServiceLinkDeviceConnector dc = (ServiceLinkDeviceConnector)selectedDeviceInterface;
|
||||||
|
dc.setDeviceSerial(Integer.parseInt(descriptionText.substring(5)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -608,6 +617,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
channelDisplays[n].setVoltage((double)analogs[n]);
|
channelDisplays[n].setVoltage((double)analogs[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (NoDeviceConnectionException e){
|
} catch (NoDeviceConnectionException e){
|
||||||
log("No Device");
|
log("No Device");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
|
@ -686,6 +696,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void messageArrived(String message) {
|
public synchronized void messageArrived(String message) {
|
||||||
if (EventQueue.isDispatchThread()){
|
if (EventQueue.isDispatchThread()){
|
||||||
|
|
Loading…
Reference in New Issue