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
560e3327
Commit
560e3327
authored
Mar 07, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4f9cd8b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
asyncua_server.py
asyncua_server.py
+3
-3
opcua_receiver.py
opcua_receiver.py
+8
-8
opcua_subscriber/opcua_subscribe.py
opcua_subscriber/opcua_subscribe.py
+2
-2
No files found.
asyncua_server.py
View file @
560e3327
...
@@ -5,7 +5,7 @@ import socket
...
@@ -5,7 +5,7 @@ import socket
import
threading
import
threading
from
time
import
sleep
from
time
import
sleep
localIP
=
"2.2.2.
7
"
localIP
=
"2.2.2.
5
"
localPort
=
20002
localPort
=
20002
bufferSize
=
1024
bufferSize
=
1024
UDPServerSocket
=
socket
.
socket
(
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_DGRAM
)
UDPServerSocket
=
socket
.
socket
(
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_DGRAM
)
...
@@ -63,7 +63,7 @@ asr = asyncua_server()
...
@@ -63,7 +63,7 @@ asr = asyncua_server()
def
hash_receive
():
def
hash_receive
():
prev_hash
=
0
prev_hash
=
0
sleep
(
5
)
sleep
(
1
)
while
(
True
):
while
(
True
):
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
...
@@ -79,4 +79,4 @@ def hash_receive():
...
@@ -79,4 +79,4 @@ def hash_receive():
def
st
():
def
st
():
t1
=
threading
.
Thread
(
target
=
hash_receive
)
t1
=
threading
.
Thread
(
target
=
hash_receive
)
t1
.
start
()
t1
.
start
()
asyncio
.
run
(
asr
.
start_server
(
"opc.tcp://2.2.2.
7
:53531/myopc/free"
,
"http://klopc.com"
))
asyncio
.
run
(
asr
.
start_server
(
"opc.tcp://2.2.2.
5
:53531/myopc/free"
,
"http://klopc.com"
))
opcua_receiver.py
View file @
560e3327
...
@@ -5,7 +5,7 @@ from asyncua_server import st
...
@@ -5,7 +5,7 @@ from asyncua_server import st
import
asyncio
import
asyncio
import
threading
import
threading
localIP
=
"2.2.2.
7
"
localIP
=
"2.2.2.
5
"
localPort
=
20001
localPort
=
20001
...
@@ -26,13 +26,13 @@ UDPServerSocket.bind((localIP, localPort))
...
@@ -26,13 +26,13 @@ UDPServerSocket.bind((localIP, localPort))
print
(
"UDP server up and listening"
)
print
(
"UDP server up and listening"
)
t1
=
threading
.
Thread
(
target
=
st
,
args
=
())
t1
=
threading
.
Thread
(
target
=
st
,
args
=
())
t1
.
start
()
t1
.
start
()
sleep
(
1
)
sleep
(
30
)
print
(
"here"
)
print
(
"here"
)
opua
=
opcua_pack
()
opua
=
opcua_pack
()
sock
=
opua
.
connect
(
"opc.tcp://2.2.2.
7
:53531/myopc/free"
)
sock
=
opua
.
connect
(
"opc.tcp://2.2.2.
5
:53531/myopc/free"
)
while
(
True
):
#
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)
opcua_subscriber/opcua_subscribe.py
View file @
560e3327
...
@@ -141,7 +141,7 @@ class opcua_pack():
...
@@ -141,7 +141,7 @@ class opcua_pack():
DiscoveryProfileUri
=
binascii
.
unhexlify
(
"ffffffff"
)
DiscoveryProfileUri
=
binascii
.
unhexlify
(
"ffffffff"
)
ArraySize
=
0
ArraySize
=
0
ServerUri
=
binascii
.
unhexlify
(
"ffffffff"
)
ServerUri
=
binascii
.
unhexlify
(
"ffffffff"
)
EndpointUrl
=
"opc.tcp://2.2.2.
7
:53531/myopc/free"
EndpointUrl
=
"opc.tcp://2.2.2.
5
:53531/myopc/free"
EndpointUrllen
=
len
(
EndpointUrl
.
encode
())
.
to_bytes
(
4
,
byteorder
=
"little"
)
EndpointUrllen
=
len
(
EndpointUrl
.
encode
())
.
to_bytes
(
4
,
byteorder
=
"little"
)
SessionName
=
"Pure Python Client Session1"
SessionName
=
"Pure Python Client Session1"
SessionNamelen
=
len
(
SessionName
.
encode
())
.
to_bytes
(
4
,
byteorder
=
"little"
)
SessionNamelen
=
len
(
SessionName
.
encode
())
.
to_bytes
(
4
,
byteorder
=
"little"
)
...
@@ -426,7 +426,7 @@ class opcua_pack():
...
@@ -426,7 +426,7 @@ class opcua_pack():
return
session
return
session
def
connect
(
self
,
address
):
def
connect
(
self
,
address
):
server_address
=
(
'2.2.2.
7
'
,
53531
)
server_address
=
(
'2.2.2.
5
'
,
53531
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
connect
(
server_address
)
sock
.
connect
(
server_address
)
message
=
self
.
helf
(
address
)
message
=
self
.
helf
(
address
)
...
...
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