8
8
from src import sparql
9
9
from src .failuredetection import PingFailureDetector
10
10
from src .netscan import HostListScanner
11
- from src .semantics import InputTypeBuilder , UnknownSemanticsException
11
+ from src .semantics import TDInputBuilder , UnknownSemanticsException
12
12
from src .td import ThingDescription
13
13
14
14
# Configuration. Location of the different things:
@@ -31,29 +31,6 @@ class AlarmSystem(object):
31
31
32
32
last_auth_time = datetime .datetime (1970 , 1 , 1 , 0 , 0 , 0 )
33
33
34
- def __build_alarm_action_params (self , action ):
35
- """
36
- Tries to determine the semantics of the input type of a alarm action.
37
- @type action TDAction
38
- @param action The alarm action to construct input data for.
39
- @rtype dict
40
- @return Input data for the given alarm action.
41
- """
42
- it = action .input_type () # Get input type description
43
- ns_repo = action .get_td ().namespace_repository ()
44
-
45
- if it ['type' ] == 'number' :
46
- # Determine semantics for this boolean value:
47
- for key , value in it .items ():
48
- if key != 'type' and sparql .classes_equivalent (ns_repo .resolve (key ),
49
- 'http://www.matthias-fisch.de/ontologies/wot#Duration' ):
50
- # So this is the duration of the alarm...
51
- # Determine its unit:
52
- if sparql .classes_equivalent (ns_repo .resolve (value ), 'http://dbpedia.org/resource/Second' ):
53
- return self .alarm_duration_secs
54
- elif sparql .classes_equivalent (ns_repo .resolve (value ), 'http://dbpedia.org/resource/Millisecond' ):
55
- return self .alarm_duration_secs * 1000
56
-
57
34
def on_door_opened (self , is_opened ):
58
35
if is_opened : # If the door is opened and not closed
59
36
# Calculate seconds since last authentication:
@@ -62,7 +39,7 @@ def on_door_opened(self, is_opened):
62
39
if secs <= self .auth_ttl_secs : # Permission case
63
40
welcome_action = self .alarm_source .get_action_by_types (['http://www.matthias-fisch.de/ontologies/wot#PlaybackAction' ])
64
41
if welcome_action :
65
- pb = InputTypeBuilder ()
42
+ pb = TDInputBuilder ()
66
43
pb .add_option_rule ('http://www.matthias-fisch.de/ontologies/wot#SoundFile' , 'http://www.matthias-fisch.de/ontologies/wot#WelcomeSound' )
67
44
68
45
try :
@@ -78,7 +55,7 @@ def on_door_opened(self, is_opened):
78
55
alarm_action = self .alarm_source .get_action_by_types (
79
56
['http://www.matthias-fisch.de/ontologies/wot#AlarmAction' ])
80
57
81
- pb = InputTypeBuilder ()
58
+ pb = TDInputBuilder ()
82
59
pb .add_value_rule ('http://www.matthias-fisch.de/ontologies/wot#Duration' ,
83
60
'http://dbpedia.org/resource/Second' , self .alarm_duration_secs )
84
61
pb .add_value_rule ('http://www.matthias-fisch.de/ontologies/wot#Duration' ,
@@ -95,6 +72,7 @@ def on_door_opened(self, is_opened):
95
72
96
73
def on_authentication (self , data ):
97
74
self .last_auth_time = datetime .datetime .strptime (data ['time' ], "%d-%m-%Y %H:%M:%S" )
75
+ print ("Entry authenticated at %s for %d seconds..." % (self .last_auth_time .strftime ("%d-%m-%Y %H:%M:%S" ), self .auth_ttl_secs ))
98
76
99
77
100
78
def get_td (url ):
0 commit comments