Sammelupdate 20160915 / HSQLDB, MultiDevice

WIP-PC2
Harald Wolff 2016-09-15 16:52:11 +02:00
parent 84e912b73e
commit 0582ec77e6
11 changed files with 1115 additions and 644 deletions

View File

@ -119,84 +119,83 @@ public class ExportSetting {
c.setTime(d); c.setTime(d);
return filename return filename
.replaceAll("\\%S", String.format("%d", ss.getDeviceSerial()))
.replaceAll("\\%Y", String.format("%04d", new Integer(c.get(Calendar.YEAR)))) .replaceAll("\\%Y", String.format("%04d", new Integer(c.get(Calendar.YEAR))))
.replaceAll("\\%M", String.format("%02d", new Integer(c.get(Calendar.MONTH)+1))) .replaceAll("\\%M", String.format("%02d", new Integer(c.get(Calendar.MONTH)+1)))
.replaceAll("\\%D", String.format("%02d", new Integer(c.get(Calendar.DAY_OF_MONTH)))); .replaceAll("\\%D", String.format("%02d", new Integer(c.get(Calendar.DAY_OF_MONTH))));
} }
public void export(){ public void export(){
// SnapshotManager ssm = PulsCounterApplication.getApplication().getSnapshotManager(); Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
//
// Hashtable<String, CSV> hash = new Hashtable<String, CSV>(); for (SnapShot ss: PulsCounterApplication.getApplication().getDatabase().loadSnapshots(0))
// {
// for (int n=0;n<ssm.size();n++){ String fn = calculateFileName(fileName, ss);
// SnapShot ss = ssm.loadSnapShot(n);
// String fn = calculateFileName(fileName, ss); if ((triggerType==TriggerType.ALL)||(ss.getTriggerType()==triggerType)){
// if (triggerSource.equals(-1) || triggerSource.equals(ss.getSource())){
// if ((triggerType==TriggerType.ALL)||(ss.getTriggerType()==triggerType)){
// if (triggerSource.equals(-1) || triggerSource.equals(ss.getSource())){ if (!hash.containsKey(fn)){
// hash.put(fn, new CSV());
// if (!hash.containsKey(fn)){ if (extended){
// hash.put(fn, new CSV()); hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
// if (extended){ "Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
// hash.get(fn).getRecords().add(new CSVRecord(new Object[]{ "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
// "Zeitstempel", "Datum/Zeit", "Trigger", "Quelle", "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
// "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7", "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
// "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15", "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
// "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23", "AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
// "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31", } else {
// "AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"})); hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
// } else { "Datum/Zeit",
// hash.get(fn).getRecords().add(new CSVRecord(new Object[]{ "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
// "Datum/Zeit", "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
// "CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7", "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
// "CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15", "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
// "CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23", "AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
// "CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31", }
// "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()){
// if (recordDelta){
// for (String fn: hash.keySet()){ CSV csv = hash.get(fn);
// if (recordDelta){ if (!csv.getRecords().isEmpty()){
// CSV csv = hash.get(fn); Iterator<CSVRecord> iter = csv.getRecords().iterator();
// if (!csv.getRecords().isEmpty()){
// Iterator<CSVRecord> iter = csv.getRecords().iterator(); iter.next();
//
// iter.next(); CSVRecord n = iter.next();
// Integer[] vals = new Integer[32];
// CSVRecord n = iter.next();
// Integer[] vals = new Integer[32]; for (int i=0;i<32;i++){
// vals[i] = n.getIntegerValue(extended ? i + 4 : i + 1 );
// for (int i=0;i<32;i++){ }
// vals[i] = n.getIntegerValue(extended ? i + 4 : i + 1 );
// } while (iter.hasNext()){
// n = iter.next();
// while (iter.hasNext()){
// n = iter.next(); for (int i=0;i<32;i++){
// Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 );
// for (int i=0;i<32;i++){ n.setValue(extended ? i + 4 : i + 1 , v - vals[i]);
// Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 ); vals[i] = v;
// n.setValue(extended ? i + 4 : i + 1 , v - vals[i]); }
// 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));
// }
} }

View File

