WIP161026
parent
ccf6e4d9f7
commit
a7e43ec0b4
|
@ -7,3 +7,4 @@ chnames.prop
|
||||||
*.log
|
*.log
|
||||||
*.old
|
*.old
|
||||||
*.cfg
|
*.cfg
|
||||||
|
synololog-hsql.*
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.Date;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.hwo.ObjectTable;
|
||||||
|
import org.hwo.ObjectTable.ObjectSet;
|
||||||
import org.hwo.configuration.ConfigurableAttribute;
|
import org.hwo.configuration.ConfigurableAttribute;
|
||||||
import org.hwo.configuration.ConfigurableObject;
|
import org.hwo.configuration.ConfigurableObject;
|
||||||
import org.hwo.csv.CSV;
|
import org.hwo.csv.CSV;
|
||||||
|
@ -117,93 +119,82 @@ public class ExportSetting {
|
||||||
this.recordDelta = recordDelta;
|
this.recordDelta = recordDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String calculateFileName(String filename,SnapShot ss){
|
private String calculateFileName(String filename, ObjectSet row, int deviceSerial){
|
||||||
Date d = new Date(((long)ss.getTimestamp())*1000);
|
Date d = new Date(((long)row.getInteger(0))*1000);
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.setTime(d);
|
c.setTime(d);
|
||||||
|
|
||||||
filename = filename
|
filename = filename
|
||||||
.replaceAll("\\%S", String.format("%d", ss.getDeviceSerial()))
|
.replaceAll("\\%S", String.format("%d", deviceSerial))
|
||||||
.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))))
|
||||||
|
.replaceAll("\\%h", String.format("%02d", new Integer(c.get(Calendar.HOUR))))
|
||||||
|
.replaceAll("\\%m", String.format("%02d", new Integer(c.get(Calendar.MINUTE))))
|
||||||
|
.replaceAll("\\%s", String.format("%02d", new Integer(c.get(Calendar.SECOND))));
|
||||||
|
|
||||||
log(DEBUG, "exportFileName for Snapshot %s from [%s: %04d-%02d-%02d %02d:%02d:%02d] is %s", ss, ss.getDeviceSerial(), c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND),filename);
|
// log(DEBUG, "exportFileName for Snapshot %s from [%s: %04d-%02d-%02d %02d:%02d:%02d] is %s", ss, ss.getDeviceSerial(), c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND),filename);
|
||||||
return filename;
|
return filename;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void export(){
|
public void export(){
|
||||||
Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
|
|
||||||
|
|
||||||
for (SnapShot ss: PulsCounterApplication.getApplication().getDatabase().loadSnapshots(0))
|
for (int deviceSerial: PulsCounterApplication.getApplication().getDatabase().getKnownDevices()){
|
||||||
{
|
ObjectTable ot = PulsCounterApplication.getApplication().getDatabase().getSnapshotsAsTable(deviceSerial);
|
||||||
String fn = calculateFileName(fileName, ss);
|
|
||||||
|
|
||||||
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 (extended){
|
|
||||||
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
|
||||||
"Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
|
|
||||||
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
|
||||||
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
|
||||||
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
|
||||||
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
|
||||||
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
|
||||||
} else {
|
|
||||||
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
|
||||||
"Datum/Zeit",
|
|
||||||
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
|
||||||
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
|
||||||
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
|
||||||
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
|
||||||
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hash.get(fn).getRecords().add(ss.getCSVRecord(extended));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String fn: hash.keySet()){
|
|
||||||
if (recordDelta){
|
if (recordDelta){
|
||||||
CSV csv = hash.get(fn);
|
PulsCounterApplication.getApplication().getDatabase().calulateTableDeltas(ot);
|
||||||
if (!csv.getRecords().isEmpty()){
|
|
||||||
Iterator<CSVRecord> iter = csv.getRecords().iterator();
|
|
||||||
|
|
||||||
iter.next();
|
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
while (iter.hasNext()){
|
|
||||||
n = iter.next();
|
|
||||||
|
|
||||||
for (int i=0;i<32;i++){
|
|
||||||
Integer v = n.getIntegerValue(extended ? i + 4 : i + 1 );
|
|
||||||
n.setValue(extended ? i + 4 : i + 1 , v - vals[i]);
|
|
||||||
vals[i] = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
csv.getRecords().remove(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Hashtable<String, CSV> hash = new Hashtable<String, CSV>();
|
||||||
|
|
||||||
|
int[] simpleSelection = new int[]{
|
||||||
|
1,
|
||||||
|
4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,
|
||||||
|
34,35,36,37,38,39,40,41
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
for (ObjectSet row: ot.getRows()){
|
||||||
|
String fn = calculateFileName(fileName, row, deviceSerial);
|
||||||
|
|
||||||
|
if ((triggerType==TriggerType.ALL)||(triggerType.getValue().equals(row.getInteger(2)))){
|
||||||
|
if (triggerSource.equals(-1) || triggerSource.equals( row.getInteger(3) )){
|
||||||
|
|
||||||
|
if (!hash.containsKey(fn)){
|
||||||
|
hash.put(fn, new CSV());
|
||||||
|
if (extended){
|
||||||
|
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
|
"Zeitstempel", "Datum/Zeit", "Trigger", "Quelle",
|
||||||
|
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
|
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
|
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
|
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
|
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
|
} else {
|
||||||
|
hash.get(fn).getRecords().add(new CSVRecord(new Object[]{
|
||||||
|
"Datum/Zeit",
|
||||||
|
"CH0","CH1","CH2","CH3","CH4","CH5","CH6","CH7",
|
||||||
|
"CH8","CH9","CH10","CH11","CH12","CH13","CH14","CH15",
|
||||||
|
"CH16","CH17","CH18","CH19","CH20","CH21","CH22","CH23",
|
||||||
|
"CH24","CH25","CH26","CH27","CH28","CH29","CH30","CH31",
|
||||||
|
"AN0","AN1","AN2","AN3","AN4","AN5","AN6","AN7"}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hash.get(fn).getRecords().add(new CSVRecord( extended ? row.getValues() : row.selectColums(simpleSelection)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String fn: hash.keySet()){
|
||||||
|
hash.get(fn).saveToFile(new File(path,fn));
|
||||||
|
}
|
||||||
|
|
||||||
hash.get(fn).saveToFile(new File(path,fn));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.hwo.pulscounter;
|
||||||
import static org.hwo.logging.Logging.log;
|
import static org.hwo.logging.Logging.log;
|
||||||
import static org.hwo.logging.LogLevel.*;
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -39,6 +40,7 @@ import org.hwo.pulscounter.device.SimulatedCounter;
|
||||||
import org.hwo.pulscounter.ui.AppSettingsListener;
|
import org.hwo.pulscounter.ui.AppSettingsListener;
|
||||||
import org.hwo.pulscounter.ui.BatchRunner;
|
import org.hwo.pulscounter.ui.BatchRunner;
|
||||||
import org.hwo.pulscounter.ui.NewMainWindow;
|
import org.hwo.pulscounter.ui.NewMainWindow;
|
||||||
|
import org.hwo.pulscounter.ui.ShutdownNotification;
|
||||||
import org.hwo.scheduler.Scheduler;
|
import org.hwo.scheduler.Scheduler;
|
||||||
|
|
||||||
public class PulsCounterApplication implements ServiceLinkListener{
|
public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
@ -178,6 +180,8 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
log(ERROR,"I/O Error reading synololog.cfg");
|
log(ERROR,"I/O Error reading synololog.cfg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applicationConfiguration.setProperty("ui.class", NewMainWindow.class.getCanonicalName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Properties getApplicationConfiguration(){
|
public Properties getApplicationConfiguration(){
|
||||||
|
@ -208,14 +212,15 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
public void start(){
|
public void start(){
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
String uiClassName = applicationConfiguration.getProperty("ui.class");
|
String uiClassName = applicationConfiguration.getProperty("ui.class");
|
||||||
|
Object ui = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class uiClazz = PulsCounterApplication.class.getClassLoader().loadClass(uiClassName);
|
Class uiClazz = PulsCounterApplication.class.getClassLoader().loadClass(uiClassName);
|
||||||
|
|
||||||
Constructor<?> constructor = uiClazz.getConstructor(PulsCounterApplication.class);
|
Constructor<?> constructor = uiClazz.getConstructor(PulsCounterApplication.class);
|
||||||
Object ui = (Object) constructor.newInstance(this);
|
ui = (Object) constructor.newInstance(this);
|
||||||
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
log(FATAL,"user interface class could not be loaded [%s] %s",uiClassName,e.getMessage());
|
log(FATAL,"user interface class could not be loaded [%s] %s",uiClassName,e.getMessage());
|
||||||
|
@ -230,13 +235,21 @@ public class PulsCounterApplication implements ServiceLinkListener{
|
||||||
|
|
||||||
waitUiFinished();
|
waitUiFinished();
|
||||||
|
|
||||||
|
ShutdownNotification sn = new ShutdownNotification();
|
||||||
|
if (Component.class.isInstance(ui)){
|
||||||
|
sn.setLocationRelativeTo((Component)ui);
|
||||||
|
}
|
||||||
|
sn.setVisible(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
shutdown();
|
shutdown();
|
||||||
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sn.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
|
|
|
@ -4,17 +4,26 @@ import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.sql.Array;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
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.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.hsqldb.jdbc.JDBCArrayBasic;
|
||||||
|
import org.hsqldb.types.Type;
|
||||||
|
import org.hwo.ArrayHelper;
|
||||||
|
import org.hwo.ObjectTable;
|
||||||
|
import org.hwo.ObjectTable.ObjectSet;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
import org.hwo.pulscounter.SnapShot;
|
import org.hwo.pulscounter.SnapShot;
|
||||||
import org.hwo.pulscounter.simplescript.SimpleScript;
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
import org.hwo.sql.Schema;
|
||||||
|
|
||||||
import static org.hwo.logging.Logging.*;
|
import static org.hwo.logging.Logging.*;
|
||||||
import static org.hwo.logging.LogLevel.*;
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
@ -28,6 +37,10 @@ public class PulsCounterDatabase {
|
||||||
try {
|
try {
|
||||||
getClass().getClassLoader().loadClass("org.hsqldb.jdbcDriver");
|
getClass().getClassLoader().loadClass("org.hsqldb.jdbcDriver");
|
||||||
dbConnection = DriverManager.getConnection("jdbc:hsqldb:file:synololog-hsql", "SA", "");
|
dbConnection = DriverManager.getConnection("jdbc:hsqldb:file:synololog-hsql", "SA", "");
|
||||||
|
log(INFO,"HSQLDB Version: %s",dbConnection.getMetaData().getDatabaseProductVersion());
|
||||||
|
|
||||||
|
Schema schema = new Schema(dbConnection);
|
||||||
|
schema.print();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -76,11 +89,19 @@ public class PulsCounterDatabase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement stmt = dbConnection.prepareStatement(query);
|
PreparedStatement stmt = dbConnection.prepareStatement(query);
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
for (int i=0;i<args.length;i++){
|
try {
|
||||||
stmt.setObject(i+1, args[i]);
|
for (i=0;i<args.length;i++){
|
||||||
|
if (Array.class.isInstance(args[i]))
|
||||||
|
stmt.setArray(i+1, (Array)args[i]);
|
||||||
|
else
|
||||||
|
stmt.setObject(i+1, args[i]);
|
||||||
|
}
|
||||||
|
} catch (SQLException e){
|
||||||
|
log(ERROR,"Exception while binding: %d = %s",i,args[i]);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
|
||||||
ResultSet result = stmt.getResultSet();
|
ResultSet result = stmt.getResultSet();
|
||||||
|
@ -92,6 +113,12 @@ public class PulsCounterDatabase {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log(ERROR,"SQL Statement failed: %s",query);
|
log(ERROR,"SQL Statement failed: %s",query);
|
||||||
log(ERROR,"Exception: %s", e.toString());
|
log(ERROR,"Exception: %s", e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
if (e.getCause() != null){
|
||||||
|
log(ERROR,"Caused-By: %s",e.getCause().toString());
|
||||||
|
e.getCause().printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -174,10 +201,24 @@ public class PulsCounterDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SnapShot[] loadSnapshots(int fromTimestamp){
|
public Integer[] getKnownDevices(){
|
||||||
|
List<Integer> devices = new LinkedList<>();
|
||||||
|
|
||||||
|
ResultSet result = executeSimpleSQL("SELECT DISTINCT device FROM snapshots ORDER BY device");
|
||||||
|
try {
|
||||||
|
while (result.next()){
|
||||||
|
devices.add( result.getInt(1));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
return devices.toArray(new Integer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnapShot[] loadSnapshots(int fromTimestamp,int deviceSerial){
|
||||||
List<SnapShot> snapshots = new LinkedList<>();
|
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);
|
ResultSet result = executeSimpleSQL("SELECT id,device,snap_id,timestamp,counters,analogs,inputs,outputs,pullups,inverts,field0 FROM snapshots WHERE timestamp >= ? AND device = ? ORDER BY device,timestamp", fromTimestamp, deviceSerial);
|
||||||
try {
|
try {
|
||||||
while (result.next()){
|
while (result.next()){
|
||||||
|
|
||||||
|
@ -192,8 +233,66 @@ public class PulsCounterDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleScript[] getSimpleScripts(){
|
public SimpleScript[] getSimpleScripts(){
|
||||||
return null;
|
ResultSet result = executeSimpleSQL("SELECT id,name,description,elements FROM scripts");
|
||||||
|
ArrayList<SimpleScript> r = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
while (result.next()){
|
||||||
|
r.add(new SimpleScript(UUID.fromString(result.getString(1)), result.getString(2), result.getString(3), ArrayHelper.cast((Object[])result.getArray(4).getArray(),new Integer[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return r.toArray(new SimpleScript[0]);
|
||||||
|
}
|
||||||
|
public void removeSimpleScript(UUID id){
|
||||||
|
executeSimpleQueryObject("DELETE FROM scripts WHERE id=?", id);
|
||||||
|
}
|
||||||
|
public void storeSimpleScript(SimpleScript simpleScript){
|
||||||
|
|
||||||
|
|
||||||
|
/* executeSimpleQueryObject("MERGE INTO scripts USING (VALUES ?,?,?,?) AS ins(uid,name,desc,elements) ON scripts.id=ins.uid WHEN MATCHED THEN UPDATE SET scripts.name=ins.name,scripts.description=ins.desc,scripts.elements=ins.elements WHEN NOT MATCHED THEN INSERT (id,name,description,elements) VALUES(ins.uid,ins.name,ins.desc,ins.elements)",
|
||||||
|
simpleScript.getId().toString(),
|
||||||
|
simpleScript.getName(),
|
||||||
|
simpleScript.getDescription(),
|
||||||
|
simpleScript.getSimpleScriptElementsAsInt()
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
executeSimpleSQL("DELETE FROM scripts WHERE id=?",simpleScript.getId());
|
||||||
|
executeSimpleSQL("INSERT INTO scripts VALUES(?,?,?,?)",
|
||||||
|
simpleScript.getId(),
|
||||||
|
simpleScript.getName(),
|
||||||
|
simpleScript.getDescription(),
|
||||||
|
simpleScript.getSimpleScriptElementsAsInt()
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ObjectTable getSnapshotsAsTable(int deviceSerial){
|
||||||
|
ObjectTable ot = new ObjectTable();
|
||||||
|
|
||||||
|
for (SnapShot ss: loadSnapshots(0,deviceSerial)){
|
||||||
|
ot.add( ss.getCSVRecord(true).getValuesAsArray() );
|
||||||
|
|
||||||
|
}
|
||||||
|
return ot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calulateTableDeltas(ObjectTable objectTable){
|
||||||
|
ObjectSet tmp = objectTable.new ObjectSet();
|
||||||
|
|
||||||
|
for (ObjectSet row: objectTable.getRows()){
|
||||||
|
for (int p=4;p<36;p++){
|
||||||
|
int i = row.getInteger(p) - tmp.getInteger(p);
|
||||||
|
tmp.set(p,row.getInteger(p));
|
||||||
|
row.set(p,i);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ create table if not exists props (id uuid primary key,name varchar(255) unique,v
|
||||||
create table if not exists devices (id uuid,serial varchar(12));
|
create table if not exists devices (id uuid,serial varchar(12));
|
||||||
create table if not exists 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);
|
create table if not exists 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);
|
||||||
|
|
||||||
create table if not exists scripts (id uuid primary key,name varchar(128),description text,elements integer ARRAY default ARRAY[]);
|
create table if not exists scripts (id uuid primary key,name varchar(128),description longvarchar,elements integer ARRAY[512] default ARRAY[]);
|
||||||
|
|
||||||
delete from props where name='db.schema.version';
|
delete from props where name='db.schema.version';
|
||||||
insert into props (id,name,value) values(uuid(),'db.schema.version','0');
|
insert into props (id,name,value) values(uuid(),'db.schema.version','0');
|
||||||
|
|
|
@ -15,19 +15,32 @@ public class SimpleScript {
|
||||||
|
|
||||||
public SimpleScript(){
|
public SimpleScript(){
|
||||||
id = UUID.randomUUID();
|
id = UUID.randomUUID();
|
||||||
name = "";
|
name = "SimpleScript";
|
||||||
description = "";
|
description = "-";
|
||||||
simpleScriptElements = new ArrayList<>();
|
simpleScriptElements = new ArrayList<>();
|
||||||
|
simpleScriptElements.add(new SimpleScriptElement(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleScript(String name,String description,SimpleScriptElement elements[]){
|
public SimpleScript(UUID uuid,String name,String description,SimpleScriptElement elements[]){
|
||||||
this.id = UUID.randomUUID();
|
this.id = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.simpleScriptElements = new ArrayList<>();
|
this.simpleScriptElements = new ArrayList<>();
|
||||||
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleScript(UUID uuid,String name,String description,Integer[] elementCodes){
|
||||||
|
this.id = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.simpleScriptElements = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Integer code: elementCodes){
|
||||||
|
this.simpleScriptElements.add(new SimpleScriptElement(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +48,7 @@ public class SimpleScript {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="name",order=10,width=120)
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +56,7 @@ public class SimpleScript {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TableColumn(label="Bezeichnung",order=20)
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +68,20 @@ public class SimpleScript {
|
||||||
return simpleScriptElements;
|
return simpleScriptElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer[] getSimpleScriptElementsAsInt(){
|
||||||
|
Integer[] sse = new Integer[simpleScriptElements.size()];
|
||||||
|
|
||||||
|
for (int i=0;i<sse.length;i++){
|
||||||
|
sse[i] = simpleScriptElements.get(i).getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return sse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimpleScriptElements(SimpleScriptElement[] elements){
|
||||||
|
this.simpleScriptElements.clear();
|
||||||
|
this.simpleScriptElements.addAll(Arrays.asList(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum ScriptOperation {
|
public enum ScriptOperation {
|
||||||
|
@ -188,16 +217,28 @@ public class SimpleScript {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableColumn(label="A",order=0)
|
@TableColumn(label="A",order=0)
|
||||||
|
public String getHumanA(){
|
||||||
|
return SimpleScriptAddress.toString(getA());
|
||||||
|
}
|
||||||
|
|
||||||
public int getA(){
|
public int getA(){
|
||||||
return code & 0xff;
|
return code & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableColumn(label="B",order=10)
|
@TableColumn(label="B",order=10)
|
||||||
|
public String getHumanB(){
|
||||||
|
return SimpleScriptAddress.toString(getB());
|
||||||
|
}
|
||||||
|
|
||||||
public int getB(){
|
public int getB(){
|
||||||
return (code >> 8) & 0xff;
|
return (code >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableColumn(label="Z",order=90)
|
@TableColumn(label="Z",order=90)
|
||||||
|
public String getHumanZ(){
|
||||||
|
return SimpleScriptAddress.toString(getZ());
|
||||||
|
}
|
||||||
|
|
||||||
public int getZ(){
|
public int getZ(){
|
||||||
return (code >> 16) & 0xff;
|
return (code >> 16) & 0xff;
|
||||||
}
|
}
|
||||||
|
@ -254,6 +295,6 @@ public class SimpleScript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.hwo.pulscounter.simplescript;
|
||||||
|
|
||||||
|
public class SimpleScriptAddress{
|
||||||
|
private int address;
|
||||||
|
|
||||||
|
public SimpleScriptAddress(){
|
||||||
|
this.address = 0;
|
||||||
|
}
|
||||||
|
public SimpleScriptAddress(int a){
|
||||||
|
this.address = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return toString(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(int address) {
|
||||||
|
if (address < 32){
|
||||||
|
return String.format("Zählerstand %d",address);
|
||||||
|
} else if (address < 40){
|
||||||
|
return String.format("Analogspannung %d", address - 32);
|
||||||
|
} else if (address < 64){
|
||||||
|
return String.format("Merker %d", address - 40);
|
||||||
|
} else if (address < 96){
|
||||||
|
return String.format("PullUp %d", address - 64);
|
||||||
|
} else if (address < 128){
|
||||||
|
return String.format("Ausgang %d", address - 96);
|
||||||
|
} else if (address < 160){
|
||||||
|
return String.format("Inverter %d", address - 128);
|
||||||
|
} else {
|
||||||
|
return String.format("Variable %d", address - 160);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ 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.servicelink.ServiceLinkException;
|
import org.hwo.servicelink.ServiceLinkException;
|
||||||
|
import static org.hwo.logging.Logging.*;
|
||||||
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
public class BatchRunner implements PulsCounterApplicationListener{
|
public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
|
|
||||||
|
@ -14,45 +16,39 @@ public class BatchRunner implements PulsCounterApplicationListener{
|
||||||
|
|
||||||
pulsCounterApplication.addPulsCounterApplicationListener(this);
|
pulsCounterApplication.addPulsCounterApplicationListener(this);
|
||||||
|
|
||||||
pulsCounterApplication.notifyUiIsFinished(true);
|
try {
|
||||||
|
run();
|
||||||
|
} catch (Exception e){
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
|
||||||
// run();
|
pulsCounterApplication.notifyUiIsFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
/*
|
|
||||||
try {
|
PulsCounterApplication.getApplication().checkForSnapShots();
|
||||||
|
|
||||||
for (ExportSetting es: pulsCounterApplication.getExportSettings()){
|
for (ExportSetting es: PulsCounterApplication.getApplication().getExportSettings()){
|
||||||
if (es.getAutostart()){
|
if (es.getAutostart()){
|
||||||
es.export();
|
es.export();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ServiceLinkException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
pulsCounterApplication.notifyUiIsFinished(false);
|
pulsCounterApplication.notifyUiIsFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageArrived(String message) {
|
public void messageArrived(String message) {
|
||||||
System.err.println(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication) {
|
public void interfaceClassesChanged(PulsCounterApplication pulsCounterApplication) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
public void interfacesChanged(PulsCounterApplication pulsCounterApplication) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class ExportFilesFrame extends JFrame {
|
||||||
gbc_toolBar.gridy = 0;
|
gbc_toolBar.gridy = 0;
|
||||||
contentPane.add(toolBar, gbc_toolBar);
|
contentPane.add(toolBar, gbc_toolBar);
|
||||||
|
|
||||||
bAdd = new JButton("+");
|
bAdd = new JButton("Export hinzufügen");
|
||||||
bAdd.setToolTipText("<html>\n<b>Neue Exportkonfiguration hinzufügen</b><br/>\n</html>");
|
bAdd.setToolTipText("<html>\n<b>Neue Exportkonfiguration hinzufügen</b><br/>\n</html>");
|
||||||
bAdd.addActionListener(new ActionListener() {
|
bAdd.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -80,7 +80,7 @@ public class ExportFilesFrame extends JFrame {
|
||||||
});
|
});
|
||||||
toolBar.add(bAdd);
|
toolBar.add(bAdd);
|
||||||
|
|
||||||
bEdit = new JButton("e");
|
bEdit = new JButton("Einstellungen");
|
||||||
bEdit.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration bearbeiten</b>\n</html>");
|
bEdit.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration bearbeiten</b>\n</html>");
|
||||||
bEdit.addActionListener(new ActionListener() {
|
bEdit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -95,7 +95,7 @@ public class ExportFilesFrame extends JFrame {
|
||||||
bEdit.setEnabled(false);
|
bEdit.setEnabled(false);
|
||||||
toolBar.add(bEdit);
|
toolBar.add(bEdit);
|
||||||
|
|
||||||
bRemove = new JButton("-");
|
bRemove = new JButton("Export löschen");
|
||||||
bRemove.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration entfernen</b>\n</html>");
|
bRemove.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration entfernen</b>\n</html>");
|
||||||
bRemove.addActionListener(new ActionListener() {
|
bRemove.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -111,7 +111,7 @@ public class ExportFilesFrame extends JFrame {
|
||||||
separator = new JSeparator();
|
separator = new JSeparator();
|
||||||
toolBar.add(separator);
|
toolBar.add(separator);
|
||||||
|
|
||||||
btnExec = new JButton("EXEC");
|
btnExec = new JButton("Export ausführen");
|
||||||
btnExec.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration jetzt ausführen</b><br/>\n</html>");
|
btnExec.setToolTipText("<html>\n<b>Ausgewählte Exportkonfiguration jetzt ausführen</b><br/>\n</html>");
|
||||||
btnExec.setEnabled(false);
|
btnExec.setEnabled(false);
|
||||||
btnExec.addActionListener(new ActionListener() {
|
btnExec.addActionListener(new ActionListener() {
|
||||||
|
@ -119,15 +119,15 @@ public class ExportFilesFrame extends JFrame {
|
||||||
doExport();
|
doExport();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
toolBar.add(btnExec);
|
||||||
|
|
||||||
btnBatch = new JButton("BATCH");
|
btnBatch = new JButton("Automatik");
|
||||||
btnBatch.addActionListener(new ActionListener() {
|
btnBatch.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
doBatchExport();
|
doBatchExport();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBar.add(btnBatch);
|
toolBar.add(btnBatch);
|
||||||
toolBar.add(btnExec);
|
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
scrollPane.setToolTipText("<html>\n<b>Exportkonfigurationen</b><br/>\nZeigt eine Übersicht über die aktuell vorhandenen Exportkonfigurationen\n</html>");
|
scrollPane.setToolTipText("<html>\n<b>Exportkonfigurationen</b><br/>\nZeigt eine Übersicht über die aktuell vorhandenen Exportkonfigurationen\n</html>");
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Set cross-platform Java L&F (also called "Metal")
|
// Set cross-platform Java L&F (also called "Metal")
|
||||||
UIManager.setLookAndFeel(
|
UIManager.setLookAndFeel(
|
||||||
UIManager.getCrossPlatformLookAndFeelClassName());
|
UIManager.getCrossPlatformLookAndFeelClassName());
|
||||||
}
|
}
|
||||||
catch (UnsupportedLookAndFeelException e) {
|
catch (UnsupportedLookAndFeelException e) {
|
||||||
|
@ -167,27 +167,6 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
|
|
||||||
pulsCounterApplication.addPulsCounterApplicationListener(this);
|
pulsCounterApplication.addPulsCounterApplicationListener(this);
|
||||||
|
|
||||||
if (false){
|
|
||||||
|
|
||||||
this.connected = false;
|
|
||||||
|
|
||||||
knownTasklets = new DefaultListModel<Tasklet>();
|
|
||||||
lTasklets.setModel(knownTasklets);
|
|
||||||
TaskletManager.instance().addTaskletListener(this);
|
|
||||||
|
|
||||||
messageListModel = new DefaultListModel<String>();
|
|
||||||
lMessages.setModel(messageListModel);
|
|
||||||
|
|
||||||
timerReconnect = new Timer("ReconnectThread",true);
|
|
||||||
|
|
||||||
application().addPulsCounterApplicationListener(this);
|
|
||||||
|
|
||||||
application().message("Synololog Applikation wurde gestartet.");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
frmSynolog.addWindowListener(new WindowAdapter() {
|
frmSynolog.addWindowListener(new WindowAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,8 +313,9 @@ public class NewMainWindow implements PulsCounterApplicationListener, TaskletLis
|
||||||
btnSkripte = new JButton("Skripte");
|
btnSkripte = new JButton("Skripte");
|
||||||
btnSkripte.addActionListener(new ActionListener() {
|
btnSkripte.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
SimpleScriptEditor editor = new SimpleScriptEditor();
|
SimpleScriptSetup sss = new SimpleScriptSetup();
|
||||||
editor.setVisible(true);
|
sss.setLocationRelativeTo(frmSynolog);
|
||||||
|
sss.setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBar.add(btnSkripte);
|
toolBar.add(btnSkripte);
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Window.Type;
|
||||||
|
import java.awt.Font;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
public class ShutdownNotification extends JFrame {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public ShutdownNotification() {
|
||||||
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
|
setTitle("Synolo-Log Software wird beendet");
|
||||||
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 770, 162);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
setContentPane(contentPane);
|
||||||
|
|
||||||
|
JLabel lblEinenMomentBittedie = new JLabel("<html>Einen Moment bitte.<br/>Die Synolo-Log Software wartet noch auf die Fertigstellung von Hintergrunddiensten...</html>");
|
||||||
|
lblEinenMomentBittedie.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
lblEinenMomentBittedie.setFont(new Font("DejaVu Sans", Font.BOLD | Font.ITALIC, 14));
|
||||||
|
contentPane.add(lblEinenMomentBittedie, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
|
||||||
|
public class SimpleScriptAddressEditor extends JPanel {
|
||||||
|
|
||||||
|
AddressRange[] addressRanges = new AddressRange[]{
|
||||||
|
new AddressRange("Zähler", 0, 32),
|
||||||
|
new AddressRange("Analogspannung", 32, 8),
|
||||||
|
new AddressRange("Merker", 40, 24),
|
||||||
|
new AddressRange("PullUp Status", 64, 32),
|
||||||
|
new AddressRange("Ausgang", 96, 32),
|
||||||
|
new AddressRange("Inverter", 128, 32),
|
||||||
|
new AddressRange("Variable", 160, 96)
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
public SimpleScriptAddressEditor() {
|
||||||
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
||||||
|
gridBagLayout.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
|
JComboBox comboBox = new JComboBox();
|
||||||
|
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
||||||
|
gbc_comboBox.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_comboBox.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_comboBox.gridx = 0;
|
||||||
|
gbc_comboBox.gridy = 0;
|
||||||
|
add(comboBox, gbc_comboBox);
|
||||||
|
|
||||||
|
JSpinner spinner = new JSpinner();
|
||||||
|
GridBagConstraints gbc_spinner = new GridBagConstraints();
|
||||||
|
gbc_spinner.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_spinner.gridx = 1;
|
||||||
|
gbc_spinner.gridy = 0;
|
||||||
|
add(spinner, gbc_spinner);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class AddressRange{
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int base;
|
||||||
|
private int size;
|
||||||
|
|
||||||
|
public AddressRange(String name,int base,int size){
|
||||||
|
this.name = name;
|
||||||
|
this.size = size;
|
||||||
|
this.base = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBase() {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.hwo.pulscounter.ui;
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
@ -24,9 +25,30 @@ import javax.swing.JLabel;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
|
||||||
public class SimpleScriptEditor extends JDialog {
|
public class SimpleScriptEditor extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean show(SimpleScript simpleScript){
|
||||||
|
return show(null,simpleScript);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean show(Component parent,SimpleScript simpleScript){
|
||||||
|
SimpleScriptEditor sse = new SimpleScriptEditor();
|
||||||
|
sse.setSimpleScript(simpleScript);
|
||||||
|
if (parent != null){
|
||||||
|
sse.setLocationRelativeTo(parent);
|
||||||
|
}
|
||||||
|
sse.setVisible(true);
|
||||||
|
return sse.isAccepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private SimpleScript simpleScript;
|
private SimpleScript simpleScript;
|
||||||
private boolean accepted;
|
private boolean accepted;
|
||||||
|
|
||||||
|
@ -39,6 +61,8 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
* Create the dialog.
|
* Create the dialog.
|
||||||
*/
|
*/
|
||||||
public SimpleScriptEditor() {
|
public SimpleScriptEditor() {
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
setBounds(100, 100, 921, 474);
|
setBounds(100, 100, 921, 474);
|
||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
@ -94,7 +118,6 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
gbc_scrollPane.gridwidth = 2;
|
gbc_scrollPane.gridwidth = 2;
|
||||||
gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
gbc_scrollPane.gridx = 0;
|
gbc_scrollPane.gridx = 0;
|
||||||
gbc_scrollPane.gridy = 2;
|
gbc_scrollPane.gridy = 2;
|
||||||
|
@ -110,12 +133,22 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
{
|
{
|
||||||
JButton okButton = new JButton("OK");
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
});
|
||||||
okButton.setActionCommand("OK");
|
okButton.setActionCommand("OK");
|
||||||
buttonPane.add(okButton);
|
buttonPane.add(okButton);
|
||||||
getRootPane().setDefaultButton(okButton);
|
getRootPane().setDefaultButton(okButton);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JButton cancelButton = new JButton("Cancel");
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
cancelButton.setActionCommand("Cancel");
|
cancelButton.setActionCommand("Cancel");
|
||||||
buttonPane.add(cancelButton);
|
buttonPane.add(cancelButton);
|
||||||
}
|
}
|
||||||
|
@ -126,6 +159,11 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void accept(){
|
private void accept(){
|
||||||
|
|
||||||
|
simpleScript.setName(tfName.getText());
|
||||||
|
simpleScript.setDescription(taDescription.getText());
|
||||||
|
|
||||||
|
|
||||||
accepted = true;
|
accepted = true;
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -138,16 +176,15 @@ public class SimpleScriptEditor extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
if (simpleScript == null){
|
if (this.simpleScript == null){
|
||||||
simpleScript = new SimpleScript("Ein Skript", "Eine Beschreibung", new SimpleScriptElement[]{
|
this.simpleScript = new SimpleScript();
|
||||||
new SimpleScriptElement(),
|
|
||||||
new SimpleScriptElement()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tfName.setText(simpleScript.getName());
|
tfName.setText(simpleScript.getName());
|
||||||
taDescription.setText(simpleScript.getDescription());
|
taDescription.setText(simpleScript.getDescription());
|
||||||
mtScriptElements.getTableMapper().setRows(simpleScript.getSimpleScriptElements());
|
mtScriptElements.getTableMapper().setRows(simpleScript.getSimpleScriptElements().toArray(new SimpleScriptElement[0]));
|
||||||
|
|
||||||
|
mtScriptElements.getTableMapper().setSortingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleScript getSimpleScript(){
|
public SimpleScript getSimpleScript(){
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript.SimpleScriptElement;
|
||||||
|
import java.awt.Dialog.ModalExclusionType;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
|
|
||||||
|
public class SimpleScriptElementEditor extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean show(Component parent,SimpleScriptElement simpleScriptElement){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SimpleScriptElement simpleScriptElement;
|
||||||
|
private boolean accepted;
|
||||||
|
|
||||||
|
private final JPanel contentPanel = new JPanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the dialog.
|
||||||
|
*/
|
||||||
|
public SimpleScriptElementEditor() {
|
||||||
|
setTitle("Skriptelement bearbeiten");
|
||||||
|
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
|
setBounds(100, 100, 519, 370);
|
||||||
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
contentPanel.setLayout(new FlowLayout());
|
||||||
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
|
{
|
||||||
|
JPanel buttonPane = new JPanel();
|
||||||
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||||
|
{
|
||||||
|
JButton okButton = new JButton("OK");
|
||||||
|
okButton.setActionCommand("OK");
|
||||||
|
buttonPane.add(okButton);
|
||||||
|
getRootPane().setDefaultButton(okButton);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.setActionCommand("Cancel");
|
||||||
|
buttonPane.add(cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleScriptElement getSimpleScriptElement() {
|
||||||
|
return simpleScriptElement;
|
||||||
|
}
|
||||||
|
public void setSimpleScriptElement(SimpleScriptElement simpleScriptElement) {
|
||||||
|
this.simpleScriptElement = simpleScriptElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void accept(){
|
||||||
|
accepted = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
private void cancel(){
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccepted() {
|
||||||
|
return accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,195 @@
|
||||||
|
package org.hwo.pulscounter.ui;
|
||||||
|
|
||||||
|
import static org.hwo.logging.LogLevel.*;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.swing.border.BevelBorder;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.models.TableMapper.TableMapperListener;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
import org.hwo.ui.JMappedTable;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import static org.hwo.logging.Logging.*;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.swing.border.BevelBorder;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.models.TableMapper.TableMapperListener;
|
||||||
|
import org.hwo.pulscounter.PulsCounterApplication;
|
||||||
|
import org.hwo.pulscounter.simplescript.SimpleScript;
|
||||||
|
import org.hwo.ui.JMappedTable;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class SimpleScriptSetup extends JFrame {
|
||||||
|
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JMappedTable scriptTable;
|
||||||
|
|
||||||
|
private ArrayList<SimpleScript> simpleScripts;
|
||||||
|
private JButton btnEntfernen;
|
||||||
|
private JButton btnBearbeiten;
|
||||||
|
private JButton btnNeu;
|
||||||
|
|
||||||
|
public SimpleScriptSetup() {
|
||||||
|
setTitle("Formeln");
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 831, 406);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
setContentPane(contentPane);
|
||||||
|
GridBagLayout gbl_contentPane = new GridBagLayout();
|
||||||
|
gbl_contentPane.columnWidths = new int[]{0, 0};
|
||||||
|
gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
|
gbl_contentPane.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
||||||
|
contentPane.setLayout(gbl_contentPane);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
|
||||||
|
flowLayout.setAlignment(FlowLayout.LEFT);
|
||||||
|
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 0;
|
||||||
|
contentPane.add(panel, gbc_panel);
|
||||||
|
|
||||||
|
btnNeu = new JButton("neu...");
|
||||||
|
btnNeu.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
scriptTable.getTableMapper().addRow(new SimpleScript());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(btnNeu);
|
||||||
|
|
||||||
|
btnBearbeiten = new JButton("bearbeiten...");
|
||||||
|
btnBearbeiten.setEnabled(false);
|
||||||
|
panel.add(btnBearbeiten);
|
||||||
|
|
||||||
|
btnEntfernen = new JButton("entfernen");
|
||||||
|
btnEntfernen.setEnabled(false);
|
||||||
|
btnEntfernen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SimpleScript sscript = scriptTable.getTableMapper().getSelectedRow(SimpleScript.class);
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().removeSimpleScript( sscript.getId() );
|
||||||
|
scriptTable.getTableMapper().removeRow(sscript);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(btnEntfernen);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
||||||
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_scrollPane.gridx = 0;
|
||||||
|
gbc_scrollPane.gridy = 1;
|
||||||
|
contentPane.add(scrollPane, gbc_scrollPane);
|
||||||
|
|
||||||
|
scriptTable = new JMappedTable(SimpleScript.class);
|
||||||
|
scrollPane.setViewportView(scriptTable);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
FlowLayout flowLayout_1 = (FlowLayout) panel_1.getLayout();
|
||||||
|
flowLayout_1.setAlignment(FlowLayout.RIGHT);
|
||||||
|
GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
||||||
|
gbc_panel_1.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_panel_1.gridx = 0;
|
||||||
|
gbc_panel_1.gridy = 2;
|
||||||
|
contentPane.add(panel_1, gbc_panel_1);
|
||||||
|
|
||||||
|
JButton btnSchliessen = new JButton("schliessen");
|
||||||
|
btnSchliessen.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnSchliessen);
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
this.simpleScripts = new ArrayList<>();
|
||||||
|
|
||||||
|
this.simpleScripts.addAll(Arrays.asList(PulsCounterApplication.getApplication().getDatabase().getSimpleScripts()));
|
||||||
|
|
||||||
|
this.scriptTable.getTableMapper().setRows(simpleScripts);
|
||||||
|
this.scriptTable.getTableMapper().setReadOnly(true);
|
||||||
|
this.scriptTable.getTableMapper().setEditorEnabled(true);
|
||||||
|
this.scriptTable.getTableMapper().addListSelectionListener(new ListSelectionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
if (scriptTable.getTableMapper().getSelectedRow() == null){
|
||||||
|
btnBearbeiten.setEnabled(false);
|
||||||
|
btnEntfernen.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
btnBearbeiten.setEnabled(true);
|
||||||
|
btnEntfernen.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.scriptTable.getTableMapper().addTableMapperListener(new TableMapperListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editorRequest(TableMapper tableMapper, Object row) {
|
||||||
|
if (row != null){
|
||||||
|
if (SimpleScriptEditor.show(SimpleScriptSetup.this,(SimpleScript)row)){
|
||||||
|
log(INFO,"store SimpleScript");
|
||||||
|
PulsCounterApplication.getApplication().getDatabase().storeSimpleScript((SimpleScript)row);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ValueChanged(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue