Skip to content
GitLab
Explore
Sign in
Register
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
1a3b5d3b
Commit
1a3b5d3b
authored
1 year ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
watchdog added (not working)
parent
5031533e
No related branches found
No related tags found
No related merge requests found
Pipeline
#55748
passed
1 year ago
Stage: run
Stage: image
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pypcc/opcuaserv/yamlreader.py
+12
-5
12 additions, 5 deletions
pypcc/opcuaserv/yamlreader.py
pypcc/pypcc.py
+18
-6
18 additions, 6 deletions
pypcc/pypcc.py
with
30 additions
and
11 deletions
pypcc/opcuaserv/yamlreader.py
+
12
−
5
View file @
1a3b5d3b
...
...
@@ -134,6 +134,8 @@ class yamlreader(yamlconfig):
self
.
statusid
=
self
.
getvarid
(
self
.
basename
+
"
_translator_busy
"
);
self
.
monitorvarid
=
self
.
getvarid
(
self
.
basename
+
"
_monitor_rate
"
);
self
.
statusOPC
=
None
self
.
lastSend
=
time
.
localtime
()
self
.
lastRecv
=
time
.
localtime
()
def
SetBusy
(
self
):
if
self
.
statusid
is
None
:
return
...
...
@@ -224,6 +226,7 @@ class yamlreader(yamlconfig):
mask
=
v
.
get
(
'
maskOPC
'
,
None
);
mask
=
mask
.
get_value
()
if
(
mask
!=
None
)
else
[];
self
.
SetBusy
()
self
.
lastSend
=
time
.
localtime
()
self
.
server
.
callmethod
(
id1
,
mask
)
def
CallInit
(
self
):
...
...
@@ -248,6 +251,7 @@ class yamlreader(yamlconfig):
logging
.
info
(
str
((
"
setvar
"
,
v
[
'
name
'
],
data2
,
mask
)));
if
data2
is
None
:
return
self
.
SetBusy
()
self
.
lastSend
=
time
.
localtime
()
self
.
server
.
setvar
(
id1
,
data2
,
mask
)
def
getvar
(
self
):
...
...
@@ -258,6 +262,7 @@ class yamlreader(yamlconfig):
# try:
item
=
self
.
server
.
readdata
()
if
item
is
None
:
break
;
self
.
lastRecv
=
time
.
localtime
()
id1
,
data
,
mask
=
item
;
logging
.
debug
(
str
((
"
**getvar
"
,
id1
,
data
,
mask
)));
if
len
(
data
)
==
0
:
continue
;
...
...
@@ -290,18 +295,20 @@ class yamlreader(yamlconfig):
# if v['name']=='UNB2_FPGA_POL_ERAM_IOUT': logging.warn(str((data3,data2,mask,var1.get_value(),[hex(d) for d in data])));
if
len
(
data3
)
==
1
:
data3
=
data3
[
0
];
var1
.
set_value
(
data3
,
datatype
);
def
watchdog
(
self
):
print
(
self
.
lastRecv
,
self
.
lastSend
,
self
.
lastSend
-
self
.
lastRecv
)
return
self
.
lastSend
-
self
.
lastRecv
;
def
Monitor
(
self
):
if
self
.
monitorvar
is
None
:
return
;
if
self
.
monitorvar
is
None
:
return
T1
=
self
.
monitorvar
.
get_value
()
*
10
;
if
T1
<=
0
:
return
;
if
T1
<=
0
:
return
self
.
timecount
+=
1
;
# if self.statusOPC is None: self.statusOPC=self.conf['variables'][self.statusid].get('OPCR')
while
self
.
timecount
>=
T1
:
if
self
.
GetBusy
():
logging
.
info
(
"
Busy, try monitor again in 1s
"
)
self
.
timecount
=
T1
-
10
;
#busy, so try again in 1s
return
;
return
if
not
(
self
.
statusOPC
is
None
)
and
self
.
statusOPC
.
get_value
():
return
;
if
self
.
server
.
QoutLength
()
>
0
:
return
;
v
=
self
.
conf
[
'
variables
'
][
self
.
monitorvarcnt
];
...
...
@@ -309,10 +316,10 @@ class yamlreader(yamlconfig):
mask
=
(
v
[
'
maskOPC
'
].
get_value
()
if
v
.
get
(
'
maskOPC
'
)
else
[])
# print("monitor",v['name'],mask)
# self.SetBusy()
self
.
lastSend
=
time
.
localtime
()
self
.
server
.
readvar
(
self
.
monitorvarcnt
,
mask
=
mask
)
self
.
monitorvarcnt
+=
1
;
if
self
.
monitorvarcnt
>=
len
(
self
.
conf
[
'
variables
'
]):
self
.
monitorvarcnt
=
0
;
self
.
timecount
=
0
;
# self.OPCset(self.statusid,[1],[])
This diff is collapsed.
Click to expand it.
pypcc/pypcc.py
+
18
−
6
View file @
1a3b5d3b
...
...
@@ -54,17 +54,18 @@ else:
#I2Cports=['UNB2','RCU','CLK']
#I2Cports=['RCU']
I2Cports
=
[
x
for
x
in
args
.
config
.
split
(
'
,
'
)]
thread
s
=
[]
I2C_proces
s
=
[]
I2Cclients
=
[]
for
name
in
I2Cports
:
RCU_I2C
=
i2client
.
i2client
(
name
=
name
)
if
not
(
args
.
simulator
):
thread1
=
i2cthread
.
start
(
*
RCU_I2C
.
GetInfo
(),
lock
=
lock
)
thread
s
.
append
(
thread1
)
thread1
=
i2cthread
.
start
(
*
RCU_I2C
.
GetInfo
(),
lock
=
lock
)
#Start a new I2C process
I2C_proces
s
.
append
(
thread1
)
I2Cclients
.
append
(
RCU_I2C
)
#Initialise OPCUA server and load variables
logging
.
info
(
"
Initialised OPC-UA Server
"
)
configs
=
[]
I2C_threads
=
[]
if
not
(
args
.
test
):
handler
=
opcuaserv
.
InitServer
(
port
=
args
.
port
)
logging
.
info
(
"
Load OPCUA variables & start i2c listing thread
"
)
...
...
@@ -79,7 +80,7 @@ if not(args.test):
thread2
=
threading
.
Thread
(
target
=
RCU_conf
.
getvar
);
#Thread on OPC-UA side of pipe
thread2
.
start
()
threads
.
append
(
thread2
)
I2C_
threads
.
append
(
thread2
)
time
.
sleep
(
1
)
logging
.
info
(
"
Start OPC-UA server
"
)
opcuaserv
.
start
()
...
...
@@ -97,7 +98,18 @@ try:
else
:
time
.
sleep
(
0.1
);
for
c
in
configs
:
c
.
Monitor
();
if
c
.
Monitor
():
continue
if
not
(
args
.
simulator
)
and
not
(
args
.
test
):
for
i
,
c
in
enumerate
(
configs
):
timeout
=
c
.
watchdog
()
if
timeout
>
60
:
logging
.
warning
(
"
Restarting I2C process!
"
)
I2C_process
[
i
].
terminate
()
RCU_I2C
=
I2Cclients
[
i
];
thread1
=
i2cthread
.
start
(
*
RCU_I2C
.
GetInfo
(),
lock
=
lock
)
#Start a new I2C process
I2C_process
[
i
]
=
thread1
configs
[
i
].
CallInit
()
finally
:
if
not
(
args
.
test
):
logging
.
info
(
"
Stop OPC-UA server
"
)
...
...
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