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
7d8ab000
Commit
7d8ab000
authored
1 year ago
by
Oliver Rostig
Browse files
Options
Downloads
Patches
Plain Diff
added comments and dockerfile
parent
0b027f0d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+13
-0
13 additions, 0 deletions
Dockerfile
newmodeljsonparse.py
+17
-11
17 additions, 11 deletions
newmodeljsonparse.py
requirements.txt
+5
-0
5 additions, 0 deletions
requirements.txt
with
35 additions
and
11 deletions
Dockerfile
0 → 100644
+
13
−
0
View file @
7d8ab000
# syntax=docker/dockerfile:1
FROM
python:3.10
# install app dependencies
#python vorpackage
WORKDIR
/app
RUN
./requirements.txt .
RUN
pip3
install
-r
requirements.txt
COPY
* /app
CMD
["python", "newmodeljsonparse.py", "robot.json"]
This diff is collapsed.
Click to expand it.
newmodeljsonparse.py
+
17
−
11
View file @
7d8ab000
...
@@ -4,19 +4,20 @@ import sys
...
@@ -4,19 +4,20 @@ import sys
import
writefile
as
wf
import
writefile
as
wf
from
collections
import
namedtuple
from
collections
import
namedtuple
#creates the constructor for the measurement-object with corresponding parameters
def
measurementJsonDecod
(
measurementdict
):
def
measurementJsonDecod
(
measurementdict
):
return
namedtuple
(
'
Measurement
'
,
measurementdict
.
keys
())(
*
measurementdict
.
values
())
return
namedtuple
(
'
Measurement
'
,
measurementdict
.
keys
())(
*
measurementdict
.
values
())
#creates the constructor for the parameter-object with corresponding parameters
def
parameterJsonDecod
(
parameterdict
):
def
parameterJsonDecod
(
parameterdict
):
return
namedtuple
(
'
Parameter
'
,
parameterdict
.
keys
())(
*
parameterdict
.
values
())
return
namedtuple
(
'
Parameter
'
,
parameterdict
.
keys
())(
*
parameterdict
.
values
())
#creates the constructor for the function-object with corresponding parameters
def
functionJsonDecod
(
functiondict
):
def
functionJsonDecod
(
functiondict
):
return
namedtuple
(
'
Function
'
,
functiondict
.
keys
())(
*
functiondict
.
values
())
return
namedtuple
(
'
Function
'
,
functiondict
.
keys
())(
*
functiondict
.
values
())
#Measurement class that can be instantiated using JsonDecod functions
class
Measurement
:
class
Measurement
:
def
__init__
(
self
,
name
,
description
,
datatype
,
value
,
dimension
,
unit
=
None
,
range
=
None
):
def
__init__
(
self
,
name
,
description
,
datatype
,
value
,
dimension
,
unit
=
None
,
range
=
None
):
self
.
name
=
name
self
.
name
=
name
...
@@ -31,7 +32,7 @@ class Measurement:
...
@@ -31,7 +32,7 @@ class Measurement:
else
:
else
:
self
.
value
=
value
self
.
value
=
value
#Parameter class that can be instantiated using JsonDecod functions
class
Parameter
:
class
Parameter
:
def
__init__
(
self
,
name
,
description
,
datatype
,
dimension
,
value
,
rangevar
=
None
,
unit
=
None
,
default
=
None
,
constant
=
False
):
def
__init__
(
self
,
name
,
description
,
datatype
,
dimension
,
value
,
rangevar
=
None
,
unit
=
None
,
default
=
None
,
constant
=
False
):
self
.
name
=
name
self
.
name
=
name
...
@@ -59,6 +60,9 @@ class Parameter:
...
@@ -59,6 +60,9 @@ class Parameter:
# self.value = self.datatype(default)
# self.value = self.datatype(default)
#Function class that can be instantiated using JsonDecod functions
class
Function
:
class
Function
:
def
__init__
(
self
,
name
,
description
,
inargsdatatypes
=
None
,
outargsdatatypes
=
None
):
def
__init__
(
self
,
name
,
description
,
inargsdatatypes
=
None
,
outargsdatatypes
=
None
):
self
.
name
=
name
self
.
name
=
name
...
@@ -67,6 +71,8 @@ class Function:
...
@@ -67,6 +71,8 @@ class Function:
self
.
outargsdatatypes
=
outargsdatatypes
self
.
outargsdatatypes
=
outargsdatatypes
#switches the dimension into the right format
def
dimensionchange
(
string
):
def
dimensionchange
(
string
):
dimarr
=
string
[
"
dimension
"
]
dimarr
=
string
[
"
dimension
"
]
if
type
(
dimarr
)
==
list
:
if
type
(
dimarr
)
==
list
:
...
@@ -77,7 +83,7 @@ def dimensionchange(string):
...
@@ -77,7 +83,7 @@ def dimensionchange(string):
newdimension
=
{
"
dimension
"
:
value
}
newdimension
=
{
"
dimension
"
:
value
}
string
.
update
(
newdimension
)
string
.
update
(
newdimension
)
#gets the datatypes of functions to set for opcua
def
getdatatypes
(
argarray
):
def
getdatatypes
(
argarray
):
returnarr
=
[]
returnarr
=
[]
if
len
(
argarray
)
>
0
:
if
len
(
argarray
)
>
0
:
...
@@ -87,7 +93,7 @@ def getdatatypes(argarray):
...
@@ -87,7 +93,7 @@ def getdatatypes(argarray):
else
:
else
:
return
None
return
None
#switches range into the right format
def
changerange
(
string
):
def
changerange
(
string
):
if
iskeythere
(
string
,
"
range
"
):
if
iskeythere
(
string
,
"
range
"
):
rangeval
=
string
[
"
range
"
]
rangeval
=
string
[
"
range
"
]
...
@@ -97,7 +103,7 @@ def changerange(string):
...
@@ -97,7 +103,7 @@ def changerange(string):
string
.
update
({
"
range
"
:
(
None
,
None
)})
string
.
update
({
"
range
"
:
(
None
,
None
)})
# print(string)
# print(string)
#gets the objectnames for arguments of the function
def
getobjnames
(
argarray
):
def
getobjnames
(
argarray
):
returnarr
=
[]
returnarr
=
[]
if
len
(
argarray
)
>
0
:
if
len
(
argarray
)
>
0
:
...
@@ -108,9 +114,8 @@ def getobjnames(argarray):
...
@@ -108,9 +114,8 @@ def getobjnames(argarray):
else
:
else
:
return
None
return
None
#returns a list of all the parameters as objects
def
getParameters
(
parametersDict
):
def
getParameters
(
parametersDict
):
# extracts the measurements of a Json-Model
parameterobj
=
[]
parameterobj
=
[]
if
len
(
parametersDict
)
>
0
:
if
len
(
parametersDict
)
>
0
:
for
i
in
parametersDict
:
for
i
in
parametersDict
:
...
@@ -122,7 +127,7 @@ def getParameters(parametersDict):
...
@@ -122,7 +127,7 @@ def getParameters(parametersDict):
parameterobj
.
append
(
parameterobji
)
parameterobj
.
append
(
parameterobji
)
return
parameterobj
return
parameterobj
#returns a list of all the measurements as objects
def
getMeasurements
(
measurementsDict
):
def
getMeasurements
(
measurementsDict
):
measurementobj
=
[]
measurementobj
=
[]
if
len
(
measurementsDict
)
>
0
:
if
len
(
measurementsDict
)
>
0
:
...
@@ -138,7 +143,7 @@ def getMeasurements(measurementsDict):
...
@@ -138,7 +143,7 @@ def getMeasurements(measurementsDict):
measurementobj
.
append
(
measurementobji
)
measurementobj
.
append
(
measurementobji
)
return
measurementobj
return
measurementobj
#returns a list of all the functions as objects
def
getFunctions
(
functionsDict
,
jsonmeasurements
,
jsonparameters
):
def
getFunctions
(
functionsDict
,
jsonmeasurements
,
jsonparameters
):
functionobj
=
[]
functionobj
=
[]
if
len
(
functionsDict
)
>
0
:
if
len
(
functionsDict
)
>
0
:
...
@@ -304,6 +309,7 @@ def main():
...
@@ -304,6 +309,7 @@ def main():
jsoncomponents
.
append
(
obj
)
jsoncomponents
.
append
(
obj
)
elif
obj
[
"
elementType
"
]
==
"
interface
"
:
elif
obj
[
"
elementType
"
]
==
"
interface
"
:
jsoninterfaces
.
append
(
obj
)
jsoninterfaces
.
append
(
obj
)
typesdict
=
buildComponents
({},
jsoninterfaces
,
jsoncomponents
,
jsonmeasurements
,
jsonparameters
,
jsonfunctions
,
[])
typesdict
=
buildComponents
({},
jsoninterfaces
,
jsoncomponents
,
jsonmeasurements
,
jsonparameters
,
jsonfunctions
,
[])
intantiateddict
=
instantiate
(
typesdict
,
jsoninterfaces
,
jsoncomponents
)
intantiateddict
=
instantiate
(
typesdict
,
jsoninterfaces
,
jsoncomponents
)
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
5
−
0
View file @
7d8ab000
asyncua
tomli
toml
numpy
opcua-client
\ No newline at end of file
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