Commit 72210acf authored by Christian Kniss's avatar Christian Kniss

Initialisierung GitLab-Repo fuer Sourcecode der SWE...

Initialisierung GitLab-Repo fuer Sourcecode der SWE de.bsvrz.dua.progglaette-FREI_V2.0.2_D2016-08-01
parents
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Peuker
Created-By: Apache Maven 3.2.3
Build-Jdk: 1.8.0_92
package de.bsvrz.dua.progglaette;
public class PackageRuntimeInfo {
public static String getLicence() { return "GPL";}
public static String getRelease() { return "DuA Version 2.0.0";}
public static String getVersion() { return "2.0.0";}
public static String getRevision() { return "6a0b88a94970a0b18bee22b8e3169c1dafb674a0";}
public static String getCompileTime() { return "03.05.2016 11:45:44";}
public static String getDependsOnCompiled() { return "de.bsvrz.dav.daf, de.bsvrz.dav.dav, de.bsvrz.sys.funclib.commandLineArgs, de.bsvrz.sys.funclib.debug, de.bsvrz.sys.funclib.application, de.bsvrz.sys.funclib.operatingMessage, de.bsvrz.sys.funclib.bitctrl.dua, de.bsvrz.sys.funclib.bitctrl";}
public static String getDependsOnSource() { return "";}
public static String getDependsOnLib() { return "";}
public static String getJvmVersion() { return "1.8";}
}
\ No newline at end of file
/*
* Segment Datenübernahme und Aufbereitung (DUA), SWE Glättewarnung und -prognose
* Copyright 2016 by Kappich Systemberatung Aachen
*
* This file is part of de.bsvrz.dua.progglaette.
*
* de.bsvrz.dua.progglaette is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.bsvrz.dua.progglaette is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.bsvrz.dua.progglaette. If not, see <http://www.gnu.org/licenses/>.
* Contact Information:
* Kappich Systemberatung
* Martin-Luther-Straße 14
* 52062 Aachen, Germany
* phone: +49 241 4090 436
* mail: <info@kappich.de>
*/
/**
* Segment Datenübernahme und Aufbereitung (DUA), SWE Glättewarnung und -prognose
*
* @author Kappich Systemberatung
*/
package de.bsvrz.dua.progglaette;
/*
*
* Copyright (C) 2007-2015 BitCtrl Systems GmbH
* Copyright 2016 by Kappich Systemberatung Aachen
*
* This file is part of de.bsvrz.dua.progglaette.
*
* de.bsvrz.dua.progglaette is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.bsvrz.dua.progglaette is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.bsvrz.dua.progglaette. If not, see <http://www.gnu.org/licenses/>.
* Contact Information:
* Kappich Systemberatung
* Martin-Luther-Straße 14
* 52062 Aachen, Germany
* phone: +49 241 4090 436
* mail: <info@kappich.de>
*/
package de.bsvrz.dua.progglaette.progglaette;
import java.util.SortedSet;
import java.util.TreeSet;
/**
* Berechnet eine Prognose von Messwerten mit der Methode der Linearen
* Trendextrapolation ( Least Square Method ) Die Prognose ist nach AFo im
* Horizont 5, 15, 30, 60, 90 Minuten.
*
* @author BitCtrl Systems GmbH, Bachraty
*/
public class PrognoseZustand {
/**
* Minute in Millisekunden.
*/
public static final long MIN_IN_MS = 60L * 1000L;
/**
* Standardkonstruktor.
*/
protected PrognoseZustand() {
}
/**
* Berechnet die Prognose.
*
* @param werteArray
* Messwerte
* @param zeitArrayOriginal
* Zeitpunkte der Messwerten
* @param indexAktuell
* Index des letzten Messwertes ( aktuellen )
* @return Prognose fuer den Messwert in 5, 15, 30, 60 und 90 Minuten
*/
static double[] berechnePrognose(final double[] werteArray,
final long[] zeitArrayOriginal, final int indexAktuell) {
/**
* kleinsten Zeitstempel heraussuchen
*/
final SortedSet<Long> ordnung = new TreeSet<Long>();
for (final Long zeitStempel : zeitArrayOriginal) {
if (zeitStempel > 0) {
ordnung.add(zeitStempel);
}
}
final long kleinsterZeitStempel = ordnung.first();
long t0 = 0;
final long[] zeitArray = new long[zeitArrayOriginal.length];
for (int i = 0; i < zeitArrayOriginal.length; i++) {
if (zeitArrayOriginal[i] > 0) {
zeitArray[i] = ((zeitArrayOriginal[i] - kleinsterZeitStempel) / ((long) (60 * 1000))) + 1;
if (zeitArray[i] > t0) {
t0 = zeitArray[i];
}
} else {
zeitArray[i] = 0;
}
}
double a, b;
final double[] y = new double[5];
double sumT = 0.0f;
double sumT2 = 0.0f;
double sumW = 0.0f;
double sumTW = 0.0f;
double tMitte, yMitte;
final int n = werteArray.length;
int m = n;
for (int i = 0; i < n; i++) {
// Zeitstempel ist 0, wenn ein Datum fehlt
if (zeitArray[i] != 0) {
sumT += zeitArray[i];
sumW += werteArray[i];
sumT2 += zeitArray[i] * zeitArray[i];
sumTW += zeitArray[i] * werteArray[i];
} else {
m--;
}
}
tMitte = sumT / m;
yMitte = sumW / m;
a = (sumTW - (m * tMitte * yMitte)) / (sumT2 - (m * tMitte * tMitte));
b = yMitte - (a * tMitte);
y[0] = (a * (t0 + 5L)) + b;
y[1] = (a * (t0 + 15L)) + b;
y[2] = (a * (t0 + 30L)) + b;
y[3] = (a * (t0 + 60L)) + b;
y[4] = (a * (t0 + 90L)) + b;
return y;
}
}
/*
*
* Copyright (C) 2007-2015 BitCtrl Systems GmbH
* Copyright 2016 by Kappich Systemberatung Aachen
*
* This file is part of de.bsvrz.dua.progglaette.
*
* de.bsvrz.dua.progglaette is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.bsvrz.dua.progglaette is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.bsvrz.dua.progglaette. If not, see <http://www.gnu.org/licenses/>.
* Contact Information:
* Kappich Systemberatung
* Martin-Luther-Straße 14
* 52062 Aachen, Germany
* phone: +49 241 4090 436
* mail: <info@kappich.de>
*/
/**
* Klassen für die SWE 4.14 Glättewarnung und -prognose
*/
package de.bsvrz.dua.progglaette.progglaette;
Platzhalterdatei, damit Ornderstruktur fuer Gradle in GitLab eingecheckt werden kann (Git ignoriert leere Ordner).
\ No newline at end of file
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Peuker
Created-By: Apache Maven 3.2.3
Build-Jdk: 1.8.0_92
/*
* Copyright 2016 by Kappich Systemberatung Aachen
*
* This file is part of de.bsvrz.dua.progglaette.tests.
*
* de.bsvrz.dua.progglaette.tests is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.bsvrz.dua.progglaette.tests is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.bsvrz.dua.progglaette.tests. If not, see <http://www.gnu.org/licenses/>.
* Contact Information:
* Kappich Systemberatung
* Martin-Luther-Straße 14
* 52062 Aachen, Germany
* phone: +49 241 4090 436
* mail: <info@kappich.de>
*/
package de.bsvrz.dua.progglaette.tests;
import de.bsvrz.dav.daf.main.ResultData;
import de.bsvrz.dav.daf.main.SendSubscriptionNotConfirmed;
import de.bsvrz.dua.progglaette.progglaette.GlaetteWarnungUndPrognose;
import de.bsvrz.dua.tests.DuATestBase;
import de.bsvrz.sys.funclib.commandLineArgs.ArgumentList;
import org.junit.After;
import org.junit.Before;
/**
* TBD Dokumentation
*
* @author Kappich Systemberatung
*/
public class DuAProgGlaetteTestBase extends DuATestBase {
protected GlaetteWarnungUndPrognose _glaetteWarnungUndPrognose;
protected String[] getUfdArgs() {
return new String[]{"-KonfigurationsBereichsPid=kb.duaTestUfd"};
}
@Override
protected String[] getConfigurationAreas() {
return new String[]{"kb.duaTestUfd"};
}
@Before
public void setUp() throws Exception {
super.setUp();
_glaetteWarnungUndPrognose = new GlaetteWarnungUndPrognose();
_glaetteWarnungUndPrognose.parseArguments(new ArgumentList(getUfdArgs()));
_glaetteWarnungUndPrognose.initialize(_connection);
}
@After
public void tearDown() throws Exception {
super.tearDown();
}
@Override
public void sendData(final ResultData... resultDatas) throws SendSubscriptionNotConfirmed {
_glaetteWarnungUndPrognose.update(resultDatas);
}
}
package de.bsvrz.dua.progglaette.tests;
public class PackageRuntimeInfo {
public static String getLicence() { return "GPL";}
public static String getRelease() { return "DuA Version 2.0.0";}
public static String getVersion() { return "2.0.0";}
public static String getRevision() { return "6a0b88a94970a0b18bee22b8e3169c1dafb674a0";}
public static String getCompileTime() { return "03.05.2016 13:42:55";}
public static String getDependsOnCompiled() { return "de.bsvrz.dav.daf, de.bsvrz.dav.dav, de.bsvrz.sys.funclib.commandLineArgs, de.bsvrz.sys.funclib.debug, de.bsvrz.sys.funclib.application, de.bsvrz.sys.funclib.operatingMessage, de.bsvrz.dua.guete, de.bsvrz.sys.funclib.bitctrl.dua, de.bsvrz.sys.funclib.bitctrl, de.bsvrz.dua.progglaette, de.bsvrz.dua.tests";}
public static String getDependsOnSource() { return "";}
public static String getDependsOnLib() { return "";}
public static String getJvmVersion() { return "1.8";}
}
\ No newline at end of file
/*
* Copyright 2016 by Kappich Systemberatung Aachen
*
* This file is part of de.bsvrz.dua.progglaette.tests.
*
* de.bsvrz.dua.progglaette.tests is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.bsvrz.dua.progglaette.tests is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.bsvrz.dua.progglaette.tests. If not, see <http://www.gnu.org/licenses/>.
* Contact Information:
* Kappich Systemberatung
* Martin-Luther-Straße 14
* 52062 Aachen, Germany
* phone: +49 241 4090 436
* mail: <info@kappich.de>
*/
package de.bsvrz.dua.progglaette.tests;
import de.bsvrz.dav.daf.main.Data;
import de.bsvrz.dav.daf.main.DataDescription;
import de.bsvrz.dav.daf.main.ResultData;
import de.bsvrz.dav.daf.main.config.Aspect;
import de.bsvrz.dav.daf.main.config.AttributeGroup;
import de.bsvrz.dav.daf.main.config.SystemObject;
import de.bsvrz.sys.funclib.bitctrl.dua.DUAKonstanten;
import de.kappich.pat.testumg.util.DavTestUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicLong;
/**
* TBD Dokumentation
*
* @author Kappich Systemberatung
*/
public class TestDuAProgGlaette extends DuAProgGlaetteTestBase {
private SystemObject _tpt;
private SystemObject _fbz;
private SystemObject _lt;
private SystemObject _rlf;
private SystemObject _fbt;
private SystemObject _messstelle;
private AttributeGroup _atgtpt;
private AttributeGroup _atgfbz;
private AttributeGroup _atglt;
private AttributeGroup _atgrlf;
private AttributeGroup _atgfbt;
private Aspect _aspAnalyse;
private AttributeGroup _atgGlaette;
private AttributeGroup _atgtptAna;
private DataDescription _ddGlaette;
private Aspect _aspPrognose;
private static final AtomicLong _timestamp = new AtomicLong(60000);
@Override
@Before
public void setUp() throws Exception {
super.setUp();
_tpt = _dataModel.getObject("ufd.tpt");
_fbz = _dataModel.getObject("ufd.fbz");
_lt = _dataModel.getObject("ufd.lt");
_rlf = _dataModel.getObject("ufd.rlf");
_fbt = _dataModel.getObject("ufd.fbt");
_messstelle = _dataModel.getObject("ufdm.1");
_atgtpt = _dataModel.getAttributeGroup("atg.ufds" + "TaupunktTemperatur");
_atgfbz = _dataModel.getAttributeGroup("atg.ufds" + "FahrBahnOberFlächenZustand");
_atglt = _dataModel.getAttributeGroup("atg.ufds" + "LuftTemperatur");
_atgrlf = _dataModel.getAttributeGroup("atg.ufds" + "RelativeLuftFeuchte");
_atgfbt = _dataModel.getAttributeGroup("atg.ufds" + "FahrBahnOberFlächenTemperatur");
_atgtptAna = _dataModel.getAttributeGroup("atg.ufdmsTaupunktTemperaturFahrBahn");
_atgGlaette = _dataModel.getAttributeGroup("atg.ufdmsGlätte");
_aspAnalyse = _dataModel.getAspect(DUAKonstanten.ASP_ANALYSE);
_aspPrognose = _dataModel.getAspect("asp.prognose");
_ddGlaette = new DataDescription(_atgGlaette, _aspPrognose);
_timestamp.set(60000);
DavTestUtil.startRead(_messstelle, _ddGlaette);
}
@Test
public void testProgGlaette() throws Exception {
expect(null);
sendData(fbt(5.1), lt(2.0), tpt(0.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag möglich");
nextInterval();
sendData(fbt(5.1), lt(2.1), tpt(0.0), fbz("trocken"));
expect("Keine Glättegefahr");
nextInterval();
sendData(fbt(5.0), lt(2.1), tpt(0.0), fbz("trocken"));
expect("Glättegefahr bei Wetteränderung möglich");
nextInterval();
sendData(fbt(3.0), lt(2.1), tpt(0.0), fbz("trocken"));
expect("Glättegefahr bei Wetteränderung möglich");
nextInterval();
sendData(fbt(3.0), lt(2.1), tpt(0.0), fbz("feucht"));
expect("Eisglätte möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt(0.0), fbz("feucht"));
expect("Eisglätte sofort möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt(0.0), fbz("nass"));
expect("Eisglätte sofort möglich");
nextInterval();
sendData(fbt(1.0), lt(2.1), tpt(0.0), fbz("Eis"));
expect("Glätte vorhanden");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt(0.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sofort sowie Reifglätte möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt(-1.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sofort möglich");
nextInterval();
sendData(fbt(-3.0), lt(2.1), tpt(-1.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sowie Reifglätte sofort möglich");
nextInterval();
}
@Test
public void testProgGlaetteTptAnalyse() throws Exception {
expect(null);
sendData(fbt(5.1), lt(2.0), tpt("fehlerhaft"), tptAna(0.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag möglich");
nextInterval();
sendData(fbt(5.1), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("trocken"));
expect("Keine Glättegefahr");
nextInterval();
sendData(fbt(5.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("trocken"));
expect("Glättegefahr bei Wetteränderung möglich");
nextInterval();
sendData(fbt(3.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("trocken"));
expect("Glättegefahr bei Wetteränderung möglich");
nextInterval();
sendData(fbt(3.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("feucht"));
expect("Eisglätte möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("feucht"));
expect("Eisglätte sofort möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("nass"));
expect("Eisglätte sofort möglich");
nextInterval();
sendData(fbt(1.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("Eis"));
expect("Glätte vorhanden");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt("fehlerhaft"), tptAna(0.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sofort sowie Reifglätte möglich");
nextInterval();
sendData(fbt(2.0), lt(2.1), tpt("fehlerhaft"), tptAna(-1.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sofort möglich");
nextInterval();
sendData(fbt(-3.0), lt(2.1), tpt("fehlerhaft"), tptAna(-1.0), fbz("trocken"));
expect("Schneeglätte oder Glatteis bei Niederschlag sowie Reifglätte sofort möglich");
nextInterval();
}
private void expect(final String expected) throws InterruptedException {
ResultData read = DavTestUtil.readData(_messstelle, _ddGlaette);
System.out.println(read.getData());
if(expected == null){
if(read.hasData()){
Assert.fail("Erwartet: Leer, aber war: " + read.getData());
}
}
else {
if(!read.hasData()){
Assert.fail("Erwartet: " + expected + ", aber war leer.");
}
Assert.assertEquals(expected, read.getData().getTextValue("AktuellerZustand").getText());
}
}
private ResultData fbt(final Object value) {
Data data = _connection.createData(_atgfbt);
resetMyData(data);
if(value == null) {
data = null;
}
else {
data.getItem("FahrBahnOberFlächenTemperatur").getTextValue("Wert").setText(value.toString());
}
return new ResultData(_fbt, new DataDescription(_atgfbt, _aspAnalyse), _timestamp.get(), data);
}
private ResultData fbz(final Object value) {
Data data = _connection.createData(_atgfbz);
resetMyData(data);
if(value == null) {
data = null;
}
else {
data.getItem("FahrBahnOberFlächenZustand").getTextValue("Wert").setText(value.toString());
}
return new ResultData(_fbz, new DataDescription(_atgfbz, _aspAnalyse), _timestamp.get(), data);
}
private ResultData lt(final Object value) {
Data data = _connection.createData(_atglt);
resetMyData(data);
if(value == null) {
data = null;
}
else {
data.getItem("LuftTemperatur").getTextValue("Wert").setText(value.toString());
}
return new ResultData(_lt, new DataDescription(_atglt, _aspAnalyse), _timestamp.get(), data);
}
private ResultData tpt(final Object value) {
Data data = _connection.createData(_atgtpt);
resetMyData(data);
if(value == null) {
data = null;
}
else {
data.getItem("TaupunktTemperatur").getTextValue("Wert").setText(value.toString());
}
return new ResultData(_tpt, new DataDescription(_atgtpt, _aspAnalyse), _timestamp.get(), data);
}
private ResultData tptAna(final Object value) {
Data data = _connection.createData(_atgtptAna);
if(value == null) {
data = null;
}
else {
data.getTextValue("TaupunktTemperaturFahrBahn").setText(value.toString());
}
return new ResultData(_tpt, new DataDescription(_atgtptAna, _aspAnalyse), _timestamp.get(), data);
}
private void nextInterval() {
_timestamp.getAndAdd(60000);
}
public void resetMyData(final Data data) {
resetData(data);
data.getTimeValue("T").setMillis(60000);
}
}
Platzhalterdatei, damit Ornderstruktur fuer Gradle in GitLab eingecheckt werden kann (Git ignoriert leere Ordner).
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment