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
e8cf5f21
Commit
e8cf5f21
authored
1 year ago
by
Oliver Rostig
Browse files
Options
Downloads
Patches
Plain Diff
added toml config file
parent
336611e3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.toml
+11
-0
11 additions, 0 deletions
config.toml
newmodeljsonparse.py
+1
-1
1 addition, 1 deletion
newmodeljsonparse.py
requirements.txt
+0
-0
0 additions, 0 deletions
requirements.txt
writefile.py
+14
-4
14 additions, 4 deletions
writefile.py
with
26 additions
and
5 deletions
config.toml
0 → 100644
+
11
−
0
View file @
e8cf5f21
#config file
# set server endpoint example
#for example: 'opc.tcp://0.0.0.0:4840/freeopcua/server/'
server
=
'opc.tcp://0.0.0.0:4840/freeopcua/server/'
#set namespace
#for example: 'http://examples.freeopcua.github.io/'
namespace
=
'http://examples.freeopcua.github.io/'
This diff is collapsed.
Click to expand it.
newmodeljsonparse.py
+
1
−
1
View file @
e8cf5f21
...
...
@@ -308,7 +308,7 @@ def instantiate(typesdict, interfaces, jsoncomponents):
def
main
():
try
:
JSON_MODEL
=
sys
.
argv
[
1
][:
-
5
]
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
'
..
'
,
'
SOIL
OPC-UA
'
,
f
'
{
JSON_MODEL
}
.json
'
)):
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
'
..
'
,
'
SOIL
-
OPC-UA
'
,
f
'
{
JSON_MODEL
}
.json
'
)):
raise
Exception
()
except
Exception
as
e
:
print
(
'
You must provide a file from the folder to be used as root file of the parsing, e.g.,
"
python jsonparser.py model.json
"
.
'
)
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
0 → 100644
+
0
−
0
View file @
e8cf5f21
This diff is collapsed.
Click to expand it.
writefile.py
+
14
−
4
View file @
e8cf5f21
import
jsonparse
import
os
import
tomli
def
defFunction
(
functionname
,
file
,
indent
,
inargs
):
writeindent
=
""
...
...
@@ -26,6 +28,14 @@ def getVariantType(datatype):
elif
datatype
==
"
Boolean
"
:
varianttype
=
"
ua.VariantType.Boolean
"
return
varianttype
with
open
(
"
config.toml
"
,
"
rb
"
)
as
t
:
toml_dict
=
tomli
.
load
(
t
)
server_endpoint
=
toml_dict
[
'
server
'
]
namespace
=
toml_dict
[
'
namespace
'
]
def
writebeginning
():
if
os
.
path
.
exists
(
"
opcua-server.py
"
):
os
.
remove
(
"
opcua-server.py
"
)
...
...
@@ -44,14 +54,14 @@ _logger = logging.getLogger('asyncua')
server
.
write
(
"
\n
async def main():
"
)
#äinten = "\tab"
server
.
write
(
"""
server
.
write
(
f
"""
# setup our server
server = Server()
await server.init()
server.set_endpoint(
'
opc.tcp://0.0.0.0:4840/freeopcua/server/
'
)
server.set_endpoint(
'
{
server_endpoint
}
'
)
# setup our own namespace, not really necessary but should as spec
uri =
'
http://examples.freeopcua.github.io/
'
uri =
'
{
namespace
}
'
idx = await server.register_namespace(uri)
#id of rangetype
rangeid = await server.nodes.base_data_type.get_child([
"
0:Structure
"
,
"
0:Range
"
])
...
...
@@ -61,7 +71,7 @@ _logger = logging.getLogger('asyncua')
#creating dataypes for parameters and measurements
measurementtype = await server.nodes.base_data_type.add_data_type(idx,
"
Measurement
"
)
parametertype = await server.nodes.base_data_type.add_data_type(idx,
"
Parameter
"
)
"""
)
"""
)
def
openobject
(
objname
,
description
):
server
=
open
(
"
opcua-server.py
"
,
"
a
"
)
writeindent
=
"
"
...
...
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