src
flexbe_core
core
state.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
from
flexbe_core.core.exceptions
import
StateError
3
4
5
def
_remove_duplicates
(input_list):
6
output_list = list()
7
for
entry
in
input_list:
8
if
entry
not
in
output_list:
9
output_list.append(entry)
10
return
output_list
11
12
13
class
State
(object):
14
15
def
__init__
(self, *args, **kwargs):
16
self.
_outcomes
=
_remove_duplicates
(kwargs.get(
'outcomes'
, []))
17
io_keys = kwargs.get(
'io_keys'
, [])
18
self.
_input_keys
=
_remove_duplicates
(kwargs.get(
'input_keys'
, []) + io_keys)
19
self.
_output_keys
=
_remove_duplicates
(kwargs.get(
'output_keys'
, []) + io_keys)
20
# properties of instances of a state machine
21
self.
_name
=
None
22
self.
_parent
=
None
23
24
def
execute
(self, userdata):
25
pass
26
27
def
sleep
(self):
28
pass
29
30
@property
31
def
sleep_duration
(self):
32
return
0.
33
34
@property
35
def
outcomes
(self):
36
return
self.
_outcomes
37
38
@property
39
def
input_keys
(self):
40
return
self.
_input_keys
41
42
@property
43
def
output_keys
(self):
44
return
self.
_output_keys
45
46
# instance properties
47
48
@property
49
def
name
(self):
50
return
self.
_name
51
52
def
set_name
(self, value):
53
if
self.
_name
is
not
None
:
54
raise
StateError
(
"Cannot change the name of a state!"
)
55
else
:
56
self.
_name
= value
57
58
@property
59
def
parent
(self):
60
return
self.
_parent
61
62
def
set_parent
(self, value):
63
if
self.
_parent
is
not
None
:
64
raise
StateError
(
"Cannot change the parent of a state!"
)
65
else
:
66
self.
_parent
= value
67
68
@property
69
def
path
(self):
70
return
""
if
self.
parent
is
None
else
self.
parent
.path +
"/"
+ self.
name
flexbe_core.core.state.State._outcomes
_outcomes
Definition:
state.py:16
flexbe_core.core.exceptions
Definition:
exceptions.py:1
flexbe_core.core.exceptions.StateError
Definition:
exceptions.py:4
flexbe_core.core.state.State.output_keys
def output_keys(self)
Definition:
state.py:43
flexbe_core.core.state.State._input_keys
_input_keys
Definition:
state.py:18
flexbe_core.core.state.State.sleep
def sleep(self)
Definition:
state.py:27
flexbe_core.core.state.State.__init__
def __init__(self, *args, **kwargs)
Definition:
state.py:15
flexbe_core.core.state.State._name
_name
Definition:
state.py:21
flexbe_core.core.state.State
Definition:
state.py:13
flexbe_core.core.state.State.execute
def execute(self, userdata)
Definition:
state.py:24
flexbe_core.core.state.State._output_keys
_output_keys
Definition:
state.py:19
flexbe_core.core.state.State.outcomes
def outcomes(self)
Definition:
state.py:35
flexbe_core.core.state.State.path
def path(self)
Definition:
state.py:69
flexbe_core.core.state.State.parent
def parent(self)
Definition:
state.py:59
flexbe_core.core.state._remove_duplicates
def _remove_duplicates(input_list)
Definition:
state.py:5
flexbe_core.core.state.State.input_keys
def input_keys(self)
Definition:
state.py:39
flexbe_core.core.state.State._parent
_parent
Definition:
state.py:22
flexbe_core.core.state.State.set_name
def set_name(self, value)
Definition:
state.py:52
flexbe_core.core.state.State.set_parent
def set_parent(self, value)
Definition:
state.py:62
flexbe_core.core.state.State.sleep_duration
def sleep_duration(self)
Definition:
state.py:31
flexbe_core.core.state.State.name
def name(self)
Definition:
state.py:49
flexbe_core
Author(s): Philipp Schillinger
autogenerated on Fri Jul 21 2023 02:26:05