From 80dbefb8fabebb50dd3076d8e67a7171a56257b8 Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 16 Mar 2021 14:39:54 +0100 Subject: [PATCH 01/16] demo cypher query able to produce all SensorType nodes --- .gitignore | 85 +++++++++++++------------- graphdb_create_sensor_type_info.cypher | 23 +++++++ 2 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 graphdb_create_sensor_type_info.cypher diff --git a/.gitignore b/.gitignore index 8c6ee34..944c4fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,44 @@ -* -!*/ - -# whitelist -!gradle/* -!src/**/* -!.dockerignore -!Dockerfile -!docker-compose.yaml -!.gitattributes -!.gitignore -!.gitlab-ci.yml -!build.gradle -!settings.gradle -!gradlew -!gradlew.bat -!run.sh -!LICENSE -!README.md -!logging.properties -!sensor2graph.properties -!graphdb.gwdg.de.pem - - - - - -# blacklist: - -#.gradle -#build -#.classpath -#.project -#.settings -#.factorypath -#.vscode -#bin -#data -#*.log -#*.html -#already_uploaded_days.txt -#failed_to_upload.txt +* +!*/ + +# whitelist +!gradle/* +!src/**/* +!.dockerignore +!Dockerfile +!docker-compose.yaml +!.gitattributes +!.gitignore +!.gitlab-ci.yml +!build.gradle +!settings.gradle +!gradlew +!gradlew.bat +!run.sh +!LICENSE +!README.md +!logging.properties +!sensor2graph.properties +!graphdb.gwdg.de.pem +!graphdb_create_sensor_type_info.cypher + + + + + +# blacklist: + +#.gradle +#build +#.classpath +#.project +#.settings +#.factorypath +#.vscode +#bin +#data +#*.log +#*.html +#already_uploaded_days.txt +#failed_to_upload.txt #*.lck \ No newline at end of file diff --git a/graphdb_create_sensor_type_info.cypher b/graphdb_create_sensor_type_info.cypher new file mode 100644 index 0000000..c4d534d --- /dev/null +++ b/graphdb_create_sensor_type_info.cypher @@ -0,0 +1,23 @@ +:param sensor_type_info => [ + { + props: { + sensor_type: "asdf", + description: "asdf", + instrument_type: "asdf", + manufacturers: "asdf" + }, + measured_variables: [ + "humidity", + "temp" + ] + } +] + +unwind $sensor_type_info as sensor_type_info +merge (n:SensorType {sensor_type: sensor_type_info.props.sensor_type}) +set n = sensor_type_info.props +with n, sensor_type_info +unwind sensor_type_info.measured_variables as measured_variable +merge (m:MeasuredVariable {variable: measured_variable}) +merge (n)-[:MEASURES]->(m) +return n,m \ No newline at end of file -- GitLab From 5849aa6f54ceb37077f8d80184634380214e183e Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 16 Mar 2021 17:14:19 +0100 Subject: [PATCH 02/16] create SensorTypes at the beginning of a run --- .gitignore | 2 +- graphdb_create_sensor_type_info.cypher | 23 ------------------- sensor_type_info.json | 16 +++++++++++++ src/main/java/sensor2graph/Main.java | 31 +++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 27 deletions(-) delete mode 100644 graphdb_create_sensor_type_info.cypher create mode 100644 sensor_type_info.json diff --git a/.gitignore b/.gitignore index 944c4fa..d5a9346 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ !logging.properties !sensor2graph.properties !graphdb.gwdg.de.pem -!graphdb_create_sensor_type_info.cypher +!sensor_type_info.json diff --git a/graphdb_create_sensor_type_info.cypher b/graphdb_create_sensor_type_info.cypher deleted file mode 100644 index c4d534d..0000000 --- a/graphdb_create_sensor_type_info.cypher +++ /dev/null @@ -1,23 +0,0 @@ -:param sensor_type_info => [ - { - props: { - sensor_type: "asdf", - description: "asdf", - instrument_type: "asdf", - manufacturers: "asdf" - }, - measured_variables: [ - "humidity", - "temp" - ] - } -] - -unwind $sensor_type_info as sensor_type_info -merge (n:SensorType {sensor_type: sensor_type_info.props.sensor_type}) -set n = sensor_type_info.props -with n, sensor_type_info -unwind sensor_type_info.measured_variables as measured_variable -merge (m:MeasuredVariable {variable: measured_variable}) -merge (n)-[:MEASURES]->(m) -return n,m \ No newline at end of file diff --git a/sensor_type_info.json b/sensor_type_info.json new file mode 100644 index 0000000..99ebddd --- /dev/null +++ b/sensor_type_info.json @@ -0,0 +1,16 @@ +{ + "sensor_type_info": [ + { + "measured_variables": [ + "humidity", + "temp" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "asdf" + } + } + ] +} \ No newline at end of file diff --git a/src/main/java/sensor2graph/Main.java b/src/main/java/sensor2graph/Main.java index ea68329..e4e45c1 100644 --- a/src/main/java/sensor2graph/Main.java +++ b/src/main/java/sensor2graph/Main.java @@ -3,6 +3,9 @@ package sensor2graph; import org.neo4j.driver.*; import org.neo4j.driver.Config.*; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + import sensor2graph.webdirget.*; import java.io.*; @@ -53,8 +56,8 @@ public class Main { //.withMaxTransactionRetryTime(3, TimeUnit.SECONDS) //.withLeakedSessionsLogging() .withMaxConnectionPoolSize(concurrency) - .withEncryption() - .withTrustStrategy(TrustStrategy.trustCustomCertificateSignedBy(neo4j_server_certificate_file)) + // .withEncryption() + // .withTrustStrategy(TrustStrategy.trustCustomCertificateSignedBy(neo4j_server_certificate_file)) .build() ); } @@ -162,7 +165,8 @@ public class Main { try { test_auth(); - run(); + pre_run_graphdb_actions(); + //run(); } catch (org.neo4j.driver.exceptions.AuthenticationException e) { Main.logger.log(Level.SEVERE, "Authentication failed, are your credentials correct?"); } catch (Exception e) { @@ -242,6 +246,27 @@ public class Main { } + private static void pre_run_graphdb_actions() throws Exception { + Map parameters = new Gson().fromJson(new FileReader("sensor_type_info.json"), new TypeToken >() {}.getType()); + try (var session = Main.driver.session(SessionConfig.forDatabase(Main.database_name))) { + session.writeTransaction(tx -> { + Result res = tx.run( + "unwind $sensor_type_info as sensor_type_info\n" + + "merge (n:SensorType {sensor_type: sensor_type_info.props.sensor_type})\n" + + "set n = sensor_type_info.props\n" + + "with n, sensor_type_info\n" + + "unwind sensor_type_info.measured_variables as measured_variable\n" + + "merge (m:MeasuredVariable {variable: measured_variable})\n" + + "merge (n)-[:MEASURES]->(m)\n" + + "return 1", + parameters + ); + return 5; + }); + } + } + + private static void test_auth() { Main.logger.fine("testing authentication"); try (Session session = Main.driver.session(SessionConfig.forDatabase(Main.database_name))) { -- GitLab From b545394dd09483b64a51147abd681f932fb1d18a Mon Sep 17 00:00:00 2001 From: neop Date: Mon, 12 Apr 2021 18:19:24 +0200 Subject: [PATCH 03/16] add all sensor_types --- .dockerignore | 1 + .gitignore | 1 + sensor_info/sensor_info_skeleton_generator.py | 55 +++ sensor_type_info.json | 321 +++++++++++++++++- 4 files changed, 375 insertions(+), 3 deletions(-) create mode 100644 sensor_info/sensor_info_skeleton_generator.py diff --git a/.dockerignore b/.dockerignore index d232686..b60a273 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,3 +9,4 @@ !*.gradle !*.pem !*.properties +!sensor_type_info.json \ No newline at end of file diff --git a/.gitignore b/.gitignore index d5a9346..be82de5 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ !sensor2graph.properties !graphdb.gwdg.de.pem !sensor_type_info.json +!sensor_info/**/* diff --git a/sensor_info/sensor_info_skeleton_generator.py b/sensor_info/sensor_info_skeleton_generator.py new file mode 100644 index 0000000..57e57fc --- /dev/null +++ b/sensor_info/sensor_info_skeleton_generator.py @@ -0,0 +1,55 @@ +info = [ + ( + ["pressure", "altitude", "pressure_sealevel", "temperature", "humidity"], + "BME280", + ), + (["pressure", "altitude", "pressure_sealevel", "temperature"], "BMP180"), + (["pressure", "altitude", "pressure_sealevel", "temperature"], "BMP280"), + (["temperature", "humidity"], "DHT22"), + (["temperature"], "DS18B20"), + (["P1", "P2"], "HPM"), + (["temperature", "humidity"], "HTU21D"), + ( + ["noise_LAeq", "noise_LA_min", "noise_LA_max", "noise_LA01", "noise_LA95"], + "Laerm", + ), + (["P1", "P2", "P0"], "PMS1003"), + (["P1", "P2", "P0"], "PMS3003"), + (["P1", "P2", "P0"], "PMS5003"), + (["P1", "P2", "P0"], "PMS6003"), + (["P1", "P2", "P0"], "PMS7003"), + (["P1", "durP1", "ratioP1", "P2", "durP2", "ratioP2"], "PPD42NS"), + ( + ["counts_per_minute", "hv_pulses", "tube", "counts", "sample_time_ms"], + "Radiation_SBM-19", + ), + ( + ["counts_per_minute", "hv_pulses", "tube", "counts", "sample_time_ms"], + "Radiation_SBM-20", + ), + ( + ["counts_per_minute", "hv_pulses", "tube", "counts", "sample_time_ms"], + "Radiation_Si22G", + ), + (["P1", "durP1", "ratioP1", "P2", "durP2", "ratioP2"], "SDS011"), + (["temperature", "humidity"], "SHT11"), + (["temperature", "humidity"], "SHT30"), + (["temperature", "humidity"], "SHT31"), + (["temperature", "humidity"], "SHT35"), + (["temperature", "humidity"], "SHT85"), + (["P1", "P4", "P2", "P0", "N10", "N4", "N25", "N1", "N05", "TS"], "SPS30"), +] + +import json + +print(json.dumps({ "sensor_type_info": [{ + "measured_variables": variables, + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": typ + } +} for variables, typ in info]})) + + diff --git a/sensor_type_info.json b/sensor_type_info.json index 99ebddd..24cf411 100644 --- a/sensor_type_info.json +++ b/sensor_type_info.json @@ -2,14 +2,329 @@ "sensor_type_info": [ { "measured_variables": [ - "humidity", - "temp" + "pressure", + "altitude", + "pressure_sealevel", + "temperature", + "humidity" ], "props": { "manufacturers": "asdf", "description": "asdf", "instrument_type": "asdf", - "sensor_type": "asdf" + "sensor_type": "BME280" + } + }, + { + "measured_variables": [ + "pressure", + "altitude", + "pressure_sealevel", + "temperature" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "BMP180" + } + }, + { + "measured_variables": [ + "pressure", + "altitude", + "pressure_sealevel", + "temperature" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "BMP280" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "DHT22" + } + }, + { + "measured_variables": [ + "temperature" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "DS18B20" + } + }, + { + "measured_variables": [ + "P1", + "P2" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "HPM" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "HTU21D" + } + }, + { + "measured_variables": [ + "noise_LAeq", + "noise_LA_min", + "noise_LA_max", + "noise_LA01", + "noise_LA95" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "Laerm" + } + }, + { + "measured_variables": [ + "P1", + "P2", + "P0" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PMS1003" + } + }, + { + "measured_variables": [ + "P1", + "P2", + "P0" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PMS3003" + } + }, + { + "measured_variables": [ + "P1", + "P2", + "P0" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PMS5003" + } + }, + { + "measured_variables": [ + "P1", + "P2", + "P0" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PMS6003" + } + }, + { + "measured_variables": [ + "P1", + "P2", + "P0" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PMS7003" + } + }, + { + "measured_variables": [ + "P1", + "durP1", + "ratioP1", + "P2", + "durP2", + "ratioP2" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "PPD42NS" + } + }, + { + "measured_variables": [ + "counts_per_minute", + "hv_pulses", + "tube", + "counts", + "sample_time_ms" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "Radiation_SBM-19" + } + }, + { + "measured_variables": [ + "counts_per_minute", + "hv_pulses", + "tube", + "counts", + "sample_time_ms" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "Radiation_SBM-20" + } + }, + { + "measured_variables": [ + "counts_per_minute", + "hv_pulses", + "tube", + "counts", + "sample_time_ms" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "Radiation_Si22G" + } + }, + { + "measured_variables": [ + "P1", + "durP1", + "ratioP1", + "P2", + "durP2", + "ratioP2" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SDS011" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SHT11" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SHT30" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SHT31" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SHT35" + } + }, + { + "measured_variables": [ + "temperature", + "humidity" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SHT85" + } + }, + { + "measured_variables": [ + "P1", + "P4", + "P2", + "P0", + "N10", + "N4", + "N25", + "N1", + "N05", + "TS" + ], + "props": { + "manufacturers": "asdf", + "description": "asdf", + "instrument_type": "asdf", + "sensor_type": "SPS30" } } ] -- GitLab From 2d236977fae81441028cde48b69d764a20a3bdac Mon Sep 17 00:00:00 2001 From: neop Date: Mon, 12 Apr 2021 19:45:40 +0200 Subject: [PATCH 04/16] implement valid LandingPage --- src/main/java/sensor2graph/Main.java | 7 +++---- src/main/java/sensor2graph/Sensor.java | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/sensor2graph/Main.java b/src/main/java/sensor2graph/Main.java index e4e45c1..119aa8f 100644 --- a/src/main/java/sensor2graph/Main.java +++ b/src/main/java/sensor2graph/Main.java @@ -250,18 +250,17 @@ public class Main { Map parameters = new Gson().fromJson(new FileReader("sensor_type_info.json"), new TypeToken >() {}.getType()); try (var session = Main.driver.session(SessionConfig.forDatabase(Main.database_name))) { session.writeTransaction(tx -> { - Result res = tx.run( + tx.run( "unwind $sensor_type_info as sensor_type_info\n" + "merge (n:SensorType {sensor_type: sensor_type_info.props.sensor_type})\n" + "set n = sensor_type_info.props\n" + "with n, sensor_type_info\n" + "unwind sensor_type_info.measured_variables as measured_variable\n" + "merge (m:MeasuredVariable {variable: measured_variable})\n" + - "merge (n)-[:MEASURES]->(m)\n" + - "return 1", + "merge (n)-[:MEASURES]->(m)\n", parameters ); - return 5; + return 42; }); } } diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 27c4a2a..fbc9a13 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -74,6 +74,9 @@ class Sensor { "21.T11148/709a23220f2c3d64d1e1", rec.get("sensor_type").asString() ); + add_attribute(body, "21.T11148/9a15a4735d4bda329d80", + "https://sensor.community" + ); Main.glogger.fine("sent body: " + body); HttpRequest request = HttpRequest.newBuilder(URI.create(Main.pid_registry_uri + target_uri)) -- GitLab From c4a7adc2567ce410b2ae4a265604648efe99e461 Mon Sep 17 00:00:00 2001 From: neop Date: Mon, 12 Apr 2021 20:05:24 +0200 Subject: [PATCH 05/16] implement Owners property validly --- src/main/java/sensor2graph/Sensor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index fbc9a13..ee33efe 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -74,9 +74,14 @@ class Sensor { "21.T11148/709a23220f2c3d64d1e1", rec.get("sensor_type").asString() ); - add_attribute(body, "21.T11148/9a15a4735d4bda329d80", + add_attribute(body, + "21.T11148/9a15a4735d4bda329d80", "https://sensor.community" ); + add_attribute(body, + "21.T11148/4eaec4bc0f1df68ab2a7", + "{\"Owners\":[{\"Owner\":{\"ownerName\":\"SensorCommunity\",\"ownerContact\":\"contact@open-forecast.eu\"}}]}" + ); Main.glogger.fine("sent body: " + body); HttpRequest request = HttpRequest.newBuilder(URI.create(Main.pid_registry_uri + target_uri)) -- GitLab From 389f91e13ad0306517b0f1664321ef5c9884a161 Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 17:54:09 +0200 Subject: [PATCH 06/16] implement date according to schema --- src/main/java/sensor2graph/Sensor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index ee33efe..1f1470a 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -68,7 +68,7 @@ class Sensor { ); add_attribute(body, "21.T11148/22c62082a4d2d9ae2602", - "[{\"Date\":{\"date\":\"" + rec.get("min(all_measurements.first_msg)").asLocalDate().toString() + "\",\"dateType\":\"first measurement\"}},{\"Date\":{\"date\":\"" + rec.get("max(all_measurements.last_msg)").asLocalDate().toString() + "\",\"dateType\":\"last measurement\"}}]" + "[{\"dateType\":\"Commissioned\", \"date\":" + rec.get("min(all_measurements.first_msg)").asLocalDate().toString() + "},{\"dateType\":\"last message\", \"date\":" + rec.get("max(all_measurements.last_msg)").asLocalDate().toString() + "}]" ); add_attribute(body, "21.T11148/709a23220f2c3d64d1e1", -- GitLab From 6076716a860da319ef4a3dcfddafdcccc66523c8 Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 18:27:08 +0200 Subject: [PATCH 07/16] add Model according to spec and fix quotes --- src/main/java/sensor2graph/Sensor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 1f1470a..80ebe26 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -68,12 +68,16 @@ class Sensor { ); add_attribute(body, "21.T11148/22c62082a4d2d9ae2602", - "[{\"dateType\":\"Commissioned\", \"date\":" + rec.get("min(all_measurements.first_msg)").asLocalDate().toString() + "},{\"dateType\":\"last message\", \"date\":" + rec.get("max(all_measurements.last_msg)").asLocalDate().toString() + "}]" + "[{\"dateType\":\"Commissioned\", \"date\":\"" + rec.get("min(all_measurements.first_msg)").asLocalDate().toString() + "\"},{\"dateType\":\"last message\", \"date\":\"" + rec.get("max(all_measurements.last_msg)").asLocalDate().toString() + "\"}]" ); add_attribute(body, "21.T11148/709a23220f2c3d64d1e1", rec.get("sensor_type").asString() ); + add_attribute(body, + "21.T11148/68c2cc7f0ceaa3e499ec", + "{\"Model\":{\"modelName\":\"" + rec.get("sensor_type").asString() + "\"}}" + ); add_attribute(body, "21.T11148/9a15a4735d4bda329d80", "https://sensor.community" -- GitLab From ae005b7e757c9848c5fcb85c9883bd73d3c583e4 Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 19:35:57 +0200 Subject: [PATCH 08/16] produce correct json for string only attributes --- src/main/java/sensor2graph/Sensor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 80ebe26..413c591 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -72,7 +72,7 @@ class Sensor { ); add_attribute(body, "21.T11148/709a23220f2c3d64d1e1", - rec.get("sensor_type").asString() + '\"' + rec.get("sensor_type").asString() + '\"' ); add_attribute(body, "21.T11148/68c2cc7f0ceaa3e499ec", @@ -80,12 +80,13 @@ class Sensor { ); add_attribute(body, "21.T11148/9a15a4735d4bda329d80", - "https://sensor.community" + "\"https://sensor.community\"" ); add_attribute(body, "21.T11148/4eaec4bc0f1df68ab2a7", "{\"Owners\":[{\"Owner\":{\"ownerName\":\"SensorCommunity\",\"ownerContact\":\"contact@open-forecast.eu\"}}]}" ); + Main.glogger.fine("sent body: " + body); HttpRequest request = HttpRequest.newBuilder(URI.create(Main.pid_registry_uri + target_uri)) @@ -149,9 +150,9 @@ class Sensor { " measurement.first_msg = case when date_ > measurement.first_msg then measurement.first_msg else date_ end," + " measurement.last_msg = case when date_ < measurement.last_msg then measurement.last_msg else date_ end " + - "with s, type.sensor_type as sensor_type\n" + + "with s, type.sensor_type as sensor_type, type.manufacturer as manufacturer\n" + "match (s)--(all_measurements:MeasurementLocation)" + - "return s.pid, id(s), sensor_type, min(all_measurements.first_msg), max(all_measurements.last_msg)" + "return s.pid, id(s), sensor_type, manufacturer, min(all_measurements.first_msg), max(all_measurements.last_msg)" ).withParameters(properties); } -- GitLab From 6e6f89bb119a294c83723eec5c0c0982664928e3 Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 19:36:45 +0200 Subject: [PATCH 09/16] add manufacturers --- src/main/java/sensor2graph/Sensor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 413c591..548b0b3 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -86,7 +86,13 @@ class Sensor { "21.T11148/4eaec4bc0f1df68ab2a7", "{\"Owners\":[{\"Owner\":{\"ownerName\":\"SensorCommunity\",\"ownerContact\":\"contact@open-forecast.eu\"}}]}" ); - + add_attribute(body, + "21.T11148/1f3e82ddf0697a497432", + "{\"Manufacturers\":[{\"Manufacturer\":{\"manufacturerName\":\""+ rec.get("manufacturer").asString() +"\"}}]}" + ); + + + Main.glogger.fine("sent body: " + body); HttpRequest request = HttpRequest.newBuilder(URI.create(Main.pid_registry_uri + target_uri)) -- GitLab From c657a0038c7d77b53de4c9e07e4eaea2147dd66c Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 19:37:09 +0200 Subject: [PATCH 10/16] add skeleton instrument type --- src/main/java/sensor2graph/Sensor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 548b0b3..d818c8b 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -90,6 +90,10 @@ class Sensor { "21.T11148/1f3e82ddf0697a497432", "{\"Manufacturers\":[{\"Manufacturer\":{\"manufacturerName\":\""+ rec.get("manufacturer").asString() +"\"}}]}" ); + add_attribute(body, + "21.T11148/f76ad9d0324302fc47dd", + "\"instrument type string\"" + ); -- GitLab From f2bcd64bdd81f5ac884cb1c851db083cebb9fb9d Mon Sep 17 00:00:00 2001 From: neop Date: Tue, 13 Apr 2021 19:38:37 +0200 Subject: [PATCH 11/16] add some BME280 info --- sensor_type_info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensor_type_info.json b/sensor_type_info.json index 24cf411..17a3e40 100644 --- a/sensor_type_info.json +++ b/sensor_type_info.json @@ -9,8 +9,8 @@ "humidity" ], "props": { - "manufacturers": "asdf", - "description": "asdf", + "manufacturer": "Bosch Sensortec GmbH", + "description": "The BME280 is a humidity sensor especially developed for mobile applications and wearables where size and low power consumption are key design parameters. The unit combines high linearity and high accuracy sensors and is perfectly feasible for low current consumption, long-term stability and high EMC robustness. The humidity sensor offers an extremely fast response time and therefore supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range.", "instrument_type": "asdf", "sensor_type": "BME280" } -- GitLab From 921b3bf1d89945d5056c1766733845ee14d964ff Mon Sep 17 00:00:00 2001 From: neop Date: Thu, 15 Apr 2021 14:54:32 +0200 Subject: [PATCH 12/16] add more manufacturers and rename P1 to PM10 and P2 to PM2.5 --- sensor_type_info.json | 84 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/sensor_type_info.json b/sensor_type_info.json index 17a3e40..316c3b7 100644 --- a/sensor_type_info.json +++ b/sensor_type_info.json @@ -23,7 +23,7 @@ "temperature" ], "props": { - "manufacturers": "asdf", + "manufacturer": "Bosch Sensortec GmbH", "description": "asdf", "instrument_type": "asdf", "sensor_type": "BMP180" @@ -37,8 +37,8 @@ "temperature" ], "props": { - "manufacturers": "asdf", - "description": "asdf", + "manufacturer": "Bosch Sensortec GmbH", + "description": "The BMP280 is an absolute barometric pressure sensor, which is especially feasible for mobile applications. Its small dimensions and its low power consumption allow for the implementation in battery-powered devices such as mobile phones, GPS modules or watches. The BMP280 is based on Bosch’s proven piezo-resistive pressure sensor technology featuring high accuracy and linearity as well as long-term stability and high EMC robustness. Numerous device operation options guarantee for highest flexibility. The device is optimized in terms of power consumption, resolution and filter performance.", "instrument_type": "asdf", "sensor_type": "BMP280" } @@ -49,7 +49,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "Aosong Electronics Co.,Ltd", "description": "asdf", "instrument_type": "asdf", "sensor_type": "DHT22" @@ -60,7 +60,7 @@ "temperature" ], "props": { - "manufacturers": "asdf", + "manufacturer": "Maxim Integrated Products, Inc.", "description": "asdf", "instrument_type": "asdf", "sensor_type": "DS18B20" @@ -68,11 +68,11 @@ }, { "measured_variables": [ - "P1", - "P2" + "PM10", + "PM2.5" ], "props": { - "manufacturers": "asdf", + "manufacturer": "Honeywell International Inc.", "description": "asdf", "instrument_type": "asdf", "sensor_type": "HPM" @@ -84,7 +84,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "TE Connectivity", "description": "asdf", "instrument_type": "asdf", "sensor_type": "HTU21D" @@ -99,7 +99,7 @@ "noise_LA95" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "Laerm" @@ -107,12 +107,12 @@ }, { "measured_variables": [ - "P1", - "P2", + "PM10", + "PM2.5", "P0" ], "props": { - "manufacturers": "asdf", + "manufacturer": "PlanTower", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PMS1003" @@ -120,12 +120,12 @@ }, { "measured_variables": [ - "P1", - "P2", + "PM10", + "PM2.5", "P0" ], "props": { - "manufacturers": "asdf", + "manufacturer": "PlanTower", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PMS3003" @@ -133,12 +133,12 @@ }, { "measured_variables": [ - "P1", - "P2", + "PM10", + "PM2.5", "P0" ], "props": { - "manufacturers": "asdf", + "manufacturer": "PlanTower", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PMS5003" @@ -146,12 +146,12 @@ }, { "measured_variables": [ - "P1", - "P2", + "PM10", + "PM2.5", "P0" ], "props": { - "manufacturers": "asdf", + "manufacturer": "PlanTower", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PMS6003" @@ -159,12 +159,12 @@ }, { "measured_variables": [ - "P1", - "P2", + "PM10", + "PM2.5", "P0" ], "props": { - "manufacturers": "asdf", + "manufacturer": "PlanTower", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PMS7003" @@ -172,15 +172,15 @@ }, { "measured_variables": [ - "P1", + "PM10", "durP1", "ratioP1", - "P2", + "PM2.5", "durP2", "ratioP2" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "PPD42NS" @@ -195,7 +195,7 @@ "sample_time_ms" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "Radiation_SBM-19" @@ -210,7 +210,7 @@ "sample_time_ms" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "Radiation_SBM-20" @@ -225,7 +225,7 @@ "sample_time_ms" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "Radiation_Si22G" @@ -233,15 +233,15 @@ }, { "measured_variables": [ - "P1", + "PM10", "durP1", "ratioP1", - "P2", + "PM2.5", "durP2", "ratioP2" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SDS011" @@ -253,7 +253,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SHT11" @@ -265,7 +265,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SHT30" @@ -277,7 +277,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SHT31" @@ -289,7 +289,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SHT35" @@ -301,7 +301,7 @@ "humidity" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SHT85" @@ -309,9 +309,9 @@ }, { "measured_variables": [ - "P1", + "PM10", "P4", - "P2", + "PM2.5", "P0", "N10", "N4", @@ -321,7 +321,7 @@ "TS" ], "props": { - "manufacturers": "asdf", + "manufacturer": "asdf", "description": "asdf", "instrument_type": "asdf", "sensor_type": "SPS30" -- GitLab From d0458000cc82f995bdce3a1a3df2b44611c7d1ac Mon Sep 17 00:00:00 2001 From: neop Date: Thu, 15 Apr 2021 19:58:57 +0200 Subject: [PATCH 13/16] add the final manufacturer --- sensor_type_info.json | 70 ++++++++----------------------------------- 1 file changed, 12 insertions(+), 58 deletions(-) diff --git a/sensor_type_info.json b/sensor_type_info.json index 316c3b7..ff47405 100644 --- a/sensor_type_info.json +++ b/sensor_type_info.json @@ -11,7 +11,6 @@ "props": { "manufacturer": "Bosch Sensortec GmbH", "description": "The BME280 is a humidity sensor especially developed for mobile applications and wearables where size and low power consumption are key design parameters. The unit combines high linearity and high accuracy sensors and is perfectly feasible for low current consumption, long-term stability and high EMC robustness. The humidity sensor offers an extremely fast response time and therefore supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range.", - "instrument_type": "asdf", "sensor_type": "BME280" } }, @@ -24,8 +23,6 @@ ], "props": { "manufacturer": "Bosch Sensortec GmbH", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "BMP180" } }, @@ -39,7 +36,6 @@ "props": { "manufacturer": "Bosch Sensortec GmbH", "description": "The BMP280 is an absolute barometric pressure sensor, which is especially feasible for mobile applications. Its small dimensions and its low power consumption allow for the implementation in battery-powered devices such as mobile phones, GPS modules or watches. The BMP280 is based on Bosch’s proven piezo-resistive pressure sensor technology featuring high accuracy and linearity as well as long-term stability and high EMC robustness. Numerous device operation options guarantee for highest flexibility. The device is optimized in terms of power consumption, resolution and filter performance.", - "instrument_type": "asdf", "sensor_type": "BMP280" } }, @@ -50,8 +46,6 @@ ], "props": { "manufacturer": "Aosong Electronics Co.,Ltd", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "DHT22" } }, @@ -61,8 +55,6 @@ ], "props": { "manufacturer": "Maxim Integrated Products, Inc.", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "DS18B20" } }, @@ -73,8 +65,6 @@ ], "props": { "manufacturer": "Honeywell International Inc.", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "HPM" } }, @@ -85,8 +75,6 @@ ], "props": { "manufacturer": "TE Connectivity", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "HTU21D" } }, @@ -99,9 +87,6 @@ "noise_LA95" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "Laerm" } }, @@ -113,8 +98,6 @@ ], "props": { "manufacturer": "PlanTower", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "PMS1003" } }, @@ -126,8 +109,6 @@ ], "props": { "manufacturer": "PlanTower", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "PMS3003" } }, @@ -139,8 +120,6 @@ ], "props": { "manufacturer": "PlanTower", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "PMS5003" } }, @@ -152,8 +131,6 @@ ], "props": { "manufacturer": "PlanTower", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "PMS6003" } }, @@ -165,8 +142,6 @@ ], "props": { "manufacturer": "PlanTower", - "description": "asdf", - "instrument_type": "asdf", "sensor_type": "PMS7003" } }, @@ -180,9 +155,7 @@ "ratioP2" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Shinyei", "sensor_type": "PPD42NS" } }, @@ -195,9 +168,7 @@ "sample_time_ms" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Russian Federation", "sensor_type": "Radiation_SBM-19" } }, @@ -210,9 +181,7 @@ "sample_time_ms" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Russian Federation", "sensor_type": "Radiation_SBM-20" } }, @@ -225,9 +194,7 @@ "sample_time_ms" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Russian Federation", "sensor_type": "Radiation_Si22G" } }, @@ -241,9 +208,7 @@ "ratioP2" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Nova Fitness Co., Ltd. ", "sensor_type": "SDS011" } }, @@ -253,9 +218,7 @@ "humidity" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", "sensor_type": "SHT11" } }, @@ -265,9 +228,7 @@ "humidity" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", "sensor_type": "SHT30" } }, @@ -277,9 +238,7 @@ "humidity" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", "sensor_type": "SHT31" } }, @@ -289,9 +248,7 @@ "humidity" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", "sensor_type": "SHT35" } }, @@ -301,9 +258,7 @@ "humidity" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", "sensor_type": "SHT85" } }, @@ -321,9 +276,8 @@ "TS" ], "props": { - "manufacturer": "asdf", - "description": "asdf", - "instrument_type": "asdf", + "manufacturer": "Sensirion AG", + "description": "The SPS30 Particulate Matter (PM) sensor is a technological breakthrough in optical PM sensors. Its measurement principle is based on laser scattering and makes use of Sensirion's innovative contaminationresistance technology. This technology, together with high-quality and long-lasting components, enables precise measurements from its first operation and throughout its lifetime of more than ten years. In addition, Sensirion's advanced algorithms provide superior precision for different PM types and higher-resolution particle size binning, opening up new possibilities for the detection of different sorts of environmental dust and other particles. With dimensions of only 41 x 41 x 12 mm3, it is also the perfect solution for applications where size is of paramount importance, such as wall-mounted or compact air quality devices.", "sensor_type": "SPS30" } } -- GitLab From ebd0f5338059181802f1c5c2024eca7ffffe646d Mon Sep 17 00:00:00 2001 From: neop Date: Thu, 15 Apr 2021 20:01:10 +0200 Subject: [PATCH 14/16] add sht11 description --- sensor_type_info.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sensor_type_info.json b/sensor_type_info.json index ff47405..e9b5ead 100644 --- a/sensor_type_info.json +++ b/sensor_type_info.json @@ -219,6 +219,7 @@ ], "props": { "manufacturer": "Sensirion AG", + "description": "SHT1x (including SHT10, SHT11 and SHT15) is Sensirion’s family of surface mountable relative humidity and temperature sensors. The sensors integrate sensor elements plus signal processing on a tiny foot print and provide a fully calibrated digital output. A unique capacitive sensor element is used for measuring relative humidity while temperature is measured by a band-gap sensor. The applied CMOSens® technology guarantees excellent reliability and long term stability. Both sensors are seamlessly coupled to a 14bit analog to digital converter and a serial interface circuit. This results in superior signal quality, a fast response time and insensitivity to external disturbances (EMC). Each SHT1x is individually calibrated in a precision humidity chamber. The calibration coefficients are programmed into an OTP memory on the chip. These coefficients are used to internally calibrate the signals from the sensors. The 2-wire serial interface and internal voltage regulation allows for easy and fast system integration. The tiny size and low power consumption makes SHT1x the ultimate choice for even the most demanding applications. SHT1x is supplied in a surface-mountable LCC (Leadless Chip Carrier) which is approved for standard reflow soldering processes. The same sensor is also available with pins (SHT7x) or on flex print (SHTA1).", "sensor_type": "SHT11" } }, -- GitLab From 8f46dd080a9f05c2bb8a1ed047a0b400c49587e9 Mon Sep 17 00:00:00 2001 From: neop Date: Thu, 15 Apr 2021 20:24:11 +0200 Subject: [PATCH 15/16] implement description --- src/main/java/sensor2graph/Sensor.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index d818c8b..097c07c 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -90,10 +90,16 @@ class Sensor { "21.T11148/1f3e82ddf0697a497432", "{\"Manufacturers\":[{\"Manufacturer\":{\"manufacturerName\":\""+ rec.get("manufacturer").asString() +"\"}}]}" ); - add_attribute(body, - "21.T11148/f76ad9d0324302fc47dd", - "\"instrument type string\"" - ); + if (!rec.get("description").isNull()) { + add_attribute(body, + "21.T11148/55f8ebc805e65b5b71dd", + "\""+ rec.get("description") +"\"" + ); + } + // add_attribute(body, + // "21.T11148/f76ad9d0324302fc47dd", + // "\"instrument type string\"" + // ); @@ -160,9 +166,9 @@ class Sensor { " measurement.first_msg = case when date_ > measurement.first_msg then measurement.first_msg else date_ end," + " measurement.last_msg = case when date_ < measurement.last_msg then measurement.last_msg else date_ end " + - "with s, type.sensor_type as sensor_type, type.manufacturer as manufacturer\n" + + "with s, type.sensor_type as sensor_type, type.manufacturer as manufacturer, type.description as description\n" + "match (s)--(all_measurements:MeasurementLocation)" + - "return s.pid, id(s), sensor_type, manufacturer, min(all_measurements.first_msg), max(all_measurements.last_msg)" + "return s.pid, id(s), sensor_type, manufacturer, description min(all_measurements.first_msg), max(all_measurements.last_msg)" ).withParameters(properties); } -- GitLab From f1ebf90fba09946469833a0da9b17da43520bd59 Mon Sep 17 00:00:00 2001 From: neop Date: Thu, 15 Apr 2021 20:43:29 +0200 Subject: [PATCH 16/16] implement Identifier --- src/main/java/sensor2graph/Sensor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/sensor2graph/Sensor.java b/src/main/java/sensor2graph/Sensor.java index 097c07c..6f5cfd8 100644 --- a/src/main/java/sensor2graph/Sensor.java +++ b/src/main/java/sensor2graph/Sensor.java @@ -28,7 +28,7 @@ class Sensor { private Map properties = new HashMap(); public void process(Session session, TransactionConfig transaction_config) throws Exception { - org.neo4j.driver.Record rec = session.writeTransaction(tx -> { + var rec = session.writeTransaction(tx -> { Result res = tx.run(get_creation_query()); return res.single(); }, transaction_config); @@ -96,6 +96,12 @@ class Sensor { "\""+ rec.get("description") +"\"" ); } + if (!rec.get("s.pid").isNull()) { + add_attribute(body, + "21.T11148/8eb858ee0b12e8e463a5", + "{\"identifier-general-with-type\":{\"identifierValue\":\""+ rec.get("s.pid") +"\", \"identifierType\":\"Handle\"}}" + ); + } // add_attribute(body, // "21.T11148/f76ad9d0324302fc47dd", // "\"instrument type string\"" -- GitLab