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
f0cb915e
Commit
f0cb915e
authored
Mar 07, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f27700bd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
11 deletions
+6
-11
asyncua_server.py
asyncua_server.py
+3
-7
opcua_receiver.py
opcua_receiver.py
+3
-1
opcua_subscriber/opcua_subscribe.py
opcua_subscriber/opcua_subscribe.py
+0
-3
No files found.
asyncua_server.py
View file @
f0cb915e
...
@@ -17,17 +17,15 @@ class asyncua_server():
...
@@ -17,17 +17,15 @@ class asyncua_server():
self
.
idx
=
None
self
.
idx
=
None
async
def
add_object
(
self
,
obj
,
hierarchy
):
async
def
add_object
(
self
,
obj
,
hierarchy
):
print
(
hierarchy
[
obj
])
if
(
hierarchy
[
obj
][
"name"
]
==
"String"
):
if
(
hierarchy
[
obj
][
"name"
]
==
"String"
):
var_obj
=
await
self
.
server
.
nodes
.
objects
.
add_folder
(
self
.
idx
,
obj
)
var_obj
=
await
self
.
server
.
nodes
.
objects
.
add_folder
(
self
.
idx
,
obj
)
val_array
=
pickle
.
loads
(
hierarchy
[
obj
][
"obj"
])
val_array
=
pickle
.
loads
(
hierarchy
[
obj
][
"obj"
])
print
(
val_array
)
for
identifier
in
val_array
:
for
identifier
in
val_array
:
if
(
val_array
[
identifier
][
"datatype"
]
==
11
):
if
(
val_array
[
identifier
][
"datatype"
]
==
11
):
var
=
await
var_obj
.
add_variable
(
ua
.
NodeId
(
identifier
,
3
),
val_array
[
identifier
][
"node_name"
],
ua
.
NodeId
(
ua
.
ObjectIds
.
Double
))
var
=
await
var_obj
.
add_variable
(
ua
.
NodeId
(
identifier
,
3
),
val_array
[
identifier
][
"node_name"
],
float
(
0.0
))
#
ua.NodeId(ua.ObjectIds.Double))
await
var
.
set_writable
()
await
var
.
set_writable
()
if
(
val_array
[
identifier
][
"datatype"
]
==
6
):
if
(
val_array
[
identifier
][
"datatype"
]
==
6
):
var
=
await
var_obj
.
add_variable
(
ua
.
NodeId
(
identifier
,
3
),
val_array
[
identifier
][
"node_name"
],
ua
.
NodeId
(
ua
.
ObjectIds
.
Int32
))
var
=
await
var_obj
.
add_variable
(
ua
.
NodeId
(
identifier
,
3
),
val_array
[
identifier
][
"node_name"
],
0
,
ua
.
VariantType
.
Int32
)
#
ua.NodeId(ua.ObjectIds.Int32))
await
var
.
set_writable
()
await
var
.
set_writable
()
else
:
else
:
await
self
.
server
.
nodes
.
objects
.
add_folder
(
self
.
idx
,
obj
)
await
self
.
server
.
nodes
.
objects
.
add_folder
(
self
.
idx
,
obj
)
...
@@ -38,7 +36,6 @@ class asyncua_server():
...
@@ -38,7 +36,6 @@ class asyncua_server():
return
var
return
var
async
def
start_server
(
self
,
url
,
uri
):
async
def
start_server
(
self
,
url
,
uri
):
print
(
url
)
# create a server
# create a server
self
.
server
=
Server
()
self
.
server
=
Server
()
await
self
.
server
.
init
()
await
self
.
server
.
init
()
...
@@ -70,7 +67,6 @@ def hash_receive():
...
@@ -70,7 +67,6 @@ def hash_receive():
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
hierarchy
=
pickle
.
loads
(
message
)
hierarchy
=
pickle
.
loads
(
message
)
print
(
hierarchy
[
"hash"
])
if
(
prev_hash
!=
hierarchy
[
"hash"
]):
if
(
prev_hash
!=
hierarchy
[
"hash"
]):
for
object
in
hierarchy
:
for
object
in
hierarchy
:
if
(
object
!=
"hash"
):
if
(
object
!=
"hash"
):
...
...
opcua_receiver.py
View file @
f0cb915e
...
@@ -35,4 +35,6 @@ while (True):
...
@@ -35,4 +35,6 @@ 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
(
"&"
)
if
(
"int"
in
datatype
):
print
(
value
)
opua
.
write_opcua_value
(
sock
,
ns
,
nodeid
,
value
,
datatype
)
opua
.
write_opcua_value
(
sock
,
ns
,
nodeid
,
value
,
datatype
)
\ No newline at end of file
opcua_subscriber/opcua_subscribe.py
View file @
f0cb915e
...
@@ -383,7 +383,6 @@ class opcua_pack():
...
@@ -383,7 +383,6 @@ class opcua_pack():
else
:
else
:
Message_Size
=
123
Message_Size
=
123
vt_type
=
6
vt_type
=
6
print
(
value
)
vt_value
=
struct
.
pack
(
'i'
,
int
(
value
))
vt_value
=
struct
.
pack
(
'i'
,
int
(
value
))
statuscode
=
binascii
.
unhexlify
(
"00000000"
)
statuscode
=
binascii
.
unhexlify
(
"00000000"
)
...
@@ -448,14 +447,12 @@ class opcua_pack():
...
@@ -448,14 +447,12 @@ class opcua_pack():
if
count
==
0
:
if
count
==
0
:
self
.
identifier_string
=
data
.
hex
()[
156
:
156
+
64
]
self
.
identifier_string
=
data
.
hex
()[
156
:
156
+
64
]
count
=
count
+
1
count
=
count
+
1
print
(
'Received:'
,
data
)
except
:
except
:
break
break
data
=
self
.
start_session
(
self
.
SecureChannelId
,
self
.
TokenId
,
self
.
identifier_string
)
data
=
self
.
start_session
(
self
.
SecureChannelId
,
self
.
TokenId
,
self
.
identifier_string
)
sock
.
sendall
(
data
)
sock
.
sendall
(
data
)
res
=
sock
.
recv
(
1024
)
res
=
sock
.
recv
(
1024
)
sock
.
sendall
(
self
.
write_request
(
self
.
SecureChannelId
,
self
.
TokenId
,
self
.
identifier_string
,
4
,
3
,
1002
,
1
,
"<class 'int'>"
))
sock
.
sendall
(
self
.
write_request
(
self
.
SecureChannelId
,
self
.
TokenId
,
self
.
identifier_string
,
4
,
3
,
1002
,
1
,
"<class 'int'>"
))
print
(
sock
.
recv
(
1024
))
return
sock
return
sock
def
write_opcua_value
(
self
,
sock
,
ns
,
nodeid
,
val
,
datatype
):
def
write_opcua_value
(
self
,
sock
,
ns
,
nodeid
,
val
,
datatype
):
...
...
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