@ -28,6 +28,7 @@ import org.hsqldb.persist.EventLogInterface;
import org.hwo.StringHelper; import org.hwo.StringHelper;
import org.hwo.configuration.ConfigurableObjects; import org.hwo.configuration.ConfigurableObjects;
import org.hwo.io.NewSerialPort.NewSerialPort; import org.hwo.io.NewSerialPort.NewSerialPort;
import org.hwo.logging.Logging;
import org.hwo.platform.Platform; import org.hwo.platform.Platform;
import org.hwo.servicelink.ServiceLink; import org.hwo.servicelink.ServiceLink;
import org.hwo.servicelink.ServiceLinkListener; import org.hwo.servicelink.ServiceLinkListener;
@ -101,6 +102,7 @@ public class PulsCounterApplication implements ServiceLinkListener{
uiSynchronization = new Object(); uiSynchronization = new Object();
applicationListeners = new LinkedList<PulsCounterApplicationListener>(); applicationListeners = new LinkedList<PulsCounterApplicationListener>();
unseenMessages = new Vector<String>(); unseenMessages = new Vector<String>();
exportSettings = new ArrayList<>();
interfaceClasses = new ArrayList<>(); interfaceClasses = new ArrayList<>();
interfaces = new ArrayList<>(); interfaces = new ArrayList<>();
@ -183,6 +185,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
} }
private static void logStartup(){ private static void logStartup(){
Logging.setLogFileName("synololog.log");
log("Synololog Application Startup"); log("Synololog Application Startup");
log("JAVA Environment: %s (%s)", System.getProperty("java.version"), log("JAVA Environment: %s (%s)", System.getProperty("java.version"),
@ -270,6 +274,20 @@ public class PulsCounterApplication implements ServiceLinkListener{
log(INFO,"Database Schema Version: %s", database.getSchemaVersion()); log(INFO,"Database Schema Version: %s", database.getSchemaVersion());
String sProfiles = database.getProperty("export.profiles");
if (sProfiles != null){
Integer nProfiles = new Integer(sProfiles);
for (int n=0;n<nProfiles;n++){
String profileConf = database.getProperty(String.format("export.profiles.%d",n));
if (profileConf != null){
ExportSetting es = new ExportSetting();
ConfigurableObjects.setConfiguration(es, profileConf);
exportSettings.add(es);
}
}
}
} }
private void shutdown(){ private void shutdown(){
@ -280,10 +298,7 @@ public class PulsCounterApplication implements ServiceLinkListener{
for (Frame frame: JFrame.getFrames()){ for (Frame frame: JFrame.getFrames()){
frame.setVisible(false); frame.setVisible(false);
frame.dispose(); frame.dispose();
} }
database.close();
if (shouldSaveConfiguration){ if (shouldSaveConfiguration){
@ -293,6 +308,15 @@ public class PulsCounterApplication implements ServiceLinkListener{
applicationConfiguration.setProperty(String.format("interfaces.%d.settings", n), interfaces.get(n).getConnectionSettings()); applicationConfiguration.setProperty(String.format("interfaces.%d.settings", n), interfaces.get(n).getConnectionSettings());
} }
for (int n=0;n<exportSettings.size();n++){
String conf = ConfigurableObjects.getConfiguration(exportSettings.get(n));
if (conf != null){
database.setProperty(String.format("export.profiles.%d", n), conf);
}
}
database.setProperty("export.profiles", new Integer(exportSettings.size()).toString());
try { try {
log(INFO,"Save application configuration"); log(INFO,"Save application configuration");
@ -310,17 +334,10 @@ public class PulsCounterApplication implements ServiceLinkListener{
} }
database.close();
/*
this.scheduler.shutdown();
this.snapshotManager.doShutdown();
TaskletManager.instance().shutdown();
this.getServiceLink().close();
this.savePrefs();
*/
} }
@ -403,11 +420,12 @@ public class PulsCounterApplication implements ServiceLinkListener{
public void checkForSnapShots(){ public void checkForSnapShots(){
for (IDeviceConnector idc: this.interfaces){ for (IDeviceConnector idc: this.interfaces){
Integer avail = idc.getAvailableSnapshots(); Integer deviceSerial = idc.getDeviceSerial();
Integer highestIndex = database.highestSnapShot(deviceSerial);
log(INFO,"Interface %s has %d available Snapshots", idc.toString(), avail); log(INFO,"Highest known snapshot index for device #%d is %d", deviceSerial, highestIndex);
SnapShot[] snapshots = idc.readSnapShots(); SnapShot[] snapshots = idc.readSnapShots(highestIndex+1);
if (snapshots != null){ if (snapshots != null){
getDatabase().storeSnapshots(snapshots); getDatabase().storeSnapshots(snapshots);
} }

View File

@ -2,6 +2,8 @@ package org.hwo.pulscounter;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@ -13,6 +15,7 @@ import org.hwo.servicelink.ServiceLinkException;
public class SnapShot { public class SnapShot {
Integer deviceSerial; Integer deviceSerial;
Integer index;
Integer timestamp; Integer timestamp;
Integer field0; Integer field0;
@ -47,6 +50,30 @@ public class SnapShot {
fromBytes(bytes); fromBytes(bytes);
} }
public SnapShot(ResultSet rs) throws SQLException {
this.values = new Integer[32];
this.analog = new Integer[8];
this.deviceSerial = rs.getInt("device");
this.index = rs.getInt("snap_id");
this.timestamp = rs.getInt("timestamp");
this.inputmask = rs.getInt("inputs");
this.outputmask = rs.getInt("outputs");
this.invertmask = rs.getInt("inverts");
this.triggermask = 0;
this.pullupmask = rs.getInt("pullups");
this.field0 = rs.getInt("field0");
Object[] va = (Object[])rs.getArray("counters").getArray();
for (int i=0;i<32;i++){
this.values[i] = (Integer)va[i];
}
va = (Object[])rs.getArray("analogs").getArray();
for (int i=0;i<8;i++){
this.analog[i] = (Integer)va[i];
}
}
public Integer getDeviceSerial() { public Integer getDeviceSerial() {
return deviceSerial; return deviceSerial;
} }
@ -54,6 +81,13 @@ public class SnapShot {
this.deviceSerial = deviceSerial; this.deviceSerial = deviceSerial;
} }
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public void setField0(Integer field0) { public void setField0(Integer field0) {
this.field0 = field0; this.field0 = field0;
} }

View File

@ -5,6 +5,9 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import org.hwo.pulscounter.SnapShot; import org.hwo.pulscounter.SnapShot;
@ -79,14 +82,30 @@ public class PulsCounterDatabase {
return null; return null;
} }
private Object executeSimpleQueryObject(String query,Object... args){
ResultSet result = executeSimpleSQL(query,args);
if (result != null){
try {
if (result.next()){
return result.getObject(1);
}
} catch (SQLException e) {
log(ERROR,"SQL Statement failed: %s",query);
log(ERROR,"Exception: %s", e.toString());
}
}
return null;
}
public String getProperty(String name){ public String getProperty(String name){
return executeVerySimpleQuery("SELECT value FROM properties WHERE name=?", name); return executeVerySimpleQuery("SELECT value FROM props WHERE name=?", name);
} }
public void setProperty(String name,String value){ public void setProperty(String name,String value){
executeSimpleSQL("MERGE INTO properties USING (VALUES(?,?)) as p(name,value) ON properties.name = p.name WHEN MATCHED THEN UPDATE SET properties.value = p.value WHEN NOT MATCHED THEN INSERT VALUES uuid(), p.name, p.value", name,value); executeSimpleSQL("MERGE INTO props USING (VALUES(?,?)) as p(name,value) ON props.name = p.name WHEN MATCHED THEN UPDATE SET props.value = p.value WHEN NOT MATCHED THEN INSERT VALUES uuid(), p.name, p.value", name,value);
} }
public void removeProperty(String name){ public void removeProperty(String name){
executeSimpleSQL("DELETE FROM properties WHERE properties.name = ?", name); executeSimpleSQL("DELETE FROM props WHERE props.name = ?", name);
} }
public String getSchemaVersion(){ public String getSchemaVersion(){
@ -100,21 +119,46 @@ public class PulsCounterDatabase {
} }
private void storeSnapshot(SnapShot snapShot){ private void storeSnapshot(SnapShot snapShot){
log(INFO,"db store snapshot [%d]",snapShot.getIndex());
executeVerySimpleQuery("INSERT INTO snapshots (id,device,timestamp,counters,analogs,inputs,outputs,pullups,inverts) VALUES(uuid(),?,?,?,?,?,?,?,?)",
executeVerySimpleQuery("INSERT INTO snapshots (id,device,snap_id,timestamp,counters,analogs,inputs,outputs,pullups,inverts,field0) VALUES(uuid(),?,?,?,?,?,?,?,?,?,?)",
snapShot.getDeviceSerial(), snapShot.getDeviceSerial(),
snapShot.getIndex(),
snapShot.getTimestamp(), snapShot.getTimestamp(),
snapShot.getValues(), snapShot.getValues(),
snapShot.getAnalog(), snapShot.getAnalog(),
snapShot.getInputmask(), snapShot.getInputmask(),
snapShot.getOutputmask(), snapShot.getOutputmask(),
snapShot.getPullupmask(), snapShot.getPullupmask(),
snapShot.getInvertmask() snapShot.getInvertmask(),
); snapShot.getField0()
);
// (id uuid,device integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer); }
public int highestSnapShot(int deviceSerial){
Integer ind = (Integer)executeSimpleQueryObject("SELECT max(snap_id) FROM snapshots WHERE device=? GROUP BY device", deviceSerial);
if (ind == null){
return -1;
} else {
return ind;
}
}
public SnapShot[] loadSnapshots(int fromTimestamp){
List<SnapShot> snapshots = new LinkedList<>();
ResultSet result = executeSimpleSQL("SELECT id,device,snap_id,timestamp,counters,analogs,inputs,outputs,pullups,inverts,field0 FROM snapshots WHERE timestamp >= ?", fromTimestamp);
try {
while (result.next()){
SnapShot ss = new SnapShot(result);
snapshots.add(ss);
}
} catch (SQLException e) {
log(e);
}
return snapshots.toArray(new SnapShot[0]);
} }

View File

@ -7,8 +7,7 @@
create table props (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 integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer); create table snapshots (id uuid,device integer,snap_id integer,timestamp integer,counters integer array[32],analogs integer array[8],inputs integer,outputs integer,pullups integer,inverts integer,field0 integer);
insert into props (id,name,value) values(uuid(),'db.schema.version','0'); insert into props (id,name,value) values(uuid(),'db.schema.version','0');

View File

@ -30,10 +30,37 @@ public interface IDeviceConnector {
public void setPullups(int pullups); public void setPullups(int pullups);
public int getInverts(); public int getInverts();
public void setInverts(int inverts); public void setInverts(int inverts);
public int getTriggers();
public void setTriggers(int triggers);
public int getConfigOutputs();
public void setConfigOutputs(int outputs);
public int getConfigPullups();
public void setConfigPullups(int pullups);
public int getConfigInverts();
public void setConfigInverts(int inverts);
public int getConfigTriggers();
public void setConfigTriggers(int triggers);
public int getAvailableSnapshots(); public int[] getDebounce();
public void setDebounce(int[] filters);
public int[] getWindows();
public void setWindows(int[] windows);
public int getInterval(int iNo);
public boolean isIntervalDailyBased(int iNo);
public void setInterval(int iNo,int intervall,boolean dailyBase);
public int getDailyBaseMask();
public int getHighestSnapShotIndex();
public SnapShot[] public SnapShot[]
readSnapShots(); readSnapShots(int startIndex);
public SnapShot readSnapShot();
public void reset(int flags);
public void syncConfigToLive();
} }

View File

@ -2,4 +2,10 @@ package org.hwo.pulscounter.device;
public class NoDeviceConnectionException extends RuntimeException { public class NoDeviceConnectionException extends RuntimeException {
public NoDeviceConnectionException(){
}
public NoDeviceConnectionException(Exception cause){
super(cause);
}
} }

View File

@ -2,6 +2,7 @@ package org.hwo.pulscounter.device;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -21,7 +22,6 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
private ServiceLink serviceLink; private ServiceLink serviceLink;
private Integer deviceSerial; private Integer deviceSerial;
private Integer indSnapshotOldest;
public ServiceLinkDeviceConnector() { public ServiceLinkDeviceConnector() {
serviceLink = new ServiceLink(new NewSerialPort("COM1:")); serviceLink = new ServiceLink(new NewSerialPort("COM1:"));
@ -112,6 +112,8 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
values[n] = getCounter(n); values[n] = getCounter(n);
} }
checkRealTimeClock();
return values; return values;
} }
@ -218,15 +220,43 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
@Override @Override
public int getInverts() { public int getInverts() {
// TODO Auto-generated method stub checkOpen();
return 0;
try {
Integer v = serviceLink.readInt(13, 0, 0x0684 );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
} }
@Override @Override
public void setInverts(int inverts) { public void setInverts(int inverts) {
// TODO Auto-generated method stub try {
serviceLink.writeInt(13, 0, 0x0684, inverts);
} catch (IOException | ServiceLinkException e) {
log(e);
}
} }
@Override
public int getTriggers(){
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x0685 );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
};
@Override
public void setTriggers(int triggers){
try {
serviceLink.writeInt(13, 0, 0x0685, triggers);
} catch (IOException | ServiceLinkException e) {
log(e);
}
};
@Override @Override
public float[] getAnalogs() { public float[] getAnalogs() {
@ -259,69 +289,53 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
} }
@Override @Override
public int getAvailableSnapshots() { public int getHighestSnapShotIndex() {
Integer s = readDeviceSerial(); Integer s = readDeviceSerial();
if (s != null){ if (s != null){
Integer oldest,newest,sssize;
try { try {
return serviceLink.readInt(13, 0, 0x0581);
if (s.equals(deviceSerial) && (indSnapshotOldest != null)){
oldest = indSnapshotOldest;
} else {
oldest = serviceLink.readInt(13, 0, 0x0580);
}
newest = serviceLink.readInt(13, 0, 0x0581);
sssize = serviceLink.readInt(13, 0, 0x0582);
Integer avail = newest - oldest;
if (avail < 0){
avail += sssize;
}
return avail;
} catch (IOException | ServiceLinkException e) { } catch (IOException | ServiceLinkException e) {
log(e); log(ERROR,"ServiceLinkDeviceConnector: getHighestSnapShotIndex(): Exception: %s",e.toString());
} }
} }
return -1;
return 0;
} }
@Override @Override
public SnapShot[] readSnapShots() { public SnapShot[] readSnapShots(int startIndex) {
Integer s = readDeviceSerial(); Integer s = readDeviceSerial();
List<SnapShot> snapshots = new LinkedList<>(); List<SnapShot> snapshots = new LinkedList<>();
if (s != null){ if (s != null){
Integer oldest,newest,sssize; Integer newest,sssize;
int ind;
Integer id;
try { try {
if (s.equals(deviceSerial) && (indSnapshotOldest != null)){
oldest = indSnapshotOldest;
} else {
oldest = serviceLink.readInt(13, 0, 0x0580);
}
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) if ((newest == null) || (sssize == null)){
return null; return null;
}
while (!oldest.equals(newest)){
if (startIndex < (newest - sssize)){
Integer id; startIndex = newest - sssize;
}
if (startIndex < 0){
startIndex = 0;
}
log(INFO,"ServiceLinkDeviceConnector: reading snapshots [%d ... %d]",startIndex,newest);
for (ind = startIndex; ind <= newest; ind++){
try { try {
serviceLink.writeInt(13, 0, 0x0500, oldest); serviceLink.writeInt(13, 0, 0x0500, ind);
id = serviceLink.readInt(13, 0, 0x0500); id = serviceLink.readInt(13, 0, 0x0500);
if (!id.equals(oldest)){ if (!id.equals(ind)){
log(WARN,"Snapshot could not be selected [%d]",oldest); log(WARN,"Snapshot could not be selected [%d != %d]",ind,id);
} else { } else {
Integer timestamp, Integer timestamp,
flags, flags,
@ -341,6 +355,7 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
pu = serviceLink.readInt(13, 0, 0x0505); pu = serviceLink.readInt(13, 0, 0x0505);
inv = serviceLink.readInt(13, 0, 0x0506); inv = serviceLink.readInt(13, 0, 0x0506);
trigger = serviceLink.readInt(13, 0, 0x0507); trigger = serviceLink.readInt(13, 0, 0x0507);
id = serviceLink.readInt(13, 0, 0x0530);
counters = new Integer[32]; counters = new Integer[32];
analogs = new Integer[8]; analogs = new Integer[8];
@ -355,6 +370,7 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
SnapShot ss = new SnapShot(s); SnapShot ss = new SnapShot(s);
ss.setTimestamp(timestamp); ss.setTimestamp(timestamp);
ss.setIndex(id);
ss.setField0(flags); ss.setField0(flags);
ss.setInputmask(in); ss.setInputmask(in);
ss.setOutputmask(out); ss.setOutputmask(out);
@ -376,13 +392,7 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
log(e); log(e);
} }
oldest++;
if (oldest >= sssize){
oldest = 0;
}
} }
indSnapshotOldest = oldest;
} catch (IOException | ServiceLinkException e) { } catch (IOException | ServiceLinkException e) {
log(e); log(e);
} }
@ -392,9 +402,274 @@ public class ServiceLinkDeviceConnector implements IDeviceConnector {
} }
@Override @Override
public SnapShot readSnapShot() { public int getInterval(int iNo) {
// TODO Auto-generated method stub checkOpen();
return null;
iNo %= 4;
try {
Integer v = serviceLink.readInt(13, 0, 0x1010 + iNo );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public boolean isIntervalDailyBased(int iNo) {
iNo %= 4;
return ((getDailyBaseMask() & (1<<iNo))!=0);
}
@Override
public void setInterval(int iNo, int intervall, boolean dailyBase) {
checkOpen();
iNo %= 4;
try {
Integer v = serviceLink.readInt(13, 0, 0x1003 );
if (dailyBase){
v |= (1<<iNo);
} else {
v &= ~(1<<iNo);
}
serviceLink.writeInt(13, 0, 0x1003, v);
serviceLink.writeInt(13, 0, 0x1010 + iNo , intervall);
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException(e);
}
}
@Override
public int getDailyBaseMask() {
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x1003 );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
private int getDebounce(int channel){
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x1020 + channel );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
private void setDebounce(int channel,int value){
checkOpen();
try {
serviceLink.writeInt(13, 0, 0x1020 + channel, value );
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public int[] getDebounce() {
int[] filters = new int[32];
for (int i=0;i<32;i++){
filters[i] = getDebounce(i);
}
return filters;
}
@Override
public void setDebounce(int[] filters) {
for (int i=0;i<32;i++){
setDebounce(i,filters[i]);
}
}
private int getWindow(int channel){
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x1280 + channel );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
private void setWindow(int channel,int value){
checkOpen();
try {
serviceLink.writeInt(13, 0, 0x1280 + channel, value );
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public int[] getWindows() {
int[] windows = new int[32];
for (int i=0;i<32;i++){
windows[i] = getWindow(i);
}
return windows;
}
@Override
public void setWindows(int[] windows) {
for (int i=0;i<32;i++){
setWindow(i,windows[i]);
}
}
@Override
public void syncConfigToLive() {
checkOpen();
try {
serviceLink.writeInt(13, 0, 0x1001, 1 );
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public void reset(int flags) {
checkOpen();
try {
serviceLink.writeInt(13, 0, 0x0581, -1 );
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public int getConfigOutputs() {
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x1008 );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public void setConfigOutputs(int outputs) {
try {
serviceLink.writeInt(13, 0, 0x1008, outputs);
} catch (IOException | ServiceLinkException e) {
log(e);
}
}
@Override
public int getConfigPullups() {
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x1009 );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public void setConfigPullups(int pullups) {
try {
serviceLink.writeInt(13, 0, 0x1009, pullups);
} catch (IOException | ServiceLinkException e) {
log(e);
}
}
@Override
public int getConfigInverts() {
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x100A );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
}
@Override
public void setConfigInverts(int inverts) {
try {
serviceLink.writeInt(13, 0, 0x100A, inverts);
} catch (IOException | ServiceLinkException e) {
log(e);
}
}
@Override
public int getConfigTriggers(){
checkOpen();
try {
Integer v = serviceLink.readInt(13, 0, 0x100B );
return v;
} catch (IOException | ServiceLinkException e) {
throw new NoDeviceConnectionException();
}
};
@Override
public void setConfigTriggers(int triggers){
try {
serviceLink.writeInt(13, 0, 0x100B, triggers);
} catch (IOException | ServiceLinkException e) {
log(e);
}
};
public void checkRealTimeClock(){
Calendar calendar = Calendar.getInstance();
try {
Integer deviceTime = serviceLink.readInt(13, 0, 0x001C);
Long delta = deviceTime - (System.currentTimeMillis()/1000);
if ((delta < -1) || (delta > 1)){
log(INFO,"realtime clock has a %d seconds shift",delta);
serviceLink.writeInt((byte)13, (byte)0, 0x001C, (int)(calendar.getTimeInMillis() / 1000L));
log(INFO,"realtime clock has been corrected.");
}
} catch (ServiceLinkRequestFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceLinkException e) {
e.printStackTrace();
}
} }

View File

@ -149,7 +149,58 @@ public class SimulatedCounter implements IDeviceConnector {
public void setInverts(int inverts) { public void setInverts(int inverts) {
this.inverts = inverts; this.inverts = inverts;
} }
@Override
public int getTriggers() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setTriggers(int triggers) {
// TODO Auto-generated method stub
}
@Override
public int getConfigOutputs() {
return outputs;
}
@Override
public void setConfigOutputs(int outputs) {
this.outputs = outputs;
}
@Override
public int getConfigPullups() {
return pullups;
}
@Override
public void setConfigPullups(int pullups) {
this.pullups = pullups;
}
@Override
public int getConfigInverts() {
return inverts;
}
@Override
public void setConfigInverts(int inverts) {
this.inverts = inverts;
}
@Override
public int getConfigTriggers() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setConfigTriggers(int triggers) {
// TODO Auto-generated method stub
}
@Override @Override
public float[] getAnalogs() { public float[] getAnalogs() {
return analogs; return analogs;
@ -160,22 +211,75 @@ public class SimulatedCounter implements IDeviceConnector {
return analogs[channel]; return analogs[channel];
} }
@Override @Override
public int getAvailableSnapshots() { public int getHighestSnapShotIndex() {
// TODO Auto-generated method stub
return 0;
}
@Override
public SnapShot[] readSnapShots(int startIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getInterval(int iNo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0; return 0;
} }
@Override @Override
public SnapShot[] readSnapShots() { public boolean isIntervalDailyBased(int iNo) {
// TODO Auto-generated method stub
return false;
}
@Override
public void setInterval(int iNo, int intervall, boolean dailyBase) {
// TODO Auto-generated method stub
}
@Override
public int[] getDebounce() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public SnapShot readSnapShot() { public void setDebounce(int[] filters) {
// TODO Auto-generated method stub
}
@Override
public int[] getWindows() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override
public void setWindows(int[] windows) {
// TODO Auto-generated method stub
}
@Override
public int getDailyBaseMask() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void syncConfigToLive() {
// TODO Auto-generated method stub
}
public void reset(int flags) {
};
} }

View File

@ -10,6 +10,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.hwo.pulscounter.PulsCounterApplication; import org.hwo.pulscounter.PulsCounterApplication;
import org.hwo.pulscounter.device.IDeviceConnector;
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;
@ -25,6 +26,7 @@ import javax.swing.JComboBox;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Arrays;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JSpinner; import javax.swing.JSpinner;
@ -43,468 +45,413 @@ 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;
int currentChannel;
private BitFieldEditor bfeIntervall;
private JTimeSpanEditor tseI3;
private JTimeSpanEditor tseI2;
private JTimeSpanEditor tseI1;
private JTimeSpanEditor tseI0;
// private JPanel contentPane; private TableMapper tmSettings;
//
// int outputs,
// int currentChannel; pullups,
// private BitFieldEditor bfeIntervall; inverts,
// private JTimeSpanEditor tseI3; trigger;
// private JTimeSpanEditor tseI2;
// private JTimeSpanEditor tseI1; int[] filter,
// private JTimeSpanEditor tseI0; windows;
// private JTable tSettings;
// private TableMapper tmSettings;
// private IDeviceConnector deviceConnector;
// int outputs,
// pullups, /**
// inverts, * Create the frame.
// trigger; */
// public DeviceConfiguration(IDeviceConnector deviceConnector) {
// int[] filter, this.deviceConnector = deviceConnector;
// windows;
// private JTable tSettings; setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// setBounds(100, 100, 860, 498);
// contentPane = new JPanel();
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
// /** setContentPane(contentPane);
// * Create the frame. GridBagLayout gbl_contentPane = new GridBagLayout();
// */ gbl_contentPane.columnWidths = new int[] {30, 0, 0};
// public DeviceConfiguration() { gbl_contentPane.rowHeights = new int[] {183, 0};
// setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0};
// setBounds(100, 100, 860, 498); gbl_contentPane.rowWeights = new double[]{1.0, 0.0};
// contentPane = new JPanel(); contentPane.setLayout(gbl_contentPane);
// contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
// setContentPane(contentPane); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
// GridBagLayout gbl_contentPane = new GridBagLayout(); GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
// gbl_contentPane.columnWidths = new int[] {30, 0, 0}; gbc_tabbedPane.gridwidth = 3;
// gbl_contentPane.rowHeights = new int[] {183, 0}; gbc_tabbedPane.fill = GridBagConstraints.BOTH;
// gbl_contentPane.columnWeights = new double[]{1.0, 0.0, 0.0}; gbc_tabbedPane.insets = new Insets(0, 0, 5, 0);
// gbl_contentPane.rowWeights = new double[]{1.0, 0.0}; gbc_tabbedPane.gridx = 0;
// contentPane.setLayout(gbl_contentPane); gbc_tabbedPane.gridy = 0;
// contentPane.add(tabbedPane, gbc_tabbedPane);
// JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
// GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); JPanel panel_2 = new JPanel();
// gbc_tabbedPane.gridwidth = 3; tabbedPane.addTab("Intervalle", null, panel_2, null);
// gbc_tabbedPane.fill = GridBagConstraints.BOTH; GridBagLayout gbl_panel_2 = new GridBagLayout();
// gbc_tabbedPane.insets = new Insets(0, 0, 5, 0); gbl_panel_2.columnWidths = new int[]{0, 0, 0};
// gbc_tabbedPane.gridx = 0; gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
// gbc_tabbedPane.gridy = 0; gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
// contentPane.add(tabbedPane, gbc_tabbedPane); gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
// panel_2.setLayout(gbl_panel_2);
// JPanel panel_2 = new JPanel();
// tabbedPane.addTab("Intervalle", null, panel_2, null); bfeIntervall = new BitFieldEditor();
// GridBagLayout gbl_panel_2 = new GridBagLayout(); 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>");
// gbl_panel_2.columnWidths = new int[]{0, 0, 0}; bfeIntervall.addChangeListener(new ChangeListener() {
// gbl_panel_2.rowHeights = new int[]{0, 0, 0, 0, 0, 0}; public void stateChanged(ChangeEvent e) {
// gbl_panel_2.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE}; int v = bfeIntervall.getIntValue();
// gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; tseI0.setDaysEnabled(((v & 0x01)==0));
// panel_2.setLayout(gbl_panel_2); tseI1.setDaysEnabled(((v & 0x02)==0));
// tseI2.setDaysEnabled(((v & 0x04)==0));
// bfeIntervall = new BitFieldEditor(); tseI3.setDaysEnabled(((v & 0x08)==0));
// 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() { });
// public void stateChanged(ChangeEvent e) {
// int v = bfeIntervall.getIntValue(); JLabel lblTageszeitabhngigkeit = new JLabel("Tageszeitabhängigkeit:");
// tseI0.setDaysEnabled(((v & 0x01)==0)); GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints();
// tseI1.setDaysEnabled(((v & 0x02)==0)); gbc_lblTageszeitabhngigkeit.fill = GridBagConstraints.HORIZONTAL;
// tseI2.setDaysEnabled(((v & 0x04)==0)); gbc_lblTageszeitabhngigkeit.insets = new Insets(0, 0, 5, 5);
// tseI3.setDaysEnabled(((v & 0x08)==0)); gbc_lblTageszeitabhngigkeit.gridx = 0;
// gbc_lblTageszeitabhngigkeit.gridy = 0;
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); panel_2.add(lblTageszeitabhngigkeit, gbc_lblTageszeitabhngigkeit);
// try { GridBagConstraints gbc_bfeIntervall = new GridBagConstraints();
// gbc_bfeIntervall.anchor = GridBagConstraints.NORTH;
// sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue()); gbc_bfeIntervall.insets = new Insets(0, 0, 5, 0);
// gbc_bfeIntervall.fill = GridBagConstraints.HORIZONTAL;
// } catch (ServiceLinkRequestFailedException e1) { gbc_bfeIntervall.gridx = 1;
// e1.printStackTrace(); gbc_bfeIntervall.gridy = 0;
// } catch (IOException e1) { panel_2.add(bfeIntervall, gbc_bfeIntervall);
// e1.printStackTrace();
// } catch (ServiceLinkException e1) { JLabel lblIntervall = new JLabel("Intervall 0:");
// e1.printStackTrace(); 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();
// } gbc_lblIntervall.fill = GridBagConstraints.HORIZONTAL;
// }); gbc_lblIntervall.insets = new Insets(0, 0, 5, 5);
// gbc_lblIntervall.gridx = 0;
// JLabel lblTageszeitabhngigkeit = new JLabel("Tageszeitabhängigkeit:"); gbc_lblIntervall.gridy = 1;
// GridBagConstraints gbc_lblTageszeitabhngigkeit = new GridBagConstraints(); panel_2.add(lblIntervall, gbc_lblIntervall);
// gbc_lblTageszeitabhngigkeit.fill = GridBagConstraints.HORIZONTAL;
// gbc_lblTageszeitabhngigkeit.insets = new Insets(0, 0, 5, 5); tseI0 = new JTimeSpanEditor();
// gbc_lblTageszeitabhngigkeit.gridx = 0; 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>");
// gbc_lblTageszeitabhngigkeit.gridy = 0; tseI0.addFocusListener(new FocusAdapter() {
// panel_2.add(lblTageszeitabhngigkeit, gbc_lblTageszeitabhngigkeit); @Override
// GridBagConstraints gbc_bfeIntervall = new GridBagConstraints(); public void focusLost(FocusEvent e) {
// gbc_bfeIntervall.anchor = GridBagConstraints.NORTH; }
// gbc_bfeIntervall.insets = new Insets(0, 0, 5, 0); });
// gbc_bfeIntervall.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gbc_tseI0 = new GridBagConstraints();
// gbc_bfeIntervall.gridx = 1; gbc_tseI0.anchor = GridBagConstraints.WEST;
// gbc_bfeIntervall.gridy = 0; gbc_tseI0.insets = new Insets(0, 0, 5, 0);
// panel_2.add(bfeIntervall, gbc_bfeIntervall); gbc_tseI0.gridx = 1;
// gbc_tseI0.gridy = 1;
// JLabel lblIntervall = new JLabel("Intervall 0:"); panel_2.add(tseI0, gbc_tseI0);
// 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_1 = new JLabel("Intervall 1:");
// gbc_lblIntervall.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.insets = new Insets(0, 0, 5, 5); GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints();
// gbc_lblIntervall.gridx = 0; gbc_lblIntervall_1.fill = GridBagConstraints.HORIZONTAL;
// gbc_lblIntervall.gridy = 1; gbc_lblIntervall_1.insets = new Insets(0, 0, 5, 5);
// panel_2.add(lblIntervall, gbc_lblIntervall); gbc_lblIntervall_1.gridx = 0;
// gbc_lblIntervall_1.gridy = 2;
// tseI0 = new JTimeSpanEditor(); panel_2.add(lblIntervall_1, gbc_lblIntervall_1);
// 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() { 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() {
// System.err.println("FOCUS LOST 0"); @Override
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); public void focusLost(FocusEvent e) {
// try { }
// });
// sl.writeInt(13, 0, 0x1010, (Integer)tseI0.getValue()); GridBagConstraints gbc_tseI1 = new GridBagConstraints();
// gbc_tseI1.anchor = GridBagConstraints.WEST;
// } catch (ServiceLinkRequestFailedException e1) { gbc_tseI1.insets = new Insets(0, 0, 5, 0);
// e1.printStackTrace(); gbc_tseI1.gridx = 1;
// } catch (IOException e1) { gbc_tseI1.gridy = 2;
// e1.printStackTrace(); panel_2.add(tseI1, gbc_tseI1);
// } catch (ServiceLinkException e1) {
// e1.printStackTrace(); JLabel lblIntervall_2 = new JLabel("Intervall 2:");
// } 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();
// }); gbc_lblIntervall_2.fill = GridBagConstraints.HORIZONTAL;
// GridBagConstraints gbc_tseI0 = new GridBagConstraints(); gbc_lblIntervall_2.insets = new Insets(0, 0, 5, 5);
// gbc_tseI0.anchor = GridBagConstraints.WEST; gbc_lblIntervall_2.gridx = 0;
// gbc_tseI0.insets = new Insets(0, 0, 5, 0); gbc_lblIntervall_2.gridy = 3;
// gbc_tseI0.gridx = 1; panel_2.add(lblIntervall_2, gbc_lblIntervall_2);
// gbc_tseI0.gridy = 1;
// panel_2.add(tseI0, gbc_tseI0); tseI2 = new JTimeSpanEditor();
// 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>");
// JLabel lblIntervall_1 = new JLabel("Intervall 1:"); tseI2.addFocusListener(new FocusAdapter() {
// 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>"); @Override
// GridBagConstraints gbc_lblIntervall_1 = new GridBagConstraints(); public void focusLost(FocusEvent e) {
// gbc_lblIntervall_1.fill = GridBagConstraints.HORIZONTAL; }
// gbc_lblIntervall_1.insets = new Insets(0, 0, 5, 5); });
// gbc_lblIntervall_1.gridx = 0; GridBagConstraints gbc_tseI2 = new GridBagConstraints();
// gbc_lblIntervall_1.gridy = 2; gbc_tseI2.anchor = GridBagConstraints.WEST;
// panel_2.add(lblIntervall_1, gbc_lblIntervall_1); gbc_tseI2.insets = new Insets(0, 0, 5, 0);
// gbc_tseI2.gridx = 1;
// tseI1 = new JTimeSpanEditor(); gbc_tseI2.gridy = 3;
// 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>"); panel_2.add(tseI2, gbc_tseI2);
// tseI1.addFocusListener(new FocusAdapter() {
// @Override JLabel lblIntervall_3 = new JLabel("Intervall 3:");
// public void focusLost(FocusEvent e) { 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();
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); gbc_lblIntervall_3.fill = GridBagConstraints.HORIZONTAL;
// try { gbc_lblIntervall_3.insets = new Insets(0, 0, 5, 5);
// gbc_lblIntervall_3.gridx = 0;
// sl.writeInt(13, 0, 0x1011, (Integer)tseI1.getValue()); gbc_lblIntervall_3.gridy = 4;
// panel_2.add(lblIntervall_3, gbc_lblIntervall_3);
// } catch (ServiceLinkRequestFailedException e1) {
// e1.printStackTrace(); tseI3 = new JTimeSpanEditor();
// } catch (IOException e1) { 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>");
// e1.printStackTrace(); tseI3.addFocusListener(new FocusAdapter() {
// } catch (ServiceLinkException e1) { @Override
// e1.printStackTrace(); public void focusLost(FocusEvent e) {
// } }
// } });
// }); GridBagConstraints gbc_tseI3 = new GridBagConstraints();
// GridBagConstraints gbc_tseI1 = new GridBagConstraints(); gbc_tseI3.insets = new Insets(0, 0, 5, 0);
// gbc_tseI1.anchor = GridBagConstraints.WEST; gbc_tseI3.anchor = GridBagConstraints.WEST;
// gbc_tseI1.insets = new Insets(0, 0, 5, 0); gbc_tseI3.gridx = 1;
// gbc_tseI1.gridx = 1; gbc_tseI3.gridy = 4;
// gbc_tseI1.gridy = 2; panel_2.add(tseI3, gbc_tseI3);
// panel_2.add(tseI1, gbc_tseI1);
// JButton btnSnapshotSpeicherZurcksetzen = new JButton("SnapShot Speicher zurücksetzen");
// JLabel lblIntervall_2 = new JLabel("Intervall 2:"); btnSnapshotSpeicherZurcksetzen.addActionListener(new ActionListener() {
// 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>"); public void actionPerformed(ActionEvent e) {
// GridBagConstraints gbc_lblIntervall_2 = new GridBagConstraints(); resetSnapShots();
// gbc_lblIntervall_2.fill = GridBagConstraints.HORIZONTAL; }
// gbc_lblIntervall_2.insets = new Insets(0, 0, 5, 5); });
// gbc_lblIntervall_2.gridx = 0; GridBagConstraints gbc_btnSnapshotSpeicherZurcksetzen = new GridBagConstraints();
// gbc_lblIntervall_2.gridy = 3; gbc_btnSnapshotSpeicherZurcksetzen.gridwidth = 2;
// panel_2.add(lblIntervall_2, gbc_lblIntervall_2); gbc_btnSnapshotSpeicherZurcksetzen.fill = GridBagConstraints.HORIZONTAL;
// gbc_btnSnapshotSpeicherZurcksetzen.insets = new Insets(0, 0, 5, 5);
// tseI2 = new JTimeSpanEditor(); gbc_btnSnapshotSpeicherZurcksetzen.gridx = 0;
// 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>"); gbc_btnSnapshotSpeicherZurcksetzen.gridy = 5;
// tseI2.addFocusListener(new FocusAdapter() { panel_2.add(btnSnapshotSpeicherZurcksetzen, gbc_btnSnapshotSpeicherZurcksetzen);
// @Override
// public void focusLost(FocusEvent e) { JButton btnAlleZhlerLschen = new JButton("Alle Zähler zurücksetzen");
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); btnAlleZhlerLschen.addActionListener(new ActionListener() {
// try { public void actionPerformed(ActionEvent e) {
// resetCounters();
// sl.writeInt(13, 0, 0x1012, (Integer)tseI2.getValue()); }
// });
// } catch (ServiceLinkRequestFailedException e1) { GridBagConstraints gbc_btnAlleZhlerLschen = new GridBagConstraints();
// e1.printStackTrace(); gbc_btnAlleZhlerLschen.gridwidth = 2;
// } catch (IOException e1) { gbc_btnAlleZhlerLschen.fill = GridBagConstraints.HORIZONTAL;
// e1.printStackTrace(); gbc_btnAlleZhlerLschen.insets = new Insets(0, 0, 0, 5);
// } catch (ServiceLinkException e1) { gbc_btnAlleZhlerLschen.gridx = 0;
// e1.printStackTrace(); gbc_btnAlleZhlerLschen.gridy = 6;
// } panel_2.add(btnAlleZhlerLschen, gbc_btnAlleZhlerLschen);
// }
// }); JPanel panel_1 = new JPanel();
// GridBagConstraints gbc_tseI2 = new GridBagConstraints(); tabbedPane.addTab("Kanäle", null, panel_1, null);
// gbc_tseI2.anchor = GridBagConstraints.WEST; GridBagLayout gbl_panel_1 = new GridBagLayout();
// gbc_tseI2.insets = new Insets(0, 0, 5, 0); gbl_panel_1.columnWidths = new int[] {100};
// gbc_tseI2.gridx = 1; gbl_panel_1.rowHeights = new int[] {30};
// gbc_tseI2.gridy = 3; gbl_panel_1.columnWeights = new double[]{1.0};
// panel_2.add(tseI2, gbc_tseI2); gbl_panel_1.rowWeights = new double[]{1.0};
// panel_1.setLayout(gbl_panel_1);
// JLabel lblIntervall_3 = new JLabel("Intervall 3:");
// 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>"); JScrollPane scrollPane = new JScrollPane();
// GridBagConstraints gbc_lblIntervall_3 = new GridBagConstraints(); GridBagConstraints gbc_scrollPane = new GridBagConstraints();
// gbc_lblIntervall_3.fill = GridBagConstraints.HORIZONTAL; gbc_scrollPane.fill = GridBagConstraints.BOTH;
// gbc_lblIntervall_3.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.gridx = 0;
// gbc_lblIntervall_3.gridx = 0; gbc_scrollPane.gridy = 0;
// gbc_lblIntervall_3.gridy = 4; panel_1.add(scrollPane, gbc_scrollPane);
// panel_2.add(lblIntervall_3, gbc_lblIntervall_3);
// tSettings = new JTable();
// tseI3 = new JTimeSpanEditor(); tSettings.setRowHeight(32);
// 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>"); tSettings.setFillsViewportHeight(true);
// tseI3.addFocusListener(new FocusAdapter() { tSettings.setCellSelectionEnabled(true);
// @Override scrollPane.setViewportView(tSettings);
// public void focusLost(FocusEvent e) {
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); JButton btnSchliessen = new JButton("abbrechen");
// try { btnSchliessen.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// sl.writeInt(13, 0, 0x1013, (Integer)tseI3.getValue()); setVisible(false);
// }
// } catch (ServiceLinkRequestFailedException e1) { });
// e1.printStackTrace();
// } catch (IOException e1) { JButton btnOk = new JButton("OK");
// e1.printStackTrace(); btnOk.addActionListener(new ActionListener() {
// } catch (ServiceLinkException e1) { public void actionPerformed(ActionEvent e) {
// e1.printStackTrace(); writeDevice();
// } setVisible(false);
// } }
// }); });
// GridBagConstraints gbc_tseI3 = new GridBagConstraints(); GridBagConstraints gbc_btnOk = new GridBagConstraints();
// gbc_tseI3.anchor = GridBagConstraints.WEST; gbc_btnOk.fill = GridBagConstraints.BOTH;
// gbc_tseI3.gridx = 1; gbc_btnOk.insets = new Insets(0, 0, 0, 5);
// gbc_tseI3.gridy = 4; gbc_btnOk.gridx = 1;
// panel_2.add(tseI3, gbc_tseI3); gbc_btnOk.gridy = 1;
// contentPane.add(btnOk, gbc_btnOk);
// JPanel panel_1 = new JPanel(); GridBagConstraints gbc_btnSchliessen = new GridBagConstraints();
// tabbedPane.addTab("Kanäle", null, panel_1, null); gbc_btnSchliessen.fill = GridBagConstraints.BOTH;
// GridBagLayout gbl_panel_1 = new GridBagLayout(); gbc_btnSchliessen.gridx = 2;
// gbl_panel_1.columnWidths = new int[] {100}; gbc_btnSchliessen.gridy = 1;
// gbl_panel_1.rowHeights = new int[] {30}; contentPane.add(btnSchliessen, gbc_btnSchliessen);
// gbl_panel_1.columnWeights = new double[]{1.0};
// gbl_panel_1.rowWeights = new double[]{1.0}; this.initialize();
// panel_1.setLayout(gbl_panel_1); }
//
// JScrollPane scrollPane = new JScrollPane(); private Integer intOr0(Integer i){
// GridBagConstraints gbc_scrollPane = new GridBagConstraints(); if (i==null)
// gbc_scrollPane.fill = GridBagConstraints.BOTH; return 0;
// gbc_scrollPane.gridx = 0; return i;
// gbc_scrollPane.gridy = 0; }
// panel_1.add(scrollPane, gbc_scrollPane);
// private void initialize(){
// tSettings = new JTable(); currentChannel = -1;
// tSettings.setRowHeight(32); filter = new int[32];
// tSettings.setFillsViewportHeight(true); windows = new int[32];
// tSettings.setCellSelectionEnabled(true); tmSettings = new TableMapper(ChannelConfiguration.class, tSettings);
// scrollPane.setViewportView(tSettings);
// BitField bf = new BitField();
// JButton btnSchliessen = new JButton("abbrechen"); bf.clear();
// btnSchliessen.addActionListener(new ActionListener() { bf.addField(new Field(bf, 0, 1, "Intervall 0 basiert auf Tageszeit"));
// public void actionPerformed(ActionEvent e) { bf.addField(new Field(bf, 1, 1, "Intervall 1 basiert auf Tageszeit"));
// setVisible(false); bf.addField(new Field(bf, 2, 1, "Intervall 2 basiert auf Tageszeit"));
// } bf.addField(new Field(bf, 3, 1, "Intervall 3 basiert auf Tageszeit"));
// }); bfeIntervall.setBitField(bf);
// for (int i=0;i<32;i++){
// JButton btnOk = new JButton("OK"); tmSettings.addRow(new ChannelConfiguration(i));
// btnOk.addActionListener(new ActionListener() { }
// public void actionPerformed(ActionEvent e) {
// writeDevice();
// setVisible(false); readDevice();
// } }
// });
// GridBagConstraints gbc_btnOk = new GridBagConstraints(); private void resetSnapShots(){
// gbc_btnOk.fill = GridBagConstraints.BOTH; deviceConnector.reset(0);
// gbc_btnOk.insets = new Insets(0, 0, 0, 5); }
// gbc_btnOk.gridx = 1;
// gbc_btnOk.gridy = 1; private void resetCounters(){
// contentPane.add(btnOk, gbc_btnOk); int[] zero = new int[32];
// GridBagConstraints gbc_btnSchliessen = new GridBagConstraints(); Arrays.fill(zero, 0);
// gbc_btnSchliessen.fill = GridBagConstraints.BOTH; deviceConnector.setCounters(zero);
// gbc_btnSchliessen.gridx = 2; }
// gbc_btnSchliessen.gridy = 1;
// contentPane.add(btnSchliessen, gbc_btnSchliessen); private void readDevice(){
// Integer v;
// this.initialize();
// } outputs = intOr0(deviceConnector.getConfigOutputs());
// pullups = intOr0(deviceConnector.getConfigPullups());
// private Integer intOr0(Integer i){ inverts = intOr0(deviceConnector.getConfigInverts());
// if (i==null) trigger = intOr0(deviceConnector.getConfigTriggers());
// return 0;
// return i; bfeIntervall.setIntValue(deviceConnector.getDailyBaseMask());
// }
// filter = deviceConnector.getDebounce();
// private void initialize(){ windows = deviceConnector.getWindows();
// currentChannel = -1;
// filter = new int[32]; tseI0.setValue( deviceConnector.getInterval(0) );
// windows = new int[32]; tseI1.setValue( deviceConnector.getInterval(1) );
// tmSettings = new TableMapper(ChannelConfiguration.class, tSettings); tseI2.setValue( deviceConnector.getInterval(2) );
// tseI3.setValue( deviceConnector.getInterval(3) );
// BitField bf = new BitField(); }
// bf.clear();
// bf.addField(new Field(bf, 0, 1, "Intervall 0 basiert auf Tageszeit")); private void writeDevice(){
// bf.addField(new Field(bf, 1, 1, "Intervall 1 basiert auf Tageszeit"));
// bf.addField(new Field(bf, 2, 1, "Intervall 2 basiert auf Tageszeit")); deviceConnector.setInterval(0, tseI0.getValue(), ((bfeIntervall.getIntValue() & (1<<0)) != 0) ? true : false);
// bf.addField(new Field(bf, 3, 1, "Intervall 3 basiert auf Tageszeit")); deviceConnector.setInterval(1, tseI1.getValue(), ((bfeIntervall.getIntValue() & (1<<1)) != 0) ? true : false);
// bfeIntervall.setBitField(bf); deviceConnector.setInterval(2, tseI2.getValue(), ((bfeIntervall.getIntValue() & (1<<2)) != 0) ? true : false);
// for (int i=0;i<32;i++){ deviceConnector.setInterval(3, tseI3.getValue(), ((bfeIntervall.getIntValue() & (1<<3)) != 0) ? true : false);
// tmSettings.addRow(new ChannelConfiguration(i));
// } deviceConnector.setConfigOutputs(outputs);
// deviceConnector.setConfigPullups(pullups);
// deviceConnector.setConfigInverts(inverts);
// readDevice(); deviceConnector.setConfigTriggers(trigger);
// }
// deviceConnector.setDebounce(filter);
// private void readDevice(){ deviceConnector.setWindows(windows);
// Integer v;
// deviceConnector.syncConfigToLive();
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); }
//
// outputs = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1008)); class ChannelConfiguration{
// pullups = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1009));
// inverts = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100A)); int channel;
// trigger = intOr0(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x100B));
// public ChannelConfiguration(int channel) {
// bfeIntervall.setIntValue(sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1003)); this.channel = channel;
// }
// for (int i=0;i<32;i++){
// filter[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1020 + i)); @TableColumn(label="Channel",width=80,order=0)
// windows[i] = intOr0( sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1280 + i)); public int getChannel(){
// } return channel;
// }
//
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1010); @TableColumn(label="Ausgang",width=80,order=10)
// if (v!=null){ public Boolean getOutput(){
// tseI0.setValue(v); return (outputs & 1<<channel) == 0 ? false : true;
// } }
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1011); public void setOutput(Boolean value){
// if (v!=null){ outputs &= ~(1<<channel);
// tseI1.setValue(v); if (value){
// } outputs |= (1<<channel);
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1012); }
// if (v!=null){ }
// tseI2.setValue(v);
// } @TableColumn(label="Passiver Schalter",width=80,order=20)
// v = sl.getServiceRegisterCache().getCachedInteger(13, 0, 0x1013); public Boolean getPullup(){
// if (v!=null){ return (pullups & 1<<channel) == 0 ? false : true;
// tseI3.setValue(v); }
// } public void setPullup(Boolean value){
// pullups &= ~(1<<channel);
// if (value){
// pullups |= (1<<channel);
// }
// } }
//
// private void writeDevice(){ @TableColumn(label="Invertiert",width=80,order=30)
// ServiceLink sl = PulsCounterApplication.getApplication().getServiceLink(); public Boolean getInvert(){
// try { return (inverts & 1<<channel) == 0 ? false : true;
// sl.writeInt(13, 0, 0x1008, outputs); }
// sl.writeInt(13, 0, 0x1009, pullups); public void setInvert(Boolean value){
// sl.writeInt(13, 0, 0x100A, inverts); inverts &= ~(1<<channel);
// sl.writeInt(13, 0, 0x100B, trigger); if (value){
// inverts |= (1<<channel);
// sl.writeInt(13, 0, 0x1003, bfeIntervall.getIntValue()); }
// }
// for (int i=0;i<32;i++){
// sl.writeInt(13, 0, 0x1020 + i, filter[i]); @TableColumn(label="Löst Snapshot aus",width=80,order=40)
// sl.writeInt(13, 0, 0x1280 + i, windows[i]); public Boolean getTrigger(){
// } return (trigger & 1<<channel) == 0 ? false : true;
// }
// public void setTrigger(Boolean value){
// sl.writeInt(13, 0, 0x1010, tseI0.getValue()); trigger &= ~(1<<channel);
// sl.writeInt(13, 0, 0x1011, tseI1.getValue()); if (value){
// sl.writeInt(13, 0, 0x1012, tseI2.getValue()); trigger |= (1<<channel);
// sl.writeInt(13, 0, 0x1013, tseI3.getValue()); }
// }
// /* Konfiguration auf Live-System übertragen */
// sl.writeInt(13, 0, 0x1001, 1); @TableColumn(label="Signalfenster",width=80,order=200)
// } catch (Exception e){ public Integer getWindow(){
// e.printStackTrace(); return windows[channel];
// } }
// } public void setWindow(Integer value){
// windows[channel] = value;
// class ChannelConfiguration{ }
//
// int channel; @TableColumn(label="Signalfilter",width=80,order=210)
// public Integer getFilter(){
// public ChannelConfiguration(int channel) { return filter[channel];
// this.channel = channel; }
// } public void setFilter(Integer value){
// filter[channel] = value;
// @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;
// }
// public void setOutput(Boolean value){
// 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;
// }
// public void setPullup(Boolean value){
// 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;
// }
// public void setInvert(Boolean value){
// 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;
// }
// public void setTrigger(Boolean value){
// trigger &= ~(1<<channel);
// if (value){
// trigger |= (1<<channel);
// }
// }
//
// @TableColumn(label="Signalfenster",width=80,order=200)
// public Integer getWindow(){
// return windows[channel];
// }
// public void setWindow(Integer value){
// windows[channel] = value;
// }
//
// @TableColumn(label="Signalfilter",width=80,order=210)
// public Integer getFilter(){
// return filter[channel];
// }
// public void setFilter(Integer value){
// filter[channel] = value;
// }
//
// }
//
//
//
//}

View File

@ -30,6 +30,7 @@ import org.hwo.tasklet.TaskletListener;
import org.hwo.tasklet.TaskletManager; import org.hwo.tasklet.TaskletManager;
import org.hwo.ui.JObjectSelector; import org.hwo.ui.JObjectSelector;
import org.hwo.ui.dialog.SerialPortChooser; import org.hwo.ui.dialog.SerialPortChooser;
import org.hwo.ui.states.WindowStateManager;
import org.omg.CORBA.Environment; import org.omg.CORBA.Environment;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -94,7 +95,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
private JFrame frmSynolog; private JFrame frmSynolog;
private JSplitPane splitter; private JSplitPane splitter;
private JButton btnSetup;
private DefaultListModel<String> messageListModel; private DefaultListModel<String> messageListModel;
private JList lMessages; private JList lMessages;
@ -188,7 +188,11 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
frmSynolog.addWindowListener(new WindowAdapter() { frmSynolog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
saveState();
}
@Override @Override
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
backgroundThread.exit(); backgroundThread.exit();
@ -206,9 +210,33 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
backgroundThread = new BackgroundThread(); backgroundThread = new BackgroundThread();
backgroundThread.start(); backgroundThread.start();
restoreState();
frmSynolog.setVisible(true); frmSynolog.setVisible(true);
} }
private void restoreState(){
String state = application().getApplicationConfiguration().getProperty("ui.NewMainWindow.state");
if (state != null){
WindowStateManager wsm = new WindowStateManager();
wsm.applyState(this.frmSynolog, state);
log(INFO,"UI state restored");
} else {
log(INFO,"UI state information not found");
}
}
private void saveState(){
WindowStateManager wsm = new WindowStateManager();
String state = wsm.saveState(frmSynolog);
if (state != null){
application().getApplicationConfiguration().setProperty("ui.NewMainWindow.state", state);
log(INFO,"UI state was saved");
} else {
log(ERROR,"UI State was not saved");
}
}
private void initializeChannelPanels(){ private void initializeChannelPanels(){
channelDisplays = new ChannelDisplay[32]; channelDisplays = new ChannelDisplay[32];
@ -275,32 +303,19 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
toolBar.setFloatable(false); toolBar.setFloatable(false);
frmSynolog.getContentPane().add(toolBar, BorderLayout.NORTH); frmSynolog.getContentPane().add(toolBar, BorderLayout.NORTH);
btnSetup = new JButton("S"); btnC = new JButton("Synololog einstellen");
btnSetup.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AppSettingsFrame asf = new AppSettingsFrame();
asf.setModalityType(ModalityType.APPLICATION_MODAL);
// if ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0)
// asf.debugging();
asf.setVisible(true);
}
});
btnSetup.setToolTipText("<html>\n<b>Einstellungen</b><br/>\n<br/>\nEinstellungen der Synololog PC Software ändern.\n</html>");
toolBar.add(btnSetup);
btnC = new JButton("C");
btnC.setToolTipText("<html>\n<b>Konfiguration</b><br/>\n<br/>\nKonfiguration des Synololog bearbeiten.\n</html>"); btnC.setToolTipText("<html>\n<b>Konfiguration</b><br/>\n<br/>\nKonfiguration des Synololog bearbeiten.\n</html>");
btnC.addActionListener(new ActionListener() { btnC.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DeviceConfiguration cc = new DeviceConfiguration(); if (selectedDeviceInterface != null){
cc.setVisible(true); DeviceConfiguration cc = new DeviceConfiguration(selectedDeviceInterface);
cc.setVisible(true);
}
} }
}); });
toolBar.add(btnC); toolBar.add(btnC);
btnDatenExportieren = new JButton("Daten exportieren..."); btnDatenExportieren = new JButton("Daten exportieren");
btnDatenExportieren.setToolTipText("<html>\n<b>Daten exportieren</b><br/>\n<br/>\nExport definitionen bearbeiten und ausführen.<br/>\nHiermit können die Aufzeichnungsdaten in Textdateien exportiert werden.<br/>\n</html>"); btnDatenExportieren.setToolTipText("<html>\n<b>Daten exportieren</b><br/>\n<br/>\nExport definitionen bearbeiten und ausführen.<br/>\nHiermit können die Aufzeichnungsdaten in Textdateien exportiert werden.<br/>\n</html>");
btnDatenExportieren.addActionListener(new ActionListener() { btnDatenExportieren.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -913,6 +928,9 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
} }
} catch (InterruptedException e){ } catch (InterruptedException e){
} catch (Exception e){
log(ERROR,"Unexpected Exception in backgroundThread: %s", e.toString());
e.printStackTrace();
} }
} }