Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
pluto
Commits
78b4d76e
Commit
78b4d76e
authored
Apr 29, 2020
by
Anders Blomdell
Browse files
Improved AUTO handling. Made safe-cell logic auto generated
parent
b8f8b8e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
robotlab_safety/pluto_auto.py
View file @
78b4d76e
...
...
@@ -17,23 +17,26 @@ class PlutoVariables:
pass
def
codegen
(
self
,
expr
):
m
=
re
.
match
(
'([^=]+)=AND\{(.*),(.*)\}'
,
expr
)
m
=
re
.
match
(
'([^=]+)=
(
AND
|OR)
\{(.*),(.*)\}'
,
expr
)
if
m
:
lh
=
m
.
group
(
1
)
regexp
=
m
.
group
(
2
).
replace
(
'*'
,
'.*'
)
rh
=
[
m
.
group
(
3
).
format
(
v
,
pluto
=
self
.
by_name
[
v
][
0
])
for
v
in
self
.
by_name
if
re
.
match
(
regexp
,
v
)]
return
(
"%s=%s"
%
(
lh
,
'*'
.
join
(
rh
)))
m
=
re
.
match
(
'([^=]+)=OR\{(.*),(.*)\}'
,
expr
)
if
m
:
lh
=
m
.
group
(
1
)
regexp
=
m
.
group
(
2
).
replace
(
'*'
,
'.*'
)
rh
=
[
m
.
group
(
3
).
format
(
v
,
pluto
=
self
.
by_name
[
v
][
0
])
for
v
in
self
.
by_name
if
re
.
match
(
regexp
,
v
)]
return
(
"%s=%s"
%
(
lh
,
'+'
.
join
(
rh
)))
op
=
m
.
group
(
2
)
regexp
=
m
.
group
(
3
).
replace
(
'*'
,
'.*'
)
expr
=
m
.
group
(
4
)
rh
=
[]
for
k
,
v
in
sorted
(
self
.
by_name
.
items
()):
rh_m
=
re
.
match
(
regexp
,
k
)
if
rh_m
:
matches
=
(
k
,)
+
rh_m
.
groups
()
rh
.
append
(
expr
.
format
(
*
matches
,
pluto
=
v
[
0
]))
pass
pass
if
op
==
'AND'
:
return
(
"%s=%s"
%
(
lh
,
'*'
.
join
(
rh
)))
elif
op
==
'OR'
:
return
(
"%s=%s"
%
(
lh
,
'+'
.
join
(
rh
)))
raise
Exception
(
'Invalid expression'
,
expr
)
class
SPS
:
def
__init__
(
self
,
path
):
...
...
robotlab_safety/safety_2020.sps
View file @
78b4d76e
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment