WIP 160913
parent
246955f622
commit
84e912b73e
|
@ -125,78 +125,78 @@ public class ExportSetting {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void export(){
|
public void export(){
|
||||||
SnapshotManager ssm = PulsCounterApplication.getApplication().getSnapshotManager();
|
// SnapshotManager ssm = PulsCounterApplication.getApplication().getSnapshotManager();
|
||||||
|
//
|
||||||
Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
|
// Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
|
||||||
|
//
|
||||||
for (int n=0;n<ssm.size();n++){
|
// for (int n=0;n<ssm.size();n++){
|
||||||
SnapShot ss = ssm.loadSnapShot(n);
|
// SnapShot ss = ssm.loadSnapShot(n);
|
||||||
String fn = calculateFileName(fileName, ss);
|
// String fn = calculateFileName(fileName, ss);
|
||||||
|
//
|
||||||
if ((triggerType==TriggerType.ALL)||(ss.getTriggerType()==triggerType)){
|
// if ((triggerType==TriggerType.ALL)||(ss.getTriggerType()==triggerType)){
|
||||||
if (triggerSource.equals(-1) || triggerSource.equals(ss.getSource())){
|
// if (triggerSource.equals(-1) || triggerSource.equals(ss.getSource())){
|
||||||
|
//
|
||||||
if (!hash.containsKey(fn)){
|
// if (!hash.containsKey(fn)){
|
||||||
hash.put(fn, new CSV());
|
// hash.put(fn, new CSV());
|
||||||
if (extended){
|
// if (extended){
|
||||||
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
// hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
"Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
|
// "Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
|
||||||
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
// "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
// "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
// "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
// "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
// "AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
} else {
|
// } else {
|
||||||
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
// hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
"Datum/Zeit",
|
// "Datum/Zeit",
|
||||||
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
// "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
// "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
// "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
// "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
// "AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
hash.get(fn).getRecords().add(ss.getCSVRecord(extended));
|
// hash.get(fn).getRecords().add(ss.getCSVRecord(extended));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (String fn: hash.keySet()){
|
// for (String fn: hash.keySet()){
|
||||||
if (recordDelta){
|
// if (recordDelta){
|
||||||
CSV csv = hash.get(fn);
|
// CSV csv = hash.get(fn);
|
||||||
if (!csv.getRecords().isEmpty()){
|
// if (!csv.getRecords().isEmpty()){
|
||||||
Iterator<CSVRecord> iter = csv.getRecords().iterator();
|
// Iterator<CSVRecord> iter = csv.getRecords().iterator();
|
||||||
|
//
|
||||||
iter.next();
|
// iter.next();
|
||||||
|
//
|
||||||
CSVRecord n = iter.next();
|
// CSVRecord n = iter.next();
|
||||||
Integer[] vals = new Integer[32];
|
// Integer[] vals = new Integer[32];
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// for (int i=0;i<32;i++){
|
||||||
vals[i] = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
// vals[i] = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
while (iter.hasNext()){
|
// while (iter.hasNext()){
|
||||||
n = iter.next();
|
// n = iter.next();
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// for (int i=0;i<32;i++){
|
||||||
Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
// Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
||||||
n.setValue(extended ? i + 4 : i + 1 , v - vals[i]);
|
// n.setValue(extended ? i + 4 : i + 1 , v - vals[i]);
|
||||||
vals[i] = v;
|
// vals[i] = v;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
csv.getRecords().remove(1);
|
// csv.getRecords().remove(1);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
hash.get(fn).saveToFile(new File(path,fn));
|
// hash.get(fn).saveToFile(new File(path,fn));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
private Properties applicationConfiguration,
|
private Properties applicationConfiguration,
|
||||||
defaultConfiguration;
|
defaultConfiguration;
|
||||||
private List<IDeviceConnector> deviceConnectors;
|
|
||||||
|
|
||||||
private Object uiSynchronization;
|
private Object uiSynchronization;
|
||||||
private boolean uiIsFinished;
|
private boolean uiIsFinished;
|
||||||
|
@ -80,8 +79,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
private boolean snapshotLock;
|
private boolean snapshotLock;
|
||||||
|
|
||||||
|
|
||||||
private SnapshotManager snapshotManager;
|
|
||||||
|
|
||||||
private List<ExportSetting> exportSettings;
|
private List<ExportSetting> exportSettings;
|
||||||
|
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
@ -102,7 +99,6 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
/* Initialize fields... */
|
/* Initialize fields... */
|
||||||
uiIsFinished = false;
|
uiIsFinished = false;
|
||||||
uiSynchronization = new Object();
|
uiSynchronization = new Object();
|
||||||
deviceConnectors = new ArrayList<>();
|
|
||||||
applicationListeners = new LinkedList<PulsCounterApplicationListener>();
|
applicationListeners = new LinkedList<PulsCounterApplicationListener>();
|
||||||
unseenMessages = new Vector<String>();
|
unseenMessages = new Vector<String>();
|
||||||
|
|
||||||
|
@ -403,6 +399,27 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Snapshots */
|
||||||
|
public void checkForSnapShots(){
|
||||||
|
|
||||||
|
for (IDeviceConnector idc: this.interfaces){
|
||||||
|
Integer avail = idc.getAvailableSnapshots();
|
||||||
|
|
||||||
|
log(INFO,"Interface %s has %d available Snapshots", idc.toString(), avail);
|
||||||
|
|
||||||
|
SnapShot[] snapshots = idc.readSnapShots();
|
||||||
|
if (snapshots != null){
|
||||||
|
getDatabase().storeSnapshots(snapshots);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSnapshotToDatabase(SnapShot snapShot){
|
||||||
|
getDatabase().storeSnapshots(new SnapShot[]{ snapShot });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ToDO: Upgrade the old stuff ... */
|
/* ToDO: Upgrade the old stuff ... */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -465,115 +482,10 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized NewSerialPort getSerialPort() {
|
|
||||||
if (serialPort == null){
|
|
||||||
serialPort = new NewSerialPort("COM1:");
|
|
||||||
}
|
|
||||||
return serialPort;
|
|
||||||
}
|
|
||||||
public synchronized void setSerialPort(NewSerialPort serialPort) {
|
|
||||||
if (serviceLink != null){
|
|
||||||
serviceLink.close();
|
|
||||||
serviceLink = null;
|
|
||||||
}
|
|
||||||
this.serialPort = serialPort;
|
|
||||||
|
|
||||||
getServiceLink();
|
|
||||||
|
|
||||||
fireServiceLinkChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized ServiceLink getServiceLink() {
|
|
||||||
if (serviceLink == null){
|
|
||||||
serviceLink = new ServiceLink(getSerialPort());
|
|
||||||
serviceLink.getSerialPort().setTimeOut(200);
|
|
||||||
serviceLink.addServiceLinkListener(this);
|
|
||||||
}
|
|
||||||
return serviceLink;
|
|
||||||
}
|
|
||||||
public synchronized void setServiceLink(ServiceLink serviceLink) {
|
|
||||||
if (serviceLink != null){
|
|
||||||
serviceLink.close();
|
|
||||||
}
|
|
||||||
this.serviceLink = serviceLink;
|
|
||||||
|
|
||||||
fireServiceLinkChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Preferences getPreferencesNode(){
|
|
||||||
return Preferences.userNodeForPackage(getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void savePrefs(){
|
|
||||||
Preferences prefs = getPreferencesNode();
|
|
||||||
|
|
||||||
if (serialPort != null)
|
|
||||||
prefs.put("io.port", getSerialPort().getPortName());
|
|
||||||
|
|
||||||
System.out.println(String.format("savePrefs(): %d exportSettings werden gesichert.", exportSettings.size()));
|
|
||||||
if (exportSettings.size()>0)
|
|
||||||
{
|
|
||||||
for (int n=0;n<exportSettings.size();n++){
|
|
||||||
prefs.put(String.format("export.configuration.%d", n), ConfigurableObjects.getConfiguration(exportSettings.get(n)));
|
|
||||||
}
|
|
||||||
prefs.putInt("export.configurations", exportSettings.size());
|
|
||||||
};
|
|
||||||
|
|
||||||
Preferences nChannels = prefs.node("channels");
|
|
||||||
for (int n=0;n<32;n++){
|
|
||||||
nChannels.put(String.format("%d.description", n), channelDescriptions[n]);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
prefs.flush();
|
|
||||||
} catch (BackingStoreException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadPrefs(){
|
|
||||||
Preferences prefs = getPreferencesNode();
|
|
||||||
|
|
||||||
String sn = prefs.get("io.port", null);
|
|
||||||
|
|
||||||
if (sn != null){
|
|
||||||
NewSerialPort nsp = new NewSerialPort(sn);
|
|
||||||
setSerialPort(nsp);
|
|
||||||
}
|
|
||||||
|
|
||||||
exportSettings.clear();
|
|
||||||
int nESC = prefs.getInt("export.configurations", 0);
|
|
||||||
for (int n=0;n<nESC;n++){
|
|
||||||
ExportSetting es = new ExportSetting();
|
|
||||||
ConfigurableObjects.setConfiguration(es, prefs.get(String.format("export.configuration.%d", n), ""));
|
|
||||||
exportSettings.add(es);
|
|
||||||
}
|
|
||||||
System.out.println(String.format("loadPrefs(): %d exportSettings geladen.", nESC));
|
|
||||||
|
|
||||||
Preferences nChannels = prefs.node("channels");
|
|
||||||
|
|
||||||
for (int n=0;n<32;n++){
|
|
||||||
channelDescriptions[n] = nChannels.get(String.format("%d.description", n), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChannelDescription(int n){
|
|
||||||
return ""; // channelDescriptions[n];
|
|
||||||
}
|
|
||||||
public void setChannelDescription(int n,String desc){
|
|
||||||
channelDescriptions[n] = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStateChanged(Boolean connected) {
|
public void connectionStateChanged(Boolean connected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapshotManager getSnapshotManager() {
|
|
||||||
return snapshotManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ExportSetting> getExportSettings() {
|
public List<ExportSetting> getExportSettings() {
|
||||||
return exportSettings;
|
return exportSettings;
|
||||||
|
|
|
@ -211,20 +211,7 @@ public class SnapShot {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
return String.format("SnapShot [ Device: %d Timestamp: %d ]",this.deviceSerial,this.timestamp);
|
||||||
|
|
||||||
sb.append("SnapShot(");
|
|
||||||
sb.append(this.timestamp);
|
|
||||||
sb.append(":");
|
|
||||||
for (int i=0;i<32;i++){
|
|
||||||
if (i>0)
|
|
||||||
sb.append(",");
|
|
||||||
sb.append(this.values[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(")");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,321 +0,0 @@
|
||||||
package org.hwo.pulscounter;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
|
||||||
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
|
||||||
import org.hwo.tasklet.Tasklet;
|
|
||||||
import org.hwo.tasklet.TaskletManager;
|
|
||||||
|
|
||||||
public class SnapshotManager {
|
|
||||||
|
|
||||||
public enum Notification { INITIALIZE, SHUTDOWN, SYNC, FULLSYNC };
|
|
||||||
|
|
||||||
private RandomAccessFile file;
|
|
||||||
|
|
||||||
private Hashtable<Long,Integer> hashList;
|
|
||||||
|
|
||||||
private Integer lastNewest,
|
|
||||||
snapshotSize;
|
|
||||||
|
|
||||||
|
|
||||||
public SnapshotManager() throws FileNotFoundException {
|
|
||||||
this.file = new RandomAccessFile("snapshots.dat", "rws");
|
|
||||||
this.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SnapshotManager(File file) throws FileNotFoundException {
|
|
||||||
this.file = new RandomAccessFile(file, "rws");
|
|
||||||
this.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void initialize(){
|
|
||||||
hashList = new Hashtable<Long, Integer>();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private PulsCounterApplication application(){
|
|
||||||
return PulsCounterApplication.getApplication();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void notify(Notification notification){
|
|
||||||
switch (notification){
|
|
||||||
case INITIALIZE:
|
|
||||||
TaskletManager.instance().enqueue(new Tasklet("SnapShot Manager initialisieren") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
doInitialize();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case SHUTDOWN:
|
|
||||||
doShutdown();
|
|
||||||
return;
|
|
||||||
case FULLSYNC:
|
|
||||||
TaskletManager.instance().enqueue(new Tasklet("Volle Synchronisation") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
doFullSync();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case SYNC:
|
|
||||||
TaskletManager.instance().enqueue(new Tasklet("Schnelle Synchronisation") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
doSync();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public synchronized void doInitialize(){
|
|
||||||
try {
|
|
||||||
byte[] buffer = new byte[256];
|
|
||||||
ByteBuffer bb = ByteBuffer.wrap(buffer);
|
|
||||||
Integer ind = 0;
|
|
||||||
|
|
||||||
application().message("SnapShotManager: Initialisieren");
|
|
||||||
|
|
||||||
hashList.clear();
|
|
||||||
file.seek(0);
|
|
||||||
|
|
||||||
while (file.read(buffer)==256){
|
|
||||||
Integer timestamp,field0;
|
|
||||||
Long hash;
|
|
||||||
|
|
||||||
timestamp = bb.getInt(0);
|
|
||||||
field0 = bb.getInt(4);
|
|
||||||
|
|
||||||
hash = ((long)timestamp << 32) | field0;
|
|
||||||
|
|
||||||
hashList.put(hash, ind++);
|
|
||||||
}
|
|
||||||
|
|
||||||
application().message(String.format("SnapShotManager: %d SnapShots lokal", hashList.size()));
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
application().message("SnapShotManager meldet Fehler: " + e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void doShutdown(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void doFullSync(){
|
|
||||||
Integer ind_oldest,ind_newest,ind;
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
application().message("SnapShotManager: Beginne volle synchronisation");
|
|
||||||
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
snapshotSize = application().getServiceLink().readInt(13, 0, 0x0582);
|
|
||||||
} catch (ServiceLinkRequestFailedException e){
|
|
||||||
snapshotSize = 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
ind_oldest = application().getServiceLink().readInt(13, 0, 0x0580);
|
|
||||||
ind_newest = application().getServiceLink().readInt(13, 0, 0x0581);
|
|
||||||
lastNewest = ind_newest;
|
|
||||||
|
|
||||||
System.out.println(String.format("ind_oldest: %d", ind_oldest));
|
|
||||||
System.out.println(String.format("ind_newest: %d", ind_newest));
|
|
||||||
|
|
||||||
ind = ind_oldest;
|
|
||||||
|
|
||||||
do {
|
|
||||||
TaskletManager.instance().setProgress(String.format("%d / %d", n++, snapshotSize));
|
|
||||||
|
|
||||||
Integer id;
|
|
||||||
try {
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0500, ind);
|
|
||||||
id = application().getServiceLink().readInt(13, 0, 0x0500);
|
|
||||||
if (!id.equals(ind)){
|
|
||||||
System.out.println(String.format("bus_snapshot_id: %d != %d",ind,id));
|
|
||||||
} else {
|
|
||||||
Integer ts,f0;
|
|
||||||
|
|
||||||
ts = application().getServiceLink().readInt(13, 0, 0x0501);
|
|
||||||
f0 = application().getServiceLink().readInt(13, 0, 0x0502);
|
|
||||||
|
|
||||||
Long hash = ((long)ts<<32) | f0;
|
|
||||||
|
|
||||||
if (!hashList.containsKey(hash)){
|
|
||||||
SnapShot snap = snapshotFromDevice(ind);
|
|
||||||
if (snap != null){
|
|
||||||
Integer find = snapshotToFile(snap);
|
|
||||||
if (find != -1){
|
|
||||||
hashList.put(snap.getHashCode(), find);
|
|
||||||
} else {
|
|
||||||
application().message("Snapshot konnte nicht gespeichert werden!");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ind.equals(ind_newest))
|
|
||||||
break;
|
|
||||||
|
|
||||||
} catch (ServiceLinkRequestFailedException failed){
|
|
||||||
failed.printStackTrace();
|
|
||||||
};
|
|
||||||
|
|
||||||
ind++;
|
|
||||||
if (ind > snapshotSize){
|
|
||||||
ind = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (!ind.equals(ind_oldest));
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
application().message(String.format("SnapShotManager: %d bekannte Snapshots nach FullSync", hashList.size()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void doSync(){
|
|
||||||
Integer ind_oldest,ind_newest,ind;
|
|
||||||
int n,c;
|
|
||||||
|
|
||||||
try {
|
|
||||||
ind_newest = application().getServiceLink().readInt(13, 0, 0x0581);
|
|
||||||
|
|
||||||
if (ind_newest == lastNewest)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ind = lastNewest;
|
|
||||||
|
|
||||||
c = ind_newest - lastNewest;
|
|
||||||
if (c < 0)
|
|
||||||
c+=snapshotSize;
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
if (c == 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
TaskletManager.instance().setProgress(String.format("%d / %d", n,c));
|
|
||||||
|
|
||||||
ind ++;
|
|
||||||
ind &= 0x1FF;
|
|
||||||
n++;
|
|
||||||
|
|
||||||
SnapShot snap = snapshotFromDevice(ind);
|
|
||||||
if (snap != null){
|
|
||||||
Integer ind_file = snapshotToFile(snap);
|
|
||||||
|
|
||||||
hashList.put(snap.getHashCode(), ind_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (!ind.equals(ind_newest));
|
|
||||||
|
|
||||||
lastNewest = ind_newest;
|
|
||||||
|
|
||||||
application().message(String.format("%d neue Snapshots", n));
|
|
||||||
|
|
||||||
|
|
||||||
} catch (ServiceLinkRequestFailedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ServiceLinkException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized SnapShot loadSnapShot(int ind){
|
|
||||||
byte[] bytes = new byte[256];
|
|
||||||
|
|
||||||
try {
|
|
||||||
file.seek(ind * 256);
|
|
||||||
file.read(bytes);
|
|
||||||
return new SnapShot(bytes);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized Integer size(){
|
|
||||||
try {
|
|
||||||
return ((int)(file.length())/256);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized Integer snapshotToFile(SnapShot snap){
|
|
||||||
Long find;
|
|
||||||
try {
|
|
||||||
|
|
||||||
find = file.length()/256;
|
|
||||||
|
|
||||||
file.seek(find * 256);
|
|
||||||
file.write(snap.toBytes());
|
|
||||||
|
|
||||||
|
|
||||||
return find.intValue();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SnapShot snapshotFromDevice(Integer ind){
|
|
||||||
SnapShot ss = new SnapShot();
|
|
||||||
Integer id;
|
|
||||||
try {
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0500, ind);
|
|
||||||
id = application().getServiceLink().readInt(13, 0, 0x0500);
|
|
||||||
if (!id.equals(ind)){
|
|
||||||
System.out.println(String.format("bus_snapshot_id: %d != %d",ind,id));
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
ss.setTimestamp( application().getServiceLink().readInt(13, 0, 0x0501));
|
|
||||||
ss.setField0( application().getServiceLink().readInt(13, 0, 0x0502));
|
|
||||||
ss.setInputmask( application().getServiceLink().readInt(13, 0, 0x0503));
|
|
||||||
ss.setOutputmask( application().getServiceLink().readInt(13, 0, 0x0504));
|
|
||||||
ss.setPullupmask( application().getServiceLink().readInt(13, 0, 0x0505));
|
|
||||||
ss.setInvertmask( application().getServiceLink().readInt(13, 0, 0x0506));
|
|
||||||
ss.setTriggermask( application().getServiceLink().readInt(13, 0, 0x0507));
|
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
|
||||||
ss.setValue(i, application().getServiceLink().readInt(13, 0, 0x0510 + i));
|
|
||||||
}
|
|
||||||
for (int i=0;i<8;i++){
|
|
||||||
ss.setAnalog(i, application().getServiceLink().readInt(13, 0, 0x0508 + i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.print(String.format("Snapshot from Device: %s\n", ss.toString()));
|
|
||||||
|
|
||||||
return ss;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -94,6 +94,26 @@ public class PulsCounterDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeSnapshots(SnapShot[] snapShots){
|
public void storeSnapshots(SnapShot[] snapShots){
|
||||||
|
for (SnapShot snapShot: snapShots){
|
||||||
|
storeSnapshot(snapShot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeSnapshot(SnapShot snapShot){
|
||||||
|
|
||||||
|
executeVerySimpleQuery("INSERT INTO snapshots (id,device,timestamp,counters,analogs,inputs,outputs,pullups,inverts) VALUES(uuid(),?,?,?,?,?,?,?,?)",
|
||||||
|
snapShot.getDeviceSerial(),
|
||||||
|
snapShot.getTimestamp(),
|
||||||
|
snapShot.getValues(),
|
||||||
|
snapShot.getAnalog(),
|
||||||
|
snapShot.getInputmask(),
|
||||||
|
snapShot.getOutputmask(),
|
||||||
|
snapShot.getPullupmask(),
|
||||||
|
snapShot.getInvertmask()
|
||||||
|
);
|
||||||
|
|
||||||
|
// (id uuid,device integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
create table properties (id uuid primary key,name varchar(255) unique,value varchar(255));
|
create table props (id uuid primary key,name varchar(255) unique,value varchar(255));
|
||||||
create table devices (id uuid,serial varchar(12));
|
create table devices (id uuid,serial varchar(12));
|
||||||
create table snapshots (id uuid,device uuid,timestamp integer,counters int array[32],analogs int array[8],inputs int,outputs int,pullups int,inverts int);
|
create table snapshots (id uuid,device integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer);
|
||||||
|
|
||||||
insert into properties (id,name,value) values(uuid(),'db.schema.version','0');
|
|
||||||
|
insert into props (id,name,value) values(uuid(),'db.schema.version','0');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package org.hwo.pulscounter.device;
|
package org.hwo.pulscounter.device;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
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;
|
||||||
|
@ -292,6 +295,7 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
@Override
|
@Override
|
||||||
public SnapShot[] readSnapShots() {
|
public SnapShot[] readSnapShots() {
|
||||||
Integer s = readDeviceSerial();
|
Integer s = readDeviceSerial();
|
||||||
|
List<SnapShot> snapshots = new LinkedList<>();
|
||||||
|
|
||||||
if (s != null){
|
if (s != null){
|
||||||
Integer oldest,newest,sssize;
|
Integer oldest,newest,sssize;
|
||||||
|
@ -307,6 +311,9 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
newest = serviceLink.readInt(13, 0, 0x0581);
|
newest = serviceLink.readInt(13, 0, 0x0581);
|
||||||
sssize = serviceLink.readInt(13, 0, 0x0582);
|
sssize = serviceLink.readInt(13, 0, 0x0582);
|
||||||
|
|
||||||
|
if (newest == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
while (!oldest.equals(newest)){
|
while (!oldest.equals(newest)){
|
||||||
|
|
||||||
Integer id;
|
Integer id;
|
||||||
|
@ -348,25 +355,40 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
|
||||||
|
|
||||||
SnapShot ss = new SnapShot(s);
|
SnapShot ss = new SnapShot(s);
|
||||||
ss.setTimestamp(timestamp);
|
ss.setTimestamp(timestamp);
|
||||||
|
ss.setField0(flags);
|
||||||
|
ss.setInputmask(in);
|
||||||
|
ss.setOutputmask(out);
|
||||||
|
ss.setInvertmask(inv);
|
||||||
|
ss.setTriggermask(trigger);
|
||||||
|
ss.setPullupmask(pu);
|
||||||
|
for (int i=0;i<32;i++){
|
||||||
|
ss.setValue(i, counters[i]);
|
||||||
|
}
|
||||||
|
for (int i=0;i<8;i++){
|
||||||
|
ss.setAnalog(i, analogs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
log(INFO,"Snapshot read: %s",id);
|
||||||
|
snapshots.add(ss);
|
||||||
|
|
||||||
};
|
};
|
||||||
} catch (ServiceLinkRequestFailedException e){
|
} catch (ServiceLinkRequestFailedException e){
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldest++;
|
||||||
|
if (oldest >= sssize){
|
||||||
|
oldest = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indSnapshotOldest = oldest;
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException | ServiceLinkException e) {
|
} catch (IOException | ServiceLinkException e) {
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return snapshots.toArray(new SnapShot[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.hwo.io.SerialPort;
|
||||||
import org.hwo.io.NewSerialPort.NewSerialPort;
|
import org.hwo.io.NewSerialPort.NewSerialPort;
|
||||||
import org.hwo.pulscounter.PulsCounterApplication;
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
import org.hwo.pulscounter.SnapshotManager;
|
|
||||||
import org.hwo.servicelink.ServiceLink;
|
import org.hwo.servicelink.ServiceLink;
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
import org.hwo.servicelink.ServiceLinkRequestFailedException;
|
||||||
|
@ -132,7 +131,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton btnWhlen = new JButton("wählen...");
|
JButton btnWhlen = new JButton("wählen...");
|
||||||
btnWhlen.addActionListener(new ActionListener() {
|
btnWhlen.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
chooseSerialPort();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnWhlen = new GridBagConstraints();
|
GridBagConstraints gbc_btnWhlen = new GridBagConstraints();
|
||||||
|
@ -239,7 +238,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton btnUpdate = new JButton("Update...");
|
JButton btnUpdate = new JButton("Update...");
|
||||||
btnUpdate.addActionListener(new ActionListener() {
|
btnUpdate.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
readDebug();
|
// readDebug();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
|
GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
|
||||||
|
@ -258,7 +257,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton btnDumpSnapshots = new JButton("Dump Snapshots");
|
JButton btnDumpSnapshots = new JButton("Dump Snapshots");
|
||||||
btnDumpSnapshots.addActionListener(new ActionListener() {
|
btnDumpSnapshots.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
dumpSnapshots();
|
// dumpSnapshots();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnDumpSnapshots = new GridBagConstraints();
|
GridBagConstraints gbc_btnDumpSnapshots = new GridBagConstraints();
|
||||||
|
@ -270,7 +269,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton btnResetDevice = new JButton("Reset Device");
|
JButton btnResetDevice = new JButton("Reset Device");
|
||||||
btnResetDevice.addActionListener(new ActionListener() {
|
btnResetDevice.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
doRESETDevice();
|
// doRESETDevice();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnResetDevice = new GridBagConstraints();
|
GridBagConstraints gbc_btnResetDevice = new GridBagConstraints();
|
||||||
|
@ -282,7 +281,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton btnRckDump = new JButton("RCK Dump");
|
JButton btnRckDump = new JButton("RCK Dump");
|
||||||
btnRckDump.addActionListener(new ActionListener() {
|
btnRckDump.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
doRCKDump();
|
// doRCKDump();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnRckDump = new GridBagConstraints();
|
GridBagConstraints gbc_btnRckDump = new GridBagConstraints();
|
||||||
|
@ -291,7 +290,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
panel_5.add(btnRckDump, gbc_btnRckDump);
|
panel_5.add(btnRckDump, gbc_btnRckDump);
|
||||||
btnRamImage.addActionListener(new ActionListener() {
|
btnRamImage.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
doRAMImage();
|
// doRAMImage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -395,9 +394,7 @@ public class AppSettingsFrame extends JDialog {
|
||||||
JButton bOK = new JButton("OK");
|
JButton bOK = new JButton("OK");
|
||||||
bOK.addActionListener(new ActionListener() {
|
bOK.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
accept();
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
application().savePrefs();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_bOK = new GridBagConstraints();
|
GridBagConstraints gbc_bOK = new GridBagConstraints();
|
||||||
|
@ -406,9 +403,10 @@ public class AppSettingsFrame extends JDialog {
|
||||||
gbc_bOK.gridy = 0;
|
gbc_bOK.gridy = 0;
|
||||||
panel_1.add(bOK, gbc_bOK);
|
panel_1.add(bOK, gbc_bOK);
|
||||||
|
|
||||||
initialize();
|
//initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
PulsCounterApplication pc2a = PulsCounterApplication.getApplication();
|
PulsCounterApplication pc2a = PulsCounterApplication.getApplication();
|
||||||
|
|
||||||
|
@ -554,10 +552,6 @@ public class AppSettingsFrame extends JDialog {
|
||||||
Integer i32 = sl.readInt(13, 0, 0x00ee);
|
Integer i32 = sl.readInt(13, 0, 0x00ee);
|
||||||
|
|
||||||
o.write(i32 & 0xff);
|
o.write(i32 & 0xff);
|
||||||
/* o.write((i32>>8) & 0xff);
|
|
||||||
o.write((i32>>16) & 0xff);
|
|
||||||
o.write((i32>>24) & 0xff);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
o.close();
|
o.close();
|
||||||
|
@ -638,6 +632,6 @@ SnapshotManager ssm = PulsCounterApplication.getApplication().getSnapshotManager
|
||||||
}
|
}
|
||||||
msgExc.setText(sb.toString());
|
msgExc.setText(sb.toString());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.hwo.pulscounter.ui;
|
||||||
import org.hwo.pulscounter.ExportSetting;
|
import org.hwo.pulscounter.ExportSetting;
|
||||||
import org.hwo.pulscounter.PulsCounterApplication;
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
import org.hwo.pulscounter.SnapshotManager.Notification;
|
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
public class BatchRunner implements PulsCounterApplicationListener{
|
public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
|
@ -21,12 +20,8 @@ public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
pulsCounterApplication.getServiceLink().open();
|
|
||||||
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
pulsCounterApplication.getSnapshotManager().doFullSync();
|
|
||||||
|
|
||||||
for (ExportSetting es: pulsCounterApplication.getExportSettings()){
|
for (ExportSetting es: pulsCounterApplication.getExportSettings()){
|
||||||
if (es.getAutostart()){
|
if (es.getAutostart()){
|
||||||
|
@ -40,7 +35,7 @@ public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pulsCounterApplication.notifyUiIsFinished(false);
|
pulsCounterApplication.notifyUiIsFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,466 +43,468 @@ import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
public class DeviceConfiguration extends JFrame {
|
public class DeviceConfiguration extends JFrame {
|
||||||
|
};
|
||||||
private JPanel contentPane;
|
|
||||||
|
|
||||||
|
// private JPanel contentPane;
|
||||||
int currentChannel;
|
//
|
||||||
private BitFieldEditor bfeIntervall;
|
//
|
||||||
private JTimeSpanEditor tseI3;
|
// int currentChannel;
|
||||||
private JTimeSpanEditor tseI2;
|
// private BitFieldEditor bfeIntervall;
|
||||||
private JTimeSpanEditor tseI1;
|
// private JTimeSpanEditor tseI3;
|
||||||
private JTimeSpanEditor tseI0;
|
// private JTimeSpanEditor tseI2;
|
||||||
|
// private JTimeSpanEditor tseI1;
|
||||||
private TableMapper tmSettings;
|
// private JTimeSpanEditor tseI0;
|
||||||
|
//
|
||||||
int outputs,
|
// private TableMapper tmSettings;
|
||||||
pullups,
|
//
|
||||||
inverts,
|
// int outputs,
|
||||||
trigger;
|
// pullups,
|
||||||
|
// inverts,
|
||||||
int[] filter,
|
// trigger;
|
||||||
windows;
|
//
|
||||||
private JTable tSettings;
|
// int[] filter,
|
||||||
|
// windows;
|
||||||
|
// private JTable tSettings;
|
||||||
|
//
|
||||||
/**
|
//
|
||||||
* Create the frame.
|
//
|
||||||
*/
|
// /**
|
||||||
public DeviceConfiguration() {
|
// * Create the frame.
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
// */
|
||||||
setBounds(100, 100, 860, 498);
|
// public DeviceConfiguration() {
|
||||||
contentPane = new JPanel();
|
// setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
// setBounds(100, 100, 860, 498);
|
||||||
setContentPane(contentPane);
|
// contentPane = new JPanel();
|
||||||
GridBagLayout gbl_contentPane = new GridBagLayout();
|
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
gbl_contentPane.columnWidths = new int[] {30, 0, 0};
|
// setContentPane(contentPane);
|
||||||
gbl_contentPane.rowHeights = new int[] {183, 0};
|
// GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||||
gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0};
|
// gbl_contentPane.columnWidths = new int[] {30, 0, 0};
|
||||||
gbl_contentPane.rowWeights = new double[]{1.0, 0.0};
|
// gbl_contentPane.rowHeights = new int[] {183, 0};
|
||||||
contentPane.setLayout(gbl_contentPane);
|
// gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0};
|
||||||
|
// gbl_contentPane.rowWeights = new double[]{1.0, 0.0};
|
||||||
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
// contentPane.setLayout(gbl_contentPane);
|
||||||
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
|
//
|
||||||
gbc_tabbedPane.gridwidth = 3;
|
// JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
// GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
|
||||||
gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
|
// gbc_tabbedPane.gridwidth = 3;
|
||||||
gbc_tabbedPane.gridx = 0;
|
// gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
||||||
gbc_tabbedPane.gridy = 0;
|
// gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
|
||||||
contentPane.add(tabbedPane, gbc_tabbedPane);
|
// gbc_tabbedPane.gridx = 0;
|
||||||
|
// gbc_tabbedPane.gridy = 0;
|
||||||
JPanel panel_2 = new JPanel();
|
// contentPane.add(tabbedPane, gbc_tabbedPane);
|
||||||
tabbedPane.addTab("Intervalle", null, panel_2, null);
|
//
|
||||||
GridBagLayout gbl_panel_2 = new GridBagLayout();
|
// JPanel panel_2 = new JPanel();
|
||||||
gbl_panel_2.columnWidths = new int[]{0, 0, 0};
|
// tabbedPane.addTab("Intervalle", null, panel_2, null);
|
||||||
gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
// GridBagLayout gbl_panel_2 = new GridBagLayout();
|
||||||
gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
// gbl_panel_2.columnWidths = new int[]{0, 0, 0};
|
||||||
gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
// gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
||||||
panel_2.setLayout(gbl_panel_2);
|
// gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
// gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
bfeIntervall = new BitFieldEditor();
|
// panel_2.setLayout(gbl_panel_2);
|
||||||
bfeIntervall.setToolTipText("<html>\n<b>Tagesbasierte Intervalle</b><br/>\n<br/>\nTagesbasierte Intervalle werden immer auf 0:00:00 Uhr des aktuellen Tages bezogen ausgeführt.<br/>\nDies ermöglicht nicht nur eine Regelmäßige Aufzeichnung, sondern erzwingt auch eine Aufzeichnung<br/>\nin einem festgelegten immer gleichen Raster.<br/>\n<br/>\nNicht tageszeitbasierte Intervalle werden mit Bezug auf den 1.1.1970 0:00:00 Uhr ausgeführt.<br/>\nDiese ermöglichen eine stete regelmäßige Aufzeichnung bei der die tageszeit ignoriert wird.\n</html>");
|
//
|
||||||
bfeIntervall.addChangeListener(new ChangeListener() {
|
// bfeIntervall = new BitFieldEditor();
|
||||||
public void stateChanged(ChangeEvent e) {
|
// bfeIntervall.setToolTipText("<html>\n<b>Tagesbasierte Intervalle</b><br/>\n<br/>\nTagesbasierte Intervalle werden immer auf 0:00:00 Uhr des aktuellen Tages bezogen ausgeführt.<br/>\nDies ermöglicht nicht nur eine Regelmäßige Aufzeichnung, sondern erzwingt auch eine Aufzeichnung<br/>\nin einem festgelegten immer gleichen Raster.<br/>\n<br/>\nNicht tageszeitbasierte Intervalle werden mit Bezug auf den 1.1.1970 0:00:00 Uhr ausgeführt.<br/>\nDiese ermöglichen eine stete regelmäßige Aufzeichnung bei der die tageszeit ignoriert wird.\n</html>");
|
||||||
int v = bfeIntervall.getIntValue();
|
// bfeIntervall.addChangeListener(new ChangeListener() {
|
||||||
tseI0.setDaysEnabled(((v & 0x01)==0));
|
// public void stateChanged(ChangeEvent e) {
|
||||||
tseI1.setDaysEnabled(((v & 0x02)==0));
|
// int v = bfeIntervall.getIntValue();
|
||||||
tseI2.setDaysEnabled(((v & 0x04)==0));
|
// tseI0.setDaysEnabled(((v & 0x01)==0));
|
||||||
tseI3.setDaysEnabled(((v & 0x08)==0));
|
// tseI1.setDaysEnabled(((v & 0x02)==0));
|
||||||
|
// tseI2.setDaysEnabled(((v & 0x04)==0));
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// tseI3.setDaysEnabled(((v & 0x08)==0));
|
||||||
try {
|
//
|
||||||
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
// try {
|
||||||
|
//
|
||||||
} catch (ServiceLinkRequestFailedException e1) {
|
// sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
||||||
e1.printStackTrace();
|
//
|
||||||
} catch (IOException e1) {
|
// } catch (ServiceLinkRequestFailedException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
} catch (ServiceLinkException e1) {
|
// } catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
}
|
// } catch (ServiceLinkException e1) {
|
||||||
}
|
// e1.printStackTrace();
|
||||||
});
|
// }
|
||||||
|
// }
|
||||||
JLabel lblTageszeitabhngigkeit = new JLabel("Tageszeitabhängigkeit:");
|
// });
|
||||||
GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints();
|
//
|
||||||
gbc_lblTageszeitabhngigkeit.fill = GridBagConstraints.HORIZONTAL;
|
// JLabel lblTageszeitabhngigkeit = new JLabel("Tageszeitabhängigkeit:");
|
||||||
gbc_lblTageszeitabhngigkeit.insets = new Insets(0, 0, 5, 5);
|
// GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints();
|
||||||
gbc_lblTageszeitabhngigkeit.gridx = 0;
|
// gbc_lblTageszeitabhngigkeit.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_lblTageszeitabhngigkeit.gridy = 0;
|
// gbc_lblTageszeitabhngigkeit.insets = new Insets(0, 0, 5, 5);
|
||||||
panel_2.add(lblTageszeitabhngigkeit, gbc_lblTageszeitabhngigkeit);
|
// gbc_lblTageszeitabhngigkeit.gridx = 0;
|
||||||
GridBagConstraints gbc_bfeIntervall = new GridBagConstraints();
|
// gbc_lblTageszeitabhngigkeit.gridy = 0;
|
||||||
gbc_bfeIntervall.anchor = GridBagConstraints.NORTH;
|
// panel_2.add(lblTageszeitabhngigkeit, gbc_lblTageszeitabhngigkeit);
|
||||||
gbc_bfeIntervall.insets = new Insets(0, 0, 5, 0);
|
// GridBagConstraints gbc_bfeIntervall = new GridBagConstraints();
|
||||||
gbc_bfeIntervall.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_bfeIntervall.anchor = GridBagConstraints.NORTH;
|
||||||
gbc_bfeIntervall.gridx = 1;
|
// gbc_bfeIntervall.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_bfeIntervall.gridy = 0;
|
// gbc_bfeIntervall.fill = GridBagConstraints.HORIZONTAL;
|
||||||
panel_2.add(bfeIntervall, gbc_bfeIntervall);
|
// gbc_bfeIntervall.gridx = 1;
|
||||||
|
// gbc_bfeIntervall.gridy = 0;
|
||||||
JLabel lblIntervall = new JLabel("Intervall 0:");
|
// panel_2.add(bfeIntervall, gbc_bfeIntervall);
|
||||||
lblIntervall.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
GridBagConstraints gbc_lblIntervall = new GridBagConstraints();
|
// JLabel lblIntervall = new JLabel("Intervall 0:");
|
||||||
gbc_lblIntervall.fill = GridBagConstraints.HORIZONTAL;
|
// lblIntervall.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
gbc_lblIntervall.insets = new Insets(0, 0, 5, 5);
|
// GridBagConstraints gbc_lblIntervall = new GridBagConstraints();
|
||||||
gbc_lblIntervall.gridx = 0;
|
// gbc_lblIntervall.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_lblIntervall.gridy = 1;
|
// gbc_lblIntervall.insets = new Insets(0, 0, 5, 5);
|
||||||
panel_2.add(lblIntervall, gbc_lblIntervall);
|
// gbc_lblIntervall.gridx = 0;
|
||||||
|
// gbc_lblIntervall.gridy = 1;
|
||||||
tseI0 = new JTimeSpanEditor();
|
// panel_2.add(lblIntervall, gbc_lblIntervall);
|
||||||
tseI0.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
tseI0.addFocusListener(new FocusAdapter() {
|
// tseI0 = new JTimeSpanEditor();
|
||||||
@Override
|
// tseI0.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
public void focusLost(FocusEvent e) {
|
// tseI0.addFocusListener(new FocusAdapter() {
|
||||||
System.err.println("FOCUS LOST 0");
|
// @Override
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// public void focusLost(FocusEvent e) {
|
||||||
try {
|
// System.err.println("FOCUS LOST 0");
|
||||||
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1010, (Integer)tseI0.getValue());
|
// try {
|
||||||
|
//
|
||||||
} catch (ServiceLinkRequestFailedException e1) {
|
// sl.writeInt(13, 0, 0x1010, (Integer)tseI0.getValue());
|
||||||
e1.printStackTrace();
|
//
|
||||||
} catch (IOException e1) {
|
// } catch (ServiceLinkRequestFailedException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
} catch (ServiceLinkException e1) {
|
// } catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
}
|
// } catch (ServiceLinkException e1) {
|
||||||
}
|
// e1.printStackTrace();
|
||||||
});
|
// }
|
||||||
GridBagConstraints gbc_tseI0 = new GridBagConstraints();
|
// }
|
||||||
gbc_tseI0.anchor = GridBagConstraints.WEST;
|
// });
|
||||||
gbc_tseI0.insets = new Insets(0, 0, 5, 0);
|
// GridBagConstraints gbc_tseI0 = new GridBagConstraints();
|
||||||
gbc_tseI0.gridx = 1;
|
// gbc_tseI0.anchor = GridBagConstraints.WEST;
|
||||||
gbc_tseI0.gridy = 1;
|
// gbc_tseI0.insets = new Insets(0, 0, 5, 0);
|
||||||
panel_2.add(tseI0, gbc_tseI0);
|
// gbc_tseI0.gridx = 1;
|
||||||
|
// gbc_tseI0.gridy = 1;
|
||||||
JLabel lblIntervall_1 = new JLabel("Intervall 1:");
|
// panel_2.add(tseI0, gbc_tseI0);
|
||||||
lblIntervall_1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints();
|
// JLabel lblIntervall_1 = new JLabel("Intervall 1:");
|
||||||
gbc_lblIntervall_1.fill = GridBagConstraints.HORIZONTAL;
|
// lblIntervall_1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
gbc_lblIntervall_1.insets = new Insets(0, 0, 5, 5);
|
// GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints();
|
||||||
gbc_lblIntervall_1.gridx = 0;
|
// gbc_lblIntervall_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_lblIntervall_1.gridy = 2;
|
// gbc_lblIntervall_1.insets = new Insets(0, 0, 5, 5);
|
||||||
panel_2.add(lblIntervall_1, gbc_lblIntervall_1);
|
// gbc_lblIntervall_1.gridx = 0;
|
||||||
|
// gbc_lblIntervall_1.gridy = 2;
|
||||||
tseI1 = new JTimeSpanEditor();
|
// panel_2.add(lblIntervall_1, gbc_lblIntervall_1);
|
||||||
tseI1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
tseI1.addFocusListener(new FocusAdapter() {
|
// tseI1 = new JTimeSpanEditor();
|
||||||
@Override
|
// tseI1.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
public void focusLost(FocusEvent e) {
|
// tseI1.addFocusListener(new FocusAdapter() {
|
||||||
|
// @Override
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// public void focusLost(FocusEvent e) {
|
||||||
try {
|
//
|
||||||
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1011, (Integer)tseI1.getValue());
|
// try {
|
||||||
|
//
|
||||||
} catch (ServiceLinkRequestFailedException e1) {
|
// sl.writeInt(13, 0, 0x1011, (Integer)tseI1.getValue());
|
||||||
e1.printStackTrace();
|
//
|
||||||
} catch (IOException e1) {
|
// } catch (ServiceLinkRequestFailedException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
} catch (ServiceLinkException e1) {
|
// } catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
}
|
// } catch (ServiceLinkException e1) {
|
||||||
}
|
// e1.printStackTrace();
|
||||||
});
|
// }
|
||||||
GridBagConstraints gbc_tseI1 = new GridBagConstraints();
|
// }
|
||||||
gbc_tseI1.anchor = GridBagConstraints.WEST;
|
// });
|
||||||
gbc_tseI1.insets = new Insets(0, 0, 5, 0);
|
// GridBagConstraints gbc_tseI1 = new GridBagConstraints();
|
||||||
gbc_tseI1.gridx = 1;
|
// gbc_tseI1.anchor = GridBagConstraints.WEST;
|
||||||
gbc_tseI1.gridy = 2;
|
// gbc_tseI1.insets = new Insets(0, 0, 5, 0);
|
||||||
panel_2.add(tseI1, gbc_tseI1);
|
// gbc_tseI1.gridx = 1;
|
||||||
|
// gbc_tseI1.gridy = 2;
|
||||||
JLabel lblIntervall_2 = new JLabel("Intervall 2:");
|
// panel_2.add(tseI1, gbc_tseI1);
|
||||||
lblIntervall_2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
GridBagConstraints gbc_lblIntervall_2 = new GridBagConstraints();
|
// JLabel lblIntervall_2 = new JLabel("Intervall 2:");
|
||||||
gbc_lblIntervall_2.fill = GridBagConstraints.HORIZONTAL;
|
// lblIntervall_2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
gbc_lblIntervall_2.insets = new Insets(0, 0, 5, 5);
|
// GridBagConstraints gbc_lblIntervall_2 = new GridBagConstraints();
|
||||||
gbc_lblIntervall_2.gridx = 0;
|
// gbc_lblIntervall_2.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_lblIntervall_2.gridy = 3;
|
// gbc_lblIntervall_2.insets = new Insets(0, 0, 5, 5);
|
||||||
panel_2.add(lblIntervall_2, gbc_lblIntervall_2);
|
// gbc_lblIntervall_2.gridx = 0;
|
||||||
|
// gbc_lblIntervall_2.gridy = 3;
|
||||||
tseI2 = new JTimeSpanEditor();
|
// panel_2.add(lblIntervall_2, gbc_lblIntervall_2);
|
||||||
tseI2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
tseI2.addFocusListener(new FocusAdapter() {
|
// tseI2 = new JTimeSpanEditor();
|
||||||
@Override
|
// tseI2.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
public void focusLost(FocusEvent e) {
|
// tseI2.addFocusListener(new FocusAdapter() {
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// @Override
|
||||||
try {
|
// public void focusLost(FocusEvent e) {
|
||||||
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1012, (Integer)tseI2.getValue());
|
// try {
|
||||||
|
//
|
||||||
} catch (ServiceLinkRequestFailedException e1) {
|
// sl.writeInt(13, 0, 0x1012, (Integer)tseI2.getValue());
|
||||||
e1.printStackTrace();
|
//
|
||||||
} catch (IOException e1) {
|
// } catch (ServiceLinkRequestFailedException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
} catch (ServiceLinkException e1) {
|
// } catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
}
|
// } catch (ServiceLinkException e1) {
|
||||||
}
|
// e1.printStackTrace();
|
||||||
});
|
// }
|
||||||
GridBagConstraints gbc_tseI2 = new GridBagConstraints();
|
// }
|
||||||
gbc_tseI2.anchor = GridBagConstraints.WEST;
|
// });
|
||||||
gbc_tseI2.insets = new Insets(0, 0, 5, 0);
|
// GridBagConstraints gbc_tseI2 = new GridBagConstraints();
|
||||||
gbc_tseI2.gridx = 1;
|
// gbc_tseI2.anchor = GridBagConstraints.WEST;
|
||||||
gbc_tseI2.gridy = 3;
|
// gbc_tseI2.insets = new Insets(0, 0, 5, 0);
|
||||||
panel_2.add(tseI2, gbc_tseI2);
|
// gbc_tseI2.gridx = 1;
|
||||||
|
// gbc_tseI2.gridy = 3;
|
||||||
JLabel lblIntervall_3 = new JLabel("Intervall 3:");
|
// panel_2.add(tseI2, gbc_tseI2);
|
||||||
lblIntervall_3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
GridBagConstraints gbc_lblIntervall_3 = new GridBagConstraints();
|
// JLabel lblIntervall_3 = new JLabel("Intervall 3:");
|
||||||
gbc_lblIntervall_3.fill = GridBagConstraints.HORIZONTAL;
|
// lblIntervall_3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
gbc_lblIntervall_3.insets = new Insets(0, 0, 0, 5);
|
// GridBagConstraints gbc_lblIntervall_3 = new GridBagConstraints();
|
||||||
gbc_lblIntervall_3.gridx = 0;
|
// gbc_lblIntervall_3.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_lblIntervall_3.gridy = 4;
|
// gbc_lblIntervall_3.insets = new Insets(0, 0, 0, 5);
|
||||||
panel_2.add(lblIntervall_3, gbc_lblIntervall_3);
|
// gbc_lblIntervall_3.gridx = 0;
|
||||||
|
// gbc_lblIntervall_3.gridy = 4;
|
||||||
tseI3 = new JTimeSpanEditor();
|
// panel_2.add(lblIntervall_3, gbc_lblIntervall_3);
|
||||||
tseI3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
//
|
||||||
tseI3.addFocusListener(new FocusAdapter() {
|
// tseI3 = new JTimeSpanEditor();
|
||||||
@Override
|
// tseI3.setToolTipText("<html>\n<b>Intervall</b><br/>\n<br/>\nStellen Sie die gewünschten Intervalllängen ein.<br/>\n<br/>\nEinheiten: <b>Tage, Stunden, Minuten, Sekunden</b>\n</html>");
|
||||||
public void focusLost(FocusEvent e) {
|
// tseI3.addFocusListener(new FocusAdapter() {
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// @Override
|
||||||
try {
|
// public void focusLost(FocusEvent e) {
|
||||||
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1013, (Integer)tseI3.getValue());
|
// try {
|
||||||
|
//
|
||||||
} catch (ServiceLinkRequestFailedException e1) {
|
// sl.writeInt(13, 0, 0x1013, (Integer)tseI3.getValue());
|
||||||
e1.printStackTrace();
|
//
|
||||||
} catch (IOException e1) {
|
// } catch (ServiceLinkRequestFailedException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
} catch (ServiceLinkException e1) {
|
// } catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
// e1.printStackTrace();
|
||||||
}
|
// } catch (ServiceLinkException e1) {
|
||||||
}
|
// e1.printStackTrace();
|
||||||
});
|
// }
|
||||||
GridBagConstraints gbc_tseI3 = new GridBagConstraints();
|
// }
|
||||||
gbc_tseI3.anchor = GridBagConstraints.WEST;
|
// });
|
||||||
gbc_tseI3.gridx = 1;
|
// GridBagConstraints gbc_tseI3 = new GridBagConstraints();
|
||||||
gbc_tseI3.gridy = 4;
|
// gbc_tseI3.anchor = GridBagConstraints.WEST;
|
||||||
panel_2.add(tseI3, gbc_tseI3);
|
// gbc_tseI3.gridx = 1;
|
||||||
|
// gbc_tseI3.gridy = 4;
|
||||||
JPanel panel_1 = new JPanel();
|
// panel_2.add(tseI3, gbc_tseI3);
|
||||||
tabbedPane.addTab("Kanäle", null, panel_1, null);
|
//
|
||||||
GridBagLayout gbl_panel_1 = new GridBagLayout();
|
// JPanel panel_1 = new JPanel();
|
||||||
gbl_panel_1.columnWidths = new int[] {100};
|
// tabbedPane.addTab("Kanäle", null, panel_1, null);
|
||||||
gbl_panel_1.rowHeights = new int[] {30};
|
// GridBagLayout gbl_panel_1 = new GridBagLayout();
|
||||||
gbl_panel_1.columnWeights = new double[]{1.0};
|
// gbl_panel_1.columnWidths = new int[] {100};
|
||||||
gbl_panel_1.rowWeights = new double[]{1.0};
|
// gbl_panel_1.rowHeights = new int[] {30};
|
||||||
panel_1.setLayout(gbl_panel_1);
|
// gbl_panel_1.columnWeights = new double[]{1.0};
|
||||||
|
// gbl_panel_1.rowWeights = new double[]{1.0};
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
// panel_1.setLayout(gbl_panel_1);
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
//
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
// JScrollPane scrollPane = new JScrollPane();
|
||||||
gbc_scrollPane.gridx = 0;
|
// GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
gbc_scrollPane.gridy = 0;
|
// gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
panel_1.add(scrollPane, gbc_scrollPane);
|
// gbc_scrollPane.gridx = 0;
|
||||||
|
// gbc_scrollPane.gridy = 0;
|
||||||
tSettings = new JTable();
|
// panel_1.add(scrollPane, gbc_scrollPane);
|
||||||
tSettings.setRowHeight(32);
|
//
|
||||||
tSettings.setFillsViewportHeight(true);
|
// tSettings = new JTable();
|
||||||
tSettings.setCellSelectionEnabled(true);
|
// tSettings.setRowHeight(32);
|
||||||
scrollPane.setViewportView(tSettings);
|
// tSettings.setFillsViewportHeight(true);
|
||||||
|
// tSettings.setCellSelectionEnabled(true);
|
||||||
JButton btnSchliessen = new JButton("abbrechen");
|
// scrollPane.setViewportView(tSettings);
|
||||||
btnSchliessen.addActionListener(new ActionListener() {
|
//
|
||||||
public void actionPerformed(ActionEvent e) {
|
// JButton btnSchliessen = new JButton("abbrechen");
|
||||||
setVisible(false);
|
// btnSchliessen.addActionListener(new ActionListener() {
|
||||||
}
|
// public void actionPerformed(ActionEvent e) {
|
||||||
});
|
// setVisible(false);
|
||||||
|
// }
|
||||||
JButton btnOk = new JButton("OK");
|
// });
|
||||||
btnOk.addActionListener(new ActionListener() {
|
//
|
||||||
public void actionPerformed(ActionEvent e) {
|
// JButton btnOk = new JButton("OK");
|
||||||
writeDevice();
|
// btnOk.addActionListener(new ActionListener() {
|
||||||
setVisible(false);
|
// public void actionPerformed(ActionEvent e) {
|
||||||
}
|
// writeDevice();
|
||||||
});
|
// setVisible(false);
|
||||||
GridBagConstraints gbc_btnOk = new GridBagConstraints();
|
// }
|
||||||
gbc_btnOk.fill = GridBagConstraints.BOTH;
|
// });
|
||||||
gbc_btnOk.insets = new Insets(0, 0, 0, 5);
|
// GridBagConstraints gbc_btnOk = new GridBagConstraints();
|
||||||
gbc_btnOk.gridx = 1;
|
// gbc_btnOk.fill = GridBagConstraints.BOTH;
|
||||||
gbc_btnOk.gridy = 1;
|
// gbc_btnOk.insets = new Insets(0, 0, 0, 5);
|
||||||
contentPane.add(btnOk, gbc_btnOk);
|
// gbc_btnOk.gridx = 1;
|
||||||
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
// gbc_btnOk.gridy = 1;
|
||||||
gbc_btnSchliessen.fill = GridBagConstraints.BOTH;
|
// contentPane.add(btnOk, gbc_btnOk);
|
||||||
gbc_btnSchliessen.gridx = 2;
|
// GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
||||||
gbc_btnSchliessen.gridy = 1;
|
// gbc_btnSchliessen.fill = GridBagConstraints.BOTH;
|
||||||
contentPane.add(btnSchliessen, gbc_btnSchliessen);
|
// gbc_btnSchliessen.gridx = 2;
|
||||||
|
// gbc_btnSchliessen.gridy = 1;
|
||||||
this.initialize();
|
// contentPane.add(btnSchliessen, gbc_btnSchliessen);
|
||||||
}
|
//
|
||||||
|
// this.initialize();
|
||||||
private Integer intOr0(Integer i){
|
// }
|
||||||
if (i==null)
|
//
|
||||||
return 0;
|
// private Integer intOr0(Integer i){
|
||||||
return i;
|
// if (i==null)
|
||||||
}
|
// return 0;
|
||||||
|
// return i;
|
||||||
private void initialize(){
|
// }
|
||||||
currentChannel = -1;
|
//
|
||||||
filter = new int[32];
|
// private void initialize(){
|
||||||
windows = new int[32];
|
// currentChannel = -1;
|
||||||
tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
|
// filter = new int[32];
|
||||||
|
// windows = new int[32];
|
||||||
BitField bf = new BitField();
|
// tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
|
||||||
bf.clear();
|
//
|
||||||
bf.addField(new Field(bf, 0, 1, "Intervall 0 basiert auf Tageszeit"));
|
// BitField bf = new BitField();
|
||||||
bf.addField(new Field(bf, 1, 1, "Intervall 1 basiert auf Tageszeit"));
|
// bf.clear();
|
||||||
bf.addField(new Field(bf, 2, 1, "Intervall 2 basiert auf Tageszeit"));
|
// bf.addField(new Field(bf, 0, 1, "Intervall 0 basiert auf Tageszeit"));
|
||||||
bf.addField(new Field(bf, 3, 1, "Intervall 3 basiert auf Tageszeit"));
|
// bf.addField(new Field(bf, 1, 1, "Intervall 1 basiert auf Tageszeit"));
|
||||||
bfeIntervall.setBitField(bf);
|
// bf.addField(new Field(bf, 2, 1, "Intervall 2 basiert auf Tageszeit"));
|
||||||
for (int i=0;i<32;i++){
|
// bf.addField(new Field(bf, 3, 1, "Intervall 3 basiert auf Tageszeit"));
|
||||||
tmSettings.addRow(new ChannelConfiguration(i));
|
// bfeIntervall.setBitField(bf);
|
||||||
}
|
// for (int i=0;i<32;i++){
|
||||||
|
// tmSettings.addRow(new ChannelConfiguration(i));
|
||||||
|
// }
|
||||||
readDevice();
|
//
|
||||||
}
|
//
|
||||||
|
// readDevice();
|
||||||
private void readDevice(){
|
// }
|
||||||
Integer v;
|
//
|
||||||
|
// private void readDevice(){
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
// Integer v;
|
||||||
|
//
|
||||||
outputs = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1008));
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
pullups = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1009));
|
//
|
||||||
inverts = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100A));
|
// outputs = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1008));
|
||||||
trigger = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100B));
|
// pullups = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1009));
|
||||||
|
// inverts = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100A));
|
||||||
bfeIntervall.setIntValue(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1003));
|
// trigger = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100B));
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// bfeIntervall.setIntValue(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1003));
|
||||||
filter[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1020 + i));
|
//
|
||||||
windows[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1280 + i));
|
// for (int i=0;i<32;i++){
|
||||||
}
|
// filter[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1020 + i));
|
||||||
|
// windows[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1280 + i));
|
||||||
|
// }
|
||||||
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1010);
|
//
|
||||||
if (v!=null){
|
//
|
||||||
tseI0.setValue(v);
|
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1010);
|
||||||
}
|
// if (v!=null){
|
||||||
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1011);
|
// tseI0.setValue(v);
|
||||||
if (v!=null){
|
// }
|
||||||
tseI1.setValue(v);
|
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1011);
|
||||||
}
|
// if (v!=null){
|
||||||
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1012);
|
// tseI1.setValue(v);
|
||||||
if (v!=null){
|
// }
|
||||||
tseI2.setValue(v);
|
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1012);
|
||||||
}
|
// if (v!=null){
|
||||||
v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1013);
|
// tseI2.setValue(v);
|
||||||
if (v!=null){
|
// }
|
||||||
tseI3.setValue(v);
|
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1013);
|
||||||
}
|
// if (v!=null){
|
||||||
|
// tseI3.setValue(v);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//
|
||||||
|
//
|
||||||
private void writeDevice(){
|
// }
|
||||||
ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
//
|
||||||
try {
|
// private void writeDevice(){
|
||||||
sl.writeInt(13, 0, 0x1008, outputs);
|
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink();
|
||||||
sl.writeInt(13, 0, 0x1009, pullups);
|
// try {
|
||||||
sl.writeInt(13, 0, 0x100A, inverts);
|
// sl.writeInt(13, 0, 0x1008, outputs);
|
||||||
sl.writeInt(13, 0, 0x100B, trigger);
|
// sl.writeInt(13, 0, 0x1009, pullups);
|
||||||
|
// sl.writeInt(13, 0, 0x100A, inverts);
|
||||||
sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
// sl.writeInt(13, 0, 0x100B, trigger);
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue());
|
||||||
sl.writeInt(13, 0, 0x1020 + i, filter[i]);
|
//
|
||||||
sl.writeInt(13, 0, 0x1280 + i, windows[i]);
|
// for (int i=0;i<32;i++){
|
||||||
}
|
// sl.writeInt(13, 0, 0x1020 + i, filter[i]);
|
||||||
|
// sl.writeInt(13, 0, 0x1280 + i, windows[i]);
|
||||||
|
// }
|
||||||
sl.writeInt(13, 0, 0x1010, tseI0.getValue());
|
//
|
||||||
sl.writeInt(13, 0, 0x1011, tseI1.getValue());
|
//
|
||||||
sl.writeInt(13, 0, 0x1012, tseI2.getValue());
|
// sl.writeInt(13, 0, 0x1010, tseI0.getValue());
|
||||||
sl.writeInt(13, 0, 0x1013, tseI3.getValue());
|
// sl.writeInt(13, 0, 0x1011, tseI1.getValue());
|
||||||
|
// sl.writeInt(13, 0, 0x1012, tseI2.getValue());
|
||||||
/* Konfiguration auf Live-System übertragen */
|
// sl.writeInt(13, 0, 0x1013, tseI3.getValue());
|
||||||
sl.writeInt(13, 0, 0x1001, 1);
|
//
|
||||||
} catch (Exception e){
|
// /* Konfiguration auf Live-System übertragen */
|
||||||
e.printStackTrace();
|
// sl.writeInt(13, 0, 0x1001, 1);
|
||||||
}
|
// } catch (Exception e){
|
||||||
}
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
class ChannelConfiguration{
|
// }
|
||||||
|
//
|
||||||
int channel;
|
// class ChannelConfiguration{
|
||||||
|
//
|
||||||
public ChannelConfiguration(int channel) {
|
// int channel;
|
||||||
this.channel = channel;
|
//
|
||||||
}
|
// public ChannelConfiguration(int channel) {
|
||||||
|
// this.channel = channel;
|
||||||
@TableColumn(label="Channel",width=80,order=0)
|
// }
|
||||||
public int getChannel(){
|
//
|
||||||
return channel;
|
// @TableColumn(label="Channel",width=80,order=0)
|
||||||
}
|
// public int getChannel(){
|
||||||
|
// return channel;
|
||||||
@TableColumn(label="Ausgang",width=80,order=10)
|
// }
|
||||||
public Boolean getOutput(){
|
//
|
||||||
return (outputs & 1<<channel) == 0 ? false : true;
|
// @TableColumn(label="Ausgang",width=80,order=10)
|
||||||
}
|
// public Boolean getOutput(){
|
||||||
public void setOutput(Boolean value){
|
// return (outputs & 1<<channel) == 0 ? false : true;
|
||||||
outputs &= ~(1<<channel);
|
// }
|
||||||
if (value){
|
// public void setOutput(Boolean value){
|
||||||
outputs |= (1<<channel);
|
// outputs &= ~(1<<channel);
|
||||||
}
|
// if (value){
|
||||||
}
|
// outputs |= (1<<channel);
|
||||||
|
// }
|
||||||
@TableColumn(label="Passiver Schalter",width=80,order=20)
|
// }
|
||||||
public Boolean getPullup(){
|
//
|
||||||
return (pullups & 1<<channel) == 0 ? false : true;
|
// @TableColumn(label="Passiver Schalter",width=80,order=20)
|
||||||
}
|
// public Boolean getPullup(){
|
||||||
public void setPullup(Boolean value){
|
// return (pullups & 1<<channel) == 0 ? false : true;
|
||||||
pullups &= ~(1<<channel);
|
// }
|
||||||
if (value){
|
// public void setPullup(Boolean value){
|
||||||
pullups |= (1<<channel);
|
// pullups &= ~(1<<channel);
|
||||||
}
|
// if (value){
|
||||||
}
|
// pullups |= (1<<channel);
|
||||||
|
// }
|
||||||
@TableColumn(label="Invertiert",width=80,order=30)
|
// }
|
||||||
public Boolean getInvert(){
|
//
|
||||||
return (inverts & 1<<channel) == 0 ? false : true;
|
// @TableColumn(label="Invertiert",width=80,order=30)
|
||||||
}
|
// public Boolean getInvert(){
|
||||||
public void setInvert(Boolean value){
|
// return (inverts & 1<<channel) == 0 ? false : true;
|
||||||
inverts &= ~(1<<channel);
|
// }
|
||||||
if (value){
|
// public void setInvert(Boolean value){
|
||||||
inverts |= (1<<channel);
|
// inverts &= ~(1<<channel);
|
||||||
}
|
// if (value){
|
||||||
}
|
// inverts |= (1<<channel);
|
||||||
|
// }
|
||||||
@TableColumn(label="Löst Snapshot aus",width=80,order=40)
|
// }
|
||||||
public Boolean getTrigger(){
|
//
|
||||||
return (trigger & 1<<channel) == 0 ? false : true;
|
// @TableColumn(label="Löst Snapshot aus",width=80,order=40)
|
||||||
}
|
// public Boolean getTrigger(){
|
||||||
public void setTrigger(Boolean value){
|
// return (trigger & 1<<channel) == 0 ? false : true;
|
||||||
trigger &= ~(1<<channel);
|
// }
|
||||||
if (value){
|
// public void setTrigger(Boolean value){
|
||||||
trigger |= (1<<channel);
|
// trigger &= ~(1<<channel);
|
||||||
}
|
// if (value){
|
||||||
}
|
// trigger |= (1<<channel);
|
||||||
|
// }
|
||||||
@TableColumn(label="Signalfenster",width=80,order=200)
|
// }
|
||||||
public Integer getWindow(){
|
//
|
||||||
return windows[channel];
|
// @TableColumn(label="Signalfenster",width=80,order=200)
|
||||||
}
|
// public Integer getWindow(){
|
||||||
public void setWindow(Integer value){
|
// return windows[channel];
|
||||||
windows[channel] = value;
|
// }
|
||||||
}
|
// public void setWindow(Integer value){
|
||||||
|
// windows[channel] = value;
|
||||||
@TableColumn(label="Signalfilter",width=80,order=210)
|
// }
|
||||||
public Integer getFilter(){
|
//
|
||||||
return filter[channel];
|
// @TableColumn(label="Signalfilter",width=80,order=210)
|
||||||
}
|
// public Integer getFilter(){
|
||||||
public void setFilter(Integer value){
|
// return filter[channel];
|
||||||
filter[channel] = value;
|
// }
|
||||||
}
|
// public void setFilter(Integer value){
|
||||||
|
// filter[channel] = value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import javax.swing.border.EmptyBorder;
|
||||||
import org.hwo.datetime.DateTime;
|
import org.hwo.datetime.DateTime;
|
||||||
import org.hwo.pulscounter.PulsCounterApplication;
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
import org.hwo.pulscounter.SnapshotManager.Notification;
|
|
||||||
import org.hwo.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
|
@ -27,352 +26,352 @@ import javax.swing.JButton;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
public class DeviceTestFrame extends JFrame implements PulsCounterApplicationListener {
|
public class DeviceTestFrame extends JFrame { //implements PulsCounterApplicationListener {
|
||||||
|
|
||||||
private JPanel contentPane;
|
// private JPanel contentPane;
|
||||||
private JTextField tfCommunication;
|
// private JTextField tfCommunication;
|
||||||
private JTextField tfEEPROM;
|
// private JTextField tfEEPROM;
|
||||||
private JTextField tfIO;
|
// private JTextField tfIO;
|
||||||
private JTextField tfAD;
|
// private JTextField tfAD;
|
||||||
private JTextField tfSerial;
|
// private JTextField tfSerial;
|
||||||
|
//
|
||||||
private Timer reconnectTimer;
|
// private Timer reconnectTimer;
|
||||||
|
//
|
||||||
private DeviceChecker deviceChecker;
|
// private DeviceChecker deviceChecker;
|
||||||
private JList lMessages;
|
// private JList lMessages;
|
||||||
private DefaultListModel<String> messageListModel;
|
// private DefaultListModel<String> messageListModel;
|
||||||
|
//
|
||||||
private PulsCounterApplication pulsCounterApplication;
|
// private PulsCounterApplication pulsCounterApplication;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create the frame.
|
// * Create the frame.
|
||||||
*/
|
// */
|
||||||
public DeviceTestFrame(PulsCounterApplication pulsCounterApplication) {
|
// public DeviceTestFrame(PulsCounterApplication pulsCounterApplication) {
|
||||||
this.pulsCounterApplication = pulsCounterApplication;
|
// this.pulsCounterApplication = pulsCounterApplication;
|
||||||
|
//
|
||||||
setTitle("Device Test Frame");
|
// setTitle("Device Test Frame");
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setBounds(100, 100, 701, 464);
|
// setBounds(100, 100, 701, 464);
|
||||||
contentPane = new JPanel();
|
// contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
// setContentPane(contentPane);
|
||||||
GridBagLayout gbl_contentPane = new GridBagLayout();
|
// GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||||
gbl_contentPane.columnWidths = new int[]{0, 0, 0};
|
// gbl_contentPane.columnWidths = new int[]{0, 0, 0};
|
||||||
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
// gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
// gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
// gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
contentPane.setLayout(gbl_contentPane);
|
// contentPane.setLayout(gbl_contentPane);
|
||||||
|
//
|
||||||
JLabel lblKommunikation = new JLabel("Communication:");
|
// JLabel lblKommunikation = new JLabel("Communication:");
|
||||||
GridBagConstraints gbc_lblKommunikation = new GridBagConstraints();
|
// GridBagConstraints gbc_lblKommunikation = new GridBagConstraints();
|
||||||
gbc_lblKommunikation.anchor = GridBagConstraints.EAST;
|
// gbc_lblKommunikation.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblKommunikation.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblKommunikation.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblKommunikation.gridx = 0;
|
// gbc_lblKommunikation.gridx = 0;
|
||||||
gbc_lblKommunikation.gridy = 0;
|
// gbc_lblKommunikation.gridy = 0;
|
||||||
contentPane.add(lblKommunikation, gbc_lblKommunikation);
|
// contentPane.add(lblKommunikation, gbc_lblKommunikation);
|
||||||
|
//
|
||||||
tfCommunication = new JTextField();
|
// tfCommunication = new JTextField();
|
||||||
GridBagConstraints gbc_tfCommunication = new GridBagConstraints();
|
// GridBagConstraints gbc_tfCommunication = new GridBagConstraints();
|
||||||
gbc_tfCommunication.insets = new Insets(0, 0, 5, 0);
|
// gbc_tfCommunication.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_tfCommunication.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_tfCommunication.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfCommunication.gridx = 1;
|
// gbc_tfCommunication.gridx = 1;
|
||||||
gbc_tfCommunication.gridy = 0;
|
// gbc_tfCommunication.gridy = 0;
|
||||||
contentPane.add(tfCommunication, gbc_tfCommunication);
|
// contentPane.add(tfCommunication, gbc_tfCommunication);
|
||||||
tfCommunication.setColumns(10);
|
// tfCommunication.setColumns(10);
|
||||||
|
//
|
||||||
JLabel lblLeds = new JLabel("LEDs:");
|
// JLabel lblLeds = new JLabel("LEDs:");
|
||||||
GridBagConstraints gbc_lblLeds = new GridBagConstraints();
|
// GridBagConstraints gbc_lblLeds = new GridBagConstraints();
|
||||||
gbc_lblLeds.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblLeds.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblLeds.gridx = 0;
|
// gbc_lblLeds.gridx = 0;
|
||||||
gbc_lblLeds.gridy = 1;
|
// gbc_lblLeds.gridy = 1;
|
||||||
contentPane.add(lblLeds, gbc_lblLeds);
|
// contentPane.add(lblLeds, gbc_lblLeds);
|
||||||
|
//
|
||||||
JLabel lblEeprom = new JLabel("EEPROM:");
|
// JLabel lblEeprom = new JLabel("EEPROM:");
|
||||||
GridBagConstraints gbc_lblEeprom = new GridBagConstraints();
|
// GridBagConstraints gbc_lblEeprom = new GridBagConstraints();
|
||||||
gbc_lblEeprom.anchor = GridBagConstraints.EAST;
|
// gbc_lblEeprom.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblEeprom.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblEeprom.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblEeprom.gridx = 0;
|
// gbc_lblEeprom.gridx = 0;
|
||||||
gbc_lblEeprom.gridy = 2;
|
// gbc_lblEeprom.gridy = 2;
|
||||||
contentPane.add(lblEeprom, gbc_lblEeprom);
|
// contentPane.add(lblEeprom, gbc_lblEeprom);
|
||||||
|
//
|
||||||
tfEEPROM = new JTextField();
|
// tfEEPROM = new JTextField();
|
||||||
GridBagConstraints gbc_tfEEPROM = new GridBagConstraints();
|
// GridBagConstraints gbc_tfEEPROM = new GridBagConstraints();
|
||||||
gbc_tfEEPROM.insets = new Insets(0, 0, 5, 0);
|
// gbc_tfEEPROM.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_tfEEPROM.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_tfEEPROM.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfEEPROM.gridx = 1;
|
// gbc_tfEEPROM.gridx = 1;
|
||||||
gbc_tfEEPROM.gridy = 2;
|
// gbc_tfEEPROM.gridy = 2;
|
||||||
contentPane.add(tfEEPROM, gbc_tfEEPROM);
|
// contentPane.add(tfEEPROM, gbc_tfEEPROM);
|
||||||
tfEEPROM.setColumns(10);
|
// tfEEPROM.setColumns(10);
|
||||||
|
//
|
||||||
JLabel lblIoCircuit = new JLabel("I/O Circuit:");
|
// JLabel lblIoCircuit = new JLabel("I/O Circuit:");
|
||||||
GridBagConstraints gbc_lblIoCircuit = new GridBagConstraints();
|
// GridBagConstraints gbc_lblIoCircuit = new GridBagConstraints();
|
||||||
gbc_lblIoCircuit.anchor = GridBagConstraints.EAST;
|
// gbc_lblIoCircuit.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblIoCircuit.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblIoCircuit.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblIoCircuit.gridx = 0;
|
// gbc_lblIoCircuit.gridx = 0;
|
||||||
gbc_lblIoCircuit.gridy = 3;
|
// gbc_lblIoCircuit.gridy = 3;
|
||||||
contentPane.add(lblIoCircuit, gbc_lblIoCircuit);
|
// contentPane.add(lblIoCircuit, gbc_lblIoCircuit);
|
||||||
|
//
|
||||||
tfIO = new JTextField();
|
// tfIO = new JTextField();
|
||||||
GridBagConstraints gbc_tfIO = new GridBagConstraints();
|
// GridBagConstraints gbc_tfIO = new GridBagConstraints();
|
||||||
gbc_tfIO.insets = new Insets(0, 0, 5, 0);
|
// gbc_tfIO.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_tfIO.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_tfIO.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfIO.gridx = 1;
|
// gbc_tfIO.gridx = 1;
|
||||||
gbc_tfIO.gridy = 3;
|
// gbc_tfIO.gridy = 3;
|
||||||
contentPane.add(tfIO, gbc_tfIO);
|
// contentPane.add(tfIO, gbc_tfIO);
|
||||||
tfIO.setColumns(10);
|
// tfIO.setColumns(10);
|
||||||
|
//
|
||||||
JLabel lblAdConverters = new JLabel("A/D Converters:");
|
// JLabel lblAdConverters = new JLabel("A/D Converters:");
|
||||||
GridBagConstraints gbc_lblAdConverters = new GridBagConstraints();
|
// GridBagConstraints gbc_lblAdConverters = new GridBagConstraints();
|
||||||
gbc_lblAdConverters.anchor = GridBagConstraints.EAST;
|
// gbc_lblAdConverters.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblAdConverters.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblAdConverters.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblAdConverters.gridx = 0;
|
// gbc_lblAdConverters.gridx = 0;
|
||||||
gbc_lblAdConverters.gridy = 4;
|
// gbc_lblAdConverters.gridy = 4;
|
||||||
contentPane.add(lblAdConverters, gbc_lblAdConverters);
|
// contentPane.add(lblAdConverters, gbc_lblAdConverters);
|
||||||
|
//
|
||||||
tfAD = new JTextField();
|
// tfAD = new JTextField();
|
||||||
GridBagConstraints gbc_tfAD = new GridBagConstraints();
|
// GridBagConstraints gbc_tfAD = new GridBagConstraints();
|
||||||
gbc_tfAD.insets = new Insets(0, 0, 5, 0);
|
// gbc_tfAD.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_tfAD.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_tfAD.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfAD.gridx = 1;
|
// gbc_tfAD.gridx = 1;
|
||||||
gbc_tfAD.gridy = 4;
|
// gbc_tfAD.gridy = 4;
|
||||||
contentPane.add(tfAD, gbc_tfAD);
|
// contentPane.add(tfAD, gbc_tfAD);
|
||||||
tfAD.setColumns(10);
|
// tfAD.setColumns(10);
|
||||||
|
//
|
||||||
JLabel lblSerial = new JLabel("Serial:");
|
// JLabel lblSerial = new JLabel("Serial:");
|
||||||
GridBagConstraints gbc_lblSerial = new GridBagConstraints();
|
// GridBagConstraints gbc_lblSerial = new GridBagConstraints();
|
||||||
gbc_lblSerial.anchor = GridBagConstraints.EAST;
|
// gbc_lblSerial.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblSerial.insets = new Insets(0, 0, 5, 5);
|
// gbc_lblSerial.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblSerial.gridx = 0;
|
// gbc_lblSerial.gridx = 0;
|
||||||
gbc_lblSerial.gridy = 5;
|
// gbc_lblSerial.gridy = 5;
|
||||||
contentPane.add(lblSerial, gbc_lblSerial);
|
// contentPane.add(lblSerial, gbc_lblSerial);
|
||||||
|
//
|
||||||
tfSerial = new JTextField();
|
// tfSerial = new JTextField();
|
||||||
GridBagConstraints gbc_tfSerial = new GridBagConstraints();
|
// GridBagConstraints gbc_tfSerial = new GridBagConstraints();
|
||||||
gbc_tfSerial.insets = new Insets(0, 0, 5, 0);
|
// gbc_tfSerial.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_tfSerial.fill = GridBagConstraints.HORIZONTAL;
|
// gbc_tfSerial.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_tfSerial.gridx = 1;
|
// gbc_tfSerial.gridx = 1;
|
||||||
gbc_tfSerial.gridy = 5;
|
// gbc_tfSerial.gridy = 5;
|
||||||
contentPane.add(tfSerial, gbc_tfSerial);
|
// contentPane.add(tfSerial, gbc_tfSerial);
|
||||||
tfSerial.setColumns(10);
|
// tfSerial.setColumns(10);
|
||||||
|
//
|
||||||
JButton btnSetDevice = new JButton("Confirm Device");
|
// JButton btnSetDevice = new JButton("Confirm Device");
|
||||||
GridBagConstraints gbc_btnSetDevice = new GridBagConstraints();
|
// GridBagConstraints gbc_btnSetDevice = new GridBagConstraints();
|
||||||
gbc_btnSetDevice.insets = new Insets(0, 0, 5, 0);
|
// gbc_btnSetDevice.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_btnSetDevice.gridx = 1;
|
// gbc_btnSetDevice.gridx = 1;
|
||||||
gbc_btnSetDevice.gridy = 6;
|
// gbc_btnSetDevice.gridy = 6;
|
||||||
contentPane.add(btnSetDevice, gbc_btnSetDevice);
|
// contentPane.add(btnSetDevice, gbc_btnSetDevice);
|
||||||
|
//
|
||||||
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;
|
||||||
gbc_scrollPane.gridwidth = 2;
|
// gbc_scrollPane.gridwidth = 2;
|
||||||
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
// gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
||||||
gbc_scrollPane.gridx = 0;
|
// gbc_scrollPane.gridx = 0;
|
||||||
gbc_scrollPane.gridy = 7;
|
// gbc_scrollPane.gridy = 7;
|
||||||
contentPane.add(scrollPane, gbc_scrollPane);
|
// contentPane.add(scrollPane, gbc_scrollPane);
|
||||||
|
//
|
||||||
lMessages = new JList();
|
// lMessages = new JList();
|
||||||
scrollPane.setViewportView(lMessages);
|
// scrollPane.setViewportView(lMessages);
|
||||||
|
//
|
||||||
this.initialize();
|
// this.initialize();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private PulsCounterApplication application(){
|
// private PulsCounterApplication application(){
|
||||||
return this.pulsCounterApplication;
|
// return this.pulsCounterApplication;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void initialize(){
|
// private void initialize(){
|
||||||
this.reconnectTimer = new Timer("Reconnection Timer");
|
// this.reconnectTimer = new Timer("Reconnection Timer");
|
||||||
|
//
|
||||||
messageListModel = new DefaultListModel<String>();
|
// messageListModel = new DefaultListModel<String>();
|
||||||
lMessages.setModel(messageListModel);
|
// lMessages.setModel(messageListModel);
|
||||||
|
//
|
||||||
application().addPulsCounterApplicationListener(this);
|
// application().addPulsCounterApplicationListener(this);
|
||||||
|
//
|
||||||
setVisible(true);
|
// setVisible(true);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/*
|
// /*
|
||||||
@Override
|
// @Override
|
||||||
public void connectionStateChanged(Boolean connected) {
|
// public void connectionStateChanged(Boolean connected) {
|
||||||
|
//
|
||||||
if (!connected){
|
// if (!connected){
|
||||||
tfCommunication.setText("NO CONNECTION");
|
// tfCommunication.setText("NO CONNECTION");
|
||||||
if (this.deviceChecker != null){
|
// if (this.deviceChecker != null){
|
||||||
this.deviceChecker.cancel();
|
// this.deviceChecker.cancel();
|
||||||
}
|
// }
|
||||||
reconnectTimer.schedule(new TimerTask() {
|
// reconnectTimer.schedule(new TimerTask() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
if (!application().getServiceLink().isOpen()){
|
// if (!application().getServiceLink().isOpen()){
|
||||||
try {
|
// try {
|
||||||
application().getServiceLink().open();
|
// application().getServiceLink().open();
|
||||||
} catch (ServiceLinkException e) {
|
// } catch (ServiceLinkException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, 3000);
|
// }, 3000);
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
if (this.deviceChecker != null){
|
// if (this.deviceChecker != null){
|
||||||
while (this.deviceChecker.isAlive()){
|
// while (this.deviceChecker.isAlive()){
|
||||||
try {
|
// try {
|
||||||
Thread.sleep(100);
|
// Thread.sleep(100);
|
||||||
} catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.deviceChecker = new DeviceChecker();
|
// this.deviceChecker = new DeviceChecker();
|
||||||
this.deviceChecker.start();
|
// this.deviceChecker.start();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public synchronized void messageArrived(String message) {
|
// public synchronized void messageArrived(String message) {
|
||||||
if (EventQueue.isDispatchThread()){
|
// if (EventQueue.isDispatchThread()){
|
||||||
int pos = messageListModel.size();
|
// int pos = messageListModel.size();
|
||||||
String t = String.format("%s: %s",DateTime.NOW().getSQLDateTime(),message);
|
// String t = String.format("%s: %s",DateTime.NOW().getSQLDateTime(),message);
|
||||||
messageListModel.addElement(t);
|
// messageListModel.addElement(t);
|
||||||
lMessages.ensureIndexIsVisible(messageListModel.size()-1);
|
// lMessages.ensureIndexIsVisible(messageListModel.size()-1);
|
||||||
} else {
|
// } else {
|
||||||
final String msg = message;
|
// final String msg = message;
|
||||||
EventQueue.invokeLater(new Runnable() {
|
// EventQueue.invokeLater(new Runnable() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
messageArrived(msg);
|
// messageArrived(msg);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
class DeviceChecker extends Thread {
|
// class DeviceChecker extends Thread {
|
||||||
|
//
|
||||||
private boolean cancel;
|
// private boolean cancel;
|
||||||
|
//
|
||||||
public DeviceChecker(){
|
// public DeviceChecker(){
|
||||||
cancel = false;
|
// cancel = false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void cancel(){
|
// public void cancel(){
|
||||||
this.cancel = true;
|
// this.cancel = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
|
//
|
||||||
checkCommunication();
|
// checkCommunication();
|
||||||
checkEEPROM();
|
// checkEEPROM();
|
||||||
checkIO();
|
// checkIO();
|
||||||
checkADC();
|
// checkADC();
|
||||||
|
//
|
||||||
while (!cancel){
|
// while (!cancel){
|
||||||
checkCommunication();
|
// checkCommunication();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void checkCommunication(){
|
// private void checkCommunication(){
|
||||||
if (!this.cancel){
|
// if (!this.cancel){
|
||||||
Integer version = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001A);
|
// Integer version = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x001A);
|
||||||
Integer uptime = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0022);
|
// Integer uptime = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0022);
|
||||||
|
//
|
||||||
if ((version != null)&&(uptime != null)){
|
// if ((version != null)&&(uptime != null)){
|
||||||
tfCommunication.setText(String.format("OK (V: %d.%d.%d) Up: %d:%d:%d",version >> 16, (version >> 8) & 0xff, version & 0xff, uptime / 3600, (uptime / 60)%60, uptime % 60));
|
// tfCommunication.setText(String.format("OK (V: %d.%d.%d) Up: %d:%d:%d",version >> 16, (version >> 8) & 0xff, version & 0xff, uptime / 3600, (uptime / 60)%60, uptime % 60));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void checkEEPROM(){
|
// private void checkEEPROM(){
|
||||||
if (!this.cancel){
|
// if (!this.cancel){
|
||||||
Integer eesize = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x9000);
|
// Integer eesize = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x9000);
|
||||||
if (eesize != null){
|
// if (eesize != null){
|
||||||
tfEEPROM.setText(String.format("EEPROM Size Detected: 0x%08x Bytes (%d kBytes)", eesize, (eesize >> 10)));
|
// tfEEPROM.setText(String.format("EEPROM Size Detected: 0x%08x Bytes (%d kBytes)", eesize, (eesize >> 10)));
|
||||||
} else {
|
// } else {
|
||||||
tfEEPROM.setText("EEPROM failed.");
|
// tfEEPROM.setText("EEPROM failed.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void checkIO(){
|
// private void checkIO(){
|
||||||
if (!this.cancel){
|
// if (!this.cancel){
|
||||||
|
//
|
||||||
application().message("I/O test begins...");
|
// application().message("I/O test begins...");
|
||||||
application().message("I/O reset...");
|
// application().message("I/O reset...");
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0682, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0682, 0);
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0683, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0683, 0);
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0684, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0684, 0);
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0685, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0685, 0);
|
||||||
|
//
|
||||||
application().message("counter reset.");
|
// application().message("counter reset.");
|
||||||
for (int i=0;i<32;i++){
|
// for (int i=0;i<32;i++){
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0600 + i, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0600 + i, 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
application().message("PullUP-Counter test.");
|
// application().message("PullUP-Counter test.");
|
||||||
for (int i=0;i<12;i++){
|
// for (int i=0;i<12;i++){
|
||||||
Thread.sleep(250);
|
// Thread.sleep(250);
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0683, -1);
|
// application().getServiceLink().writeInt(13, 0, 0x0683, -1);
|
||||||
Thread.sleep(250);
|
// Thread.sleep(250);
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0683, 0);
|
// application().getServiceLink().writeInt(13, 0, 0x0683, 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// for (int i=0;i<32;i++){
|
||||||
Thread.sleep(100);
|
// Thread.sleep(100);
|
||||||
|
//
|
||||||
Integer c = application().getServiceLink().readInt(13, 0, 0x0600 + i);
|
// Integer c = application().getServiceLink().readInt(13, 0, 0x0600 + i);
|
||||||
if ((c != null) && (c.equals(12))){
|
// if ((c != null) && (c.equals(12))){
|
||||||
application().message(String.format("OK: Channel %d counted %d events.", i, c));
|
// application().message(String.format("OK: Channel %d counted %d events.", i, c));
|
||||||
} else {
|
// } else {
|
||||||
application().message(String.format("FAILED: Channel %d counted %d events.", i, c));
|
// application().message(String.format("FAILED: Channel %d counted %d events.", i, c));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
application().message("I/O test finished!");
|
// application().message("I/O test finished!");
|
||||||
} catch (IOException | ServiceLinkException e) {
|
// } catch (IOException | ServiceLinkException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
//
|
||||||
application().message("I/O test FAILED!");
|
// application().message("I/O test FAILED!");
|
||||||
} catch (InterruptedException iex){
|
// } catch (InterruptedException iex){
|
||||||
iex.printStackTrace();
|
// iex.printStackTrace();
|
||||||
|
//
|
||||||
application().message("I/O test FAILED!");
|
// application().message("I/O test FAILED!");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void checkADC(){
|
// private void checkADC(){
|
||||||
if (!this.cancel){
|
// if (!this.cancel){
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication) {
|
// public void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication) {
|
||||||
// TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
// public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
||||||
// TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,6 @@ public class ExportFilesFrame extends JFrame {
|
||||||
btnSchliessen.addActionListener(new ActionListener() {
|
btnSchliessen.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
PulsCounterApplication.getApplication().savePrefs();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.hwo.models.FlexibleObjectListModel;
|
||||||
import org.hwo.platform.Platform;
|
import org.hwo.platform.Platform;
|
||||||
import org.hwo.pulscounter.PulsCounterApplication;
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
import org.hwo.pulscounter.PulsCounterApplicationListener;
|
||||||
import org.hwo.pulscounter.SnapshotManager.Notification;
|
|
||||||
import org.hwo.pulscounter.device.IDeviceConnector;
|
import org.hwo.pulscounter.device.IDeviceConnector;
|
||||||
import org.hwo.pulscounter.device.NoDeviceConnectionException;
|
import org.hwo.pulscounter.device.NoDeviceConnectionException;
|
||||||
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
|
import org.hwo.pulscounter.device.ServiceLinkDeviceConnector;
|
||||||
|
@ -169,51 +168,21 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
if (false){
|
if (false){
|
||||||
|
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
|
|
||||||
knownTasklets = new DefaultListModel<Tasklet>();
|
knownTasklets = new DefaultListModel<Tasklet>();
|
||||||
lTasklets.setModel(knownTasklets);
|
lTasklets.setModel(knownTasklets);
|
||||||
TaskletManager.instance().addTaskletListener(this);
|
TaskletManager.instance().addTaskletListener(this);
|
||||||
|
|
||||||
messageListModel = new DefaultListModel<String>();
|
messageListModel = new DefaultListModel<String>();
|
||||||
lMessages.setModel(messageListModel);
|
lMessages.setModel(messageListModel);
|
||||||
|
|
||||||
timerReconnect = new Timer("ReconnectThread",true);
|
timerReconnect = new Timer("ReconnectThread",true);
|
||||||
|
|
||||||
application().addPulsCounterApplicationListener(this);
|
application().addPulsCounterApplicationListener(this);
|
||||||
|
|
||||||
application().message("Synololog Applikation wurde gestartet.");
|
application().message("Synololog Applikation wurde gestartet.");
|
||||||
|
|
||||||
timerReconnect.scheduleAtFixedRate(new TimerTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateChannelView();
|
|
||||||
}
|
|
||||||
}, 5000, 500);
|
|
||||||
|
|
||||||
timerReconnect.schedule(new TimerTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (application().getServiceLink().isOpen()){
|
|
||||||
application().getSnapshotManager().notify(Notification.SYNC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 15000, 15000);
|
|
||||||
|
|
||||||
timerReconnect.schedule(new TimerTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (application().getServiceLink().isOpen()){
|
|
||||||
if (cbTrimDevice.isSelected()){
|
|
||||||
trimDevice();
|
|
||||||
}
|
|
||||||
syncClock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 52000, 15000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +253,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
channelDisplays[i].setDescriptionText( application().getChannelDescription(i));
|
|
||||||
|
|
||||||
pChannels.add(channelDisplays[i], gbc);
|
pChannels.add(channelDisplays[i], gbc);
|
||||||
}
|
}
|
||||||
|
@ -313,8 +281,8 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
AppSettingsFrame asf = new AppSettingsFrame();
|
AppSettingsFrame asf = new AppSettingsFrame();
|
||||||
asf.setModalityType(ModalityType.APPLICATION_MODAL);
|
asf.setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
|
// if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
|
||||||
asf.debugging();
|
// asf.debugging();
|
||||||
|
|
||||||
asf.setVisible(true);
|
asf.setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -436,7 +404,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
trimTicksOnConnect = null;
|
trimTicksOnConnect = null;
|
||||||
if (cbTrimDevice.isSelected()){
|
if (cbTrimDevice.isSelected()){
|
||||||
trimDevice();
|
// trimDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -716,164 +684,92 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private Integer trimDevice(){
|
||||||
private void updateChannelView(){
|
// try {
|
||||||
Integer inputs,outputs,pullups;
|
//
|
||||||
|
// if (trimTicksOnConnect != null){
|
||||||
if (application().getServiceLink().isOpen()){
|
// long s1,s2,T;
|
||||||
|
// Integer device_us;
|
||||||
inputs = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0681 );
|
//
|
||||||
outputs = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0682 );
|
//
|
||||||
pullups = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0683 );
|
// s1 = System.currentTimeMillis();
|
||||||
|
// device_us = application().getServiceLink().readInt(13, 0, 0x1300);
|
||||||
if (inputs == null)
|
// s2 = System.currentTimeMillis();
|
||||||
inputs = 0;
|
// T = (s1+s2)>>1;
|
||||||
if (outputs == null)
|
//
|
||||||
outputs = 0;
|
// if (device_us < 0){
|
||||||
if (pullups == null)
|
// trimTicksOnConnect = null;
|
||||||
pullups = 0;
|
// } else {
|
||||||
|
// long elapsed_us;
|
||||||
Integer[] values = new Integer[32];
|
// long diff_us;
|
||||||
Float[] analog = new Float[8];
|
// long trim_ns_per_slice;
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// elapsed_us = (T - trimTimeOnConnect) * 1000;
|
||||||
|
// diff_us = elapsed_us - device_us;
|
||||||
|
//
|
||||||
if (i<8){
|
// System.err.println(String.format("Device Triming: Elapsed us: Dev: %d PC %d Diff: %d", device_us,elapsed_us,diff_us));
|
||||||
analog[i] = application().getServiceLink().getServiceRegisterCache().getCachedFloat(13, 0, 0x8000 + i ) * 10;
|
//
|
||||||
}
|
// trim_ns_per_slice = (diff_us * 1000) * trimDeviceTimeSlice / elapsed_us;
|
||||||
|
//
|
||||||
};
|
// smoothTrim.cycle((int)trim_ns_per_slice);
|
||||||
|
//
|
||||||
for (int i=0;i<32;i++){
|
// System.err.println(String.format("Device Triming: Trim %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
||||||
channelDisplays[i].setInput( (inputs & 1<<i) != 0 );
|
//
|
||||||
channelDisplays[i].setOutput( (outputs & 1<<i) != 0);
|
// application().getServiceLink().writeInt(13, 0, 0x1002, smoothTrim.getWert());
|
||||||
channelDisplays[i].setPullup( (pullups & 1<<i) != 0);
|
//
|
||||||
channelDisplays[i].setCounter(values[i]);
|
// application().message(String.format("Trimmung wurde korrigiert auf %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
||||||
|
//
|
||||||
if (i<8){
|
// }
|
||||||
channelDisplays[i].setVoltage(new Double(analog[i]));
|
// } else {
|
||||||
}
|
// long s1,s2,T;
|
||||||
}
|
//
|
||||||
|
// try {
|
||||||
Calendar calendar = Calendar.getInstance();
|
// trimTicksOnConnect = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0027);
|
||||||
|
// s1 = System.currentTimeMillis();
|
||||||
|
// application().getServiceLink().writeInt(13, 0, 0x1301, 0);
|
||||||
|
// s2 = System.currentTimeMillis();
|
||||||
try {
|
// trimTimeOnConnect = (s1+s2)>>1;
|
||||||
Integer deviceTime = application().getServiceLink().readInt(13, 0, 0x001C);
|
//
|
||||||
Long delta = deviceTime - (System.currentTimeMillis()/1000);
|
// smoothTrim = new Smoother();
|
||||||
|
// smoothTrim.setTn( 10 );
|
||||||
if ((delta < -1) || (delta > 1)){
|
// smoothTrim.setWert( application().getServiceLink().readInt(13, 0, 0x1002) );
|
||||||
application().message(String.format("Abweichung ist %d Sekunde(-n)",delta));
|
//
|
||||||
application().getServiceLink().writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
|
// } catch (Exception e){
|
||||||
application().message("Uhr der Elektronik wurde korrigiert.");
|
// System.err.println("trimDevice(): init failed");
|
||||||
|
// e.printStackTrace();
|
||||||
}
|
// trimTicksOnConnect = null;
|
||||||
} catch (ServiceLinkRequestFailedException e) {
|
// }
|
||||||
e.printStackTrace();
|
// }
|
||||||
} catch (IOException e) {
|
//
|
||||||
e.printStackTrace();
|
//
|
||||||
} catch (ServiceLinkException e) {
|
// } catch (Exception e){
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
|
// return null;
|
||||||
checkForAssertions();
|
// }
|
||||||
|
//
|
||||||
}
|
//
|
||||||
|
// private void checkForAssertions(){
|
||||||
}
|
// Integer assert_error,assert_code;
|
||||||
|
//
|
||||||
private Integer syncClock(){
|
// try
|
||||||
return null;
|
// {
|
||||||
}
|
// assert_error = -1;
|
||||||
|
// for (int i=0;i<8;i++){
|
||||||
private Integer trimDevice(){
|
// assert_error = application().getServiceLink().readInt(13, 0, 0x0026);
|
||||||
try {
|
// assert_code = application().getServiceLink().readInt(13, 0, 0x0025);
|
||||||
|
//
|
||||||
if (trimTicksOnConnect != null){
|
// if (assert_error >= 0)
|
||||||
long s1,s2,T;
|
// break;
|
||||||
Integer device_us;
|
//
|
||||||
|
// application().message(String.format("Assertion: Error: 0x%08x (%d) Position: 0x%04x Mark: %d", assert_error,assert_error, assert_code & 0xffff, (assert_code >> 16) & 0xffff));
|
||||||
|
// application().getServiceLink().writeInt(13, 0, 0x0025, -1);
|
||||||
s1 = System.currentTimeMillis();
|
// };
|
||||||
device_us = application().getServiceLink().readInt(13, 0, 0x1300);
|
// } catch (Exception ex){
|
||||||
s2 = System.currentTimeMillis();
|
// System.err.println("Exception while checking for assertions...");
|
||||||
T = (s1+s2)>>1;
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
if (device_us < 0){
|
// }
|
||||||
trimTicksOnConnect = null;
|
|
||||||
} else {
|
|
||||||
long elapsed_us;
|
|
||||||
long diff_us;
|
|
||||||
long trim_ns_per_slice;
|
|
||||||
|
|
||||||
elapsed_us = (T - trimTimeOnConnect) * 1000;
|
|
||||||
diff_us = elapsed_us - device_us;
|
|
||||||
|
|
||||||
System.err.println(String.format("Device Triming: Elapsed us: Dev: %d PC %d Diff: %d", device_us,elapsed_us,diff_us));
|
|
||||||
|
|
||||||
trim_ns_per_slice = (diff_us * 1000) * trimDeviceTimeSlice / elapsed_us;
|
|
||||||
|
|
||||||
smoothTrim.cycle((int)trim_ns_per_slice);
|
|
||||||
|
|
||||||
System.err.println(String.format("Device Triming: Trim %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
|
||||||
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x1002, smoothTrim.getWert());
|
|
||||||
|
|
||||||
application().message(String.format("Trimmung wurde korrigiert auf %dns / %dus",smoothTrim.getWert(),trimDeviceTimeSlice));
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
long s1,s2,T;
|
|
||||||
|
|
||||||
try {
|
|
||||||
trimTicksOnConnect = application().getServiceLink().getServiceRegisterCache().getCachedInteger(13, 0, 0x0027);
|
|
||||||
s1 = System.currentTimeMillis();
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x1301, 0);
|
|
||||||
s2 = System.currentTimeMillis();
|
|
||||||
trimTimeOnConnect = (s1+s2)>>1;
|
|
||||||
|
|
||||||
smoothTrim = new Smoother();
|
|
||||||
smoothTrim.setTn( 10 );
|
|
||||||
smoothTrim.setWert( application().getServiceLink().readInt(13, 0, 0x1002) );
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
System.err.println("trimDevice(): init failed");
|
|
||||||
e.printStackTrace();
|
|
||||||
trimTicksOnConnect = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void checkForAssertions(){
|
|
||||||
Integer assert_error,assert_code;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
assert_error = -1;
|
|
||||||
for (int i=0;i<8;i++){
|
|
||||||
assert_error = application().getServiceLink().readInt(13, 0, 0x0026);
|
|
||||||
assert_code = application().getServiceLink().readInt(13, 0, 0x0025);
|
|
||||||
|
|
||||||
if (assert_error >= 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
application().message(String.format("Assertion: Error: 0x%08x (%d) Position: 0x%04x Mark: %d", assert_error,assert_error, assert_code & 0xffff, (assert_code >> 16) & 0xffff));
|
|
||||||
application().getServiceLink().writeInt(13, 0, 0x0025, -1);
|
|
||||||
};
|
|
||||||
} catch (Exception ex){
|
|
||||||
System.err.println("Exception while checking for assertions...");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void taskletQueued(final TaskletManager manager, final Tasklet tasklet) {
|
public synchronized void taskletQueued(final TaskletManager manager, final Tasklet tasklet) {
|
||||||
|
@ -943,7 +839,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private void channelSetDescription(ChannelDisplay display){
|
private void channelSetDescription(ChannelDisplay display){
|
||||||
for (int n=0;n<32;n++){
|
for (int n=0;n<32;n++){
|
||||||
if (display == channelDisplays[n]){
|
if (display == channelDisplays[n]){
|
||||||
application().setChannelDescription(n, display.getDescriptionText());
|
// application().setChannelDescription(n, display.getDescriptionText());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -969,8 +865,11 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
private int timeout;
|
private int timeout;
|
||||||
private boolean exit;
|
private boolean exit;
|
||||||
|
|
||||||
|
private int checkTimeout;
|
||||||
|
|
||||||
public BackgroundThread(){
|
public BackgroundThread(){
|
||||||
timeout = 500;
|
timeout = 500;
|
||||||
|
checkTimeout = 0;
|
||||||
exit = false;
|
exit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,6 +904,14 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
wait(timeout);
|
wait(timeout);
|
||||||
|
|
||||||
updateDeviceView();
|
updateDeviceView();
|
||||||
|
|
||||||
|
if (checkTimeout > 0){
|
||||||
|
checkTimeout--;
|
||||||
|
} else {
|
||||||
|
checkTimeout = 10;
|
||||||
|
application().checkForSnapShots();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (InterruptedException e){
|
} catch (InterruptedException e){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue