Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
osie
Commits
8dfd7cfe
Commit
8dfd7cfe
authored
Aug 01, 2023
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use erp5_url rather than IP / port.
parent
ec62bf62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
opcua-to-http-gw/opcua-to-http-gw.py
opcua-to-http-gw/opcua-to-http-gw.py
+8
-10
No files found.
opcua-to-http-gw/opcua-to-http-gw.py
View file @
8dfd7cfe
...
...
@@ -22,25 +22,23 @@ a = parser.add_argument
a
(
'--ip'
,
help
=
'The IP address on which the OPCUA Server runs'
,
default
=
"127.0.0.1"
)
a
(
'--port'
,
help
=
'The port on which the OPCUA Server runs'
,
default
=
"4840"
)
a
(
'--xml'
,
help
=
'Path of XML to configure Server. See asyncua doc for more details.'
,
default
=
None
)
a
(
'--erp5-ip'
,
help
=
'IP of ERP5 instance to which data shall be send.'
,
default
=
None
)
a
(
'--erp5-port'
,
help
=
'Port of ERP5 instance to which data shall be send.'
,
default
=
None
)
a
(
'--erp5-url'
,
help
=
'URL of ERP5 instance to which data shall be send.'
,
default
=
None
)
args
=
parser
.
parse_args
()
ip
=
args
.
ip
port
=
args
.
port
xml
=
args
.
xml
erp5_ip
=
args
.
erp5_ip
erp5_port
=
args
.
erp5_port
erp5_url
=
args
.
erp5_url
ERP5_REQUEST_API
=
"ERP5Site_handleOPCUARequest"
@
dataclass
(
frozen
=
True
)
class
ERP5Handler
(
asyncua
.
common
.
subscription
.
SubHandler
):
ip
:
str
port
:
str
url
:
str
session
:
requests
.
Session
=
field
(
default_factory
=
requests
.
Session
)
@
property
def
uri
(
self
):
return
f"http://
{
self
.
ip
}
:
{
self
.
port
}
/erp5/%s"
%
ERP5_REQUEST_API
if
self
.
url
is
not
None
:
return
f"%s/%s"
%
(
self
.
url
,
ERP5_REQUEST_API
)
def
call
(
self
,
**
data
):
params
=
urllib
.
parse
.
quote_plus
(
json
.
dumps
({
k
:
str
(
v
)
for
k
,
v
in
data
.
items
()}))
...
...
@@ -53,8 +51,8 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
self
.
call
(
event
=
event
)
erp5_handler
=
None
if
erp5_
ip
is
not
None
and
erp5_port
is
not
None
:
erp5_handler
=
ERP5Handler
(
erp5_
ip
,
erp5_port
)
if
erp5_
url
is
not
None
:
erp5_handler
=
ERP5Handler
(
erp5_
url
)
class
InternalSession
(
asyncua
.
server
.
internal_session
.
InternalSession
):
async
def
read
(
self
,
params
):
...
...
@@ -94,7 +92,7 @@ async def main():
while
True
:
await
asyncio
.
sleep
(
1
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logging
.
basicConfig
(
level
=
logging
.
ERROR
)
asyncio
.
run
(
main
(),
debug
=
True
)
if
__name__
==
'__main__'
:
...
...
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