Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyPCC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
PyPCC
Commits
bc2df747
Commit
bc2df747
authored
1 year ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
order OPCUA changes using priority queue
parent
2320ec09
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#84818
passed
1 year ago
Stage: run
Stage: image
Changes
2
Pipelines
8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pypcc/opcuaserv/opcuaserv.py
+7
-6
7 additions, 6 deletions
pypcc/opcuaserv/opcuaserv.py
pypcc/opcuaserv/yamlreader.py
+1
-1
1 addition, 1 deletion
pypcc/opcuaserv/yamlreader.py
with
8 additions
and
7 deletions
pypcc/opcuaserv/opcuaserv.py
+
7
−
6
View file @
bc2df747
...
@@ -6,7 +6,7 @@ import time
...
@@ -6,7 +6,7 @@ import time
#from opcua import ua, Server
#from opcua import ua, Server
from
asyncua.sync
import
ua
,
Server
from
asyncua.sync
import
ua
,
Server
from
datetime
import
datetime
;
from
datetime
import
datetime
;
from
queue
import
Queue
from
queue
import
Priority
Queue
import
logging
import
logging
#import Vars
#import Vars
#import HWconf
#import HWconf
...
@@ -22,17 +22,17 @@ class SubHandler(object):
...
@@ -22,17 +22,17 @@ class SubHandler(object):
Subscription Handler. To receive events from server for a subscription
Subscription Handler. To receive events from server for a subscription
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
self
.
datachange_queue
=
Queue
()
self
.
datachange_queue
=
Priority
Queue
()
def
check_datachange
(
self
,
timeout
):
def
check_datachange
(
self
,
timeout
):
while
True
:
while
True
:
try
:
try
:
node
,
val
=
self
.
datachange_queue
.
get
(
timeout
=
timeout
)
_
,
val
,
node
=
self
.
datachange_queue
.
get
(
timeout
=
timeout
)
except
:
except
:
break
break
nodeid
=
node
.
nodeid
.
Identifier
nodeid
=
node
.
nodeid
.
Identifier
vname
,
myvar
,
v
,
reader
,
opcvar
=
Vars_W
[
nodeid
]
vname
,
myvar
,
v
,
reader
,
opcvar
=
Vars_W
[
nodeid
]
# val=(val if isinstance(val, list) else [val] )
# val=(val if isinstance(val, list) else [val] )
logging
.
info
(
str
((
"
Datachange
callback
"
,
nodeid
,
vname
,
val
)))
logging
.
warn
(
str
((
"
Datachange
"
,
vname
,
val
[:
16
]
if
isinstance
(
val
,
list
)
else
val
)))
node
.
set_value
(
ua
.
DataValue
(
val
,
ua
.
StatusCode
(
ua
.
StatusCodes
.
GoodCompletesAsynchronously
)))
node
.
set_value
(
ua
.
DataValue
(
val
,
ua
.
StatusCode
(
ua
.
StatusCodes
.
GoodCompletesAsynchronously
)))
for
r
in
reader
:
for
r
in
reader
:
r
.
setvar
(
v
,
val
)
r
.
setvar
(
v
,
val
)
...
@@ -41,10 +41,11 @@ class SubHandler(object):
...
@@ -41,10 +41,11 @@ class SubHandler(object):
# NOTE: OPC variables can not be updates in the datachange_notification when using asyncua.sync!! So we put them in a queue.
# NOTE: OPC variables can not be updates in the datachange_notification when using asyncua.sync!! So we put them in a queue.
# print("Python: New data change event", node, val,data)
# print("Python: New data change event", node, val,data)
if
not
(
running
):
return
if
not
(
running
):
return
logging
.
info
(
str
((
"
Datachange callback
"
,
node
.
nodeid
.
Identifier
,
data
.
monitored_item
.
Value
.
StatusCode
)))
sourcetime
=
data
.
monitored_item
.
Value
.
SourceTimestamp
logging
.
info
(
str
((
"
Datachange callback
"
,
node
.
nodeid
.
Identifier
,
None
if
sourcetime
is
None
else
sourcetime
.
timestamp
(),
data
.
monitored_item
.
Value
.
StatusCode
)))
if
data
.
monitored_item
.
Value
.
StatusCode
!=
ua
.
StatusCode
(
ua
.
StatusCodes
.
Good
):
return
if
data
.
monitored_item
.
Value
.
StatusCode
!=
ua
.
StatusCode
(
ua
.
StatusCodes
.
Good
):
return
# logging.warning(str(("Python: New client data change event", node, val, data.monitored_item.Value.StatusCode)))
# logging.warning(str(("Python: New client data change event", node, val, data.monitored_item.Value.StatusCode)))
self
.
datachange_queue
.
put
(
[
node
,
val
]
)
self
.
datachange_queue
.
put
(
(
0
if
sourcetime
is
None
else
sourcetime
.
timestamp
(),
val
,
node
)
)
# myvar2.Value.Value=val
# myvar2.Value.Value=val
# myvar2.SourceTimestamp = datetime.utcnow()
# myvar2.SourceTimestamp = datetime.utcnow()
...
...
This diff is collapsed.
Click to expand it.
pypcc/opcuaserv/yamlreader.py
+
1
−
1
View file @
bc2df747
...
@@ -190,7 +190,7 @@ class yamlreader(yamlconfig):
...
@@ -190,7 +190,7 @@ class yamlreader(yamlconfig):
if
not
(
mask
):
continue
;
if
not
(
mask
):
continue
;
mask
=
Find
(
self
.
conf
[
'
variables
'
],
'
name
'
,
mask
)
mask
=
Find
(
self
.
conf
[
'
variables
'
],
'
name
'
,
mask
)
if
not
(
mask
):
continue
;
if
not
(
mask
):
continue
;
mask
=
mask
.
get
(
'
OPC
W
'
,
None
)
mask
=
mask
.
get
(
'
OPC
R
'
,
None
)
if
(
mask
==
None
):
continue
;
if
(
mask
==
None
):
continue
;
v
[
'
maskOPC
'
]
=
mask
v
[
'
maskOPC
'
]
=
mask
if
not
self
.
monitorvarid
is
None
:
if
not
self
.
monitorvarid
is
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment