Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-cloning
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yogesh.m
opcua-cloning
Commits
456983a3
Commit
456983a3
authored
Mar 02, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
49ee43c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
opcua_receiver.py
opcua_receiver.py
+35
-0
No files found.
opcua_receiver.py
0 → 100644
View file @
456983a3
import
socket
from
opcua
import
Client
,
ua
client
=
Client
(
"opc.tcp://DESKTOP-KMDNN6H:53530/OPCUA/SimulationServer"
)
client
.
connect
()
localIP
=
"2.2.2.5"
localPort
=
20001
bufferSize
=
1024
msgFromServer
=
"Hello UDP Client"
bytesToSend
=
str
.
encode
(
msgFromServer
)
# Create a datagram socket
UDPServerSocket
=
socket
.
socket
(
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_DGRAM
)
# Bind to address and ip
UDPServerSocket
.
bind
((
localIP
,
localPort
))
print
(
"UDP server up and listening"
)
while
(
True
):
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
datatype
,
value
,
nodeid
=
message
.
decode
()
.
split
(
"&"
)
if
(
datatype
==
"<class 'float'>"
):
client
.
get_node
(
nodeid
)
.
set_value
(
float
(
value
))
if
(
datatype
==
"<class 'int'>"
):
v
=
ua
.
DataValue
(
ua
.
Variant
(
int
(
value
),
ua
.
VariantType
.
Int32
))
client
.
get_node
(
nodeid
)
.
set_value
(
v
)
\ No newline at end of file
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