Commit 8a34dc03 authored by Nicolas Seydoux's avatar Nicolas Seydoux

Misc changes

parent 06abe2a1
{
"name":"comfort-app",
"uri":"http://localhost/",
"port":8005,
"endpoint":"http://localhost:6001/rules/add",
"ruleset":[
"shapes/abstract/r1Shape.ttl",
"shapes/abstract/r2Shape.ttl",
"shapes/abstract/r3Shape.ttl",
"shapes/abstract/r4Shape.ttl",
"shapes/abstract/r5Shape.ttl",
"shapes/abstract/r6Shape.ttl",
"shapes/abstract/r7Shape.ttl",
"shapes/abstract/r8Shape.ttl",
"shapes/abstract/r9Shape.ttl"
]
}
......@@ -47,12 +47,12 @@
# python3 simulator/generator.py -t simulator/shapes/rpi3sb_s1.json -o simulator/shapes/rpi3sb_s1_d -c n
# python3 simulator/generator.py -t simulator/shapes/rpi3sb_s1.json -o simulator/shapes/rpi3sb_s1_c -c y
# python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cdr -c cdr -r simulator/ieee/replay-minimal/
# python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cir -c cir -r simulator/ieee/replay-minimal/
# python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cdp -c cdp -r simulator/ieee/replay-minimal/
# python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cip -c cip -r simulator/ieee/replay-minimal/
# python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_adp -c adp -r simulator/ieee/replay-minimal/
#
python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cdr -c cdr
python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cir -c cir
python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cdp -c cdp
python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_cip -c cip
python3 simulator/generator.py -t simulator/ieee/minimal_local.json -o simulator/ieee/minimal_local_adp -c adp
# python3 simulator/generator.py -t simulator/coopis/mini_factory.json -o simulator/coopis/mini_factory_cdr -c cdr
# python3 simulator/generator.py -t simulator/coopis/mini_factory.json -o simulator/coopis/mini_factory_cir -c cir
# python3 simulator/generator.py -t simulator/coopis/mini_factory.json -o simulator/coopis/mini_factory_cdp -c cdp
......
......@@ -109,7 +109,7 @@ for room in rooms:
####################### WAITING FOR NODES TO START...
time.sleep(2*len(processes))
time.sleep(45)
#time.sleep(45)
####################### RESTORING SENSOR NAMES...
os.chdir("../")
sensors = glob.glob(topo_folder+'ensor*.json')
......
PREFIX edr: <http://w3id.org/laas-iot/edr#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?rule ?type
SELECT ?rule ?type ?deduction
WHERE {
?deduction edr:deducedWith ?rule;
rdf:object ?type.
......
......@@ -53,7 +53,7 @@ public class DeductionManager {
return QueryEngine.askQuery(query, inference);
}
public Map<String, String> getDeductionType(Model deduction){
public List<Map<String, String>> getDeductionType(Model deduction){
LOGGER.debug("Extracting type from deduction");
LOGGER.debug(KBManager.serializeModel(deduction));
String query = this.queries.getQueries().get("get_deductions_type");
......@@ -62,6 +62,6 @@ public class DeductionManager {
if(results.size()>1){
LOGGER.error("More than one deduction was sent in a single message from downstream node");
}
return results.get(0);
return results;
}
}
......@@ -67,7 +67,7 @@ public class InterestManager {
Node.getInstance().getConfiguration().getRemotes().size() > 0){
LOGGER.debug("Transferring interest of the central node");
// For the root node, interest propagation is always the same
Map<String, Set<String>> interests = this.listRemoteInterests();
Map<String, Set<String>> interests = this.listRemoteInterestsByNodes();
LOGGER.debug(interests);
for(String remote : interests.keySet()){
for(String interest : interests.get(remote)){
......@@ -173,19 +173,28 @@ public class InterestManager {
return result;
}
public Map<String, Set<String>> listRemoteInterests(){
public Map<String, Set<String>> listRemoteInterestsByNodes(){
Map<String, Set<String>> result = new HashMap<>();
String query = this.queries.getQueries().get("get_remote_interests");
for(Map<String, String> row : Node.getInstance().getKBManager().queryModel(query))
{
System.out.println(row);
if(!result.containsKey(row.get("node"))){
System.out.println("Adding a node to the interested");
result.put(row.get("node"), new HashSet<>());
}
result.get(row.get("node")).add(row.get("interest"));
System.out.println(result.get(row.get("node")));
}
return result;
}
public Map<String, Set<String>> listRemoteInterestsByType(){
Map<String, Set<String>> result = new HashMap<>();
String query = this.queries.getQueries().get("get_remote_interests");
for(Map<String, String> row : Node.getInstance().getKBManager().queryModel(query))
{
if(!result.containsKey(row.get("interest"))){
result.put(row.get("interest"), new HashSet<>());
}
result.get(row.get("interest")).add(row.get("node"));
}
return result;
}
......
......@@ -309,11 +309,12 @@ public class Node {
LOGGER.debug(KBManager.serializeModel(data));
this.enricher.addDeductionData(data);
// Case where the new data is a deduction from another node
Map<String, String> deductionInfo = this.dm.getDeductionType(data);
LOGGER.trace("Property appearing in the received data : "+deductionInfo.get("type"));
this.propagateNewData(data, deductionInfo.get("type"));
this.propagateDeductions(data, deductionInfo.get("rule"));
this.reasonOverNewData(data);
for(Map<String, String> deductionInfo : this.dm.getDeductionType(data)){
LOGGER.trace("Property appearing in the received data : "+deductionInfo.get("type"));
this.propagateNewData(data, deductionInfo.get("type"));
this.propagateDeductions(data, deductionInfo.get("rule"));
this.reasonOverNewData(data);
}
} else {
LOGGER.warn("Received empty message");
}
......@@ -336,6 +337,25 @@ public class Node {
}
}
// public void propagateDeductions(Model inference){
// LOGGER.debug("Propagating deduced results to interested nodes...");
// for(Map.Entry<String, Set<String>> remoteInterests : this.im.listRemoteInterestsByType().entrySet()){
// for(Map<String, String> deducedType : this.dm.getDeductionType(inference)){
// if(remoteInterests.getKey().equals(deducedType.get("type"))){
// for(String node : remoteInterests.getValue()){
// LOGGER.debug("Node "+node+" is interested in "+deducedType.get("type"));
// String endpoint = this.tm.getEndpoint(node);
// StringWriter sw = new StringWriter();
// Model deduction = this.dm.describeDeduction(deducedType.get("deduction"), inference);
// deduction.write(sw, "TTL");
// Tracer.observationSent(deducedType.get("deduction"), node);
// DataClient.sendData(endpoint, sw.toString());
// }
// }
// }
// }
// }
public void propagateDeductions(Model inference){
LOGGER.debug("Propagating deduced results to interested nodes...");
for(Map<String, String> row : this.dm.listDeductions(inference)){
......
......@@ -8,7 +8,7 @@ import argparse
logging.basicConfig(level=logging.DEBUG)
SENSOR_INITIAL_SLEEP=120000
SENSOR_INITIAL_SLEEP=120
BASE_URL = "http://example.com/ns#"
......
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