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
9c79907c
Commit
9c79907c
authored
Mar 15, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ca545eb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
12 deletions
+28
-12
asyncua_server.py
asyncua_server.py
+2
-1
opc_ua_receiver_config.yaml
opc_ua_receiver_config.yaml
+1
-1
opcua_receiver.py
opcua_receiver.py
+25
-10
No files found.
asyncua_server.py
View file @
9c79907c
...
@@ -3,9 +3,10 @@ import pickle
...
@@ -3,9 +3,10 @@ import pickle
from
asyncua
import
ua
,
Server
from
asyncua
import
ua
,
Server
import
socket
import
socket
import
threading
import
threading
from
time
import
sleep
import
json
import
json
server_up
=
False
class
asyncua_server
():
class
asyncua_server
():
def
__init__
(
self
):
def
__init__
(
self
):
self
.
server
=
None
self
.
server
=
None
...
...
opc_ua_receiver_config.yaml
View file @
9c79907c
configuration
:
configuration
:
endpoint_url
:
opc.tcp://2.2.2.5:5353
1/myopc/free
endpoint_url
:
opc.tcp://2.2.2.5:5353
0/OPUA/SimulationServer
namespace_server
:
http://klopc.com
namespace_server
:
http://klopc.com
udp_hash_receiver_ip
:
2.2.2.5
udp_hash_receiver_ip
:
2.2.2.5
udp_hash_receiver_port
:
20002
udp_hash_receiver_port
:
20002
...
...
opcua_receiver.py
View file @
9c79907c
import
os
import
socket
import
socket
from
time
import
sleep
from
opcua_subscriber.opcua_subscribe
import
opcua_pack
from
opcua_subscriber.opcua_subscribe
import
opcua_pack
from
asyncua_server
import
st
from
asyncua_server
import
st
import
threading
import
threading
...
@@ -18,15 +18,30 @@ bufferSize = 1024
...
@@ -18,15 +18,30 @@ bufferSize = 1024
UDPServerSocket
=
socket
.
socket
(
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_DGRAM
)
UDPServerSocket
=
socket
.
socket
(
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_DGRAM
)
UDPServerSocket
.
bind
((
localIP
,
localPort
))
UDPServerSocket
.
bind
((
localIP
,
localPort
))
print
(
"UDP server up and listening"
)
t1
=
threading
.
Thread
(
target
=
st
,
args
=
(
Endpoint_Url
,
Namespace_Server
,
udp_hash_receiver_ip
,
udp_hash_receiver_port
,))
t1
=
threading
.
Thread
(
target
=
st
,
args
=
(
Endpoint_Url
,
Namespace_Server
,
udp_hash_receiver_ip
,
udp_hash_receiver_port
,))
t1
.
start
()
t1
.
start
()
sleep
(
5
)
opua
=
opcua_pack
()
sock
=
opua
.
connect
(
Endpoint_Url
)
while
(
True
):
opua
=
None
sock
=
None
def
start_server
():
global
sock
global
opua
try
:
opua
=
opcua_pack
()
sock
=
opua
.
connect
(
Endpoint_Url
)
except
:
start_server
()
return
opua
,
sock
def
receive_packets
():
print
(
"wait until server starts ..."
)
opua
,
sock
=
start_server
()
print
(
"receiving packets ..."
)
while
(
True
):
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
datatype
,
value
,
ns
,
nodeid
=
message
.
decode
()
.
split
(
"&"
)
datatype
,
value
,
ns
,
nodeid
=
message
.
decode
()
.
split
(
"&"
)
opua
.
write_opcua_value
(
sock
,
ns
,
nodeid
,
value
,
datatype
)
opua
.
write_opcua_value
(
sock
,
ns
,
nodeid
,
value
,
datatype
)
receive_packets
()
\ 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