forked from danobot/entity-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagram.puml
123 lines (106 loc) · 5.77 KB
/
diagram.puml
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
@startuml
header
<font color=red>Entity Controller</font>
State Machine Diagram
endheader
skinparam backgroundColor LightYellow
skinparam state {
StartColor MediumBlue
EndColor Red
BackgroundColor Peru
BackgroundColor<<Warning>> Olive
BorderColor Gray
' FontName Arial Black
FontStyle Bold
}
hide empty description
[*] --> Idle
[*] --> Constrained : SETUP [is_within_constrain_period]
' ['idle', 'overridden', 'constrained', 'blocked', {'name': 'active', 'children': ['timer', 'stay_on'],
' machine.add_transition(trigger='constrain', source='*', dest='constrained')
Idle --> Constrained : CONSTRAIN
Blocked -right-> Constrained : CONSTRAIN
state Active {
[*] --> ActiveTimer : ENTER [!will_stay_on]
[*] --> ActiveStayOn : ENTER [will_stay_on]
}
Active --> Overridden : OVERRIDE
Active -left-> Constrained : CONSTRAIN
Overridden -left-> Constrained : CONSTRAIN
' machine.add_transition(trigger='override',
' source=['idle', 'active_timer', 'blocked'],
' dest='overridden')
Idle --> Overridden : OVERRIDE
Blocked -right-> Overridden : OVERRIDE
ActiveTimer --> Overridden : OVERRIDE
' # Idle
' machine.add_transition(trigger='sensor_on', source='idle', dest='active',
' conditions=['is_state_entities_off'])
Idle --> Active : SENSOR_ON [is_state_entities_off]
' machine.add_transition(trigger='sensor_on', source='idle', dest='blocked',
' conditions=['is_state_entities_on'])
Idle -right-> Blocked : SENSOR_ON [is_state_entities_on]
' # Blocked
' machine.add_transition(trigger='enable', source='blocked', dest='idle')
Blocked --> Idle : ENABLE
' machine.add_transition(trigger='sensor_on', source='blocked',
' dest='blocked') # re-entering self-transition (on_enter callback executed.)
Blocked --> Blocked : SENSOR_ON (required for on_enter callback)
' # Overridden
' machine.add_transition(trigger='enable', source='overridden', dest='idle',
' conditions=['is_state_entities_on', 'is_duration_sensor', 'is_sensor_off'])
Overridden --> Idle : ENABLE ['is_state_entities_on', 'is_duration_sensor', 'is_sensor_off']
' machine.add_transition(trigger='enable', source='overridden', dest='idle',
' conditions=['is_state_entities_off'])
Overridden --> Idle : ENABLE ['is_state_entities_off']
' machine.add_transition(trigger='enable', source='overridden', dest='active',
' conditions=['is_state_entities_on', 'is_event_sensor'])
Overridden --> Active : ENABLE ['is_state_entities_on', 'is_event_sensor']
' machine.add_transition(trigger='enable', source='overridden', dest='active',
' conditions=['is_state_entities_on', 'is_sensor_on'])
Overridden -right-> Active : ENABLE ['is_state_entities_on', 'is_sensor_on']
' # machine.add_transition(trigger='sensor_off', source=['overridden'], dest=None)
' Overridden --> None : SENSOR_OFF
' machine.add_transition(trigger='enter', source='active',
' dest='active_timer', unless='will_stay_on')
' machine.add_transition(trigger='enter', source='active',
' dest='active_stay_on', conditions='will_stay_on')
' # Active Timer
' machine.add_transition(trigger='sensor_on', source='active_timer',
' dest=None, after='_reset_timer')
' # machine.add_transition(trigger='sensor_off', source='active_timer', dest=None, conditions=['is_event_sensor'])
' machine.add_transition(trigger='sensor_off_duration',
' source='active_timer', dest='idle',
' conditions=['is_timer_expired'])
ActiveTimer --> Idle : SENSOR_OFF_DURATION [is_timer_expired]
' # The following two transitions must be kept seperate because they have
' # special conditional logic that cannot be combined.
' machine.add_transition(trigger='timer_expires', source='active_timer',
' dest='idle', conditions=['is_event_sensor'])
ActiveTimer --> Idle : TIMER_EXPIRES [is_event_sensor]
' machine.add_transition(trigger='timer_expires', source='active_timer',
' dest='idle',
' conditions=['is_duration_sensor', 'is_sensor_off'])
ActiveTimer --> Idle : TIMER_EXPIRES [is_duration_sensor, is_sensor_off]
' machine.add_transition(trigger='block_timer_expires', source='blocked', dest='active',
' conditions=['is_state_entities_on', 'is_event_sensor'])
Blocked --> Active : BLOCK_TIMER_EXPIRES ['is_state_entities_on', 'is_event_sensor']
' machine.add_transition(trigger='block_timer_expires', source='blocked', dest='active',
' conditions=['is_state_entities_on', 'is_sensor_on'])
Blocked --> Active : BLOCK_TIMER_EXPIRES ['is_state_entities_on', 'is_sensor_on']
' machine.add_transition(trigger='block_timer_expires', source='blocked', dest='idle',
' conditions=['is_state_entities_on', 'is_duration_sensor', 'is_sensor_off'])
Blocked --> Idle : BLOCK_TIMER_EXPIRES ['is_state_entities_on', 'is_duration_sensor', 'is_sensor_off'
' machine.add_transition(trigger='control', source='active_timer',
' dest='idle', conditions=['is_state_entities_off'])
ActiveTimer --> Idle : CONTROL [is_state_entities_off]
ActiveTimer --> Blocked : CONTROL [is_state_entities_on]
' # machine.add_transition(trigger='sensor_off', source='active_stay_on', dest=None)
' machine.add_transition(trigger='timer_expires', source='active_stay_on',
' dest=None)
' # Constrained
' machine.add_transition(trigger='enable', source='constrained', dest='idle', conditions=['is_override_state_off'])
Constrained --> Idle : ENABLE [is_override_state_off]
' machine.add_transition(trigger='enable', source='constrained', dest='overridden', conditions=['is_override_state_on'])
Constrained --> Overridden : ENABLE [is_override_state_on]
@enduml