diff --git a/.gitignore b/.gitignore index da29205..58ee149 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /dist-ccu/build /ccu-historian/run/*.log /ccu-historian/run/*.lck +/.metadata/ diff --git a/README.md b/README.md index 56c458d..9c16bda 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ Die Installation und Konfiguration ist im [Handbuch](https://github.com/mdzio/cc ## Entwicklungsumgebung -Der CCU-Historian ist größtenteils in der [Programmiersprache Apache Groovy](http://groovy-lang.org) geschrieben. Weitere Programmiersprachen sind Java und JavaScript. Als Entwicklungsumgebung wird die [Eclipse IDE](http://www.eclipse.org) in der Variante für Java-Entwickler verwendet. Das Paket ist auf der [Download-Seite](https://www.eclipse.org/downloads/packages/) zu finden. Des Weiteren wird das [Groovy-Eclipse-Plugin](https://github.com/groovy/groovy-eclipse/wiki) ab der V4.0.0 benötigt. Dieses Plugin ist im Eclipse Marketplace (*Help* → *Eclipse Marketplace*) zu finden und sollte automatisch zur Installation angeboten werden, wenn das CCU-Historian-Projekt importiert wird. Über *File* → *Import* → *Projects from Git* kann direkt das Repository geklont werden. Die Zielplattform ist Java Version 8. +Der CCU-Historian ist größtenteils in der [Programmiersprache Apache Groovy](http://groovy-lang.org) geschrieben. Weitere Programmiersprachen sind Java und JavaScript. Als Entwicklungsumgebung wird die [Eclipse IDE](http://www.eclipse.org) ab der V2022-06 in der Variante für Java-Entwickler verwendet. Das Paket ist auf der [Download-Seite](https://www.eclipse.org/downloads/packages/) zu finden. Des Weiteren wird das [Groovy-Eclipse-Plugin](https://github.com/groovy/groovy-eclipse/wiki) ab der V4.24 benötigt. Dieses Plugin ist im Eclipse Marketplace (*Help* → *Eclipse Marketplace*) zu finden und sollte automatisch zur Installation angeboten werden, wenn das CCU-Historian-Projekt importiert wird. Über *File* → *Import* → *Projects from Git* kann direkt das Repository geklont werden. Die Zielplattform ist Java Version 8. + +Für die Distribution als CCU-Add-On muss unter *Window* → *Preferences* → *Groovy* → *Compiler* die V2.5.17 eingestellt werden. Für die anderen Distributionen V3.0.11. Alle Beiträge zum Projekt müssen unter die [GNU General Public License V3](LICENSE.txt) gestellt werden. Die Lizenzen von verwendeten Bibliotheken müssen mit dieser kompatibel sein. diff --git a/ccu-historian/build.properties b/ccu-historian/build.properties index bd9c490..d1b2cf3 100644 --- a/ccu-historian/build.properties +++ b/ccu-historian/build.properties @@ -1,2 +1,2 @@ # version of this build -version=3.1.1 +version=3.2.0 diff --git a/ccu-historian/src/mdz/ccuhistorian/Database.groovy b/ccu-historian/src/mdz/ccuhistorian/Database.groovy index 11d1237..8fc1578 100644 --- a/ccu-historian/src/mdz/ccuhistorian/Database.groovy +++ b/ccu-historian/src/mdz/ccuhistorian/Database.groovy @@ -732,7 +732,7 @@ public class Database implements Storage { } } - private synchronized void createBackup(String fileName) { + public synchronized void createBackup(String fileName) { connect() log.info "Creating backup of database to file $fileName" long start=System.currentTimeMillis() diff --git a/ccu-historian/src/mdz/ccuhistorian/DatabaseSystem.groovy b/ccu-historian/src/mdz/ccuhistorian/DatabaseSystem.groovy index f6811d5..2519b79 100644 --- a/ccu-historian/src/mdz/ccuhistorian/DatabaseSystem.groovy +++ b/ccu-historian/src/mdz/ccuhistorian/DatabaseSystem.groovy @@ -36,7 +36,9 @@ import groovy.transform.CompileStatic @Log @CompileStatic public class DatabaseSystem extends BaseSystem { - + + private final static long ATSTART_TASK_DELAY = 3000; // [ms] + ExtendedStorage extendedStorage private Database internalDatabase @@ -85,7 +87,7 @@ public class DatabaseSystem extends BaseSystem { // schedule task if (task.cron=="@start") { // run once - executeTask(task, 0, {}) + executeTask(task, ATSTART_TASK_DELAY, {}) } else { // setup cron Cron cron=cparser.parse(task.cron) diff --git a/ccu-historian/src/mdz/ccuhistorian/ExtendedStorage.groovy b/ccu-historian/src/mdz/ccuhistorian/ExtendedStorage.groovy index b2c35b1..8086ffe 100644 --- a/ccu-historian/src/mdz/ccuhistorian/ExtendedStorage.groovy +++ b/ccu-historian/src/mdz/ccuhistorian/ExtendedStorage.groovy @@ -132,7 +132,12 @@ class ExtendedStorage implements Storage { fireOnRead() return storage.replaceTimeSeries(dstDp, srcSeries, startTime, endTime) } - + + public void createBackup(String fileName) { + fireOnRead() + storage.createBackup(fileName) + } + String getConfig(String name) { return storage.getConfig(name) } diff --git a/ccu-historian/src/mdz/ccuhistorian/Main.groovy b/ccu-historian/src/mdz/ccuhistorian/Main.groovy index dd39c3d..daebf11 100644 --- a/ccu-historian/src/mdz/ccuhistorian/Main.groovy +++ b/ccu-historian/src/mdz/ccuhistorian/Main.groovy @@ -24,7 +24,7 @@ import mdz.hc.persistence.Storage class Main { - public static String version='3.1.1' + public static String version='3.2.0' private static final Logger log=Logger.getLogger(Main.class.name) private static Main main diff --git a/dist-generic/src/ccu-historian-sample.config b/dist-generic/src/ccu-historian-sample.config index 68a741e..db423de 100644 --- a/dist-generic/src/ccu-historian-sample.config +++ b/dist-generic/src/ccu-historian-sample.config @@ -28,6 +28,7 @@ // database.pgEnable=false // database.pgPort=5435 // database.pgAllowOthers=false +// database.tasks ... (s.a. https://github.com/mdzio/ccu-historian/wiki#automatische-ausführung-von-skripten) // webServer.port=80 // webServer.dir='./webapp' // webServer.logLevel=Level.WARNING diff --git a/external-libs/.settings/org.eclipse.core.resources.prefs b/external-libs/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4824b80 --- /dev/null +++ b/external-libs/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/hc-utils/src/mdz/hc/persistence/BackupStorage.groovy b/hc-utils/src/mdz/hc/persistence/BackupStorage.groovy new file mode 100644 index 0000000..6e7b380 --- /dev/null +++ b/hc-utils/src/mdz/hc/persistence/BackupStorage.groovy @@ -0,0 +1,6 @@ +package mdz.hc.persistence + +interface BackupStorage { + + void createBackup(String filename) +} diff --git a/hc-utils/src/mdz/hc/persistence/ReadOnlyDecorator.groovy b/hc-utils/src/mdz/hc/persistence/ReadOnlyDecorator.groovy index b7ae331..9b13144 100644 --- a/hc-utils/src/mdz/hc/persistence/ReadOnlyDecorator.groovy +++ b/hc-utils/src/mdz/hc/persistence/ReadOnlyDecorator.groovy @@ -111,6 +111,10 @@ public class ReadOnlyDecorator implements Storage { throw new Exception('Storage is read only') } + @Override void createBackup(String fileName) { + storage.createBackup(fileName) + } + @Override public String getConfig(String name) { storage.getConfig(name) diff --git a/hc-utils/src/mdz/hc/persistence/Storage.groovy b/hc-utils/src/mdz/hc/persistence/Storage.groovy index 7295aff..62ec66b 100644 --- a/hc-utils/src/mdz/hc/persistence/Storage.groovy +++ b/hc-utils/src/mdz/hc/persistence/Storage.groovy @@ -19,5 +19,5 @@ package mdz.hc.persistence import groovy.lang.Closure; -public interface Storage extends DataPointStorage, HistoryStorage, ConfigStorage { +public interface Storage extends DataPointStorage, HistoryStorage, ConfigStorage, BackupStorage { }