WIP-160909 Simulation / MultiDevice
parent
94877bb85f
commit
e903133b95
|
@ -6,6 +6,6 @@
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.ui"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.ui"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.servicelink"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.servicelink"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.platform"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.hwo.platform"/>
|
||||||
<classpathentry kind="lib" path="/data/src/java/external/hsqldb-2.3.4/hsqldb/lib/hsqldb.jar"/>
|
<classpathentry kind="lib" path="lib/hsqldb.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -2,9 +2,6 @@ package org.hwo.pulscounter;
|
||||||
|
|
||||||
public abstract class AbstractPulsCounterApplicationListener implements PulsCounterApplicationListener {
|
public abstract class AbstractPulsCounterApplicationListener implements PulsCounterApplicationListener {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialPortChanged() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package org.hwo.pulscounter;
|
||||||
import static org.hwo.logging.Logging.log;
|
import static org.hwo.logging.Logging.log;
|
||||||
import static org.hwo.logging.LogLevel.*;
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Frame;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -19,6 +21,9 @@ import java.util.Vector;
|
||||||
import java.util.prefs.BackingStoreException;
|
import java.util.prefs.BackingStoreException;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import org.hsqldb.persist.EventLogInterface;
|
||||||
import org.hwo.StringHelper;
|
import org.hwo.StringHelper;
|
||||||
import org.hwo.configuration.ConfigurableObjects;
|
import org.hwo.configuration.ConfigurableObjects;
|
||||||
import org.hwo.io.NewSerialPort.NewSerialPort;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
|
@ -27,6 +32,7 @@ import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkListener;
|
import org.hwo.servicelink.ServiceLinkListener;
|
||||||
import org.hwo.pulscounter.device.IDeviceConnector;
|
import org.hwo.pulscounter.device.IDeviceConnector;
|
||||||
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
|
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
|
||||||
|
import org.hwo.pulscounter.device.SimulatedCounter;
|
||||||
import org.hwo.pulscounter.ui.AppSettingsListener;
|
import org.hwo.pulscounter.ui.AppSettingsListener;
|
||||||
import org.hwo.pulscounter.ui.BatchRunner;
|
import org.hwo.pulscounter.ui.BatchRunner;
|
||||||
import org.hwo.pulscounter.ui.NewMainWindow;
|
import org.hwo.pulscounter.ui.NewMainWindow;
|
||||||
|
@ -142,7 +148,10 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
/* Initialize default configuration */
|
/* Initialize default configuration */
|
||||||
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
||||||
applicationConfiguration.setProperty("interface.classes", StringHelper.join(new String[]{ServiceLinkDeviceConnector.class.getCanonicalName() }, ","));
|
applicationConfiguration.setProperty("interface.classes", StringHelper.join(new String[]{
|
||||||
|
ServiceLinkDeviceConnector.class.getCanonicalName(),
|
||||||
|
SimulatedCounter.class.getCanonicalName()
|
||||||
|
}, ","));
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -187,7 +196,7 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
public void start(){
|
public void start(){
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
String uiClassName = applicationConfiguration.getProperty("ui.class");
|
String uiClassName = applicationConfiguration.getProperty("ui.class");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -246,14 +255,18 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
log(INFO,"Application shutdown...");
|
log(INFO,"Application shutdown...");
|
||||||
|
|
||||||
|
/* Dispose all left frames */
|
||||||
|
for (Frame frame: JFrame.getFrames()){
|
||||||
|
frame.setVisible(false);
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldSaveConfiguration){
|
if (shouldSaveConfiguration){
|
||||||
|
|
||||||
applicationConfiguration.setProperty("interfaces.n", Integer.toString(interfaces.size()));
|
applicationConfiguration.setProperty("interfaces.n", Integer.toString(interfaces.size()));
|
||||||
for (int n=0;n<interfaces.size();n++){
|
for (int n=0;n<interfaces.size();n++){
|
||||||
applicationConfiguration.setProperty(String.format("interfaces.%d.class", n), interfaces.get(0).getClass().getCanonicalName());
|
applicationConfiguration.setProperty(String.format("interfaces.%d.class", n), interfaces.get(n).getClass().getCanonicalName());
|
||||||
applicationConfiguration.setProperty(String.format("interfaces.%d.settings", n), interfaces.get(0).getConnectionSettings());
|
applicationConfiguration.setProperty(String.format("interfaces.%d.settings", n), interfaces.get(n).getConnectionSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,7 +285,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,22 +415,7 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
l.ServiceLinkChanged(serviceLink);
|
l.ServiceLinkChanged(serviceLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireSerialPortChanged(){
|
|
||||||
for (PulsCounterApplicationListener listener: applicationListeners){
|
|
||||||
listener.serialPortChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fireConnectionStateChanged(){
|
|
||||||
fireConnectionStateChanged(getServiceLink().isOpen());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fireConnectionStateChanged(Boolean connected){
|
|
||||||
for (PulsCounterApplicationListener listener: applicationListeners){
|
|
||||||
listener.connectionStateChanged(connected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void message(String message){
|
public void message(String message){
|
||||||
|
|
||||||
|
@ -454,7 +451,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
getServiceLink();
|
getServiceLink();
|
||||||
|
|
||||||
fireServiceLinkChanged();
|
fireServiceLinkChanged();
|
||||||
fireSerialPortChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ServiceLink getServiceLink() {
|
public synchronized ServiceLink getServiceLink() {
|
||||||
|
@ -543,7 +539,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStateChanged(Boolean connected) {
|
public void connectionStateChanged(Boolean connected) {
|
||||||
fireConnectionStateChanged(connected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapshotManager getSnapshotManager() {
|
public SnapshotManager getSnapshotManager() {
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package org.hwo.pulscounter;
|
package org.hwo.pulscounter;
|
||||||
|
|
||||||
public interface PulsCounterApplicationListener {
|
public interface PulsCounterApplicationListener {
|
||||||
|
|
||||||
void serialPortChanged();
|
|
||||||
void connectionStateChanged(Boolean connected);
|
|
||||||
|
|
||||||
|
|
||||||
void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication);
|
void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication);
|
||||||
void interfacesChanged(PulsCounterApplication pulsCounterApplication);
|
void interfacesChanged(PulsCounterApplication pulsCounterApplication);
|
||||||
|
|
|
@ -15,11 +15,13 @@ public interface IDeviceConnector {
|
||||||
public int getCounter(int channel);
|
public int getCounter(int channel);
|
||||||
public void setCounter(int channel,int counter);
|
public void setCounter(int channel,int counter);
|
||||||
|
|
||||||
|
public float[] getAnalogs();
|
||||||
|
public float getAnalog(int channel);
|
||||||
|
|
||||||
public int[] getSimpleScript();
|
public int[] getSimpleScript();
|
||||||
public void setSimpleScript(int[] simpleScript);
|
public void setSimpleScript(int[] simpleScript);
|
||||||
|
|
||||||
public int getInputs();
|
public int getInputs();
|
||||||
public void setInputs(int inputs);
|
|
||||||
public int getOutputs();
|
public int getOutputs();
|
||||||
public void setOutputs(int outputs);
|
public void setOutputs(int outputs);
|
||||||
public int getPullups();
|
public int getPullups();
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.hwo.io.NewSerialPort.NewSerialPort;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
|
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.ServiceLinkRequestFailedException;
|
||||||
|
import org.hwo.ui.dialog.SerialPortChooser;
|
||||||
|
import static org.hwo.logging.Logging.*;
|
||||||
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
|
||||||
public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
|
@ -9,8 +18,21 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
public ServiceLinkDeviceConnector() {
|
public ServiceLinkDeviceConnector() {
|
||||||
serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
|
serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkOpen(){
|
||||||
|
if (!serviceLink.isOpen()){
|
||||||
|
try {
|
||||||
|
serviceLink.open();
|
||||||
|
serviceLink.getSerialPort().setTimeOut(250);
|
||||||
|
} catch (ServiceLinkException e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Serial [%s]", this.serviceLink.getSerialPort().getPortName());
|
return String.format("Serial [%s]", this.serviceLink.getSerialPort().getPortName());
|
||||||
|
@ -18,17 +40,21 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDeviceSerial() {
|
public String getDeviceSerial() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceSerial() {
|
public void setDeviceSerial(int serial) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showConnctionSetup() {
|
public boolean showConnctionSetup() {
|
||||||
// TODO Auto-generated method stub
|
NewSerialPort newSerialPort = SerialPortChooser.execute(serviceLink.getSerialPort().getPortName());
|
||||||
|
if (newSerialPort != null){
|
||||||
|
serviceLink.close();
|
||||||
|
serviceLink.getSerialPort().setPortName(newSerialPort.getPortName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +77,25 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getCounters() {
|
public int[] getCounters() {
|
||||||
// TODO Auto-generated method stub
|
int[] values = new int[32];
|
||||||
return null;
|
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
Integer v = null;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,12 +134,6 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInputs(int inputs) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOutputs() {
|
public int getOutputs() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -133,6 +170,18 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] getAnalogs() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getAnalog(int channel) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import static org.hwo.logging.Logging.*;
|
||||||
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class SimulatedCounter implements IDeviceConnector {
|
||||||
|
|
||||||
|
private int serial;
|
||||||
|
private int[] values;
|
||||||
|
private float[] analogs;
|
||||||
|
|
||||||
|
private int inputs,
|
||||||
|
outputs,
|
||||||
|
pullups,
|
||||||
|
inverts;
|
||||||
|
|
||||||
|
private Random random;
|
||||||
|
|
||||||
|
public SimulatedCounter() {
|
||||||
|
random = new Random();
|
||||||
|
serial = random.nextInt();
|
||||||
|
|
||||||
|
values = new int[32];
|
||||||
|
analogs = new float[8];
|
||||||
|
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
analogs[i] = (float)(random.nextFloat() * 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("Simulated Counter [%d]", serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeviceSerial() {
|
||||||
|
return String.format("%d", serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean showConnctionSetup() {
|
||||||
|
return SimulatedCounterSettingsDialog.show(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionSettings() {
|
||||||
|
return String.format("%d", serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConnectionSettings(String connectionSettings) {
|
||||||
|
if (!connectionSettings.equals("")){
|
||||||
|
log(INFO,"Simulated Counter changes serial %d -> %s",serial,connectionSettings);
|
||||||
|
serial = Integer.parseInt(connectionSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionSettingsText() {
|
||||||
|
return String.format("Device Serial: %d\nSimulated Values", serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getCounters() {
|
||||||
|
int i = random.nextInt();
|
||||||
|
|
||||||
|
values[ i & 0x1F ] += random.nextInt() & 0x07;
|
||||||
|
|
||||||
|
for (i=0;i<8;i++){
|
||||||
|
analogs[i] += (float)(random.nextFloat() * 0.6)-0.3;
|
||||||
|
if (analogs[i] > 10.0f){
|
||||||
|
analogs[i] = 10.0f;
|
||||||
|
}
|
||||||
|
if (analogs[i] < 0.0f){
|
||||||
|
analogs[i] = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs = random.nextInt();
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCounters(int[] values) {
|
||||||
|
this.values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCounter(int channel) {
|
||||||
|
return values[channel];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCounter(int channel, int counter) {
|
||||||
|
values[channel] = counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSimpleScript() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSimpleScript(int[] simpleScript) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInputs() {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOutputs() {
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOutputs(int outputs) {
|
||||||
|
this.outputs = outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPullups() {
|
||||||
|
return pullups;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPullups(int pullups) {
|
||||||
|
this.pullups = pullups;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInverts() {
|
||||||
|
return inverts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInverts(int inverts) {
|
||||||
|
this.inverts = inverts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float[] getAnalogs() {
|
||||||
|
return analogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getAnalog(int channel) {
|
||||||
|
return analogs[channel];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
public class SimulatedCounterSettingsDialog extends JDialog {
|
||||||
|
|
||||||
|
public static boolean show(SimulatedCounter counter){
|
||||||
|
SimulatedCounterSettingsDialog dlg = new SimulatedCounterSettingsDialog();
|
||||||
|
dlg.setSerial(counter.getConnectionSettings());
|
||||||
|
dlg.setVisible(true);
|
||||||
|
|
||||||
|
if (dlg.accepted){
|
||||||
|
counter.setConnectionSettings(dlg.getSerial());
|
||||||
|
dlg.dispose();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
|
||||||
|
private boolean accepted;
|
||||||
|
private JTextField tfSerial;
|
||||||
|
|
||||||
|
public SimulatedCounterSettingsDialog() {
|
||||||
|
setTitle("Simulierter Zähler");
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 450, 300);
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
||||||
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gbl_contentPanel.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JLabel lblAnschluss = new JLabel("Seriennummer:");
|
||||||
|
GridBagConstraints gbc_lblAnschluss = new GridBagConstraints();
|
||||||
|
gbc_lblAnschluss.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblAnschluss.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblAnschluss.gridx = 0;
|
||||||
|
gbc_lblAnschluss.gridy = 0;
|
||||||
|
contentPanel.add(lblAnschluss, gbc_lblAnschluss);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tfSerial = new JTextField();
|
||||||
|
GridBagConstraints gbc_tfSerial = new GridBagConstraints();
|
||||||
|
gbc_tfSerial.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_tfSerial.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_tfSerial.gridx = 1;
|
||||||
|
gbc_tfSerial.gridy = 0;
|
||||||
|
contentPanel.add(tfSerial, gbc_tfSerial);
|
||||||
|
tfSerial.setColumns(10);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
accepted = true;
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
okButton.setActionCommand("OK");
|
||||||
|
buttonPane.add(okButton);
|
||||||
|
getRootPane().setDefaultButton(okButton);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerial(){
|
||||||
|
return tfSerial.getText();
|
||||||
|
}
|
||||||
|
public void setSerial(String serial){
|
||||||
|
tfSerial.setText(serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -44,17 +44,6 @@ public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
pulsCounterApplication.notifyUiIsFinished(false);
|
pulsCounterApplication.notifyUiIsFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialPortChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connectionStateChanged(Boolean connected) {
|
|
||||||
if (connected){
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageArrived(String message) {
|
public void messageArrived(String message) {
|
||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
|
|
|
@ -151,7 +151,6 @@ public class ChannelDisplay extends JPanel {
|
||||||
|
|
||||||
lName = new JTextField();
|
lName = new JTextField();
|
||||||
lName.setEditable(false);
|
lName.setEditable(false);
|
||||||
lName.setForeground(Color.LIGHT_GRAY);
|
|
||||||
lName.setInheritsPopupMenu(true);
|
lName.setInheritsPopupMenu(true);
|
||||||
GridBagConstraints gbc_lName = new GridBagConstraints();
|
GridBagConstraints gbc_lName = new GridBagConstraints();
|
||||||
gbc_lName.fill = GridBagConstraints.HORIZONTAL;
|
gbc_lName.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
@ -291,7 +290,13 @@ public class ChannelDisplay extends JPanel {
|
||||||
}
|
}
|
||||||
public void setCounter(Integer counter) {
|
public void setCounter(Integer counter) {
|
||||||
this.counter = counter;
|
this.counter = counter;
|
||||||
tfCounter.setText(String.format("%d", counter));
|
if (counter != null){
|
||||||
|
tfCounter.setText(String.format("%d", counter));
|
||||||
|
tfCounter.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
tfCounter.setEnabled(false);
|
||||||
|
tfCounter.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getVoltage() {
|
public Double getVoltage() {
|
||||||
|
@ -299,7 +304,13 @@ public class ChannelDisplay extends JPanel {
|
||||||
}
|
}
|
||||||
public void setVoltage(Double voltage) {
|
public void setVoltage(Double voltage) {
|
||||||
this.voltage = voltage;
|
this.voltage = voltage;
|
||||||
tfAnalog.setText(String.format("%.02f V",voltage));
|
if (voltage != null){
|
||||||
|
tfAnalog.setText(String.format("%.02f V",voltage));
|
||||||
|
tfAnalog.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
tfAnalog.setEnabled(false);
|
||||||
|
tfAnalog.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChannelName(String channelName) {
|
public void setChannelName(String channelName) {
|
||||||
|
@ -317,4 +328,16 @@ public class ChannelDisplay extends JPanel {
|
||||||
return lName.getText();
|
return lName.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
if (enabled){
|
||||||
|
} else {
|
||||||
|
setVoltage(null);
|
||||||
|
setCounter(null);
|
||||||
|
setOutput(false);
|
||||||
|
setInput(false);
|
||||||
|
setPullup(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,17 +188,11 @@ public class DeviceTestFrame extends JFrame implements PulsCounterApplicationLis
|
||||||
lMessages.setModel(messageListModel);
|
lMessages.setModel(messageListModel);
|
||||||
|
|
||||||
application().addPulsCounterApplicationListener(this);
|
application().addPulsCounterApplicationListener(this);
|
||||||
application().fireConnectionStateChanged(false);
|
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*
|
||||||
public void serialPortChanged() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStateChanged(Boolean connected) {
|
public void connectionStateChanged(Boolean connected) {
|
||||||
|
|
||||||
|
@ -237,7 +231,8 @@ public class DeviceTestFrame extends JFrame implements PulsCounterApplicationLis
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void messageArrived(String message) {
|
public synchronized void messageArrived(String message) {
|
||||||
if (EventQueue.isDispatchThread()){
|
if (EventQueue.isDispatchThread()){
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.awt.GridBagLayout;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import javax.swing.JToolBar;
|
import javax.swing.JToolBar;
|
||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
@ -21,11 +22,13 @@ import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
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.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;
|
||||||
import org.hwo.tasklet.TaskletListener;
|
import org.hwo.tasklet.TaskletListener;
|
||||||
import org.hwo.tasklet.TaskletManager;
|
import org.hwo.tasklet.TaskletManager;
|
||||||
|
import org.hwo.ui.JObjectSelector;
|
||||||
import org.hwo.ui.dialog.SerialPortChooser;
|
import org.hwo.ui.dialog.SerialPortChooser;
|
||||||
import org.omg.CORBA.Environment;
|
import org.omg.CORBA.Environment;
|
||||||
|
|
||||||
|
@ -69,8 +72,13 @@ import javax.swing.event.ChangeListener;
|
||||||
import javax.swing.plaf.metal.MetalBorders.ToolBarBorder;
|
import javax.swing.plaf.metal.MetalBorders.ToolBarBorder;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import static org.hwo.logging.Logging.log;
|
import static org.hwo.logging.Logging.log;
|
||||||
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
|
||||||
public class NewMainWindow implements PulsCounterApplicationListener, TaskletListener{
|
public class NewMainWindow implements PulsCounterApplicationListener, TaskletListener{
|
||||||
|
|
||||||
|
@ -82,9 +90,10 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private FlexibleObjectListModel<IDeviceConnector>
|
private FlexibleObjectListModel<IDeviceConnector>
|
||||||
lmInterfaces = new FlexibleObjectListModel<>();
|
lmInterfaces = new FlexibleObjectListModel<>();
|
||||||
|
|
||||||
|
private BackgroundThread backgroundThread;
|
||||||
|
|
||||||
private JFrame frmSynolog;
|
private JFrame frmSynolog;
|
||||||
private JSplitPane splitter;
|
private JSplitPane splitter;
|
||||||
private JTextField tfConnection;
|
|
||||||
private JButton btnSetup;
|
private JButton btnSetup;
|
||||||
|
|
||||||
private DefaultListModel<String> messageListModel;
|
private DefaultListModel<String> messageListModel;
|
||||||
|
@ -115,7 +124,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private JButton bIntfAdd;
|
private JButton bIntfAdd;
|
||||||
private JButton bIntfDel;
|
private JButton bIntfDel;
|
||||||
private JPanel panel_4;
|
private JPanel panel_4;
|
||||||
private JTextField tfConnectionSettings;
|
private JTextArea tfConnectionSettings;
|
||||||
|
|
||||||
|
|
||||||
public static void startGUI(){
|
public static void startGUI(){
|
||||||
|
@ -172,9 +181,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
application().addPulsCounterApplicationListener(this);
|
application().addPulsCounterApplicationListener(this);
|
||||||
|
|
||||||
application().fireConnectionStateChanged();
|
|
||||||
application().fireSerialPortChanged();
|
|
||||||
|
|
||||||
application().message("Synololog Applikation wurde gestartet.");
|
application().message("Synololog Applikation wurde gestartet.");
|
||||||
|
|
||||||
timerReconnect.scheduleAtFixedRate(new TimerTask() {
|
timerReconnect.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@ -211,50 +217,24 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
frmSynolog.addWindowListener(new WindowListener() {
|
frmSynolog.addWindowListener(new WindowAdapter() {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowOpened(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowIconified(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeiconified(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeactivated(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
application().notifyUiIsFinished(true);
|
backgroundThread.exit();
|
||||||
|
application().notifyUiIsFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowActivated(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
lmInterfaces.setItems(pulsCounterApplication.getInterfaces());
|
//lmInterfaces.setItems(pulsCounterApplication.getInterfaces());
|
||||||
|
if (pulsCounterApplication.getInterfaces().size()>0){
|
||||||
|
interfacesChanged(pulsCounterApplication);
|
||||||
|
lInterfaces.setSelectedIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
backgroundThread = new BackgroundThread();
|
||||||
|
backgroundThread.start();
|
||||||
|
|
||||||
frmSynolog.setVisible(true);
|
frmSynolog.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -364,9 +344,9 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
splitter.setRightComponent(panel);
|
splitter.setRightComponent(panel);
|
||||||
GridBagLayout gbl_panel = new GridBagLayout();
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
gbl_panel.columnWidths = new int[]{0, 0};
|
gbl_panel.columnWidths = new int[]{0, 0};
|
||||||
gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_panel.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
panel.setLayout(gbl_panel);
|
panel.setLayout(gbl_panel);
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
JPanel panel_1 = new JPanel();
|
||||||
|
@ -381,9 +361,9 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
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};
|
gbl_panel_1.columnWidths = new int[]{0, 0, 0};
|
||||||
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
gbl_panel_1.rowHeights = new int[]{0, 0, 0, 0, 0};
|
||||||
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
gbl_panel_1.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
gbl_panel_1.rowWeights = new double[]{0.0, 1.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
gbl_panel_1.rowWeights = new double[]{0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
panel_1.setLayout(gbl_panel_1);
|
panel_1.setLayout(gbl_panel_1);
|
||||||
|
|
||||||
bIntfAdd = new JButton("+");
|
bIntfAdd = new JButton("+");
|
||||||
|
@ -423,6 +403,17 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
panel_1.add(scrollPane_2, gbc_scrollPane_2);
|
panel_1.add(scrollPane_2, gbc_scrollPane_2);
|
||||||
|
|
||||||
lInterfaces = new JList(lmInterfaces);
|
lInterfaces = new JList(lmInterfaces);
|
||||||
|
lInterfaces.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if ((e.getClickCount()==2)&&(e.getButton()==e.BUTTON1)){
|
||||||
|
if (selectedDeviceInterface != null){
|
||||||
|
selectedDeviceInterface.showConnctionSetup();
|
||||||
|
frmSynolog.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
lInterfaces.addListSelectionListener(new ListSelectionListener() {
|
lInterfaces.addListSelectionListener(new ListSelectionListener() {
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
selectedInterfaceChanged();
|
selectedInterfaceChanged();
|
||||||
|
@ -445,7 +436,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
panel_4.setBorder(new TitledBorder(null, "Anschlusseinstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel_4.setBorder(new TitledBorder(null, "Anschlusseinstellungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_4 = new GridBagConstraints();
|
||||||
gbc_panel_4.gridwidth = 2;
|
gbc_panel_4.gridwidth = 2;
|
||||||
gbc_panel_4.insets = new Insets(0, 0, 5, 5);
|
gbc_panel_4.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
gbc_panel_4.fill = GridBagConstraints.BOTH;
|
||||||
gbc_panel_4.gridx = 0;
|
gbc_panel_4.gridx = 0;
|
||||||
gbc_panel_4.gridy = 2;
|
gbc_panel_4.gridy = 2;
|
||||||
|
@ -457,7 +448,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
gbl_panel_4.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
gbl_panel_4.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
panel_4.setLayout(gbl_panel_4);
|
panel_4.setLayout(gbl_panel_4);
|
||||||
|
|
||||||
tfConnectionSettings = new JTextField();
|
tfConnectionSettings = new JTextArea();
|
||||||
tfConnectionSettings.setEditable(false);
|
tfConnectionSettings.setEditable(false);
|
||||||
GridBagConstraints gbc_tfConnectionSettings = new GridBagConstraints();
|
GridBagConstraints gbc_tfConnectionSettings = new GridBagConstraints();
|
||||||
gbc_tfConnectionSettings.fill = GridBagConstraints.BOTH;
|
gbc_tfConnectionSettings.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -467,25 +458,12 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
tfConnectionSettings.setColumns(10);
|
tfConnectionSettings.setColumns(10);
|
||||||
|
|
||||||
GridBagConstraints gbc_cbTrimDevice = new GridBagConstraints();
|
GridBagConstraints gbc_cbTrimDevice = new GridBagConstraints();
|
||||||
|
gbc_cbTrimDevice.gridwidth = 2;
|
||||||
gbc_cbTrimDevice.anchor = GridBagConstraints.WEST;
|
gbc_cbTrimDevice.anchor = GridBagConstraints.WEST;
|
||||||
gbc_cbTrimDevice.insets = new Insets(0, 0, 5, 5);
|
|
||||||
gbc_cbTrimDevice.gridx = 0;
|
gbc_cbTrimDevice.gridx = 0;
|
||||||
gbc_cbTrimDevice.gridy = 4;
|
gbc_cbTrimDevice.gridy = 3;
|
||||||
panel_1.add(cbTrimDevice, gbc_cbTrimDevice);
|
panel_1.add(cbTrimDevice, gbc_cbTrimDevice);
|
||||||
|
|
||||||
tfConnection = new JTextField();
|
|
||||||
tfConnection.setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
tfConnection.setText("...");
|
|
||||||
tfConnection.setBackground(Color.WHITE);
|
|
||||||
tfConnection.setEditable(false);
|
|
||||||
GridBagConstraints gbc_tfConnection = new GridBagConstraints();
|
|
||||||
gbc_tfConnection.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_tfConnection.gridwidth = 2;
|
|
||||||
gbc_tfConnection.gridx = 0;
|
|
||||||
gbc_tfConnection.gridy = 5;
|
|
||||||
panel_1.add(tfConnection, gbc_tfConnection);
|
|
||||||
tfConnection.setColumns(10);
|
|
||||||
|
|
||||||
JPanel panel_2 = new JPanel();
|
JPanel panel_2 = new JPanel();
|
||||||
panel_2.setBackground(Color.WHITE);
|
panel_2.setBackground(Color.WHITE);
|
||||||
panel_2.setBorder(new TitledBorder(null, "Meldungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel_2.setBorder(new TitledBorder(null, "Meldungen", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||||
|
@ -493,7 +471,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
gbc_panel_2.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
gbc_panel_2.fill = GridBagConstraints.BOTH;
|
||||||
gbc_panel_2.gridx = 0;
|
gbc_panel_2.gridx = 0;
|
||||||
gbc_panel_2.gridy = 4;
|
gbc_panel_2.gridy = 1;
|
||||||
panel.add(panel_2, gbc_panel_2);
|
panel.add(panel_2, gbc_panel_2);
|
||||||
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
||||||
gbl_panel_2.columnWidths = new int[]{142, 0};
|
gbl_panel_2.columnWidths = new int[]{142, 0};
|
||||||
|
@ -519,7 +497,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
GridBagConstraints gbc_panel_3 = new GridBagConstraints();
|
||||||
gbc_panel_3.fill = GridBagConstraints.BOTH;
|
gbc_panel_3.fill = GridBagConstraints.BOTH;
|
||||||
gbc_panel_3.gridx = 0;
|
gbc_panel_3.gridx = 0;
|
||||||
gbc_panel_3.gridy = 5;
|
gbc_panel_3.gridy = 2;
|
||||||
panel.add(panel_3, gbc_panel_3);
|
panel.add(panel_3, gbc_panel_3);
|
||||||
panel_3.setLayout(new BoxLayout(panel_3, BoxLayout.X_AXIS));
|
panel_3.setLayout(new BoxLayout(panel_3, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
@ -558,7 +536,9 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
} else {
|
} else {
|
||||||
bIntfDel.setEnabled(true);
|
bIntfDel.setEnabled(true);
|
||||||
|
|
||||||
|
// tfConnectionSettings.setText(String.format("<html>%s</html>", selectedDeviceInterface.getConnectionSettingsText().replaceAll("\n", "<br/>")));
|
||||||
tfConnectionSettings.setText(selectedDeviceInterface.getConnectionSettingsText());
|
tfConnectionSettings.setText(selectedDeviceInterface.getConnectionSettingsText());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -573,12 +553,22 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
||||||
lmInterfaces.setItems(pulsCounterApplication.getInterfaces());
|
lmInterfaces.setItems(pulsCounterApplication.getInterfaces());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addInterface(){
|
private void addInterface(){
|
||||||
pulsCounterApplication.addInterface(pulsCounterApplication.getInterfaceClasses().get(0), "");
|
Class<IDeviceConnector> cidc;
|
||||||
|
|
||||||
|
if (pulsCounterApplication.getInterfaceClasses().size()==1){
|
||||||
|
cidc = pulsCounterApplication.getInterfaceClasses().get(0);
|
||||||
|
} else {
|
||||||
|
cidc = (Class<IDeviceConnector>)JObjectSelector.execute(pulsCounterApplication.getInterfaceClasses().toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cidc != null){
|
||||||
|
pulsCounterApplication.addInterface(cidc, "");
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
private void removeInterface(){
|
private void removeInterface(){
|
||||||
|
@ -588,14 +578,53 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSerialPort(NewSerialPort serialPort){
|
|
||||||
PulsCounterApplication.getApplication().setSerialPort(serialPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialPortChanged() {
|
private synchronized void updateDeviceView(){
|
||||||
|
if (selectedDeviceInterface != null){
|
||||||
|
try {
|
||||||
|
int[] values = selectedDeviceInterface.getCounters();
|
||||||
|
float[] analogs = selectedDeviceInterface.getAnalogs();
|
||||||
|
int inputs,
|
||||||
|
outputs,
|
||||||
|
pullups;
|
||||||
|
|
||||||
|
inputs = selectedDeviceInterface.getInputs();
|
||||||
|
outputs = selectedDeviceInterface.getOutputs();
|
||||||
|
pullups = selectedDeviceInterface.getPullups();
|
||||||
|
|
||||||
|
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
channelDisplays[n].setEnabled(true);
|
||||||
|
channelDisplays[n].setCounter(values[n]);
|
||||||
|
|
||||||
|
channelDisplays[n].setInput( ((inputs & (1<<n)) != 0) ? true : false);
|
||||||
|
channelDisplays[n].setOutput( ((outputs & (1<<n)) != 0) ? true : false);
|
||||||
|
channelDisplays[n].setPullup( ((pullups & (1<<n)) != 0) ? true : false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int n=0;n<8;n++){
|
||||||
|
channelDisplays[n].setVoltage((double)analogs[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NoDeviceConnectionException e){
|
||||||
|
log("No Device");
|
||||||
|
} catch (Exception e){
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
channelDisplays[n].setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public void connectionStateChanged(Boolean connected) {
|
public void connectionStateChanged(Boolean connected) {
|
||||||
if (connected){
|
if (connected){
|
||||||
|
@ -615,7 +644,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
trimDeviceTimeSlice = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x1302);
|
trimDeviceTimeSlice = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x1302);
|
||||||
|
|
||||||
/* Trim helper initialisieren */
|
// Trim helper initialisieren
|
||||||
trimTicksOnConnect = null;
|
trimTicksOnConnect = null;
|
||||||
|
|
||||||
application().getSnapshotManager().notify(Notification.FULLSYNC);
|
application().getSnapshotManager().notify(Notification.FULLSYNC);
|
||||||
|
@ -656,7 +685,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
this.connected = connected;
|
this.connected = connected;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void messageArrived(String message) {
|
public synchronized void messageArrived(String message) {
|
||||||
if (EventQueue.isDispatchThread()){
|
if (EventQueue.isDispatchThread()){
|
||||||
|
@ -697,7 +726,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
Float[] analog = new Float[8];
|
Float[] analog = new Float[8];
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
for (int i=0;i<32;i++){
|
||||||
values[i] = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0600 + i);
|
|
||||||
|
|
||||||
if (i<8){
|
if (i<8){
|
||||||
analog[i] = application().getServiceLink().getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i ) * 10;
|
analog[i] = application().getServiceLink().getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i ) * 10;
|
||||||
|
@ -910,17 +939,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private void channelReset(int channel,int setValue){
|
private void channelReset(int channel,int setValue){
|
||||||
try {
|
selectedDeviceInterface.setCounter(channel, setValue);
|
||||||
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0600 + channel, setValue);
|
|
||||||
|
|
||||||
} catch (ServiceLinkRequestFailedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ServiceLinkException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void channelSet(ChannelDisplay display,int setValue){
|
private void channelSet(ChannelDisplay display,int setValue){
|
||||||
|
@ -932,6 +951,60 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class BackgroundThread extends Thread {
|
||||||
|
|
||||||
|
private int timeout;
|
||||||
|
private boolean exit;
|
||||||
|
|
||||||
|
public BackgroundThread(){
|
||||||
|
timeout = 500;
|
||||||
|
exit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exit(){
|
||||||
|
synchronized (this){
|
||||||
|
this.exit = true;
|
||||||
|
notify();
|
||||||
|
};
|
||||||
|
while (isAlive()){
|
||||||
|
try {
|
||||||
|
sleep(50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized int getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
public synchronized void setTimeout(int timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
log(INFO,"newMainWindow: backgroundThread: started");
|
||||||
|
|
||||||
|
while (!exit){
|
||||||
|
try {
|
||||||
|
wait(timeout);
|
||||||
|
|
||||||
|
updateDeviceView();
|
||||||
|
} catch (InterruptedException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log(INFO,"newMainWindow: backgroundThread: exited");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue