Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
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
Nikola Balog
opcua-asyncio
Commits
b5f9feee
Commit
b5f9feee
authored
Oct 24, 2015
by
ORD
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44 from alkor/refactor-server-faults
Refactor server-side service faults
parents
97d962d2
caf7f9df
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
opcua/internal_server.py
opcua/internal_server.py
+1
-2
opcua/uaprocessor.py
opcua/uaprocessor.py
+13
-10
opcua/utils.py
opcua/utils.py
+5
-0
No files found.
opcua/internal_server.py
View file @
b5f9feee
...
...
@@ -167,8 +167,7 @@ class InternalSession(object):
self
.
logger
.
info
(
"activate session"
)
result
=
ua
.
ActivateSessionResult
()
if
not
self
.
state
==
SessionState
.
Created
:
result
.
Results
=
[
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadSessionIdInvalid
)]
return
result
raise
utils
.
ServiceError
(
ua
.
StatusCodes
.
BadSessionIdInvalid
)
result
.
ServerNonce
=
self
.
nonce
for
_
in
params
.
ClientSoftwareCertificates
:
result
.
Results
.
append
(
ua
.
StatusCode
())
...
...
opcua/uaprocessor.py
View file @
b5f9feee
...
...
@@ -108,7 +108,17 @@ class UAProcessor(object):
def
process_message
(
self
,
algohdr
,
seqhdr
,
body
):
typeid
=
ua
.
NodeId
.
from_binary
(
body
)
requesthdr
=
ua
.
RequestHeader
.
from_binary
(
body
)
try
:
return
self
.
_process_message
(
typeid
,
requesthdr
,
algohdr
,
seqhdr
,
body
)
except
utils
.
ServiceError
as
e
:
status
=
ua
.
StatusCode
(
e
.
code
)
response
=
ua
.
ServiceFault
()
response
.
ResponseHeader
.
ServiceResult
=
status
self
.
logger
.
info
(
"sending service fault response: %s (%s)"
,
status
.
doc
,
status
.
name
)
self
.
send_response
(
requesthdr
.
RequestHandle
,
algohdr
,
seqhdr
,
response
)
return
True
def
_process_message
(
self
,
typeid
,
requesthdr
,
algohdr
,
seqhdr
,
body
):
if
typeid
==
ua
.
NodeId
(
ua
.
ObjectIds
.
CreateSessionRequest_Encoding_DefaultBinary
):
self
.
logger
.
info
(
"Create session request"
)
params
=
ua
.
CreateSessionParameters
.
from_binary
(
body
)
...
...
@@ -137,13 +147,8 @@ class UAProcessor(object):
params
=
ua
.
ActivateSessionParameters
.
from_binary
(
body
)
if
not
self
.
session
:
#result = ua.ActivateSessionResult()
# result.Results.append(ua.StatusCode(ua.StatusCodes.BadSessionIdInvalid))
response
=
ua
.
ServiceFault
()
response
.
ResponseHeader
.
ServiceResult
=
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadSessionIdInvalid
)
self
.
logger
.
info
(
"request to activate none existing session, sending service fault response"
)
self
.
send_response
(
requesthdr
.
RequestHandle
,
algohdr
,
seqhdr
,
response
)
return
True
self
.
logger
.
info
(
"request to activate non-existing session"
)
raise
utils
.
ServiceError
(
ua
.
StatusCodes
.
BadSessionIdInvalid
)
result
=
self
.
session
.
activate_session
(
params
)
...
...
@@ -344,9 +349,7 @@ class UAProcessor(object):
else
:
self
.
logger
.
warning
(
"Uknown message received %s"
,
typeid
)
sf
=
ua
.
ServiceFault
()
sf
.
ResponseHeader
.
ServiceResult
=
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadNotImplemented
)
self
.
send_response
(
requesthdr
.
RequestHandle
,
algohdr
,
seqhdr
,
sf
)
raise
utils
.
ServiceError
(
ua
.
StatusCodes
.
BadNotImplemented
)
return
True
...
...
opcua/utils.py
View file @
b5f9feee
...
...
@@ -10,6 +10,11 @@ except ImportError:
import
trollius
as
asyncio
from
trollius
import
From
class
ServiceError
(
Exception
):
def
__init__
(
self
,
code
):
super
(
ServiceError
,
self
).
__init__
(
'UA service error'
)
self
.
code
=
code
class
NotEnoughData
(
Exception
):
pass
...
...
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