WIP161117
parent
a7e43ec0b4
commit
4332bb8a14
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.hwo.csv.CSVRecord;
|
import org.hwo.csv.CSVRecord;
|
||||||
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
import org.hwo.servicelink.ServiceLink;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
|
@ -21,19 +22,24 @@ public class SnapShot {
|
||||||
|
|
||||||
Integer[] values;
|
Integer[] values;
|
||||||
Integer[] analog;
|
Integer[] analog;
|
||||||
|
Integer[] merker;
|
||||||
|
|
||||||
Integer inputmask,
|
Integer inputmask,
|
||||||
outputmask,
|
outputmask,
|
||||||
pullupmask,
|
pullupmask,
|
||||||
invertmask,
|
invertmask,
|
||||||
triggermask;
|
triggermask;
|
||||||
|
|
||||||
|
static SimpleDateFormat
|
||||||
|
df = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
|
||||||
public SnapShot(int deviceSerial){
|
public SnapShot(int deviceSerial){
|
||||||
this.deviceSerial = deviceSerial;
|
this.deviceSerial = deviceSerial;
|
||||||
|
|
||||||
this.values = new Integer[32];
|
this.values = new Integer[32];
|
||||||
this.analog = new Integer[8];
|
this.analog = new Integer[8];
|
||||||
|
this.merker = new Integer[24];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +80,7 @@ public class SnapShot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Gerät",order=5,width=80)
|
||||||
public Integer getDeviceSerial() {
|
public Integer getDeviceSerial() {
|
||||||
return deviceSerial;
|
return deviceSerial;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +88,7 @@ public class SnapShot {
|
||||||
this.deviceSerial = deviceSerial;
|
this.deviceSerial = deviceSerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="HW-Index",order=0,width=80)
|
||||||
public Integer getIndex() {
|
public Integer getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +105,7 @@ public class SnapShot {
|
||||||
public void setTimestamp(Integer timestamp) {
|
public void setTimestamp(Integer timestamp) {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getTimestamp() {
|
public Integer getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +150,9 @@ public class SnapShot {
|
||||||
return this.values[ch];
|
return this.values[ch];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Zähler #%d",order=50,fieldlength=32, width=80)
|
||||||
public Integer[] getValues(){
|
public Integer[] getValues(){
|
||||||
return Arrays.copyOf(this.values, this.values.length);
|
return Arrays.copyOf(this.values, this.values.length);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +183,12 @@ public class SnapShot {
|
||||||
public int getSource(){
|
public int getSource(){
|
||||||
return (field0 >> 8) & 0xff;
|
return (field0 >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@TableColumn(label="Zeitstempel",order=10,width=100)
|
||||||
|
public String getTimeStampFormated(){
|
||||||
|
return df.format(new Date(((long)timestamp)*1000));
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] toBytes(){
|
public byte[] toBytes(){
|
||||||
byte[] buffer = new byte[256];
|
byte[] buffer = new byte[256];
|
||||||
|
@ -226,7 +242,6 @@ public class SnapShot {
|
||||||
if (extended)
|
if (extended)
|
||||||
record.appendValue(timestamp);
|
record.appendValue(timestamp);
|
||||||
|
|
||||||
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
record.appendValue(df.format(new Date(((long)timestamp)*1000)));
|
record.appendValue(df.format(new Date(((long)timestamp)*1000)));
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class PulsCounterDatabase {
|
||||||
simpleScript.getId(),
|
simpleScript.getId(),
|
||||||
simpleScript.getName(),
|
simpleScript.getName(),
|
||||||
simpleScript.getDescription(),
|
simpleScript.getDescription(),
|
||||||
simpleScript.getSimpleScriptElementsAsInt()
|
simpleScript.getSimpleScriptElementsAsInteger()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
|
||||||
public interface IDeviceConnector {
|
public interface IDeviceConnector {
|
||||||
|
@ -9,7 +11,7 @@ public interface IDeviceConnector {
|
||||||
|
|
||||||
public Integer getDeviceSerial();
|
public Integer getDeviceSerial();
|
||||||
|
|
||||||
public boolean showConnctionSetup();
|
public boolean showConnctionSetup(Component parent);
|
||||||
public String getConnectionSettings();
|
public String getConnectionSettings();
|
||||||
public void setConnectionSettings(String connectionSettings);
|
public void setConnectionSettings(String connectionSettings);
|
||||||
public String getConnectionSettingsText();
|
public String getConnectionSettingsText();
|
||||||
|
@ -51,7 +53,10 @@ public interface IDeviceConnector {
|
||||||
|
|
||||||
public int[] getWindows();
|
public int[] getWindows();
|
||||||
public void setWindows(int[] windows);
|
public void setWindows(int[] windows);
|
||||||
|
|
||||||
|
public int[] getIncrements();
|
||||||
|
public void setIncrements(int[] increments);
|
||||||
|
|
||||||
public int getInterval(int iNo);
|
public int getInterval(int iNo);
|
||||||
public boolean isIntervalDailyBased(int iNo);
|
public boolean isIntervalDailyBased(int iNo);
|
||||||
public void setInterval(int iNo,int intervall,boolean dailyBase);
|
public void setInterval(int iNo,int intervall,boolean dailyBase);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.hwo.io.NewSerialPort.NewSerialPort;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
||||||
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;
|
||||||
|
@ -84,8 +86,8 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showConnctionSetup() {
|
public boolean showConnctionSetup(Component parent) {
|
||||||
NewSerialPort newSerialPort = SerialPortChooser.execute(serviceLink.getSerialPort().getPortName());
|
NewSerialPort newSerialPort = SerialPortChooser.execute(parent,serviceLink.getSerialPort().getPortName());
|
||||||
if (newSerialPort != null){
|
if (newSerialPort != null){
|
||||||
serviceLink.close();
|
serviceLink.close();
|
||||||
serviceLink.getSerialPort().setPortName(newSerialPort.getPortName());
|
serviceLink.getSerialPort().setPortName(newSerialPort.getPortName());
|
||||||
|
@ -161,13 +163,55 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSimpleScript() {
|
public int[] getSimpleScript() {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
|
Integer l = serviceLink.readInt(13, 0, 0x0700);
|
||||||
|
|
||||||
|
log(DEBUG,"%d ScriptElements on Device.",l);
|
||||||
|
|
||||||
|
if (l<0)
|
||||||
|
return new int[0];
|
||||||
|
|
||||||
|
int[] script = new int[l];
|
||||||
|
int p;
|
||||||
|
|
||||||
|
serviceLink.writeInt(13, 0, 0x0701, 0);
|
||||||
|
for (p=0;p<l;p++){
|
||||||
|
script[p] = serviceLink.readInt(13, 0, 0x0702);
|
||||||
|
SimpleScriptElement e = new SimpleScriptElement(script[p]);
|
||||||
|
log(DEBUG,"Element: 0x%08x [A=0x%02x B=0x%02x C=0x%02x O=0x%02x Z=0x%02x]",script[p],e.getA(),e.getB(),e.getCondition(),e.getOperation(),e.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
log(INFO,"%d von %d Skript Elementen empfangen.",p,l);
|
||||||
|
|
||||||
|
return script;
|
||||||
|
} catch (Exception e){
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSimpleScript(int[] simpleScript) {
|
public void setSimpleScript(int[] simpleScript) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0700, simpleScript.length);
|
||||||
|
|
||||||
|
for (int i=0;i<simpleScript.length;i++){
|
||||||
|
serviceLink.writeInt(13, 0, 0x0702, simpleScript[i]);
|
||||||
|
SimpleScriptElement e = new SimpleScriptElement(simpleScript[i]);
|
||||||
|
log(DEBUG,"Element: 0x%08x [A=0x%02x B=0x%02x C=0x%02x O=0x%02x Z=0x%02x]",simpleScript[i],e.getA(),e.getB(),e.getCondition(),e.getOperation(),e.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer p = serviceLink.readInt(13, 0, 0x0701);
|
||||||
|
if (!p.equals(simpleScript.length)){
|
||||||
|
log(INFO,"ServiceLinkDeviceConnector: Skript konnte nicht geschrieben werden (%d von %d Elementen erkannt)",p,simpleScript.length);
|
||||||
|
} else {
|
||||||
|
serviceLink.writeInt(13, 0, 0x0703, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,14 +364,16 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
Integer id;
|
Integer id;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Integer sbrk,stacklimit,cycletime;
|
Integer sbrk,stacklimit,cycletime,enginestate;
|
||||||
|
|
||||||
sbrk = serviceLink.readInt(13, 0, 0x0020);
|
sbrk = serviceLink.readInt(13, 0, 0x0020);
|
||||||
stacklimit = serviceLink.readInt(13, 0, 0x0021);
|
stacklimit = serviceLink.readInt(13, 0, 0x0021);
|
||||||
cycletime = serviceLink.readInt(13, 0, 0x1310);
|
cycletime = serviceLink.readInt(13, 0, 0x1310);
|
||||||
|
enginestate = serviceLink.readInt(13, 0, 0x0703);
|
||||||
|
|
||||||
log(INFO,"HEAP END: 0x%04x SYS-STACK: 0x%04x",sbrk,stacklimit);
|
log(INFO,"HEAP END: 0x%04x SYS-STACK: 0x%04x",sbrk,stacklimit);
|
||||||
log(INFO,"I/O cycle time: %dus",cycletime);
|
log(INFO,"I/O cycle time: %dus",cycletime);
|
||||||
|
log(INFO,"Engine-State: 0x%08x",enginestate);
|
||||||
|
|
||||||
newest = serviceLink.readInt(13, 0, 0x0581);
|
newest = serviceLink.readInt(13, 0, 0x0581);
|
||||||
sssize = serviceLink.readInt(13, 0, 0x0582);
|
sssize = serviceLink.readInt(13, 0, 0x0582);
|
||||||
|
@ -743,5 +789,47 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getIncrements() {
|
||||||
|
int[] values = new int[32];
|
||||||
|
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
values[n] = getIncrement(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIncrements(int[] increments) {
|
||||||
|
for (int n=0;n<32;n++){
|
||||||
|
setIncrement(n, increments[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIncrement(int channel) {
|
||||||
|
Integer v = null;
|
||||||
|
|
||||||
|
checkOpen();
|
||||||
|
|
||||||
|
try {
|
||||||
|
v = serviceLink.readInt(13, 0, 0x12A0 + channel );
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new NoDeviceConnectionException();
|
||||||
|
}
|
||||||
|
if (v != null){
|
||||||
|
return v;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncrement(int channel, int increment) {
|
||||||
|
checkOpen();
|
||||||
|
try {
|
||||||
|
serviceLink.writeInt(13, 0, 0x12A0 + channel, increment);
|
||||||
|
} catch (IOException | ServiceLinkException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
@ -21,6 +22,8 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
|
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
|
private int[] scriptElements;
|
||||||
|
|
||||||
public SimulatedCounter() {
|
public SimulatedCounter() {
|
||||||
random = new Random();
|
random = new Random();
|
||||||
serial = random.nextInt();
|
serial = random.nextInt();
|
||||||
|
@ -45,8 +48,8 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean showConnctionSetup() {
|
public boolean showConnctionSetup(Component parent) {
|
||||||
return SimulatedCounterSettingsDialog.show(this);
|
return SimulatedCounterSettingsDialog.show(parent,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,14 +108,12 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSimpleScript() {
|
public int[] getSimpleScript() {
|
||||||
// TODO Auto-generated method stub
|
return scriptElements;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSimpleScript(int[] simpleScript) {
|
public void setSimpleScript(int[] simpleScript) {
|
||||||
// TODO Auto-generated method stub
|
scriptElements = simpleScript;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -288,4 +289,15 @@ public class SimulatedCounter implements IDeviceConnector {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getIncrements() {
|
||||||
|
return new int[]{1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1};
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setIncrements(int[] triggers) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
@ -17,8 +18,11 @@ import java.awt.Insets;
|
||||||
|
|
||||||
public class SimulatedCounterSettingsDialog extends JDialog {
|
public class SimulatedCounterSettingsDialog extends JDialog {
|
||||||
|
|
||||||
public static boolean show(SimulatedCounter counter){
|
public static boolean show(Component parent,SimulatedCounter counter){
|
||||||
SimulatedCounterSettingsDialog dlg = new SimulatedCounterSettingsDialog();
|
SimulatedCounterSettingsDialog dlg = new SimulatedCounterSettingsDialog();
|
||||||
|
if (parent != null)
|
||||||
|
dlg.setLocationRelativeTo(parent);
|
||||||
|
|
||||||
dlg.setSerial(counter.getConnectionSettings());
|
dlg.setSerial(counter.getConnectionSettings());
|
||||||
dlg.setVisible(true);
|
dlg.setVisible(true);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,16 @@ public class SimpleScript {
|
||||||
return simpleScriptElements;
|
return simpleScriptElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer[] getSimpleScriptElementsAsInt(){
|
public int[] getSimpleScriptElementsAsInt(){
|
||||||
|
int[] sse = new int[simpleScriptElements.size()];
|
||||||
|
|
||||||
|
for (int i=0;i<sse.length;i++){
|
||||||
|
sse[i] = simpleScriptElements.get(i).getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return sse;
|
||||||
|
}
|
||||||
|
public Integer[] getSimpleScriptElementsAsInteger(){
|
||||||
Integer[] sse = new Integer[simpleScriptElements.size()];
|
Integer[] sse = new Integer[simpleScriptElements.size()];
|
||||||
|
|
||||||
for (int i=0;i<sse.length;i++){
|
for (int i=0;i<sse.length;i++){
|
||||||
|
@ -82,29 +91,46 @@ public class SimpleScript {
|
||||||
this.simpleScriptElements.clear();
|
this.simpleScriptElements.clear();
|
||||||
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
||||||
}
|
}
|
||||||
|
public void setSimpleScriptElements(int[] elements){
|
||||||
|
this.simpleScriptElements.clear();
|
||||||
|
for (int e: elements){
|
||||||
|
simpleScriptElements.add(new SimpleScriptElement(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void setSimpleScriptElements(Integer[] elements){
|
||||||
|
this.simpleScriptElements.clear();
|
||||||
|
for (int e: elements){
|
||||||
|
simpleScriptElements.add(new SimpleScriptElement(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum ScriptOperation {
|
public enum ScriptOperation {
|
||||||
|
|
||||||
SET_ZERO (0x00),
|
SET_ZERO (0x00,"ARITHEMTIK = 0"),
|
||||||
SET_ONE (0x01),
|
SET_ONE (0x01,"ARITHEMTIK = 1"),
|
||||||
SET_A (0x02),
|
SET_A (0x02,"ARITHEMTIK = A"),
|
||||||
SET_B (0x03),
|
SET_B (0x03,"ARITHEMTIK = B"),
|
||||||
A_PLUS_B (0x04),
|
A_PLUS_B (0x04,"ARITHEMTIK = A + B"),
|
||||||
A_MINUS_B (0x05),
|
A_MINUS_B (0x05,"ARITHEMTIK = A - B"),
|
||||||
A_MUL_B (0x06),
|
A_MUL_B (0x06,"ARITHEMTIK = A * B"),
|
||||||
A_DIV_B (0x07),
|
A_DIV_B (0x07,"ARITHEMTIK = A / B"),
|
||||||
A_AND_B (0x08),
|
A_AND_B (0x08,"LOGIK = A and B"),
|
||||||
A_OR_B (0x09),
|
A_OR_B (0x09,"LOGIK = A or B"),
|
||||||
A_XOR_B (0x0A),
|
A_XOR_B (0x0A,"LOGIK = A xor B"),
|
||||||
/* 0x0b..0x0f: frei */
|
/* 0x0b..0x0f: frei */
|
||||||
SET_NOT_A (0x10),
|
SET_NOT_A (0x10,"LOGIK = not A"),
|
||||||
SET_NOT_B (0x11)
|
SET_NOT_B (0x11,"LOGIK = not B"),
|
||||||
/* 0x12..0x1f: frei */
|
A_PLUS_ONE (0x12,"ARITHEMTIK = A + 1"),
|
||||||
|
A_MINUS_ONE (0x13,"ARITHEMTIK = A - 1"),
|
||||||
|
B_PLUS_ONE (0x14,"ARITHEMTIK = B + 1"),
|
||||||
|
B_MINUS_ONE (0x15,"ARITHEMTIK = B - 1")
|
||||||
|
/* 0x16..0x1f: frei */
|
||||||
;
|
;
|
||||||
|
|
||||||
ScriptOperation(int n){
|
ScriptOperation(int n,String desc){
|
||||||
this.n = n;
|
this.n = n;
|
||||||
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ScriptOperation operations[] = {
|
static ScriptOperation operations[] = {
|
||||||
|
@ -126,10 +152,10 @@ public class SimpleScript {
|
||||||
null,
|
null,
|
||||||
SET_NOT_A, // 0x10
|
SET_NOT_A, // 0x10
|
||||||
SET_NOT_B,
|
SET_NOT_B,
|
||||||
null,
|
A_PLUS_ONE,
|
||||||
null,
|
A_MINUS_ONE,
|
||||||
null, // 0x14
|
B_PLUS_ONE, // 0x14
|
||||||
null,
|
B_MINUS_ONE,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null, // 0x18
|
null, // 0x18
|
||||||
|
@ -146,23 +172,34 @@ public class SimpleScript {
|
||||||
return operations[code];
|
return operations[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
private int n;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
public int getCode(){
|
public int getCode(){
|
||||||
return this.n;
|
return this.n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ScriptCondition {
|
public enum ScriptCondition {
|
||||||
NEVER (0x00),
|
NEVER (0x00,"Niemals"),
|
||||||
ALWAYS (0x01),
|
ALWAYS (0x01,"Immer"),
|
||||||
A_EQ_ZERO (0x02),
|
A_EQ_ZERO (0x02,"A == 0"),
|
||||||
A_NEQ_ZERO (0x03),
|
A_NEQ_ZERO (0x03,"A != 0"),
|
||||||
A_EQ_B (0x04),
|
A_EQ_B (0x04,"A == B"),
|
||||||
A_NEQ_B (0x05),
|
A_NEQ_B (0x05,"A != B"),
|
||||||
A_LT_B (0x06),
|
A_LT_B (0x06,"A < B"),
|
||||||
A_GT_B (0x07)
|
A_GT_B (0x07,"A > B")
|
||||||
;
|
;
|
||||||
|
|
||||||
static ScriptCondition scriptConditions[] = {
|
static ScriptCondition scriptConditions[] = {
|
||||||
|
@ -175,20 +212,31 @@ public class SimpleScript {
|
||||||
A_LT_B,
|
A_LT_B,
|
||||||
A_GT_B
|
A_GT_B
|
||||||
};
|
};
|
||||||
|
|
||||||
static ScriptCondition get(int code){
|
static ScriptCondition get(int code){
|
||||||
return scriptConditions[code];
|
return scriptConditions[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
ScriptCondition(int code){
|
ScriptCondition(int code,String desc){
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCode(){
|
public int getCode(){
|
||||||
return this.code;
|
return this.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SimpleScriptElement{
|
public static class SimpleScriptElement{
|
||||||
|
@ -244,10 +292,10 @@ public class SimpleScript {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCondition(){
|
public int getCondition(){
|
||||||
return (code >> 24) & 0xff;
|
return (code >> 24) & 0x07;
|
||||||
}
|
}
|
||||||
public int getOperation(){
|
public int getOperation(){
|
||||||
return (code >> 27) & 0xff;
|
return (code >> 27) & 0x1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setA(int a){
|
public void setA(int a){
|
||||||
|
@ -272,7 +320,7 @@ public class SimpleScript {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableColumn(label="Operation",order=50)
|
@TableColumn(label="Operation",order=50)
|
||||||
ScriptOperation getScriptOperation(){
|
public ScriptOperation getScriptOperation(){
|
||||||
return ScriptOperation.get(getOperation());
|
return ScriptOperation.get(getOperation());
|
||||||
}
|
}
|
||||||
public void setScriptOperation(ScriptOperation scriptOperation){
|
public void setScriptOperation(ScriptOperation scriptOperation){
|
||||||
|
|
|
@ -10,6 +10,13 @@ public class SimpleScriptAddress{
|
||||||
this.address = a;
|
this.address = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
public void setAddress(int address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toString(address);
|
return toString(address);
|
||||||
|
@ -28,8 +35,10 @@ public class SimpleScriptAddress{
|
||||||
return String.format("Ausgang %d", address - 96);
|
return String.format("Ausgang %d", address - 96);
|
||||||
} else if (address < 160){
|
} else if (address < 160){
|
||||||
return String.format("Inverter %d", address - 128);
|
return String.format("Inverter %d", address - 128);
|
||||||
|
} else if (address < 192){
|
||||||
|
return String.format("Eingang %d", address - 160);
|
||||||
} else {
|
} else {
|
||||||
return String.format("Variable %d", address - 160);
|
return String.format("Variable %d", address - 192);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,14 @@ import javax.swing.JTabbedPane;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -44,7 +49,7 @@ import java.awt.event.FocusEvent;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
public class DeviceConfiguration extends JFrame {
|
public class DeviceConfiguration extends JDialog {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
@ -64,10 +69,16 @@ public class DeviceConfiguration extends JFrame {
|
||||||
trigger;
|
trigger;
|
||||||
|
|
||||||
int[] filter,
|
int[] filter,
|
||||||
windows;
|
windows,
|
||||||
|
increments;
|
||||||
|
|
||||||
private JTable tSettings;
|
private JTable tSettings;
|
||||||
|
|
||||||
private IDeviceConnector deviceConnector;
|
private IDeviceConnector deviceConnector;
|
||||||
|
private JPanel pManagement;
|
||||||
|
private JButton btnSnapshotSpeicherZurcksetzen;
|
||||||
|
private JButton btnSnapshotSpeicherAuf;
|
||||||
|
private JButton btnAlleZhlerLschen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
|
@ -75,6 +86,8 @@ public class DeviceConfiguration extends JFrame {
|
||||||
public DeviceConfiguration(IDeviceConnector deviceConnector) {
|
public DeviceConfiguration(IDeviceConnector deviceConnector) {
|
||||||
this.deviceConnector = deviceConnector;
|
this.deviceConnector = deviceConnector;
|
||||||
|
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 860, 498);
|
setBounds(100, 100, 860, 498);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
|
@ -224,47 +237,6 @@ public class DeviceConfiguration extends JFrame {
|
||||||
gbc_tseI3.gridy = 4;
|
gbc_tseI3.gridy = 4;
|
||||||
panel_2.add(tseI3, gbc_tseI3);
|
panel_2.add(tseI3, gbc_tseI3);
|
||||||
|
|
||||||
JButton btnSnapshotSpeicherZurcksetzen = new JButton("SnapShot Speicher zurücksetzen");
|
|
||||||
btnSnapshotSpeicherZurcksetzen.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
resetSnapShots();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnSnapshotSpeicherZurcksetzen = new GridBagConstraints();
|
|
||||||
gbc_btnSnapshotSpeicherZurcksetzen.gridwidth = 2;
|
|
||||||
gbc_btnSnapshotSpeicherZurcksetzen.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_btnSnapshotSpeicherZurcksetzen.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnSnapshotSpeicherZurcksetzen.gridx = 0;
|
|
||||||
gbc_btnSnapshotSpeicherZurcksetzen.gridy = 5;
|
|
||||||
panel_2.add(btnSnapshotSpeicherZurcksetzen, gbc_btnSnapshotSpeicherZurcksetzen);
|
|
||||||
|
|
||||||
JButton btnAlleZhlerLschen = new JButton("Alle Zähler zurücksetzen");
|
|
||||||
btnAlleZhlerLschen.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
resetCounters();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JButton btnSnapshotSpeicherAuf = new JButton("SnapShot Speicher auf letzten bekannten SnapShot setzen");
|
|
||||||
btnSnapshotSpeicherAuf.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
resetSnapShots(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
GridBagConstraints gbc_btnSnapshotSpeicherAuf = new GridBagConstraints();
|
|
||||||
gbc_btnSnapshotSpeicherAuf.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_btnSnapshotSpeicherAuf.gridwidth = 2;
|
|
||||||
gbc_btnSnapshotSpeicherAuf.insets = new Insets(0, 0, 5, 0);
|
|
||||||
gbc_btnSnapshotSpeicherAuf.gridx = 0;
|
|
||||||
gbc_btnSnapshotSpeicherAuf.gridy = 6;
|
|
||||||
panel_2.add(btnSnapshotSpeicherAuf, gbc_btnSnapshotSpeicherAuf);
|
|
||||||
GridBagConstraints gbc_btnAlleZhlerLschen = new GridBagConstraints();
|
|
||||||
gbc_btnAlleZhlerLschen.gridwidth = 2;
|
|
||||||
gbc_btnAlleZhlerLschen.fill = GridBagConstraints.HORIZONTAL;
|
|
||||||
gbc_btnAlleZhlerLschen.gridx = 0;
|
|
||||||
gbc_btnAlleZhlerLschen.gridy = 7;
|
|
||||||
panel_2.add(btnAlleZhlerLschen, gbc_btnAlleZhlerLschen);
|
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
JPanel panel_1 = new JPanel();
|
||||||
tabbedPane.addTab("Kanäle", null, panel_1, null);
|
tabbedPane.addTab("Kanäle", null, panel_1, null);
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
|
@ -287,6 +259,62 @@ public class DeviceConfiguration extends JFrame {
|
||||||
tSettings.setCellSelectionEnabled(true);
|
tSettings.setCellSelectionEnabled(true);
|
||||||
scrollPane.setViewportView(tSettings);
|
scrollPane.setViewportView(tSettings);
|
||||||
|
|
||||||
|
pManagement = new JPanel();
|
||||||
|
tabbedPane.addTab("Speicherverwaltung", null, pManagement, null);
|
||||||
|
GridBagLayout gbl_pManagement = new GridBagLayout();
|
||||||
|
gbl_pManagement.columnWidths = new int[] {100};
|
||||||
|
gbl_pManagement.rowHeights = new int[]{25, 0, 0, 0, 0};
|
||||||
|
gbl_pManagement.columnWeights = new double[]{1.0};
|
||||||
|
gbl_pManagement.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
pManagement.setLayout(gbl_pManagement);
|
||||||
|
|
||||||
|
btnAlleZhlerLschen = new JButton("Alle Zähler zurücksetzen");
|
||||||
|
btnAlleZhlerLschen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
resetCounters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnAlleZhlerLschen_1_1 = new GridBagConstraints();
|
||||||
|
gbc_btnAlleZhlerLschen_1_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_btnAlleZhlerLschen_1_1.gridx = 0;
|
||||||
|
gbc_btnAlleZhlerLschen_1_1.gridy = 0;
|
||||||
|
gbc_btnAlleZhlerLschen_1_1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
pManagement.add(btnAlleZhlerLschen, gbc_btnAlleZhlerLschen_1_1);
|
||||||
|
|
||||||
|
JLabel lblNurNachRcksprache = new JLabel("Nur nach Rücksprache mit Support:");
|
||||||
|
GridBagConstraints gbc_lblNurNachRcksprache = new GridBagConstraints();
|
||||||
|
gbc_lblNurNachRcksprache.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_lblNurNachRcksprache.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_lblNurNachRcksprache.gridx = 0;
|
||||||
|
gbc_lblNurNachRcksprache.gridy = 1;
|
||||||
|
pManagement.add(lblNurNachRcksprache, gbc_lblNurNachRcksprache);
|
||||||
|
|
||||||
|
btnSnapshotSpeicherZurcksetzen = new JButton("SnapShot Speicher zurücksetzen");
|
||||||
|
btnSnapshotSpeicherZurcksetzen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
resetSnapShots();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSnapshotSpeicherAuf = new JButton("SnapShot Speicher auf letzten bekannten SnapShot setzen");
|
||||||
|
btnSnapshotSpeicherAuf.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
resetSnapShots(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnSnapshotSpeicherAuf_1_1 = new GridBagConstraints();
|
||||||
|
gbc_btnSnapshotSpeicherAuf_1_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_btnSnapshotSpeicherAuf_1_1.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_btnSnapshotSpeicherAuf_1_1.gridx = 0;
|
||||||
|
gbc_btnSnapshotSpeicherAuf_1_1.gridy = 2;
|
||||||
|
pManagement.add(btnSnapshotSpeicherAuf, gbc_btnSnapshotSpeicherAuf_1_1);
|
||||||
|
GridBagConstraints gbc_btnSnapshotSpeicherZurcksetzen_1_1 = new GridBagConstraints();
|
||||||
|
gbc_btnSnapshotSpeicherZurcksetzen_1_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_btnSnapshotSpeicherZurcksetzen_1_1.gridx = 0;
|
||||||
|
gbc_btnSnapshotSpeicherZurcksetzen_1_1.gridy = 3;
|
||||||
|
pManagement.add(btnSnapshotSpeicherZurcksetzen, gbc_btnSnapshotSpeicherZurcksetzen_1_1);
|
||||||
|
|
||||||
|
|
||||||
JButton btnSchliessen = new JButton("abbrechen");
|
JButton btnSchliessen = new JButton("abbrechen");
|
||||||
btnSchliessen.addActionListener(new ActionListener() {
|
btnSchliessen.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -326,6 +354,8 @@ public class DeviceConfiguration extends JFrame {
|
||||||
currentChannel = -1;
|
currentChannel = -1;
|
||||||
filter = new int[32];
|
filter = new int[32];
|
||||||
windows = new int[32];
|
windows = new int[32];
|
||||||
|
increments = new int[32];
|
||||||
|
|
||||||
tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
|
tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
|
||||||
|
|
||||||
BitField bf = new BitField();
|
BitField bf = new BitField();
|
||||||
|
@ -344,17 +374,22 @@ public class DeviceConfiguration extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetSnapShots(){
|
private void resetSnapShots(){
|
||||||
resetSnapShots(false);
|
resetSnapShots(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetSnapShots(boolean toLastKnown){
|
private void resetSnapShots(boolean toLastKnown){
|
||||||
deviceConnector.reset(toLastKnown ? PulsCounterApplication.getApplication().getDatabase().highestSnapShot(deviceConnector.getDeviceSerial()) : -1);
|
if (JOptionPane.showConfirmDialog(null, "<html>Diese Funktion sollte nur auf Aufforderung durch den Support ausgeführt werden.<br/>Soll der Snapshot Index auf dem Gerät wirklich zurückgesetzt werden?</html>", "Snapshot Index zurücksetzen", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
||||||
|
deviceConnector.reset(toLastKnown ? PulsCounterApplication.getApplication().getDatabase().highestSnapShot(deviceConnector.getDeviceSerial()) : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetCounters(){
|
private void resetCounters(){
|
||||||
int[] zero = new int[32];
|
|
||||||
Arrays.fill(zero, 0);
|
if (JOptionPane.showConfirmDialog(null, "Wollen Sie wirklich alle Zählerstände auf 0 zurücksetzen?", "Alle Zählerstände zurücksetzen", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
||||||
deviceConnector.setCounters(zero);
|
int[] zero = new int[32];
|
||||||
|
Arrays.fill(zero, 0);
|
||||||
|
deviceConnector.setCounters(zero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readDevice(){
|
private void readDevice(){
|
||||||
|
@ -363,12 +398,13 @@ public class DeviceConfiguration extends JFrame {
|
||||||
outputs = intOr0(deviceConnector.getConfigOutputs());
|
outputs = intOr0(deviceConnector.getConfigOutputs());
|
||||||
pullups = intOr0(deviceConnector.getConfigPullups());
|
pullups = intOr0(deviceConnector.getConfigPullups());
|
||||||
inverts = intOr0(deviceConnector.getConfigInverts());
|
inverts = intOr0(deviceConnector.getConfigInverts());
|
||||||
trigger = intOr0(deviceConnector.getConfigTriggers());
|
trigger = intOr0(deviceConnector.getConfigTriggers());
|
||||||
|
|
||||||
bfeIntervall.setIntValue(deviceConnector.getDailyBaseMask());
|
bfeIntervall.setIntValue(deviceConnector.getDailyBaseMask());
|
||||||
|
|
||||||
filter = deviceConnector.getDebounce();
|
filter = deviceConnector.getDebounce();
|
||||||
windows = deviceConnector.getWindows();
|
windows = deviceConnector.getWindows();
|
||||||
|
increments = deviceConnector.getIncrements();
|
||||||
|
|
||||||
tseI0.setValue( deviceConnector.getInterval(0) );
|
tseI0.setValue( deviceConnector.getInterval(0) );
|
||||||
tseI1.setValue( deviceConnector.getInterval(1) );
|
tseI1.setValue( deviceConnector.getInterval(1) );
|
||||||
|
@ -390,6 +426,7 @@ public class DeviceConfiguration extends JFrame {
|
||||||
|
|
||||||
deviceConnector.setDebounce(filter);
|
deviceConnector.setDebounce(filter);
|
||||||
deviceConnector.setWindows(windows);
|
deviceConnector.setWindows(windows);
|
||||||
|
deviceConnector.setIncrements(increments);
|
||||||
|
|
||||||
deviceConnector.syncConfigToLive();
|
deviceConnector.syncConfigToLive();
|
||||||
}
|
}
|
||||||
|
@ -402,7 +439,7 @@ public class DeviceConfiguration extends JFrame {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableColumn(label="Channel",width=80,order=0)
|
@TableColumn(label="Kanal",width=60,order=0,format="%02d")
|
||||||
public int getChannel(){
|
public int getChannel(){
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
@ -467,6 +504,14 @@ public class DeviceConfiguration extends JFrame {
|
||||||
filter[channel] = value;
|
filter[channel] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Inkrement",width=80,order=190)
|
||||||
|
public Integer getIncrement(){
|
||||||
|
return increments[channel];
|
||||||
|
}
|
||||||
|
public void setIncrement(Integer increment){
|
||||||
|
increments[channel] = increment;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
|
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
@ -26,8 +28,10 @@ import java.awt.event.ActionEvent;
|
||||||
import javax.swing.JToolBar;
|
import javax.swing.JToolBar;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
|
||||||
public class ExportFilesFrame extends JFrame {
|
public class ExportFilesFrame extends JDialog {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JTable tExportSettings;
|
private JTable tExportSettings;
|
||||||
|
@ -47,6 +51,8 @@ public class ExportFilesFrame extends JFrame {
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public ExportFilesFrame() {
|
public ExportFilesFrame() {
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
setTitle("Export Einstellungen...");
|
setTitle("Export Einstellungen...");
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 825, 433);
|
setBounds(100, 100, 825, 433);
|
||||||
|
|
|
@ -107,6 +107,7 @@ public class ExportSettingsEditorDialog extends JDialog implements IObjectEditor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cbTriggerType.addItem(TriggerType.ALL);
|
cbTriggerType.addItem(TriggerType.ALL);
|
||||||
|
cbTriggerType.addItem(TriggerType.Trigger);
|
||||||
cbTriggerType.addItem(TriggerType.Intervall);
|
cbTriggerType.addItem(TriggerType.Intervall);
|
||||||
cbTriggerType.addItem(TriggerType.Timer);
|
cbTriggerType.addItem(TriggerType.Timer);
|
||||||
cbTriggerType.addItem(TriggerType.Manual);
|
cbTriggerType.addItem(TriggerType.Manual);
|
||||||
|
|
|
@ -126,6 +126,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private JPanel panel_4;
|
private JPanel panel_4;
|
||||||
private JTextArea tfConnectionSettings;
|
private JTextArea tfConnectionSettings;
|
||||||
private JButton btnSkripte;
|
private JButton btnSkripte;
|
||||||
|
private JButton btnAufzeichnungenVerwalten;
|
||||||
|
|
||||||
|
|
||||||
public static void startGUI(){
|
public static void startGUI(){
|
||||||
|
@ -276,7 +277,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
*/
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
frmSynolog = new JFrame();
|
frmSynolog = new JFrame();
|
||||||
frmSynolog.setTitle("Synololog");
|
frmSynolog.setTitle("SYNOLO-LOG");
|
||||||
frmSynolog.setBounds(100, 100, 1000, 580);
|
frmSynolog.setBounds(100, 100, 1000, 580);
|
||||||
frmSynolog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frmSynolog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frmSynolog.getContentPane().setLayout(new BorderLayout(0, 0));
|
frmSynolog.getContentPane().setLayout(new BorderLayout(0, 0));
|
||||||
|
@ -294,6 +295,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (selectedDeviceInterface != null){
|
if (selectedDeviceInterface != null){
|
||||||
DeviceConfiguration cc = new DeviceConfiguration(selectedDeviceInterface);
|
DeviceConfiguration cc = new DeviceConfiguration(selectedDeviceInterface);
|
||||||
|
cc.setLocationRelativeTo(frmSynolog);
|
||||||
cc.setVisible(true);
|
cc.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,6 +307,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
btnDatenExportieren.addActionListener(new ActionListener() {
|
btnDatenExportieren.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
ExportFilesFrame eff = new ExportFilesFrame();
|
ExportFilesFrame eff = new ExportFilesFrame();
|
||||||
|
eff.setLocationRelativeTo(frmSynolog);
|
||||||
eff.setVisible(true);
|
eff.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -320,6 +323,14 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
});
|
});
|
||||||
toolBar.add(btnSkripte);
|
toolBar.add(btnSkripte);
|
||||||
|
|
||||||
|
btnAufzeichnungenVerwalten = new JButton("Aufzeichnungen verwalten");
|
||||||
|
btnAufzeichnungenVerwalten.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SnapshotManager.show(frmSynolog);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toolBar.add(btnAufzeichnungenVerwalten);
|
||||||
|
|
||||||
splitter = new JSplitPane();
|
splitter = new JSplitPane();
|
||||||
splitter.setBorder(null);
|
splitter.setBorder(null);
|
||||||
splitter.setOneTouchExpandable(true);
|
splitter.setOneTouchExpandable(true);
|
||||||
|
@ -395,7 +406,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if ((e.getClickCount()==2)&&(e.getButton()==e.BUTTON1)){
|
if ((e.getClickCount()==2)&&(e.getButton()==e.BUTTON1)){
|
||||||
if (selectedDeviceInterface != null){
|
if (selectedDeviceInterface != null){
|
||||||
selectedDeviceInterface.showConnctionSetup();
|
selectedDeviceInterface.showConnctionSetup(frmSynolog);
|
||||||
frmSynolog.repaint();
|
frmSynolog.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,14 @@ import java.awt.GridBagLayout;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScriptAddress;
|
||||||
|
import org.hwo.ui.JComboBoxEx;
|
||||||
|
|
||||||
public class SimpleScriptAddressEditor extends JPanel {
|
public class SimpleScriptAddressEditor extends JPanel {
|
||||||
|
|
||||||
|
@ -16,8 +23,15 @@ public class SimpleScriptAddressEditor extends JPanel {
|
||||||
new AddressRange("PullUp Status", 64, 32),
|
new AddressRange("PullUp Status", 64, 32),
|
||||||
new AddressRange("Ausgang", 96, 32),
|
new AddressRange("Ausgang", 96, 32),
|
||||||
new AddressRange("Inverter", 128, 32),
|
new AddressRange("Inverter", 128, 32),
|
||||||
new AddressRange("Variable", 160, 96)
|
new AddressRange("Eingang", 160, 32),
|
||||||
|
new AddressRange("Variable", 192, 64)
|
||||||
};
|
};
|
||||||
|
private JComboBoxEx cbRange;
|
||||||
|
private JSpinner spValue;
|
||||||
|
private SpinnerNumberModel numberModel = new SpinnerNumberModel(0, 0, 0, 1);
|
||||||
|
|
||||||
|
private int
|
||||||
|
address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the panel.
|
* Create the panel.
|
||||||
|
@ -30,23 +44,72 @@ public class SimpleScriptAddressEditor extends JPanel {
|
||||||
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
setLayout(gridBagLayout);
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
JComboBox comboBox = new JComboBox();
|
cbRange = new JComboBoxEx();
|
||||||
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
GridBagConstraints gbc_cbRange = new GridBagConstraints();
|
||||||
gbc_comboBox.insets = new Insets(0, 0, 0, 5);
|
gbc_cbRange.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_comboBox.fill = GridBagConstraints.BOTH;
|
gbc_cbRange.fill = GridBagConstraints.BOTH;
|
||||||
gbc_comboBox.gridx = 0;
|
gbc_cbRange.gridx = 0;
|
||||||
gbc_comboBox.gridy = 0;
|
gbc_cbRange.gridy = 0;
|
||||||
add(comboBox, gbc_comboBox);
|
cbRange.setItems(addressRanges);
|
||||||
|
cbRange.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
syncNumberFormat();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(cbRange, gbc_cbRange);
|
||||||
|
|
||||||
JSpinner spinner = new JSpinner();
|
spValue = new JSpinner();
|
||||||
GridBagConstraints gbc_spinner = new GridBagConstraints();
|
GridBagConstraints gbc_spValue = new GridBagConstraints();
|
||||||
gbc_spinner.fill = GridBagConstraints.BOTH;
|
gbc_spValue.fill = GridBagConstraints.BOTH;
|
||||||
gbc_spinner.gridx = 1;
|
gbc_spValue.gridx = 1;
|
||||||
gbc_spinner.gridy = 0;
|
gbc_spValue.gridy = 0;
|
||||||
add(spinner, gbc_spinner);
|
spValue.setModel(numberModel);
|
||||||
|
add(spValue, gbc_spValue);
|
||||||
|
|
||||||
|
cbRange.setSelectedIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AddressRange getSelectedRange(){
|
||||||
|
return (AddressRange)cbRange.getSelectedItem();
|
||||||
|
}
|
||||||
|
private int getSelectedDisplayValue(){
|
||||||
|
return (Integer)spValue.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void syncNumberFormat(){
|
||||||
|
AddressRange range = getSelectedRange();
|
||||||
|
numberModel.setMaximum(range.getSize()-1);
|
||||||
|
|
||||||
|
if (range.getSize() <= getSelectedDisplayValue()){
|
||||||
|
numberModel.setValue(range.getSize()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAddress() {
|
||||||
|
this.address = getSelectedRange().scriptValue(((Integer)numberModel.getValue()).intValue());
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
public void setAddress(int address) {
|
||||||
|
this.address = address;
|
||||||
|
|
||||||
|
cbRange.setEnabled(true);
|
||||||
|
cbRange.setSelectedItem(findRange(address));
|
||||||
|
syncNumberFormat();
|
||||||
|
|
||||||
|
numberModel.setValue(getSelectedRange().displayValue(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
private AddressRange findRange(int address){
|
||||||
|
for (AddressRange range: addressRanges){
|
||||||
|
if (range.contains(address))
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class AddressRange{
|
private class AddressRange{
|
||||||
|
|
||||||
|
@ -70,6 +133,21 @@ public class SimpleScriptAddressEditor extends JPanel {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(int address){
|
||||||
|
return (base <= address) && (address < (base+size));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int displayValue(int address){
|
||||||
|
return address - base;
|
||||||
|
}
|
||||||
|
public int scriptValue(int displayAddress){
|
||||||
|
return displayAddress + base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,12 @@ import java.awt.FlowLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import org.hwo.models.TableMapper.TableColumn;
|
import org.hwo.models.TableMapper.TableColumn;
|
||||||
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.models.TableMapper.TableMapperListener;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript;
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript.ScriptCondition;
|
import org.hwo.pulscounter.simplescript.SimpleScript.ScriptCondition;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
||||||
|
@ -22,13 +25,20 @@ import javax.swing.JTable;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.MenuItem;
|
||||||
|
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.Dialog.ModalExclusionType;
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
import java.awt.Dialog.ModalityType;
|
import java.awt.Dialog.ModalityType;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SimpleScriptEditor extends JDialog {
|
public class SimpleScriptEditor extends JDialog {
|
||||||
|
|
||||||
|
@ -56,13 +66,13 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
private JMappedTable mtScriptElements;
|
private JMappedTable mtScriptElements;
|
||||||
private JTextField tfName;
|
private JTextField tfName;
|
||||||
private JTextArea taDescription;
|
private JTextArea taDescription;
|
||||||
|
private JScrollPane spElementTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dialog.
|
* Create the dialog.
|
||||||
*/
|
*/
|
||||||
public SimpleScriptEditor() {
|
public SimpleScriptEditor() {
|
||||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
|
||||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 921, 474);
|
setBounds(100, 100, 921, 474);
|
||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
@ -74,6 +84,77 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
gbl_contentPanel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
gbl_contentPanel.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
gbl_contentPanel.rowWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
||||||
contentPanel.setLayout(gbl_contentPanel);
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
|
||||||
|
MouseAdapter popupAdapter = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
checkPopup(e);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if ((e.getComponent() == spElementTable)){
|
||||||
|
mtScriptElements.clearSelection();
|
||||||
|
}
|
||||||
|
checkPopup(e);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
checkPopup(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPopup(MouseEvent e){
|
||||||
|
if (e.isPopupTrigger()){
|
||||||
|
JPopupMenu popupMenu = new JPopupMenu();
|
||||||
|
|
||||||
|
JMenuItem miAdd = new JMenuItem("1x neu");
|
||||||
|
miAdd.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SimpleScriptElement sse = (SimpleScriptElement)mtScriptElements.getTableMapper().getSelectedRow();
|
||||||
|
mtScriptElements.getTableMapper().addRow(new SimpleScriptElement(),sse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(miAdd);
|
||||||
|
|
||||||
|
JMenuItem miAdd5 = new JMenuItem("5x neu");
|
||||||
|
miAdd5.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SimpleScriptElement sse = (SimpleScriptElement)mtScriptElements.getTableMapper().getSelectedRow();
|
||||||
|
|
||||||
|
mtScriptElements.getTableMapper().addRows(new SimpleScriptElement[]{
|
||||||
|
new SimpleScriptElement(),
|
||||||
|
new SimpleScriptElement(),
|
||||||
|
new SimpleScriptElement(),
|
||||||
|
new SimpleScriptElement(),
|
||||||
|
new SimpleScriptElement()
|
||||||
|
}, sse);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(miAdd5);
|
||||||
|
|
||||||
|
SimpleScriptElement sse = (SimpleScriptElement)mtScriptElements.getTableMapper().getSelectedRow();
|
||||||
|
if (sse != null){
|
||||||
|
JMenuItem miRemove = new JMenuItem("Entfernen");
|
||||||
|
miRemove.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SimpleScriptElement[] selected = mtScriptElements.getTableMapper().getSelectedRows(new SimpleScriptElement[0]);
|
||||||
|
for (SimpleScriptElement se: selected){
|
||||||
|
mtScriptElements.getTableMapper().removeRow(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(miRemove);
|
||||||
|
}
|
||||||
|
|
||||||
|
popupMenu.show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
JLabel lblBezeichnung = new JLabel("Bezeichnung:");
|
JLabel lblBezeichnung = new JLabel("Bezeichnung:");
|
||||||
GridBagConstraints gbc_lblBezeichnung = new GridBagConstraints();
|
GridBagConstraints gbc_lblBezeichnung = new GridBagConstraints();
|
||||||
|
@ -115,16 +196,18 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
contentPanel.add(taDescription, gbc_taDescription);
|
contentPanel.add(taDescription, gbc_taDescription);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
spElementTable = new JScrollPane();
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
GridBagConstraints gbc_spElementTable = new GridBagConstraints();
|
||||||
gbc_scrollPane.gridwidth = 2;
|
gbc_spElementTable.gridwidth = 2;
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_spElementTable.fill = GridBagConstraints.BOTH;
|
||||||
gbc_scrollPane.gridx = 0;
|
gbc_spElementTable.gridx = 0;
|
||||||
gbc_scrollPane.gridy = 2;
|
gbc_spElementTable.gridy = 2;
|
||||||
contentPanel.add(scrollPane, gbc_scrollPane);
|
spElementTable.addMouseListener(popupAdapter);
|
||||||
|
contentPanel.add(spElementTable, gbc_spElementTable);
|
||||||
{
|
{
|
||||||
mtScriptElements = new JMappedTable(SimpleScriptElement.class);
|
mtScriptElements = new JMappedTable(SimpleScriptElement.class);
|
||||||
scrollPane.setViewportView(mtScriptElements);
|
mtScriptElements.addMouseListener(popupAdapter);
|
||||||
|
spElementTable.setViewportView(mtScriptElements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -153,16 +236,38 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
buttonPane.add(cancelButton);
|
buttonPane.add(cancelButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mtScriptElements.addTableMapperListener(new TableMapperListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editorRequest(TableMapper tableMapper, Object row) {
|
||||||
|
SimpleScriptElement e = (SimpleScriptElement)row;
|
||||||
|
if (e != null){
|
||||||
|
if (SimpleScriptElementEditor.show(SimpleScriptEditor.this, e)){
|
||||||
|
mtScriptElements.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ValueChanged(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mtScriptElements.getTableMapper().setEditorEnabled(true);
|
||||||
|
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void accept(){
|
private void accept(){
|
||||||
|
|
||||||
simpleScript.setName(tfName.getText());
|
simpleScript.setName(tfName.getText());
|
||||||
simpleScript.setDescription(taDescription.getText());
|
simpleScript.setDescription(taDescription.getText());
|
||||||
|
simpleScript.setSimpleScriptElements(mtScriptElements.getTableMapper().getRows(SimpleScriptElement.class).toArray(new SimpleScriptElement[0]));
|
||||||
|
|
||||||
accepted = true;
|
accepted = true;
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
@ -182,8 +287,7 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
|
|
||||||
tfName.setText(simpleScript.getName());
|
tfName.setText(simpleScript.getName());
|
||||||
taDescription.setText(simpleScript.getDescription());
|
taDescription.setText(simpleScript.getDescription());
|
||||||
mtScriptElements.getTableMapper().setRows(simpleScript.getSimpleScriptElements().toArray(new SimpleScriptElement[0]));
|
mtScriptElements.getTableMapper().setRows(new ArrayList<SimpleScriptElement>(simpleScript.getSimpleScriptElements()));
|
||||||
|
|
||||||
mtScriptElements.getTableMapper().setSortingEnabled(false);
|
mtScriptElements.getTableMapper().setSortingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,46 +9,215 @@ import javax.swing.JDialog;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.ScriptCondition;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.ScriptOperation;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
||||||
|
import org.hwo.ui.JComboBoxEx;
|
||||||
|
|
||||||
import java.awt.Dialog.ModalExclusionType;
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
import java.awt.Dialog.ModalityType;
|
import java.awt.Dialog.ModalityType;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.border.LineBorder;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import java.awt.Font;
|
||||||
|
|
||||||
public class SimpleScriptElementEditor extends JDialog {
|
public class SimpleScriptElementEditor extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
public static boolean show(Component parent,SimpleScriptElement simpleScriptElement){
|
public static boolean show(Component parent,SimpleScriptElement simpleScriptElement){
|
||||||
return false;
|
SimpleScriptElementEditor editor = new SimpleScriptElementEditor();
|
||||||
|
if (parent != null){
|
||||||
|
editor.setLocationRelativeTo(parent);
|
||||||
|
}
|
||||||
|
editor.setSimpleScriptElement(simpleScriptElement);
|
||||||
|
editor.setVisible(true);
|
||||||
|
return editor.isAccepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SimpleScriptElement simpleScriptElement;
|
private SimpleScriptElement simpleScriptElement;
|
||||||
private boolean accepted;
|
private boolean accepted;
|
||||||
|
|
||||||
private final JPanel contentPanel = new JPanel();
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
private SimpleScriptAddressEditor ssaA;
|
||||||
|
private SimpleScriptAddressEditor ssaB;
|
||||||
|
private SimpleScriptAddressEditor ssaZ;
|
||||||
|
private JComboBoxEx cbCondition;
|
||||||
|
private JComboBoxEx cbOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dialog.
|
* Create the dialog.
|
||||||
*/
|
*/
|
||||||
public SimpleScriptElementEditor() {
|
public SimpleScriptElementEditor() {
|
||||||
|
setResizable(false);
|
||||||
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
setTitle("Skriptelement bearbeiten");
|
setTitle("Skriptelement bearbeiten");
|
||||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
setBounds(100, 100, 519, 370);
|
setBounds(100, 100, 519, 350);
|
||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
contentPanel.setLayout(new FlowLayout());
|
|
||||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
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, 0, 0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{0.0, 1.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Eingangswert A", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 0;
|
||||||
|
contentPanel.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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
ssaA = new SimpleScriptAddressEditor();
|
||||||
|
GridBagConstraints gbc_ssaA = new GridBagConstraints();
|
||||||
|
gbc_ssaA.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_ssaA.gridx = 0;
|
||||||
|
gbc_ssaA.gridy = 0;
|
||||||
|
panel.add(ssaA, gbc_ssaA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Eingangswert B", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 1;
|
||||||
|
gbc_panel.gridy = 0;
|
||||||
|
contentPanel.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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
ssaB = new SimpleScriptAddressEditor();
|
||||||
|
GridBagConstraints gbc_ssaB = new GridBagConstraints();
|
||||||
|
gbc_ssaB.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_ssaB.gridx = 0;
|
||||||
|
gbc_ssaB.gridy = 0;
|
||||||
|
panel.add(ssaB, gbc_ssaB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Bedingung", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel.gridwidth = 2;
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 1;
|
||||||
|
contentPanel.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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
cbCondition = new JComboBoxEx();
|
||||||
|
cbCondition.setFont(new Font("Courier", Font.BOLD, 14));
|
||||||
|
GridBagConstraints gbc_cbCondition = new GridBagConstraints();
|
||||||
|
gbc_cbCondition.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_cbCondition.gridx = 0;
|
||||||
|
gbc_cbCondition.gridy = 0;
|
||||||
|
cbCondition.setItems(SimpleScript.ScriptCondition.values());
|
||||||
|
panel.add(cbCondition, gbc_cbCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Operation", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel.gridwidth = 2;
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 2;
|
||||||
|
contentPanel.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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
cbOperation = new JComboBoxEx();
|
||||||
|
cbOperation.setFont(new Font("Courier", Font.BOLD, 14));
|
||||||
|
GridBagConstraints gbc_cbOperation = new GridBagConstraints();
|
||||||
|
gbc_cbOperation.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_cbOperation.gridx = 0;
|
||||||
|
gbc_cbOperation.gridy = 0;
|
||||||
|
cbOperation.setItems(SimpleScript.ScriptOperation.values());
|
||||||
|
panel.add(cbOperation, gbc_cbOperation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Ausgangswert Z", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51)));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 3;
|
||||||
|
contentPanel.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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
ssaZ = new SimpleScriptAddressEditor();
|
||||||
|
GridBagConstraints gbc_ssaZ = new GridBagConstraints();
|
||||||
|
gbc_ssaZ.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_ssaZ.gridx = 0;
|
||||||
|
gbc_ssaZ.gridy = 0;
|
||||||
|
panel.add(ssaZ, gbc_ssaZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
JPanel buttonPane = new JPanel();
|
JPanel buttonPane = new JPanel();
|
||||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
{
|
{
|
||||||
JButton okButton = new JButton("OK");
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
});
|
||||||
okButton.setActionCommand("OK");
|
okButton.setActionCommand("OK");
|
||||||
buttonPane.add(okButton);
|
buttonPane.add(okButton);
|
||||||
getRootPane().setDefaultButton(okButton);
|
getRootPane().setDefaultButton(okButton);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JButton cancelButton = new JButton("Cancel");
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
cancelButton.setActionCommand("Cancel");
|
cancelButton.setActionCommand("Cancel");
|
||||||
buttonPane.add(cancelButton);
|
buttonPane.add(cancelButton);
|
||||||
}
|
}
|
||||||
|
@ -60,13 +229,23 @@ public class SimpleScriptElementEditor extends JDialog {
|
||||||
}
|
}
|
||||||
public void setSimpleScriptElement(SimpleScriptElement simpleScriptElement) {
|
public void setSimpleScriptElement(SimpleScriptElement simpleScriptElement) {
|
||||||
this.simpleScriptElement = simpleScriptElement;
|
this.simpleScriptElement = simpleScriptElement;
|
||||||
|
|
||||||
|
ssaA.setAddress( simpleScriptElement.getA() );
|
||||||
|
ssaB.setAddress( simpleScriptElement.getB() );
|
||||||
|
ssaZ.setAddress( simpleScriptElement.getZ() );
|
||||||
|
cbCondition.setSelectedItem(simpleScriptElement.getScriptCondition());
|
||||||
|
cbOperation.setSelectedItem(simpleScriptElement.getScriptOperation());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void accept(){
|
private void accept(){
|
||||||
|
|
||||||
|
simpleScriptElement.setA(ssaA.getAddress());
|
||||||
|
simpleScriptElement.setB(ssaB.getAddress());
|
||||||
|
simpleScriptElement.setZ(ssaZ.getAddress());
|
||||||
|
simpleScriptElement.setScriptOperation((ScriptOperation)cbOperation.getSelectedItem());
|
||||||
|
simpleScriptElement.setScriptCondition((ScriptCondition)cbCondition.getSelectedItem());
|
||||||
|
|
||||||
accepted = true;
|
accepted = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
private void cancel(){
|
private void cancel(){
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.awt.BorderLayout;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
@ -16,18 +17,25 @@ import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.border.BevelBorder;
|
import javax.swing.border.BevelBorder;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
import org.hwo.models.TableMapper.TableMapper;
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
import org.hwo.models.TableMapper.TableMapperListener;
|
import org.hwo.models.TableMapper.TableMapperListener;
|
||||||
import org.hwo.pulscounter.PulsCounterApplication;
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
|
import org.hwo.pulscounter.device.IDeviceConnector;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript;
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
import org.hwo.ui.JMappedTable;
|
import org.hwo.ui.JMappedTable;
|
||||||
|
import org.hwo.ui.JObjectSelector;
|
||||||
|
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import static org.hwo.logging.Logging.*;
|
import static org.hwo.logging.Logging.*;
|
||||||
|
|
||||||
|
@ -58,8 +66,10 @@ import org.hwo.ui.JMappedTable;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
|
||||||
public class SimpleScriptSetup extends JFrame {
|
public class SimpleScriptSetup extends JDialog {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JMappedTable scriptTable;
|
private JMappedTable scriptTable;
|
||||||
|
@ -68,9 +78,12 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
private JButton btnEntfernen;
|
private JButton btnEntfernen;
|
||||||
private JButton btnBearbeiten;
|
private JButton btnBearbeiten;
|
||||||
private JButton btnNeu;
|
private JButton btnNeu;
|
||||||
|
private JButton btnTransmit;
|
||||||
|
private JButton btnReceive;
|
||||||
|
|
||||||
public SimpleScriptSetup() {
|
public SimpleScriptSetup() {
|
||||||
setTitle("Formeln");
|
setTitle("Formeln");
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 831, 406);
|
setBounds(100, 100, 831, 406);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
|
@ -103,6 +116,11 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
panel.add(btnNeu);
|
panel.add(btnNeu);
|
||||||
|
|
||||||
btnBearbeiten = new JButton("bearbeiten...");
|
btnBearbeiten = new JButton("bearbeiten...");
|
||||||
|
btnBearbeiten.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
scriptTable.getTableMapper().openEditor();
|
||||||
|
}
|
||||||
|
});
|
||||||
btnBearbeiten.setEnabled(false);
|
btnBearbeiten.setEnabled(false);
|
||||||
panel.add(btnBearbeiten);
|
panel.add(btnBearbeiten);
|
||||||
|
|
||||||
|
@ -117,6 +135,23 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
});
|
});
|
||||||
panel.add(btnEntfernen);
|
panel.add(btnEntfernen);
|
||||||
|
|
||||||
|
btnTransmit = new JButton("auf Zähler übertragen....");
|
||||||
|
btnTransmit.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
transmit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnTransmit.setEnabled(false);
|
||||||
|
panel.add(btnTransmit);
|
||||||
|
|
||||||
|
btnReceive = new JButton("von Zähler holen....");
|
||||||
|
btnReceive.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
receive();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(btnReceive);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -163,9 +198,11 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
if (scriptTable.getTableMapper().getSelectedRow() == null){
|
if (scriptTable.getTableMapper().getSelectedRow() == null){
|
||||||
btnBearbeiten.setEnabled(false);
|
btnBearbeiten.setEnabled(false);
|
||||||
btnEntfernen.setEnabled(false);
|
btnEntfernen.setEnabled(false);
|
||||||
|
btnTransmit.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
btnBearbeiten.setEnabled(true);
|
btnBearbeiten.setEnabled(true);
|
||||||
btnEntfernen.setEnabled(true);
|
btnEntfernen.setEnabled(true);
|
||||||
|
btnTransmit.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -177,6 +214,7 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
if (SimpleScriptEditor.show(SimpleScriptSetup.this,(SimpleScript)row)){
|
if (SimpleScriptEditor.show(SimpleScriptSetup.this,(SimpleScript)row)){
|
||||||
log(INFO,"store SimpleScript");
|
log(INFO,"store SimpleScript");
|
||||||
PulsCounterApplication.getApplication().getDatabase().storeSimpleScript((SimpleScript)row);
|
PulsCounterApplication.getApplication().getDatabase().storeSimpleScript((SimpleScript)row);
|
||||||
|
scriptTable.repaint();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -185,11 +223,54 @@ public class SimpleScriptSetup extends JFrame {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ValueChanged(int row, int column) {
|
public void ValueChanged(int row, int column) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void transmit(){
|
||||||
|
IDeviceConnector[] connectors = PulsCounterApplication.getApplication().getInterfaces().toArray(new IDeviceConnector[0]);
|
||||||
|
IDeviceConnector connector = JObjectSelector.execute(
|
||||||
|
connectors,
|
||||||
|
this,
|
||||||
|
"Schnittstelle wählen...",
|
||||||
|
"Wählen Sie die Schnittstelle über die das Skript übertragen werden soll."
|
||||||
|
);
|
||||||
|
|
||||||
|
if (connector != null){
|
||||||
|
log(INFO,"Übertrage Skript an Synololog an Schnittstelle %s", connector);
|
||||||
|
|
||||||
|
connector.setSimpleScript(((SimpleScript)scriptTable.getTableMapper().getSelectedRow()).getSimpleScriptElementsAsInt());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void receive(){
|
||||||
|
IDeviceConnector[] connectors = PulsCounterApplication.getApplication().getInterfaces().toArray(new IDeviceConnector[0]);
|
||||||
|
IDeviceConnector connector = JObjectSelector.execute(
|
||||||
|
connectors,
|
||||||
|
this,
|
||||||
|
"Schnittstelle wählen...",
|
||||||
|
"Wählen Sie die Schnittstelle über die das Skript empfangen werden soll."
|
||||||
|
);
|
||||||
|
|
||||||
|
if (connector != null){
|
||||||
|
log(INFO,"Übertrage Skript von Synololog an Schnittstelle %s", connector);
|
||||||
|
|
||||||
|
int[] scriptElements = connector.getSimpleScript();
|
||||||
|
|
||||||
|
if (scriptElements == null){
|
||||||
|
JOptionPane.showMessageDialog(this, "Es konnte kein Skript vom gerät empfangen werden.");
|
||||||
|
} else {
|
||||||
|
SimpleScript simpleScript = new SimpleScript();
|
||||||
|
simpleScript.setSimpleScriptElements(scriptElements);
|
||||||
|
simpleScript.setName(String.format("Von Gerät %s geholt am %s", connector.getDeviceSerial(), DateFormat.getDateTimeInstance().format(new Date())));
|
||||||
|
|
||||||
|
scriptTable.getTableMapper().addRow(simpleScript);
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().storeSimpleScript(simpleScript);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,358 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
|
||||||
|
import org.hwo.ObjectTable;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
|
import org.hwo.pulscounter.SnapShot;
|
||||||
|
import org.hwo.ui.JMappedTable;
|
||||||
|
import org.hwo.ui.MousePopupListener;
|
||||||
|
import org.hwo.ui.diagram.LinePlotPainter;
|
||||||
|
import org.hwo.ui.diagram.SimplePlotProvider;
|
||||||
|
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import javax.swing.ScrollPaneConstants;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import org.hwo.ui.JDiagram;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
public class SnapshotManager extends JDialog {
|
||||||
|
|
||||||
|
public static Color[] plotColors = new Color[32];
|
||||||
|
|
||||||
|
public static void show(Component parent){
|
||||||
|
|
||||||
|
SnapshotManager sm = new SnapshotManager();
|
||||||
|
if (parent != null)
|
||||||
|
{
|
||||||
|
sm.setLocationRelativeTo(parent);
|
||||||
|
}
|
||||||
|
sm.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
private JList lDevices;
|
||||||
|
private JMappedTable mtSnapshots;
|
||||||
|
private JScrollPane scrollPane_1;
|
||||||
|
private JDiagram diaSnapshots;
|
||||||
|
private JCheckBox cbDifferenzen;
|
||||||
|
private JPanel paIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*/
|
||||||
|
public SnapshotManager() {
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
|
setBounds(100, 100, 991, 547);
|
||||||
|
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};
|
||||||
|
gbl_contentPanel.rowHeights = new int[]{0, 0};
|
||||||
|
gbl_contentPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPanel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
contentPanel.setLayout(gbl_contentPanel);
|
||||||
|
{
|
||||||
|
JSplitPane splitPane = new JSplitPane();
|
||||||
|
splitPane.setResizeWeight(0.2);
|
||||||
|
GridBagConstraints gbc_splitPane = new GridBagConstraints();
|
||||||
|
gbc_splitPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_splitPane.gridx = 0;
|
||||||
|
gbc_splitPane.gridy = 0;
|
||||||
|
contentPanel.add(splitPane, gbc_splitPane);
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
splitPane.setLeftComponent(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[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 0;
|
||||||
|
panel.add(scrollPane, gbc_scrollPane);
|
||||||
|
{
|
||||||
|
lDevices = new JList();
|
||||||
|
lDevices.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
showSnapshots();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
scrollPane.setViewportView(lDevices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
splitPane.setRightComponent(panel);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_panel.rowHeights = new int[] {0};
|
||||||
|
gbl_panel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{1.0};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
{
|
||||||
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
|
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
|
||||||
|
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_tabbedPane.gridx = 0;
|
||||||
|
gbc_tabbedPane.gridy = 0;
|
||||||
|
panel.add(tabbedPane, gbc_tabbedPane);
|
||||||
|
{
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
tabbedPane.addTab("Tabelle", null, panel_1, null);
|
||||||
|
panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.X_AXIS));
|
||||||
|
{
|
||||||
|
scrollPane_1 = new JScrollPane();
|
||||||
|
panel_1.add(scrollPane_1);
|
||||||
|
scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||||
|
scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
{
|
||||||
|
mtSnapshots = new JMappedTable(SnapShot.class);
|
||||||
|
mtSnapshots.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||||
|
mtSnapshots.setFillsViewportHeight(true);
|
||||||
|
mtSnapshots.setColumnSelectionAllowed(true);
|
||||||
|
scrollPane_1.setViewportView(mtSnapshots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
tabbedPane.addTab("Diagramm", null, panel_1, null);
|
||||||
|
tabbedPane.setBackgroundAt(1, Color.WHITE);
|
||||||
|
panel_1.setLayout(new BorderLayout(0, 0));
|
||||||
|
{
|
||||||
|
diaSnapshots = new JDiagram();
|
||||||
|
diaSnapshots.setBackground(Color.WHITE);
|
||||||
|
diaSnapshots.setPreferLabelHints(true);
|
||||||
|
diaSnapshots.setDrawVerticalGrid(true);
|
||||||
|
diaSnapshots.setAutoScale(true);
|
||||||
|
panel_1.add(diaSnapshots);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel panel_2 = new JPanel();
|
||||||
|
panel_1.add(panel_2, BorderLayout.NORTH);
|
||||||
|
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[]{0.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel_2.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
panel_2.setLayout(gbl_panel_2);
|
||||||
|
{
|
||||||
|
cbDifferenzen = new JCheckBox("Differenzen");
|
||||||
|
cbDifferenzen.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
updateDiagram();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_cbDifferenzen = new GridBagConstraints();
|
||||||
|
gbc_cbDifferenzen.gridx = 0;
|
||||||
|
gbc_cbDifferenzen.gridy = 0;
|
||||||
|
panel_2.add(cbDifferenzen, gbc_cbDifferenzen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
paIndex = new JPanel();
|
||||||
|
paIndex.setBackground(Color.WHITE);
|
||||||
|
paIndex.setPreferredSize(new Dimension(80, 10));
|
||||||
|
panel_1.add(paIndex, BorderLayout.EAST);
|
||||||
|
paIndex.setLayout(new FlowLayout(FlowLayout.LEADING, 5, 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("schliessen");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
Integer[] deviceSerials = PulsCounterApplication.getApplication().getDatabase().getKnownDevices();
|
||||||
|
DefaultListModel<Integer> lm = new DefaultListModel<>();
|
||||||
|
|
||||||
|
for (Integer serial: deviceSerials){
|
||||||
|
lm.addElement(serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
lDevices.setModel(lm);
|
||||||
|
|
||||||
|
mtSnapshots.getTableMapper().setReadOnly(true);
|
||||||
|
mtSnapshots.getTableMapper().addListSelectionListener(new ListSelectionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
updateDiagram();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
JLabel l = new JLabel(String.format("#%02d", i));
|
||||||
|
l.setForeground(plotColors[i]);
|
||||||
|
|
||||||
|
paIndex.add(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtSnapshots.addMouseListener(new MousePopupListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupTriggered(int x, int y) {
|
||||||
|
SnapShot[] selRows = mtSnapshots.getTableMapper().getSelectedRows(new SnapShot[0]);
|
||||||
|
|
||||||
|
if ((selRows != null)&&(selRows.length>0)){
|
||||||
|
JPopupMenu popupMenu = new JPopupMenu();
|
||||||
|
JMenuItem mi = new JMenuItem("Entfernen...");
|
||||||
|
mi.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
if (JOptionPane.showConfirmDialog(mtSnapshots, "Sollen die markierten Snapshots wirklich gelöscht werden?","Aufzeichnungen entfernen",JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
|
||||||
|
for (SnapShot ss: selRows){
|
||||||
|
mtSnapshots.getTableMapper().removeRow(ss);
|
||||||
|
}
|
||||||
|
mtSnapshots.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(mi);
|
||||||
|
|
||||||
|
popupMenu.show(mtSnapshots, x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSnapshots(){
|
||||||
|
|
||||||
|
Integer deviceSerial = (Integer)lDevices.getSelectedValue();
|
||||||
|
if (deviceSerial != null){
|
||||||
|
SnapShot[] snapshots = PulsCounterApplication.getApplication().getDatabase().loadSnapshots(0, deviceSerial);
|
||||||
|
mtSnapshots.getTableMapper().setRows(snapshots);
|
||||||
|
} else {
|
||||||
|
mtSnapshots.getTableMapper().clear();
|
||||||
|
}
|
||||||
|
updateDiagram();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDiagram(){
|
||||||
|
System.gc();
|
||||||
|
|
||||||
|
SnapShot[] rows = mtSnapshots.getTableMapper().getSelectedRows(new SnapShot[0]);
|
||||||
|
|
||||||
|
if ((rows == null)||(rows.length==0)){
|
||||||
|
rows = mtSnapshots.getTableMapper().getRows(SnapShot.class).toArray(new SnapShot[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int plotLength = rows.length;
|
||||||
|
|
||||||
|
if (cbDifferenzen.isSelected()){
|
||||||
|
plotLength--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plotLength > 1024)
|
||||||
|
plotLength = 1024;
|
||||||
|
|
||||||
|
SimplePlotProvider pp = new SimplePlotProvider(32, plotLength);
|
||||||
|
diaSnapshots.setPlotProvider(pp);
|
||||||
|
|
||||||
|
for (int p=0;p<32;p++){
|
||||||
|
Float[] v = new Float[ plotLength ];
|
||||||
|
|
||||||
|
for (int i=0;i<plotLength;i++){
|
||||||
|
v[i] = (float)rows[i].getValue(p);
|
||||||
|
if (cbDifferenzen.isSelected()){
|
||||||
|
v[i] = ((float)rows[i+1].getValue(p)) - v[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pp.setPlot(p, v);
|
||||||
|
|
||||||
|
LinePlotPainter lpp = new LinePlotPainter();
|
||||||
|
lpp.setColor(plotColors[p]);
|
||||||
|
|
||||||
|
diaSnapshots.setPlotPainter(p, lpp);
|
||||||
|
}
|
||||||
|
|
||||||
|
diaSnapshots.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
plotColors[0] = new Color(255,0,0);
|
||||||
|
plotColors[1] = new Color(0,0,255);
|
||||||
|
plotColors[2] = new Color(0,255,0);
|
||||||
|
plotColors[3] = new Color(255,0,255);
|
||||||
|
plotColors[4] = new Color(0,255,255);
|
||||||
|
plotColors[5] = new Color(255,255,0);
|
||||||
|
plotColors[6] = new Color(192,192,0);
|
||||||
|
plotColors[7] = new Color(0,192,192);
|
||||||
|
|
||||||
|
int a = 2,
|
||||||
|
b = 4;
|
||||||
|
|
||||||
|
for (int i=0;i<3;i++){
|
||||||
|
for (int j=0;j<8;j++){
|
||||||
|
plotColors[8 + (i*8) + j] = new Color(
|
||||||
|
plotColors[j].getRed() * a / b,
|
||||||
|
plotColors[j].getBlue() * a / b,
|
||||||
|
plotColors[j].getGreen() * a / b
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue