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
df6a7ede
Commit
df6a7ede
authored
Mar 02, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
cbbc7301
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
538 additions
and
10 deletions
+538
-10
.idea/workspace.xml
.idea/workspace.xml
+74
-1
opcua-transmitter.py
opcua-transmitter.py
+0
-3
opcua_receiver.py
opcua_receiver.py
+9
-6
opcua_subscriber/__pycache__/opcua_subscribe.cpython-39.pyc
opcua_subscriber/__pycache__/opcua_subscribe.cpython-39.pyc
+0
-0
opcua_subscriber/opcua_subscribe.py
opcua_subscriber/opcua_subscribe.py
+455
-0
No files found.
.idea/workspace.xml
View file @
df6a7ede
...
@@ -7,6 +7,13 @@
...
@@ -7,6 +7,13 @@
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
</component>
<component
name=
"FileTemplateManagerImpl"
>
<option
name=
"RECENT_TEMPLATES"
>
<list>
<option
value=
"Python Script"
/>
</list>
</option>
</component>
<component
name=
"Git.Settings"
>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
</component>
...
@@ -25,7 +32,7 @@
...
@@ -25,7 +32,7 @@
<recent
name=
"D:\opcua-cloning"
/>
<recent
name=
"D:\opcua-cloning"
/>
</key>
</key>
</component>
</component>
<component
name=
"RunManager"
selected=
"Python.opcua
-transmitt
er"
>
<component
name=
"RunManager"
selected=
"Python.opcua
_receiv
er"
>
<configuration
name=
"main"
type=
"PythonConfigurationType"
factoryName=
"Python"
nameIsGenerated=
"true"
>
<configuration
name=
"main"
type=
"PythonConfigurationType"
factoryName=
"Python"
nameIsGenerated=
"true"
>
<module
name=
"opcua-cloning"
/>
<module
name=
"opcua-cloning"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
...
@@ -47,6 +54,27 @@
...
@@ -47,6 +54,27 @@
<option
name=
"INPUT_FILE"
value=
""
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
<method
v=
"2"
/>
</configuration>
</configuration>
<configuration
name=
"opcua-transmitter (1)"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"opcua-cloning"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/opcua-transmitter.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"MODULE_MODE"
value=
"false"
/>
<option
name=
"REDIRECT_INPUT"
value=
"false"
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
name=
"opcua-transmitter"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
nameIsGenerated=
"true"
>
<configuration
name=
"opcua-transmitter"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"opcua-cloning"
/>
<module
name=
"opcua-cloning"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
...
@@ -68,8 +96,53 @@
...
@@ -68,8 +96,53 @@
<option
name=
"INPUT_FILE"
value=
""
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
<method
v=
"2"
/>
</configuration>
</configuration>
<configuration
name=
"opcua_receiver"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"opcua-cloning"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/opcua_receiver.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"MODULE_MODE"
value=
"false"
/>
<option
name=
"REDIRECT_INPUT"
value=
"false"
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<configuration
name=
"test"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"opcua-cloning"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/test.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"MODULE_MODE"
value=
"false"
/>
<option
name=
"REDIRECT_INPUT"
value=
"false"
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<recent_temporary>
<recent_temporary>
<list>
<list>
<item
itemvalue=
"Python.opcua_receiver"
/>
<item
itemvalue=
"Python.opcua-transmitter (1)"
/>
<item
itemvalue=
"Python.test"
/>
<item
itemvalue=
"Python.opcua-transmitter"
/>
<item
itemvalue=
"Python.opcua-transmitter"
/>
</list>
</list>
</recent_temporary>
</recent_temporary>
...
...
opcua-transmitter.py
View file @
df6a7ede
...
@@ -24,11 +24,8 @@ class MyHandler(SubHandler):
...
@@ -24,11 +24,8 @@ class MyHandler(SubHandler):
async
def
process
(
self
)
->
None
:
async
def
process
(
self
)
->
None
:
try
:
try
:
while
True
:
while
True
:
# Get data in a queue.
[
node
,
value
,
data
]
=
self
.
_queue
.
get_nowait
()
[
node
,
value
,
data
]
=
self
.
_queue
.
get_nowait
()
path
=
await
node
.
get_path
(
as_string
=
True
)
datatype
=
type
(
value
)
datatype
=
type
(
value
)
packet
=
str
(
datatype
)
+
"&"
+
str
(
value
)
+
"&"
+
'ns='
+
str
(
node
.
nodeid
.
NamespaceIndex
)
+
";i="
+
str
(
node
.
nodeid
.
Identifier
)
packet
=
str
(
datatype
)
+
"&"
+
str
(
value
)
+
"&"
+
'ns='
+
str
(
node
.
nodeid
.
NamespaceIndex
)
+
";i="
+
str
(
node
.
nodeid
.
Identifier
)
UDPClientSocket
.
sendto
(
str
.
encode
(
packet
),
serverAddressPort
)
UDPClientSocket
.
sendto
(
str
.
encode
(
packet
),
serverAddressPort
)
...
...
opcua_receiver.py
View file @
df6a7ede
import
socket
import
socket
from
opcua
import
Client
,
ua
from
opcua
import
Client
,
ua
from
opcua_subscriber.opcua_subscribe
import
*
client
=
Client
(
"opc.tcp://DESKTOP-KMDNN6H
:53530/OPCUA/SimulationServer"
)
# client = Client("opc.tcp:2.2.2.7
:53530/OPCUA/SimulationServer")
client
.
connect
()
#
client.connect()
localIP
=
"2.2.2.5"
localIP
=
"2.2.2.5"
...
@@ -20,16 +21,18 @@ UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
...
@@ -20,16 +21,18 @@ UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Bind to address and ip
# Bind to address and ip
UDPServerSocket
.
bind
((
localIP
,
localPort
))
#
UDPServerSocket.bind((localIP, localPort))
print
(
"UDP server up and listening"
)
print
(
"UDP server up and listening"
)
opua
=
opcua_pack
()
sock
=
opua
.
connect
(
"opc.tcp://2.2.2.7:53530/OPCUA/SimulationServer"
)
opua
.
write_opcua_value
(
sock
,
3
,
1002
,
11
)
while
(
True
):
while
(
True
):
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
datatype
,
value
,
nodeid
=
message
.
decode
()
.
split
(
"&"
)
datatype
,
value
,
nodeid
=
message
.
decode
()
.
split
(
"&"
)
if
(
datatype
==
"<class 'float'>"
):
if
(
datatype
==
"<class 'float'>"
):
client
.
get_node
(
nodeid
)
.
set_value
(
float
(
value
)
)
opua
.
write_opcua_value
(
sock
,
3
,
1002
,
11
)
if
(
datatype
==
"<class 'int'>"
):
if
(
datatype
==
"<class 'int'>"
):
v
=
ua
.
DataValue
(
ua
.
Variant
(
int
(
value
),
ua
.
VariantType
.
Int32
))
opua
.
write_opcua_value
(
sock
,
3
,
1002
,
6
)
client
.
get_node
(
nodeid
)
.
set_value
(
v
)
\ No newline at end of file
\ No newline at end of file
opcua_subscriber/__pycache__/opcua_subscribe.cpython-39.pyc
0 → 100644
View file @
df6a7ede
File added
opcua_subscriber/opcua_subscribe.py
0 → 100644
View file @
df6a7ede
This diff is collapsed.
Click to expand it.
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