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
0
Merge Requests
0
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
Martin Manchev
osie
Commits
576677e1
Commit
576677e1
authored
Dec 11, 2023
by
Martin Manchev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix] Double Value Type
parent
9250011c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
opcua-to-http-gw/opcua-to-http-gw.py
opcua-to-http-gw/opcua-to-http-gw.py
+19
-4
No files found.
opcua-to-http-gw/opcua-to-http-gw.py
View file @
576677e1
...
...
@@ -47,13 +47,28 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
if
self
.
url
is
not
None
:
return
f"%s/%s"
%
(
self
.
url
,
ERP5_REQUEST_API
)
def
call
(
self
,
http_method
=
"POST"
,
**
data
):
params
=
urllib
.
parse
.
quote_plus
(
json
.
dumps
({
k
:
str
(
v
)
for
k
,
v
in
data
.
items
()}))
def
call
(
self
,
http_method
=
"POST"
,
**
data
):
serialized_data
=
{}
for
k
,
v
in
data
.
items
():
# Convert non-serializable types to string
if
not
isinstance
(
v
,
(
int
,
float
,
str
)):
v
=
str
(
v
)
elif
isinstance
(
v
,
float
):
# Ensure proper serialization of float values
if
v
.
is_integer
():
v
=
int
(
v
)
else
:
v
=
float
(
v
)
serialized_data
[
k
]
=
v
print
(
f"Key:
{
k
}\
n
Value:
{
v
}\
n
Value Type:
{
type
(
v
)
}\
n
\
n
"
)
params
=
urllib
.
parse
.
quote_plus
(
json
.
dumps
(
serialized_data
))
self
.
session
.
auth
=
(
erp5_username
,
erp5_password
)
if
http_method
==
"POST"
:
self
.
session
.
post
(
f"
{
self
.
uri
}
?data=
{
params
}
"
)
self
.
session
.
post
(
f"
{
self
.
uri
}
?data=
{
params
}
"
)
elif
http_method
==
"GET"
:
return
self
.
session
.
get
(
f"
{
self
.
uri
}
"
)
return
self
.
session
.
get
(
f"
{
self
.
uri
}
"
)
def
datachange_notification
(
self
,
node
,
val
,
data
):
self
.
call
(
node
=
node
,
val
=
val
,
data
=
data
)
...
...
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