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
735a8260
Commit
735a8260
authored
Mar 03, 2023
by
yogesh.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
df04e11d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
40 deletions
+79
-40
.idea/workspace.xml
.idea/workspace.xml
+30
-8
asyncua server.py
asyncua server.py
+0
-32
asyncua_server.py
asyncua_server.py
+44
-0
opcua_receiver.py
opcua_receiver.py
+5
-0
No files found.
.idea/workspace.xml
View file @
735a8260
...
@@ -41,8 +41,8 @@
...
@@ -41,8 +41,8 @@
<recent
name=
"D:\opcua-cloning"
/>
<recent
name=
"D:\opcua-cloning"
/>
</key>
</key>
</component>
</component>
<component
name=
"RunManager"
selected=
"Python.
opcua-transmitt
er (1)"
>
<component
name=
"RunManager"
selected=
"Python.
asyncua_serv
er (1)"
>
<configuration
name=
"
main"
type=
"PythonConfigurationType"
factoryName=
"Python
"
nameIsGenerated=
"true"
>
<configuration
name=
"
asyncua_server (1)"
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=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/
main
.py"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/
asyncua_server
.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
<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"
>
<configuration
name=
"
asyncua_server
"
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=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"
$PROJECT_DIR$/opcua-transmitt
er.py"
/>
<option
name=
"SCRIPT_NAME"
value=
"
D:\opcua-cloning\asyncua_serv
er.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
<option
name=
"INPUT_FILE"
value=
""
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
<method
v=
"2"
/>
</configuration>
</configuration>
<configuration
name=
"
opcua-transmitter"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true
"
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=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
...
@@ -96,7 +96,28 @@
...
@@ -96,7 +96,28 @@
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"SCRIPT_NAME"
value=
"D:\opcua-cloning\opcua-transmitter.py"
/>
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/main.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 (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=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
...
@@ -149,10 +170,11 @@
...
@@ -149,10 +170,11 @@
</configuration>
</configuration>
<recent_temporary>
<recent_temporary>
<list>
<list>
<item
itemvalue=
"Python.asyncua_server (1)"
/>
<item
itemvalue=
"Python.asyncua_server"
/>
<item
itemvalue=
"Python.opcua-transmitter (1)"
/>
<item
itemvalue=
"Python.opcua-transmitter (1)"
/>
<item
itemvalue=
"Python.opcua_receiver"
/>
<item
itemvalue=
"Python.opcua_receiver"
/>
<item
itemvalue=
"Python.test"
/>
<item
itemvalue=
"Python.test"
/>
<item
itemvalue=
"Python.opcua-transmitter"
/>
</list>
</list>
</recent_temporary>
</recent_temporary>
</component>
</component>
...
...
asyncua server.py
deleted
100644 → 0
View file @
df04e11d
import
asyncio
from
asyncua
import
ua
,
Server
import
random
async
def
main
():
# create a server
server
=
Server
()
await
server
.
init
()
# set endpoint information
url
=
"opc.tcp://localhost:4840/myopc/free"
server
.
set_endpoint
(
url
)
# create a new address space
uri
=
"http://klopc.com"
idx
=
await
server
.
register_namespace
(
uri
)
obj
=
await
server
.
nodes
.
objects
.
add_object
(
idx
,
"MyObject"
)
var
=
await
obj
.
add_variable
(
idx
,
"MyVariable"
,
0
)
await
var
.
set_writable
()
# start the server
await
server
.
start
()
try
:
# keep the server running until interrupted
while
True
:
await
var
.
write_value
(
random
.
randint
(
1
,
100
))
await
asyncio
.
sleep
(
1
)
finally
:
# stop the server
await
server
.
stop
()
if
__name__
==
"__main__"
:
asyncio
.
run
(
main
())
asyncua_server.py
0 → 100644
View file @
735a8260
import
asyncio
from
asyncua
import
ua
,
Server
import
random
class
asyncua_server
():
def
__init__
(
self
):
self
.
server
=
None
self
.
idx
=
None
async
def
add_object
(
self
,
obj
):
return
await
self
.
server
.
nodes
.
objects
.
add_object
(
self
.
idx
,
obj
)
async
def
add_variable
(
self
,
obj
,
var
):
var
=
await
obj
.
add_variable
(
self
.
idx
,
var
,
11
)
await
var
.
set_writable
()
return
var
async
def
start_server
(
self
,
url
,
uri
):
# create a server
self
.
server
=
Server
()
await
self
.
server
.
init
()
# set endpoint information
url
=
url
self
.
server
.
set_endpoint
(
url
)
# create a new address space
uri
=
uri
self
.
idx
=
await
self
.
server
.
register_namespace
(
uri
)
# obj = await self.add_object(self.idx,"MyObject")
# var = await self.add_variable(obj,self.idx,"Myvar")
# start the server
await
self
.
server
.
start
()
try
:
# keep the server running until interrupted
while
True
:
#await var.write_value(random.randint(1, 100))
await
asyncio
.
sleep
(
1
)
finally
:
# stop the server
await
self
.
server
.
stop
()
if
__name__
==
"__main__"
:
asua
=
asyncua_server
()
asyncio
.
run
(
asua
.
start_server
())
opcua_receiver.py
View file @
735a8260
import
socket
import
socket
from
opcua
import
Client
,
ua
from
opcua
import
Client
,
ua
from
opcua_subscriber.opcua_subscribe
import
*
from
opcua_subscriber.opcua_subscribe
import
*
from
asyncua_server
import
asyncua_server
# client = Client("opc.tcp:2.2.2.7:53530/OPCUA/SimulationServer")
# client = Client("opc.tcp:2.2.2.7:53530/OPCUA/SimulationServer")
# client.connect()
# client.connect()
...
@@ -27,6 +28,10 @@ print("UDP server up and listening")
...
@@ -27,6 +28,10 @@ print("UDP server up and listening")
opua
=
opcua_pack
()
opua
=
opcua_pack
()
sock
=
opua
.
connect
(
"opc.tcp://2.2.2.5:53530/OPCUA/SimulationServer"
)
sock
=
opua
.
connect
(
"opc.tcp://2.2.2.5:53530/OPCUA/SimulationServer"
)
as_server
=
asyncua_server
()
as_server
.
start_server
(
"opc.tcp://localhost:4840/myopc/free"
,
"http://klopc.com"
)
as_server
.
add_object
(
"Myobj_"
)
while
(
True
):
while
(
True
):
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
bytesAddressPair
=
UDPServerSocket
.
recvfrom
(
bufferSize
)
message
=
bytesAddressPair
[
0
]
message
=
bytesAddressPair
[
0
]
...
...
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