Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOIL2OPC UA Translator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WZL-IQS-Public
Sensor Interfacing Language (SOIL)
SOIL2OPC UA Translator
Commits
ab6bda5f
Commit
ab6bda5f
authored
2 years ago
by
Susanna Weber
Browse files
Options
Downloads
Patches
Plain Diff
parser for functions added
parent
a673410c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
jsonparse.py
+43
-2
43 additions, 2 deletions
jsonparse.py
robot.py
+9
-0
9 additions, 0 deletions
robot.py
with
52 additions
and
2 deletions
jsonparse.py
+
43
−
2
View file @
ab6bda5f
...
...
@@ -8,9 +8,15 @@ from collections import namedtuple
def
measurementJsonDecod
(
measurementdict
):
return
namedtuple
(
'
Measurement
'
,
measurementdict
.
keys
())(
*
measurementdict
.
values
())
def
parameterJsonDecod
(
parameterdict
):
return
namedtuple
(
'
Parameter
'
,
parameterdict
.
keys
())(
*
parameterdict
.
values
())
def
functionJsonDecod
(
functiondict
):
return
namedtuple
(
'
Function
'
,
functiondict
.
keys
())(
*
functiondict
.
values
())
class
Measurement
:
def
__init__
(
self
,
name
,
description
,
datatype
,
value
,
dimension
,
unit
=
None
,
range
=
None
):
self
.
name
=
name
...
...
@@ -61,6 +67,14 @@ class Parameter:
# else:
# self.value = self.datatype(default)
class
Function
:
def
__init__
(
self
,
name
,
description
,
inargsdatatypes
=
None
,
outargsdatatypes
=
None
):
self
.
name
=
name
self
.
description
=
description
self
.
inargsdatatypes
=
inargsdatatypes
self
.
outargsdatatypes
=
outargsdatatypes
def
dimensionchange
(
string
):
dimarr
=
string
[
"
dimension
"
]
if
dimarr
:
...
...
@@ -71,6 +85,16 @@ def dimensionchange(string):
string
.
update
(
newdimension
)
def
getdatatypes
(
argarray
):
returnarr
=
[]
if
len
(
argarray
)
>
0
:
for
i
in
argarray
:
returnarr
.
append
(
i
[
"
datatype
"
])
return
returnarr
else
:
return
None
def
changerange
(
string
):
#print(type(string["range"][0]))
if
string
[
"
range
"
]
!=
"
[None, None]
"
:
...
...
@@ -108,7 +132,7 @@ def main():
dimensionchange
(
obj
)
#if i["range"]:
changerange
(
obj
)
obj
=
json
.
dumps
(
i
)
obj
=
json
.
dumps
(
obj
)
measurementobji
=
json
.
loads
(
obj
,
object_hook
=
measurementJsonDecod
)
measurementobj
.
append
(
measurementobji
)
...
...
@@ -124,10 +148,27 @@ def main():
dimensionchange
(
obj
)
if
i
[
"
range
"
]:
changerange
(
obj
)
obj
=
json
.
dumps
(
i
)
obj
=
json
.
dumps
(
obj
)
parameterobji
=
json
.
loads
(
obj
,
object_hook
=
parameterJsonDecod
)
parameterobj
.
append
(
parameterobji
)
functions
=
robotload
[
"
functions
"
]
if
len
(
functions
)
>
0
:
functionobj
=
[]
for
i
in
functions
:
obj
=
i
# del obj["value"]
obj
[
"
inargsdatatypes
"
]
=
getdatatypes
(
obj
[
"
arguments
"
])
obj
[
"
outargsdatatypes
"
]
=
getdatatypes
(
obj
[
"
returns
"
])
del
obj
[
"
uuid
"
]
del
obj
[
"
arguments
"
]
del
obj
[
"
returns
"
]
obj
=
json
.
dumps
(
obj
)
functionobji
=
json
.
loads
(
obj
,
object_hook
=
functionJsonDecod
)
functionobj
.
append
(
functionobji
)
print
(
functionobj
)
print
(
parameterobj
)
...
...
This diff is collapsed.
Click to expand it.
robot.py
+
9
−
0
View file @
ab6bda5f
...
...
@@ -142,6 +142,7 @@ async def main():
await
unitprop
.
set_modelling_rule
(
True
)
description
=
await
para
.
add_property
(
idx
,
"
Description
"
,
a
.
description
)
await
description
.
set_modelling_rule
(
True
)
#gripper als componente
...
...
@@ -164,6 +165,8 @@ async def main():
positionrobot
=
await
mobilerobot
.
get_child
([
robotposname
])
await
positionrobot
.
set_writable
(
True
)
@uamethod
def
goTo
(
parent
,
position
):
positionrobot
.
set_value
(
position
)
...
...
@@ -178,6 +181,7 @@ async def main():
# tcprobmeas = await robot.get_child([tcpvarname])
#adding function goTo to robot
goTofunc
=
await
mobilerobot
.
add_method
(
idx
,
"
goTo
"
,
goTo
,
[
ua
.
VariantType
.
Float
],
[
ua
.
VariantType
.
Float
])
...
...
@@ -222,6 +226,11 @@ async def main():
await
batterywarninggen
.
trigger
(
message
=
"
Battery level is below 20%. Load shortly.
"
)
if
batteryload
<
10
:
await
batteryerrorgen
.
trigger
(
message
=
"
Battery level is below 10%. Please load the battery immediately.
"
)
if
batteryload
<=
2
:
#server.get_event_generator()
await
server
.
stop
()
# await batteryerror.response_params[idx].StatusCode.is_good()
await
asyncio
.
sleep
(
1
)
time
+=
1
batterysave
=
batteryload
-
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment