Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
osie
Commits
31045f10
Commit
31045f10
authored
May 28, 2024
by
Philipp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update opcua-client-fhi/minimal-client.py
parent
20b9b9fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
25 deletions
+36
-25
opcua-client-fhi/minimal-client.py
opcua-client-fhi/minimal-client.py
+36
-25
No files found.
opcua-client-fhi/minimal-client.py
View file @
31045f10
...
...
@@ -24,32 +24,43 @@ xml = args.xml
# Server information
if
bool
(
int
(
ipv6_enabled
)):
url
=
"opc.tcp://[{ipv6}]:{port}/PwDC"
#url = "opc.tcp://
0.0.0.0:488
0/PwDC"
url
=
f
"opc.tcp://[
{
ipv6
}
]:
{
port
}
/PwDC"
#url = "opc.tcp://
[0.0.0.0]:484
0/PwDC"
async
def
main
():
_logger
=
logging
.
getLogger
(
__name__
)
_logger
.
info
(
"Connecting to %s ..."
,
url
)
async
with
Client
(
url
=
url
,
timeout
=
2
)
as
client
:
while
True
:
await
asyncio
.
sleep
(
1
)
# Get the root node
#namespace_uri = "http://examples.freeopcua.github.io"
#nsidx = await client.get_namespace_index(namespace_uri)
nsidx
=
1
# Get the Powerfuse object
s
=
"Powerfuse_Maschinenstatus_Status_Rot"
var
=
await
client
.
nodes
.
root
.
get_child
(
f"0:Objects/
{
nsidx
}
:Powerfuse/
{
nsidx
}
:
{
s
}
"
)
value
=
await
var
.
read_value
()
name
=
await
var
.
read_browse_name
()
_logger
.
info
(
f"Value of
{
s
}
(
{
var
}
):
{
value
}
"
)
s
=
"Powerfuse_Maschinenstatus_Status_Gelb"
var
=
await
client
.
nodes
.
root
.
get_child
(
f"0:Objects/
{
nsidx
}
:Powerfuse/
{
nsidx
}
:
{
s
}
"
)
value
=
await
var
.
read_value
()
name
=
await
var
.
read_browse_name
()
_logger
.
info
(
f"Value of
{
s
}
(
{
var
}
):
{
value
}
"
)
_logger
=
logging
.
getLogger
(
__name__
)
_logger
.
info
(
"Connecting to %s ..."
,
url
)
async
with
Client
(
url
=
url
,
timeout
=
2
)
as
client
:
while
True
:
await
asyncio
.
sleep
(
1
)
# Get the root node
root
=
client
.
get_root_node
()
# Get the objects node
objects
=
await
root
.
get_child
(
"0:Objects"
)
# Get the Powerfuse object
powerfuse_obj
=
await
objects
.
get_child
(
"1:Powerfuse"
)
# Get the variables
machine_status_rot
=
await
powerfuse_obj
.
get_child
(
"1:Powerfuse_Maschinenstatus_Status_Rot"
)
machine_status_gelb
=
await
powerfuse_obj
.
get_child
(
"1:Powerfuse_Maschinenstatus_Status_Gelb"
)
# Read values
value_rot
=
await
machine_status_rot
.
read_value
()
value_gelb
=
await
machine_status_gelb
.
read_value
()
_logger
.
info
(
f"Initial values: Rot=
{
value_rot
}
, Gelb=
{
value_gelb
}
"
)
# Write values
await
machine_status_rot
.
write_value
(
True
)
await
machine_status_gelb
.
write_value
(
False
)
### write the values to the opcua-to-http-gw-service opc.tcp://[2001:67c:1254:108:404e::9]:4840/freeopcua/server/
# Currently there is just one
if
__name__
==
"__main__"
:
logging
.
basicConfig
(
level
=
logging
.
INFO
)
asyncio
.
run
(
main
())
logging
.
basicConfig
(
level
=
logging
.
INFO
)
asyncio
.
run
(
main
(),
debug
=
False
)
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