Commit 102629bb authored by Giustozzi Franco's avatar Giustozzi Franco
Browse files

new console formatter

parent 1a86f33d
......@@ -65,7 +65,7 @@
<dependency>
<groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId>
<version>3.6.5</version>
<version>3.8.0</version>
</dependency>
</dependencies>
......
......@@ -2,13 +2,19 @@ package csparql.ind;
import java.awt.Color;
import java.io.File;
import org.apache.http.message.BasicStatusLine;
import java.io.FileReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.opencsv.CSVReader;
import org.apache.log4j.PropertyConfigurator;
import org.knowm.xchart.QuickChart;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.XYChart;
import org.knowm.xchart.XYChartBuilder;
import org.knowm.xchart.style.Styler.ChartTheme;
import org.knowm.xchart.style.Styler.LegendPosition;
import org.knowm.xchart.style.markers.SeriesMarkers;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLOntology;
......@@ -37,97 +43,111 @@ public class App {
//The initialization creates the static engine (SPARQL) and the stream engine (CEP)
engine.initialize(true);
//String fileOntology = "sicopad.owl";
String fileOntology = "ContextOntology-COInd4.owl";
// put static model
engine.putStaticNamedModel("http://streamreasoning.org/ContextOntology-COInd4",CsparqlUtils.serializeRDFFile(fileOntology));
engine.putStaticNamedModel("http://streamreasoning.org/sicopad",CsparqlUtils.serializeRDFFile(fileOntology));
List<Date> axis_x_date = new ArrayList<>();
List<Double> axis_y_temp = new ArrayList<>();
int start = 4200;
CSVReader reader = new CSVReader(new FileReader("example.csv"));
List<String[]> allRows = reader.readAll();
/*
String queryS6 = "REGISTER QUERY S6detection AS "
Double value = Double.parseDouble(allRows.get(start)[3]);
String date_str = allRows.get(start)[1].replace("/", "-") + " " + allRows.get(start)[2];
SimpleDateFormat date_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
Date date = date_formatter.parse(date_str);
axis_x_date.add(date);
axis_y_temp.add(value);
final XYChart chart = new XYChartBuilder().width(800).height(600).theme(ChartTheme.XChart).title("Capsule n°2,21.00.06.F9").build();
chart.getStyler().setLegendPosition(LegendPosition.OutsideS);
chart.setXAxisTitle("Time");
chart.setYAxisTitle("°C");
chart.addSeries("Temperature", axis_x_date, axis_y_temp).setMarker(SeriesMarkers.NONE);
chart.getStyler().setYAxisMin(25.0);
chart.getStyler().setYAxisMax(40.0);
chart.getStyler().setXAxisLabelRotation(-90);
chart.getStyler().setCursorEnabled(true);
chart.getStyler().setCursorColor(Color.GREEN);
chart.getStyler().setCursorFontColor(Color.BLACK);
chart.getStyler().setCursorBackgroundColor(Color.WHITE);
chart.getStyler().setZoomEnabled(true);
chart.getStyler().setZoomResetByDoubleClick(false);
chart.getStyler().setZoomResetByButton(true);
chart.getStyler().setZoomSelectionColor(new Color(0,0 , 192, 128));
final SwingWrapper<XYChart> sw = new SwingWrapper<XYChart>(chart);
sw.displayChart();
String queryPrefievre = "REGISTER QUERY Prefievre AS "
//+ "PREFIX : <http://semanticweb.org/mathieu/ontologies/2020/11/sicopad#> "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_temp> [RANGE 60s STEP 60s] "
+ "FROM <http://streamreasoning.org/ContextOntology-COInd4> "
+ "SELECT ?s (AVG(?v1) as ?avgTemp) "
+ "FROM STREAM <Stream_S_temp> [RANGE 10s TUMBLING] "
+ "FROM <http://streamreasoning.org/sicopad> "
+ "WHERE { "
+ "{ ?m :isPartOf ?pl ."
+ " ?m sosa:hosts sosa:S_Temperature ."
+ " :S_Temperature :madeObservation ?o1 ."
+ " ?o1 :hasSimpleResult ?v1 ."
+ " FILTER ( "
+ " ?v1 > 30.0 "
+ " ) . }"
+ " } ";
*/
String queryS6 = "REGISTER QUERY S6detection AS "
+ " ?s :madeObservation ?o1 ."
+ " ?o1 :hasTime ?t ."
+ " ?t :inXSDDateTime ?ts ."
+ " ?o1 :hasSimpleResult ?v1 ."
+ " } "
+ " GROUP BY ?s "
+ " HAVING((AVG(?v1) > 37.8) && (AVG(?v1) < 38.0)) ";
String queryPrefievreNuit = "REGISTER QUERY PrefievreNuit AS "
//+ "PREFIX : <http://semanticweb.org/mathieu/ontologies/2020/11/sicopad#> "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
+ "SELECT ?s (AVG(?v1) as ?avgTemp) "
+ "FROM STREAM <Stream_S_temp> [RANGE 10s STEP 10s] "
+ "FROM <http://streamreasoning.org/ContextOntology-COInd4> "
+ "FROM STREAM <Stream_S_temp> [RANGE 10s TUMBLING] "
+ "FROM <http://streamreasoning.org/sicopad> "
+ "WHERE { "
+ " ?s :madeObservation ?o1 ."
+ " ?o1 :hasTime ?t ."
+ " ?t :inXSDDateTime ?ts ."
+ " ?o1 :hasSimpleResult ?v1 ."
+ " FILTER ( "
//+ " (hours(\"2011-01-10T14:45:13.815-05:00\"^^xsd:dateTime) = 14 ) "
+ " (hours(?ts) > 0 ) "
+ " && (hours(?ts) < 7 ) "
+ " ) "
+ " } "
+ " GROUP BY ?s "
+ " HAVING(AVG(?v1) > 30.0) ";
double[] data_temp = new double[9000];
double phase = 0;
double[][] initdata_temp = getInitData(phase,data_temp);
final XYChart chart = QuickChart.getChart("Capsule n°2,21.00.06.F9", "Time", "(°C)", "Temperature", initdata_temp[0], initdata_temp[1]);
chart.getStyler().setLegendPosition(LegendPosition.OutsideS);
//XYSeries series_TG_temp = chart.addSeries("TG_temp", initdata_TG_temp[0],initdata_TG_temp[1]);
//series_TG_temp.setMarker(SeriesMarkers.NONE);
chart.getStyler().setYAxisMin(25.0);
chart.getStyler().setYAxisMax(40.0);
chart.getStyler().setCursorEnabled(true);
chart.getStyler().setCursorColor(Color.GREEN);
chart.getStyler().setCursorFontColor(Color.ORANGE);
chart.getStyler().setCursorBackgroundColor(Color.BLUE);
final SwingWrapper<XYChart> sw = new SwingWrapper<XYChart>(chart);
sw.displayChart();
+ " HAVING((AVG(?v1) > 37.6) && (AVG(?v1) < 37.8) "
+ " ) ";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
//String ontologyURI = "http://www.semanticweb.org/mathieu/ontologies/2020/11/sicopad";
String ontologyURI = "http://semanticweb.org/STEaMINg/ContextOntology-COInd4";
String ns = ontologyURI + "#";
final OWLOntology ontology = manager.loadOntologyFromOntologyDocument(new File(fileOntology));
SensorsStreamer Stream_Temp = new SensorsStreamer("Stream_S_temp",ns,"Temperature",2,ontology,factory,data_temp,chart,sw);
SensorsStreamer Stream_Temp = new SensorsStreamer("Stream_S_temp",ns,"Temperature",1,ontology,factory,axis_x_date,axis_y_temp,chart,sw,start);
//Register new streams in the engine
engine.registerStream(Stream_Temp);
Thread Stream_C_Wtemp_Thread = new Thread(Stream_Temp);
Thread Stream_temp_Thread = new Thread(Stream_Temp);
//Register new query in the engine
CsparqlQueryResultProxy c_S6 = engine.registerQuery(queryS6, false);
CsparqlQueryResultProxy c_queryPrefievre = engine.registerQuery(queryPrefievre, false);
CsparqlQueryResultProxy c_queryPrefievreNuit = engine.registerQuery(queryPrefievreNuit, false);
//Attach a result consumer to the query result proxy to print the results on the console
c_S6.addObserver(new ConsoleFormatter("S6",ns,ontology,factory));
c_queryPrefievre.addObserver(new ConsoleFormatterPreFievre("PREFIEVRE",ns,ontology,factory,axis_x_date,chart,sw));
c_queryPrefievreNuit.addObserver(new ConsoleFormatterPreFievreNuit("PREFIEVRE-NUIT",ns,ontology,factory,axis_x_date,chart,sw));
//Start streaming data
Stream_C_Wtemp_Thread.start();
Stream_temp_Thread.start();
}catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
private static double[][] getInitData(double phase, double[] values) {
double[] xData = new double[1];
double[] yData = new double[1];
for (int i = 0; i < xData.length; i++) {
xData[i] = phase+i;
int index=(int) (phase+i);
yData[i] = values[index];
}
return new double[][] { xData, yData };
}
}
\ No newline at end of file
package csparql.ind;
import eu.larkc.csparql.common.RDFTable;
import eu.larkc.csparql.core.ResultFormatter;
import java.util.Observable;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
public class ConsoleFormatter extends ResultFormatter {
private String situationName;
private String baseUri;
private OWLOntology ontology;
private OWLDataFactory factory;
public ConsoleFormatter(String situationName, String baseUri, OWLOntology ontology, OWLDataFactory factory) {
this.situationName = situationName;
this.baseUri = baseUri;
this.ontology = ontology;
this.factory = factory;
}
@Override
public void update(Observable o, Object arg) {
RDFTable rdfTable = (RDFTable)arg;
System.out.println();
if (rdfTable.size()==0)
System.out.println("NO RESULT");
else {
System.out.println(situationName + " DETECTED. "+ rdfTable.size() + " result at SystemTime: "+System.currentTimeMillis());
rdfTable.stream().forEach((t) -> {
System.out.println(t.get(0) + " --- " + t.get(1) + " avg temp. " + situationName);
OWLClass Situation = factory.getOWLClass(IRI.create(baseUri + "Situation"));
OWLIndividual sit = factory.getOWLNamedIndividual(IRI.create(baseUri,situationName + "-" + System.currentTimeMillis()));
OWLClassAssertionAxiom sitType = factory.getOWLClassAssertionAxiom(Situation, sit);
ontology.add(sitType);
/*
OWLClass Machine = factory.getOWLClass(IRI.create(baseUri + "Machine"));
OWLIndividual M3 = factory.getOWLNamedIndividual(IRI.create(t.get(0)));
OWLClassAssertionAxiom machineM3 = factory.getOWLClassAssertionAxiom(Machine, M3);
ontology.add(machineM3);
OWLClass Line = factory.getOWLClass(IRI.create(baseUri + "Line"));
OWLIndividual PL1 = factory.getOWLNamedIndividual(IRI.create(t.get(1)));
OWLClassAssertionAxiom pordLinePL1 = factory.getOWLClassAssertionAxiom(Line, PL1);
ontology.add(pordLinePL1);
OWLObjectProperty concernBy = factory.getOWLObjectProperty(IRI.create(baseUri + "concernBy"));
OWLObjectPropertyAssertionAxiom concernByAssertM3 = factory.getOWLObjectPropertyAssertionAxiom(concernBy, M3, sit);
ontology.add(concernByAssertM3);
OWLObjectPropertyAssertionAxiom concernByAssertPL1 = factory.getOWLObjectPropertyAssertionAxiom(concernBy, PL1, sit);
ontology.add(concernByAssertPL1);
*/
try {
ontology.saveOntology();
} catch (OWLOntologyStorageException e1) {
e1.printStackTrace();
}
});
}
}
}
\ No newline at end of file
package csparql.ind;
import eu.larkc.csparql.common.RDFTable;
import eu.larkc.csparql.core.ResultFormatter;
import java.awt.Color;
import java.util.Date;
import java.util.List;
import java.util.Observable;
import org.knowm.xchart.AnnotationLine;
import org.knowm.xchart.AnnotationTextPanel;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.XYChart;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
public class ConsoleFormatterPreFievre extends ResultFormatter {
private String situationName;
private String baseUri;
private OWLOntology ontology;
private OWLDataFactory factory;
private List<Date> dataXlabel;
private XYChart chart;
private SwingWrapper<XYChart> sw;
public ConsoleFormatterPreFievre(String situationName, String baseUri, OWLOntology ontology, OWLDataFactory factory, List<Date> dataXlabel, XYChart chart, SwingWrapper<XYChart> sw) {
this.situationName = situationName;
this.baseUri = baseUri;
this.ontology = ontology;
this.factory = factory;
this.dataXlabel = dataXlabel;
this.chart = chart;
this.sw = sw;
}
@Override
public void update(Observable o, Object arg) {
RDFTable rdfTable = (RDFTable) arg;
System.out.println();
if (rdfTable.size() == 0)
System.out.println("TEMPERATURE NORMAL");
else {
System.out.println(situationName + " DETECTED. ");
rdfTable.stream().forEach((t) -> {
System.out.println(t.get(0) + " --- " + t.get(1) + " avg temp.");
AnnotationLine xLine1 = new AnnotationLine(dataXlabel.get(dataXlabel.size() - 1).getTime(), true, false);
xLine1.setColor(Color.ORANGE);
chart.addAnnotation(xLine1);
AnnotationTextPanel tp = new AnnotationTextPanel("Pre-fievre", dataXlabel.get(dataXlabel.size() - 1).getTime(), 39, false);
chart.addAnnotation(tp);
sw.repaintChart();
OWLClass Situation = factory.getOWLClass(IRI.create(baseUri + "Situation"));
OWLIndividual sit = factory.getOWLNamedIndividual(IRI.create(baseUri,situationName + "-" + System.currentTimeMillis()));
OWLClassAssertionAxiom sitType = factory.getOWLClassAssertionAxiom(Situation, sit);
ontology.add(sitType);
try {
ontology.saveOntology();
} catch (OWLOntologyStorageException e1) {
e1.printStackTrace();
}
});
}
}
}
\ No newline at end of file
package csparql.ind;
import eu.larkc.csparql.common.RDFTable;
import eu.larkc.csparql.core.ResultFormatter;
import java.awt.Color;
import java.util.Date;
import java.util.List;
import java.util.Observable;
import org.knowm.xchart.AnnotationLine;
import org.knowm.xchart.AnnotationTextPanel;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.XYChart;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
public class ConsoleFormatterPreFievreNuit extends ResultFormatter {
private String situationName;
private String baseUri;
private OWLOntology ontology;
private OWLDataFactory factory;
private List<Date> dataXlabel;
private XYChart chart;
private SwingWrapper<XYChart> sw;
public ConsoleFormatterPreFievreNuit(String situationName, String baseUri, OWLOntology ontology, OWLDataFactory factory,
List<Date> dataXlabel, XYChart chart, SwingWrapper<XYChart> sw) {
this.situationName = situationName;
this.baseUri = baseUri;
this.ontology = ontology;
this.factory = factory;
this.dataXlabel = dataXlabel;
this.chart = chart;
this.sw = sw;
}
@Override
public void update(Observable o, Object arg) {
RDFTable rdfTable = (RDFTable) arg;
System.out.println();
if (rdfTable.size() == 0)
System.out.println("TEMPERATURE NORMAL");
else {
System.out.println(situationName + " DETECTED. ");
rdfTable.stream().forEach((t) -> {
System.out.println(t.get(0) + " --- " + t.get(1) + " avg temp.");
AnnotationLine xLine1 = new AnnotationLine(dataXlabel.get(dataXlabel.size() - 1).getTime(), true, false);
xLine1.setColor(Color.RED);
chart.addAnnotation(xLine1);
AnnotationTextPanel tp = new AnnotationTextPanel("Pre-fievre-Nuit", dataXlabel.get(dataXlabel.size() - 1).getTime(), 39, false);
chart.addAnnotation(tp);
sw.repaintChart();
OWLClass Situation = factory.getOWLClass(IRI.create(baseUri + "Situation"));
OWLIndividual sit = factory.getOWLNamedIndividual(IRI.create(baseUri,situationName + "-" + System.currentTimeMillis()));
OWLClassAssertionAxiom sitType = factory.getOWLClassAssertionAxiom(Situation, sit);
ontology.add(sitType);
try {
ontology.saveOntology();
} catch (OWLOntologyStorageException e1) {
e1.printStackTrace();
}
});
}
}
}
\ No newline at end of file
package csparql.ind.streamer;
import java.io.FileReader;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.opencsv.CSVReader;
......@@ -29,34 +30,57 @@ public class SensorsStreamer extends RdfStream implements Runnable {
private String prop;
private OWLOntology ontology;
private OWLDataFactory factory;
private double[] dataValues;
private List<Date> axis_x_values;
private List<Double> axis_y_values;
private XYChart chart;
private SwingWrapper<XYChart> sw;
private int start;
public SensorsStreamer(String iri, String baseUri, String prop, long sleepTime,
OWLOntology ontology, OWLDataFactory factory, double[] dataValues, XYChart chart, SwingWrapper<XYChart> sw) {
OWLOntology ontology, OWLDataFactory factory, List<Date> axis_x_values, List<Double> axis_y_values,
XYChart chart, SwingWrapper<XYChart> sw, int start) {
super(iri);
this.sleepTime = sleepTime;
this.baseUri = baseUri;
this.prop = prop;
this.ontology = ontology;
this.factory = factory;
this.dataValues = dataValues;
this.axis_x_values = axis_x_values;
this.axis_y_values = axis_y_values;
this.chart = chart;
this.sw = sw;
this.start = start;
}
public void run() {
try {
SimpleDateFormat date_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
CSVReader reader = new CSVReader(new FileReader("example.csv"));
List<String[]> allRows = reader.readAll();
//String result;
Double result;
Double value = 0.0;
int observationIndex = 0;
int timeIndex = 0;
List<Date> data_x = new ArrayList<>();
List<Double> data_y = new ArrayList<>();
int i = 1;
for (String[] row : allRows) {
if (i > start) {
if (!row[3].isEmpty()) {
value = Double.parseDouble(row[3]);
} else {
value = 0.0;
}
String date_str = row[1].replace("/", "-") + " " + row[2];
Date date = date_formatter.parse(date_str);
data_x.add(date);
data_y.add(value);
//System.out.println("Reading Values from file");
}
i++;
}
//String ontologyURI = "http://www.semanticweb.org/mathieu/ontologies/2020/11/sicopad";
String ontologyURI = "http://semanticweb.org/STEaMINg/ContextOntology-COInd4";
String ns = ontologyURI + "#";
String pre_SOSAOnt = "http://www.w3.org/ns/sosa/";
......@@ -75,27 +99,27 @@ public class SensorsStreamer extends RdfStream implements Runnable {
while(true){
try{
result = Double.parseDouble(allRows.get(observationIndex)[3]);
Timestamp date = new Timestamp(System.currentTimeMillis());
dataValues[observationIndex] = result;
final double[][] data = getData(observationIndex,dataValues);
chart.updateXYSeries(prop, data[0], data[1], null);
value = data_y.get(observationIndex); //axis_y_values.get(observationIndex);
Date date = data_x.get(timeIndex); //axis_x_values.get(timeIndex);
axis_y_values.add(value);
axis_x_values.add(date);
chart.updateXYSeries(prop, axis_x_values, axis_y_values, null);
sw.repaintChart();
RdfQuadruple q = new RdfQuadruple(baseUri + "S_" + prop, baseUri + "madeObservation", baseUri + "S_" + prop + "-Obs-" + observationIndex, System.currentTimeMillis());
System.out.println(q);
//System.out.println(q);
this.put(q);
q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "observedProperty", baseUri + prop, System.currentTimeMillis());
System.out.println(q);
//System.out.println(q);
this.put(q);
q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "hasSimpleResult", result + "^^http://www.w3.org/2001/XMLSchema#double", System.currentTimeMillis());
q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "hasSimpleResult", value + "^^http://www.w3.org/2001/XMLSchema#double", System.currentTimeMillis());
System.out.println(q);
this.put(q);
q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "hasTime", baseUri + "t-obs-S_" + prop + "-"+ timeIndex, System.currentTimeMillis());
System.out.println(q);
//System.out.println(q);
this.put(q);
q = new RdfQuadruple(baseUri + "t-obs-S_" + prop + "-"+ timeIndex, baseUri + "inXSDDateTime", date + "^^http://www.w3.org/2001/XMLSchema#dateTimeStamp", System.currentTimeMillis());
q = new RdfQuadruple(baseUri + "t-obs-S_" + prop + "-"+ timeIndex, baseUri + "inXSDDateTime", date + "^^http://www.w3.org/2001/XMLSchema#dateTime", System.currentTimeMillis());
System.out.println(q);
this.put(q);
......@@ -122,7 +146,7 @@ public class SensorsStreamer extends RdfStream implements Runnable {
OWLDataPropertyAssertionAxiom timehasdate = factory.getOWLDataPropertyAssertionAxiom(inXSDDateTimeStamp, time, date + "^^http://www.w3.org/2001/XMLSchema#dateTimeStamp");
ontology.add(timehasdate);
OWLDataPropertyAssertionAxiom obshassimpleresult = factory.getOWLDataPropertyAssertionAxiom(hasSimpleResult, obs, result + "^^http://www.w3.org/2001/XMLSchema#double");
OWLDataPropertyAssertionAxiom obshassimpleresult = factory.getOWLDataPropertyAssertionAxiom(hasSimpleResult, obs, value + "^^http://www.w3.org/2001/XMLSchema#double");
ontology.add(obshassimpleresult);
try {
......@@ -130,8 +154,8 @@ public class SensorsStreamer extends RdfStream implements Runnable {
} catch (OWLOntologyStorageException e1) {
e1.printStackTrace();
}
TimeUnit.SECONDS.sleep(sleepTime);
TimeUnit.MILLISECONDS.sleep(sleepTime);
observationIndex++;
timeIndex++;
} catch(Exception e){
......@@ -142,21 +166,4 @@ public class SensorsStreamer extends RdfStream implements Runnable {
//TODO: handle exception
}
}
private static double[][] getData(double phase,double[] values) {
ArrayList<Double> xData1 = new ArrayList<Double>();
ArrayList<Double> yData1 = new ArrayList<Double>();
for (int i = 0; i < phase; i++) {
xData1.add(i+0.0);
int index=(int) (i);
yData1.add(values[index]);
}
double[] xData = new double[xData1.size()];
double[] yData = new double[yData1.size()];
for (int i = 0; i < phase; i++) {
xData[i] = xData1.get(i);
yData[i] = yData1.get(i);
}
return new double[][] { xData, yData };
}
}
\ 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