This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsn-ffd-owl.py
574 lines (478 loc) · 34.8 KB
/
wsn-ffd-owl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
from rdflib import Graph
from rdflib.term import URIRef, Literal, BNode
from rdflib.container import Bag
from rdflib.namespace import Namespace, RDF, RDFS
import os
import sys
if __name__ == '__main__':
##############################
# Graph Definition
##############################
wsd_ffd_owl: Graph = Graph()
# Real import of assignment 2 ontology
wsd_ffd_owl.load(os.getcwd()+'/wsd-ffd-xml.rdf')
gitlab_repo_base_uri: str = 'https://gitlab.com/paganelli.f/ws-project-paganelli-1920/-/'
# owl:imports 'https://wsn-ffd-rdf.org/' --> in realtà metto il link alla ontologia sul repo gitlab
base_rdf_ontology_uri: str = gitlab_repo_base_uri + 'raw/develop/wsd-ffd-pretty-xml.rdf'
base_rdf_ontology: str = 'https://wsn-ffd-rdf.org/'
base_owl_ontology: str = 'https://wsn-ffd-owl.org/'
##############################
# Binding/Import Namespaces
##############################
OWL: Namespace = Namespace('http://www.w3.org/2002/07/owl#')
wsd_ffd_owl.bind('owl', OWL)
SOSA: Namespace = Namespace('http://www.w3.org/ns/sosa/')
wsd_ffd_owl.bind('sosa', SOSA)
SSN: Namespace = Namespace('http://www.w3.org/ns/ssn/')
wsd_ffd_owl.bind('ssn', SSN)
SCHEMA: Namespace = Namespace('http://schema.org/')
wsd_ffd_owl.bind('schema', SCHEMA)
QUDT_UNIT: Namespace = Namespace('http://qudt.org/1.1/vocab/unit#')
wsd_ffd_owl.bind('qudt-unit-1-1', QUDT_UNIT)
GEO: Namespace = Namespace('http://www.w3.org/2003/01/geo/wgs84_pos#')
wsd_ffd_owl.bind('geo', GEO)
ontology = URIRef(value='wsn-mas-ontology', base=base_owl_ontology)
wsd_ffd_owl.add((ontology, RDF.type, OWL.Ontology))
wsd_ffd_owl.add((ontology, OWL.versionInfo, Literal('1.0')))
wsd_ffd_owl.add((ontology, OWL.imports, URIRef(value=base_rdf_ontology_uri)))
MY_RDF_ONTOLOGY: Namespace = Namespace(base_rdf_ontology_uri)
wsd_ffd_owl.bind('wsn-ffd-rdf', MY_RDF_ONTOLOGY)
##############################
# Class Definition
##############################
# WSN
router_node = URIRef(value='RouterNode', base=base_owl_ontology)
wsd_ffd_owl.add((router_node, RDF.type, OWL.Class))
wsd_ffd_owl.add((router_node, OWL.disjointWith, URIRef(value='EdgeDevice', base=base_rdf_ontology)))
wsd_ffd_owl.add((router_node, RDFS.comment, Literal('Router node of the wireless sensor network')))
wsd_ffd_owl.add((router_node, RDFS.subClassOf, SOSA.Platform))
coordinator_node = URIRef(value='CoordinatorNode', base=base_owl_ontology)
wsd_ffd_owl.add((coordinator_node, RDF.type, OWL.Class))
wsd_ffd_owl.add((coordinator_node, RDFS.comment,
Literal('Coordinator/Gateway node of the wireless sensor network'))
)
wsd_ffd_owl.add((coordinator_node, RDFS.subClassOf, router_node))
# MAS
statistics_agent = URIRef(value='StatisticsAgent', base=base_owl_ontology)
wsd_ffd_owl.add((statistics_agent, RDF.type, OWL.Class))
wsd_ffd_owl.add((statistics_agent, RDFS.comment, Literal('MAS Statistics Agent')))
wsd_ffd_owl.add((statistics_agent, OWL.disjointWith, URIRef(value='DBManagerAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((statistics_agent, OWL.disjointWith, URIRef(value='FrontEndAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((statistics_agent, OWL.disjointWith, URIRef(value='SensorAgent', base=base_rdf_ontology)))
wsd_ffd_owl.add((statistics_agent, RDFS.seeAlso,
URIRef(value=gitlab_repo_base_uri+'blob/master/processing/statisticsagent.py'))
)
wsd_ffd_owl.add((statistics_agent, RDFS.subClassOf, URIRef(value='Agent', base=base_rdf_ontology)))
dbmanager_agent = URIRef(value='DBManagerAgent', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent, RDF.type, OWL.Class))
wsd_ffd_owl.add((dbmanager_agent, RDFS.comment, Literal('MAS DBManager Agent')))
wsd_ffd_owl.add((dbmanager_agent, OWL.disjointWith, URIRef(value='FrontEndAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent, OWL.disjointWith, URIRef(value='StatisticsAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent, OWL.disjointWith, URIRef(value='SensorAgent', base=base_rdf_ontology)))
wsd_ffd_owl.add((dbmanager_agent, RDFS.seeAlso,
URIRef(value=gitlab_repo_base_uri+'blob/master/processing/dbmanageragent.py'))
)
wsd_ffd_owl.add((dbmanager_agent, RDFS.subClassOf, URIRef(value='Agent', base=base_rdf_ontology)))
frontend_agent = URIRef(value='FrontEndAgent', base=base_owl_ontology)
wsd_ffd_owl.add((frontend_agent, RDF.type, OWL.Class))
wsd_ffd_owl.add((frontend_agent, RDFS.comment, Literal('MAS FrontEnd Agent')))
wsd_ffd_owl.add((frontend_agent, OWL.disjointWith, URIRef(value='DBManagerAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((frontend_agent, OWL.disjointWith, URIRef(value='StatisticsAgent', base=base_owl_ontology)))
wsd_ffd_owl.add((frontend_agent, OWL.disjointWith, URIRef(value='SensorAgent', base=base_rdf_ontology)))
wsd_ffd_owl.add((frontend_agent, RDFS.seeAlso,
URIRef(value=gitlab_repo_base_uri+'blob/master/processing/frontendagent.py'))
)
wsd_ffd_owl.add((frontend_agent, RDFS.subClassOf, URIRef(value='Agent', base=base_rdf_ontology)))
# Sensor Procedure a.k.a. Agents Strategies
strategy = URIRef(value='Strategy', base=base_owl_ontology)
wsd_ffd_owl.add((strategy, RDFS.subClassOf, SOSA.Procedure))
trigger_strategy = URIRef(value='TriggerStrategy', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_strategy, RDFS.subClassOf, strategy))
trigger_strategy_output_restriction = BNode()
wsd_ffd_owl.add((trigger_strategy_output_restriction, RDF.type, OWL.Restriction))
wsd_ffd_owl.add((trigger_strategy_output_restriction, RDFS.comment,
Literal('Strategy implemented by a TriggerAgent to trigger a SensorAgent')))
wsd_ffd_owl.add((trigger_strategy_output_restriction, SCHEMA.unitCode, QUDT_UNIT.Bit))
wsd_ffd_owl.add((trigger_strategy_output_restriction, OWL.onProperty, SSN.hasOutput))
wsd_ffd_owl.add((trigger_strategy, RDFS.subClassOf, trigger_strategy_output_restriction))
##############################
# Property Definition
##############################
triggers = URIRef(value='triggers', base=base_owl_ontology)
wsd_ffd_owl.add((triggers, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((triggers, RDFS.comment, Literal('SensorAgents that can be triggered by this TriggerAgent')))
wsd_ffd_owl.add((triggers, RDFS.domain, URIRef(value='TriggerAgent', base=base_rdf_ontology)))
wsd_ffd_owl.add((triggers, RDFS.range, URIRef(value='SensorAgent', base=base_rdf_ontology)))
implements_strategy = URIRef(value='implementsStrategy', base=base_owl_ontology)
wsd_ffd_owl.add((implements_strategy, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((implements_strategy, RDFS.subPropertyOf, SSN.implements))
wsd_ffd_owl.add((implements_strategy, RDFS.domain, strategy))
wsd_ffd_owl.add((implements_strategy, RDFS.range, URIRef(value='Agent', base=base_rdf_ontology)))
can_route = URIRef(value='canRoute', base=base_owl_ontology)
wsd_ffd_owl.add((can_route, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((can_route, RDFS.comment, Literal('List of nodes to which this node is able to route information')))
wsd_ffd_owl.add((can_route, OWL.inverseOf, URIRef(value='isRoutedBy', base=base_rdf_ontology)))
wsd_ffd_owl.add((can_route, RDFS.domain, router_node))
wsd_ffd_owl.add((can_route, RDFS.range, SOSA.Platform))
is_hosted_by = URIRef(value='isHostedBy', base=base_owl_ontology)
wsd_ffd_owl.add((is_hosted_by, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((is_hosted_by, RDFS.comment, Literal('WSN Node that hosts this Agent Container')))
wsd_ffd_owl.add((is_hosted_by, OWL.inverseOf, URIRef(value='hostsAgentContainer', base=base_rdf_ontology)))
wsd_ffd_owl.add((is_hosted_by, RDFS.domain, URIRef(value='AgentContainer', base=base_rdf_ontology)))
wsd_ffd_owl.add((is_hosted_by, RDFS.range, SOSA.Platform))
collect_metrics_from = URIRef(value='collectMetricsFrom', base=base_owl_ontology)
wsd_ffd_owl.add((collect_metrics_from, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((collect_metrics_from, RDFS.comment,
Literal('Sensor Agents from which the DBManager Agent collects the detected data')))
wsd_ffd_owl.add((collect_metrics_from, RDFS.domain, dbmanager_agent))
wsd_ffd_owl.add((collect_metrics_from, RDFS.range, URIRef(value='#SensorAgent', base=base_rdf_ontology)))
metrics_collected_by = URIRef(value='metricsCollectedBy', base=base_owl_ontology)
wsd_ffd_owl.add((metrics_collected_by, RDF.type, OWL.ObjectProperty))
wsd_ffd_owl.add((metrics_collected_by, RDFS.comment,
Literal('DBManager Agent that collects the data detected from this Sensor Agent')))
wsd_ffd_owl.add((metrics_collected_by, RDFS.domain, URIRef(value='#SensorAgent', base=base_rdf_ontology)))
wsd_ffd_owl.add((metrics_collected_by, RDFS.range, dbmanager_agent))
wsd_ffd_owl.add((metrics_collected_by, OWL.inverseOf, URIRef(value='#collectMetricsFrom', base=base_owl_ontology)))
max_cardinality_restriction = BNode()
wsd_ffd_owl.add((max_cardinality_restriction, RDF.type, OWL.Restriction))
wsd_ffd_owl.add((max_cardinality_restriction, OWL.maxCardinality, Literal(1)))
wsd_ffd_owl.add((max_cardinality_restriction, OWL.onProperty,
URIRef(value='#metricsCollectedBy', base=base_owl_ontology)))
wsd_ffd_owl.add((URIRef(value='SensorAgent', base=base_rdf_ontology), RDFS.subClassOf, max_cardinality_restriction))
##############################
# Instance Definition
##############################
coordinator_node_instance = URIRef(value='CN0000001', base=base_owl_ontology)
router2_node_instance = URIRef(value='RN0000002', base=base_owl_ontology)
router3_node_instance = URIRef(value='RN0000003', base=base_owl_ontology)
router4_node_instance = URIRef(value='RN0000004', base=base_owl_ontology)
edge2_node_instance = URIRef(value='ED0000002', base=base_owl_ontology)
edge3_node_instance = URIRef(value='ED0000003', base=base_owl_ontology)
edge4_node_instance = URIRef(value='ED0000004', base=base_owl_ontology)
edge5_node_instance = URIRef(value='ED0000005', base=base_owl_ontology)
edge6_node_instance = URIRef(value='ED0000006', base=base_owl_ontology)
edge7_node_instance = URIRef(value='ED0000007', base=base_owl_ontology)
agent_container_edge2 = URIRef(value='AC0000002', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge2, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
agent_container_edge3 = URIRef(value='AC0000003', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge3, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
agent_container_edge4 = URIRef(value='AC0000004', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge4, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
agent_container_edge5 = URIRef(value='AC0000005', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge5, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
agent_container_edge6 = URIRef(value='AC0000006', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge6, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
agent_container_edge7 = URIRef(value='AC0000007', base=base_owl_ontology)
wsd_ffd_owl.add((agent_container_edge7, RDF.type, URIRef(value="AgentContainer", base=base_rdf_ontology)))
sensor_agent_edge2 = URIRef(value='SA0000002', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge2, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge2, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge2@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge2, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
sensor_agent_edge3 = URIRef(value='SA0000003', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge3, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge3, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge3@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge3, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
sensor_agent_edge4 = URIRef(value='SA0000004', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge4, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge4, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge4@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge4, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
sensor_agent_edge5 = URIRef(value='SA0000005', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge5, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge5, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge5@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge5, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
sensor_agent_edge6 = URIRef(value='SA0000006', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge6, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge6, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge6@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge6, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
sensor_agent_edge7 = URIRef(value='SA0000007', base=base_owl_ontology)
wsd_ffd_owl.add((sensor_agent_edge7, RDF.type, URIRef(value="SensorAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((sensor_agent_edge7, MY_RDF_ONTOLOGY.hasJID, Literal("sensoragent.edge7@wsn-mas.org")))
wsd_ffd_owl.add((sensor_agent_edge7, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
trigger_agent_edge2 = URIRef(value='TA0000002', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge2, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge2, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge2@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge2, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge2, triggers, sensor_agent_edge2))
trigger_agent_edge3 = URIRef(value='TA0000003', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge3, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge3, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge3@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge3, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge3, triggers, sensor_agent_edge3))
trigger_agent_edge4 = URIRef(value='TA0000004', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge4, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge4, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge4@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge4, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge4, triggers, sensor_agent_edge4))
trigger_agent_edge5 = URIRef(value='TA0000005', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge5, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge5, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge5@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge5, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge5, triggers, sensor_agent_edge5))
trigger_agent_edge6 = URIRef(value='TA0000006', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge6, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge6, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge6@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge6, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge6, triggers, sensor_agent_edge6))
trigger_agent_edge7 = URIRef(value='TA0000007', base=base_owl_ontology)
wsd_ffd_owl.add((trigger_agent_edge7, RDF.type, URIRef(value="TriggerAgent", base=base_rdf_ontology)))
wsd_ffd_owl.add((trigger_agent_edge7, MY_RDF_ONTOLOGY.hasJID, Literal("triggeragent.edge7@wsn-mas.org")))
wsd_ffd_owl.add((trigger_agent_edge7, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((trigger_agent_edge7, triggers, sensor_agent_edge7))
dbmanager_agent_edge2 = URIRef(value='DBMA0000002', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge2, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge2, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge2@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge2, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge2, collect_metrics_from, sensor_agent_edge2))
dbmanager_agent_edge3 = URIRef(value='DBMA0000003', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge3, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge3, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge3@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge3, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge3, collect_metrics_from, sensor_agent_edge3))
dbmanager_agent_edge4 = URIRef(value='DBMA0000004', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge4, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge4, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge4@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge4, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge4, collect_metrics_from, sensor_agent_edge4))
dbmanager_agent_edge5 = URIRef(value='DBMA0000005', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge5, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge5, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge5@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge5, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge5, collect_metrics_from, sensor_agent_edge5))
dbmanager_agent_edge6 = URIRef(value='DBMA0000006', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge6, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge6, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge6@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge6, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge6, collect_metrics_from, sensor_agent_edge6))
dbmanager_agent_edge7 = URIRef(value='DBMA0000007', base=base_owl_ontology)
wsd_ffd_owl.add((dbmanager_agent_edge7, RDF.type, URIRef(value="DBManagerAgent", base=base_owl_ontology)))
wsd_ffd_owl.add((dbmanager_agent_edge7, MY_RDF_ONTOLOGY.hasJID, Literal("dbmanageragent.edge7@wsn-mas.org")))
wsd_ffd_owl.add((dbmanager_agent_edge7, MY_RDF_ONTOLOGY.isAlive, Literal(1)))
wsd_ffd_owl.add((dbmanager_agent_edge7, collect_metrics_from, sensor_agent_edge7))
wsd_ffd_owl.add((agent_container_edge2, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge2, trigger_agent_edge2, dbmanager_agent_edge2]).uri
))
wsd_ffd_owl.add((agent_container_edge3, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge3, trigger_agent_edge3, dbmanager_agent_edge3]).uri
))
wsd_ffd_owl.add((agent_container_edge4, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge4, trigger_agent_edge4, dbmanager_agent_edge4]).uri
))
wsd_ffd_owl.add((agent_container_edge5, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge5, trigger_agent_edge5, dbmanager_agent_edge5]).uri
))
wsd_ffd_owl.add((agent_container_edge6, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge6, trigger_agent_edge6, dbmanager_agent_edge6]).uri
))
wsd_ffd_owl.add((agent_container_edge7, MY_RDF_ONTOLOGY.contains,
Bag(wsd_ffd_owl, BNode(),
[sensor_agent_edge7, trigger_agent_edge7, dbmanager_agent_edge7]).uri
))
wsd_ffd_owl.add((edge2_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge2))
wsd_ffd_owl.add((edge3_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge3))
wsd_ffd_owl.add((edge4_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge4))
wsd_ffd_owl.add((edge5_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge5))
wsd_ffd_owl.add((edge6_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge6))
wsd_ffd_owl.add((edge7_node_instance, MY_RDF_ONTOLOGY.hostsAgentContainer, agent_container_edge7))
# Sensors edge2
dht11_edge2 = URIRef(value='DHT110000002', base=base_owl_ontology)
ky026_edge2 = URIRef(value='KY0260000002', base=base_owl_ontology)
mq2_edge2 = URIRef(value='MQ20000002', base=base_owl_ontology)
sfm27_edge2 = URIRef(value='SFM270000002', base=base_owl_ontology)
# Sensors edge3
dht11_edge3 = URIRef(value='DHT110000003', base=base_owl_ontology)
ky026_edge3 = URIRef(value='KY0260000003', base=base_owl_ontology)
mq2_edge3 = URIRef(value='MQ20000003', base=base_owl_ontology)
sfm27_edge3 = URIRef(value='SFM270000003', base=base_owl_ontology)
# Sensors edge4
dht11_edge4 = URIRef(value='DHT110000004', base=base_owl_ontology)
ky026_edge4 = URIRef(value='KY0260000004', base=base_owl_ontology)
mq2_edge4 = URIRef(value='MQ20000004', base=base_owl_ontology)
sfm27_edge4 = URIRef(value='SFM270000004', base=base_owl_ontology)
# Sensors edge5
dht11_edge5 = URIRef(value='DHT110000005', base=base_owl_ontology)
ky026_edge5 = URIRef(value='KY0260000002', base=base_owl_ontology)
mq2_edge5 = URIRef(value='MQ20000005', base=base_owl_ontology)
sfm27_edge5 = URIRef(value='SFM270000005', base=base_owl_ontology)
# Sensors edge6
dht11_edge6 = URIRef(value='DHT110000006', base=base_owl_ontology)
ky026_edge6 = URIRef(value='KY0260000006', base=base_owl_ontology)
mq2_edge6 = URIRef(value='MQ20000006', base=base_owl_ontology)
sfm27_edge6 = URIRef(value='SFM270000006', base=base_owl_ontology)
# Sensors edge7
dht11_edge7 = URIRef(value='DHT110000007', base=base_owl_ontology)
ky026_edge7 = URIRef(value='KY0260000007', base=base_owl_ontology)
mq2_edge7 = URIRef(value='MQ20000007', base=base_owl_ontology)
sfm27_edge7 = URIRef(value='SFM270000007', base=base_owl_ontology)
wsd_ffd_owl.add((dht11_edge2, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge2, SOSA.isHostedBy, edge2_node_instance))
wsd_ffd_owl.add((dht11_edge3, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge3, SOSA.isHostedBy, edge3_node_instance))
wsd_ffd_owl.add((dht11_edge4, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge4, SOSA.isHostedBy, edge4_node_instance))
wsd_ffd_owl.add((dht11_edge5, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge5, SOSA.isHostedBy, edge5_node_instance))
wsd_ffd_owl.add((dht11_edge6, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge6, SOSA.isHostedBy, edge6_node_instance))
wsd_ffd_owl.add((dht11_edge7, RDF.type, URIRef(value="DHT11", base=base_rdf_ontology)))
wsd_ffd_owl.add((dht11_edge7, SOSA.isHostedBy, edge7_node_instance))
wsd_ffd_owl.add((ky026_edge2, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge2, SOSA.isHostedBy, edge2_node_instance))
wsd_ffd_owl.add((ky026_edge3, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge3, SOSA.isHostedBy, edge3_node_instance))
wsd_ffd_owl.add((ky026_edge4, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge4, SOSA.isHostedBy, edge4_node_instance))
wsd_ffd_owl.add((ky026_edge5, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge5, SOSA.isHostedBy, edge5_node_instance))
wsd_ffd_owl.add((ky026_edge6, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge6, SOSA.isHostedBy, edge6_node_instance))
wsd_ffd_owl.add((ky026_edge7, RDF.type, URIRef(value="KY026", base=base_rdf_ontology)))
wsd_ffd_owl.add((ky026_edge7, SOSA.isHostedBy, edge7_node_instance))
wsd_ffd_owl.add((sfm27_edge2, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge2, SOSA.isHostedBy, edge2_node_instance))
wsd_ffd_owl.add((sfm27_edge3, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge3, SOSA.isHostedBy, edge3_node_instance))
wsd_ffd_owl.add((sfm27_edge4, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge4, SOSA.isHostedBy, edge4_node_instance))
wsd_ffd_owl.add((sfm27_edge5, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge5, SOSA.isHostedBy, edge5_node_instance))
wsd_ffd_owl.add((sfm27_edge6, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge6, SOSA.isHostedBy, edge6_node_instance))
wsd_ffd_owl.add((sfm27_edge7, RDF.type, URIRef(value="SFM27", base=base_rdf_ontology)))
wsd_ffd_owl.add((sfm27_edge7, SOSA.isHostedBy, edge7_node_instance))
wsd_ffd_owl.add((mq2_edge2, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge2, SOSA.isHostedBy, edge2_node_instance))
wsd_ffd_owl.add((mq2_edge3, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge3, SOSA.isHostedBy, edge3_node_instance))
wsd_ffd_owl.add((mq2_edge4, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge4, SOSA.isHostedBy, edge4_node_instance))
wsd_ffd_owl.add((mq2_edge5, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge5, SOSA.isHostedBy, edge5_node_instance))
wsd_ffd_owl.add((mq2_edge6, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge6, SOSA.isHostedBy, edge6_node_instance))
wsd_ffd_owl.add((mq2_edge7, RDF.type, URIRef(value="MQ2", base=base_rdf_ontology)))
wsd_ffd_owl.add((mq2_edge7, SOSA.isHostedBy, edge7_node_instance))
wsd_ffd_owl.add((coordinator_node_instance, RDF.type, OWL.CoordinatorNode))
wsd_ffd_owl.add((coordinator_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT234GJ55500001')))
wsd_ffd_owl.add((coordinator_node_instance, GEO.lat, Literal(55.701)))
wsd_ffd_owl.add((coordinator_node_instance, GEO.long, Literal(12.552)))
wsd_ffd_owl.add((router2_node_instance, RDF.type, OWL.RouterNode))
wsd_ffd_owl.add((router2_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT456UI67800001')))
wsd_ffd_owl.add((router2_node_instance, GEO.lat, Literal(55.895)))
wsd_ffd_owl.add((router2_node_instance, GEO.long, Literal(12.437)))
wsd_ffd_owl.add((router3_node_instance, RDF.type, OWL.RouterNode))
wsd_ffd_owl.add((router3_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT456UI67900001')))
wsd_ffd_owl.add((router3_node_instance, GEO.lat, Literal(55.634)))
wsd_ffd_owl.add((router3_node_instance, GEO.long, Literal(12.606)))
wsd_ffd_owl.add((router4_node_instance, RDF.type, OWL.RouterNode))
wsd_ffd_owl.add((router4_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT456UI68000001')))
wsd_ffd_owl.add((router4_node_instance, GEO.lat, Literal(56.030)))
wsd_ffd_owl.add((router4_node_instance, GEO.long, Literal(12.112)))
wsd_ffd_owl.add((edge2_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge2_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1100001')))
wsd_ffd_owl.add((edge2_node_instance, GEO.lat, Literal(56.120)))
wsd_ffd_owl.add((edge2_node_instance, GEO.long, Literal(11.969)))
wsd_ffd_owl.add((edge2_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge2, mq2_edge2, ky026_edge2, sfm27_edge2]).uri
))
wsd_ffd_owl.add((edge3_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge3_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1200001')))
wsd_ffd_owl.add((edge3_node_instance, GEO.lat, Literal(56.330)))
wsd_ffd_owl.add((edge3_node_instance, GEO.long, Literal(11.969)))
wsd_ffd_owl.add((edge3_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge3, mq2_edge3, ky026_edge3, sfm27_edge3]).uri
))
wsd_ffd_owl.add((edge4_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge4_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1300001')))
wsd_ffd_owl.add((edge4_node_instance, GEO.lat, Literal(56.444)))
wsd_ffd_owl.add((edge4_node_instance, GEO.long, Literal(11.969)))
wsd_ffd_owl.add((edge4_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge4, mq2_edge4, ky026_edge4, sfm27_edge4]).uri
))
wsd_ffd_owl.add((edge5_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge5_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1400001')))
wsd_ffd_owl.add((edge5_node_instance, GEO.lat, Literal(56.454)))
wsd_ffd_owl.add((edge5_node_instance, GEO.long, Literal(11.888)))
wsd_ffd_owl.add((edge5_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge5, mq2_edge5, ky026_edge5, sfm27_edge5]).uri
))
wsd_ffd_owl.add((edge6_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge6_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1500001')))
wsd_ffd_owl.add((edge6_node_instance, GEO.lat, Literal(56.342)))
wsd_ffd_owl.add((edge6_node_instance, GEO.long, Literal(11.765)))
wsd_ffd_owl.add((edge6_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge6, mq2_edge6, ky026_edge6, sfm27_edge6]).uri
))
wsd_ffd_owl.add((edge7_node_instance, RDF.type, OWL.EdgeDevice))
wsd_ffd_owl.add((edge7_node_instance, MY_RDF_ONTOLOGY.SerialNum, Literal('IT833ZK1600001')))
wsd_ffd_owl.add((edge7_node_instance, GEO.lat, Literal(56.323)))
wsd_ffd_owl.add((edge7_node_instance, GEO.long, Literal(11.721)))
wsd_ffd_owl.add((edge7_node_instance, SOSA.hosts,
Bag(wsd_ffd_owl, BNode(),
[dht11_edge7, mq2_edge7, ky026_edge7, sfm27_edge7]).uri
))
# WSN TOPOLOGY
wsd_ffd_owl.add((coordinator_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000002', base=base_owl_ontology)))
wsd_ffd_owl.add((coordinator_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000003', base=base_owl_ontology)))
wsd_ffd_owl.add((coordinator_node_instance, can_route, Bag(wsd_ffd_owl, BNode(),
[router2_node_instance, router3_node_instance]).uri))
wsd_ffd_owl.add((router2_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#CN0000001', base=base_owl_ontology)))
wsd_ffd_owl.add((router2_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((router2_node_instance, can_route, Bag(wsd_ffd_owl, BNode(),
[coordinator_node_instance, router4_node_instance,
edge2_node_instance, edge3_node_instance]).uri))
wsd_ffd_owl.add((router3_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#CN0000001', base=base_owl_ontology)))
wsd_ffd_owl.add((router3_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((router3_node_instance, can_route, Bag(wsd_ffd_owl, BNode(),
[coordinator_node_instance, router4_node_instance,
edge6_node_instance, edge7_node_instance]).uri))
wsd_ffd_owl.add((router4_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000002', base=base_owl_ontology)))
wsd_ffd_owl.add((router4_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000003', base=base_owl_ontology)))
wsd_ffd_owl.add((router4_node_instance, can_route, Bag(wsd_ffd_owl, BNode(),
[router2_node_instance, router3_node_instance,
edge3_node_instance, edge4_node_instance,
edge5_node_instance, edge6_node_instance]).uri))
wsd_ffd_owl.add((edge2_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000002', base=base_owl_ontology)))
wsd_ffd_owl.add((edge3_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000002', base=base_owl_ontology)))
wsd_ffd_owl.add((edge3_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((edge4_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((edge5_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((edge6_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000003', base=base_owl_ontology)))
wsd_ffd_owl.add((edge6_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000004', base=base_owl_ontology)))
wsd_ffd_owl.add((edge7_node_instance, MY_RDF_ONTOLOGY.isRoutedBy,
URIRef(value='#RN0000003', base=base_owl_ontology)))
##############################
# RDF Serialization
##############################
if len(sys.argv) > 1:
wsd_ffd_owl.serialize(destination=os.getcwd()+'/'+sys.argv[1]+'-xml.rdf', format='xml')
wsd_ffd_owl.serialize(destination=os.getcwd()+'/'+sys.argv[1]+'-pretty-xml.rdf', format='pretty-xml')
wsd_ffd_owl.serialize(destination=os.getcwd()+'/'+sys.argv[1]+'-turtle.ttl', format='turtle')
else:
wsd_ffd_owl.serialize(destination=os.getcwd()+'/wsd-ffd-xml-owl.rdf', format='xml')
wsd_ffd_owl.serialize(destination=os.getcwd()+'/wsd-ffd-pretty-xml-owl.rdf', format='pretty-xml')
wsd_ffd_owl.serialize(destination=os.getcwd()+'/wsd-ffd-turtle-owl.ttl', format='turtle')