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
957f25b1
Commit
957f25b1
authored
2 years ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
method call added to i2cdirect. User yaml config
parent
72228623
No related branches found
No related tags found
No related merge requests found
Pipeline
#46405
passed
2 years ago
Stage: image
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pypcc/i2cdirect.py
+99
-0
99 additions, 0 deletions
pypcc/i2cdirect.py
pypcc/yamlconfig.py
+6
-3
6 additions, 3 deletions
pypcc/yamlconfig.py
python_scripts/RCU_test1.py
+2
-2
2 additions, 2 deletions
python_scripts/RCU_test1.py
with
107 additions
and
5 deletions
py
thon_scripts
/i2cdirect.py
→
py
pcc
/i2cdirect.py
+
99
−
0
View file @
957f25b1
...
...
@@ -22,8 +22,10 @@ class i2cdirect():
self
.
conf
.
linkdevices
()
self
.
conf
.
loaddrivers
()
self
.
conf
.
linkdrivers
()
self
.
name
=
self
.
conf
.
conf
[
'
name
'
]
self
.
runmethod
(
self
.
name
+
"
_Init
"
)
def
GetVal
(
self
,
name
,
N
=
1
):
def
GetVal
(
self
,
name
):
varid
=
self
.
conf
.
getvarid
(
name
);
if
varid
is
None
:
logging
.
error
(
"
Variable
"
+
name
+
"
not found
"
)
...
...
@@ -34,6 +36,7 @@ class i2cdirect():
data
=
data
[
0
].
data
return
byte2var
(
var1
,
data
),
var1
def
SetVal
(
self
,
name
,
data
):
varid
=
self
.
conf
.
getvarid
(
name
);
if
varid
is
None
:
...
...
@@ -45,7 +48,7 @@ class i2cdirect():
return
drv
.
OPCUASetVariable
(
varid
,
var1
,
data2
,[])
def
SetRegister
(
self
,
regname
,
value
):
methodid
=
self
.
conf
.
getmethodid
(
"
RECVTR
_Init
"
);
methodid
=
self
.
conf
.
getmethodid
(
self
.
name
+
"
_Init
"
);
var1
=
self
.
conf
.
getmethod
(
methodid
)
drv
=
var1
.
get
(
'
drivercls
'
);
v1
=
self
.
conf
.
getdevreg
(
regname
)
...
...
@@ -55,3 +58,42 @@ class i2cdirect():
elif
drv2
:
drv2
.
Setdevreg
(
v1
,
value
,
mask
)
else
:
logging
.
warn
(
"
Driver not specified for instruction
"
+
key
)
def
runmethod
(
self
,
methodname
):
logging
.
info
(
"
Run method:
"
+
methodname
)
methodid
=
self
.
conf
.
getmethodid
(
"
methodname
"
);
var1
=
self
.
conf
.
getmethod
(
methodid
)
drv
=
var1
.
get
(
'
drivercls
'
);
for
inst
in
var1
[
'
instructions
'
]:
for
key
,
value
in
inst
.
items
():
if
not
(
isinstance
(
value
,
list
)):
value
=
[
value
]
logging
.
info
(
str
((
"
Run instruction
"
,
key
,
value
)));
if
(
key
==
'
WAIT
'
):
time
.
sleep
(
value
[
0
]
/
1000.
)
continue
;
v1
=
self
.
conf
.
getvarid
(
key
)
if
not
(
v1
is
None
):
if
value
[
0
]
==
'
Update
'
:
self
.
GetVal
(
key
)
else
:
self
.
SetVal
(
key
,
value
)
continue
;
v1
=
self
.
conf
.
getmethodid
(
key
)
if
v1
:
self
.
runmethod
(
key
)
continue
;
v1
=
self
.
conf
.
getdevreg
(
key
)
if
v1
:
mask
=
[]
drv2
=
v1
.
get
(
'
drivercls
'
)
if
value
[
0
]
==
'
Update
'
:
if
drv
:
drv
.
Getdevreg
(
v1
,
mask
)
elif
drv2
:
drv2
.
Getdevreg
(
v1
,
mask
)
else
:
logging
.
warn
(
"
Driver not specified for instruction
"
+
key
)
else
:
if
drv
:
drv
.
Setdevreg
(
v1
,
value
,
mask
)
elif
drv2
:
drv2
.
Setdevreg
(
v1
,
value
,
mask
)
else
:
logging
.
warn
(
"
Driver not specified for instruction
"
+
key
)
continue
;
logging
.
warn
(
"
Unknown instruction
"
+
key
)
return
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pypcc/yamlconfig.py
+
6
−
3
View file @
957f25b1
...
...
@@ -29,6 +29,9 @@ def str2int(x):
class
yamlconfig
():
def
__init__
(
self
,
yamlfile
=
'
RCU
'
):
if
yamlfile
.
split
(
'
.
'
)[
-
1
]
==
'
yaml
'
:
self
.
conf
=
yaml
.
load
(
open
(
yamlfile
),
Loader
=
yaml
.
FullLoader
)
else
:
pkg
=
importlib_resources
.
files
(
"
pypcc
"
)
pkg_data_file
=
pkg
/
"
config
"
/
(
yamlfile
+
'
.yaml
'
)
self
.
conf
=
yaml
.
load
(
pkg_data_file
.
open
(),
Loader
=
yaml
.
FullLoader
)
...
...
This diff is collapsed.
Click to expand it.
python_scripts/RCU_test1.py
+
2
−
2
View file @
957f25b1
from
i2cdirect
import
i2cdirect
from
pypcc.
i2cdirect
import
i2cdirect
from
time
import
sleep
import
logging
logging
.
basicConfig
(
level
=
"
ERROR
"
,
format
=
'
%(asctime)s [%(levelname)-8s,%(filename)-20s:%(lineno)-3d] %(message)s
'
)
#logging.basicConfig(level="DEBUG",format='%(asctime)s [%(levelname)-8s,%(filename)-20s:%(lineno)-3d] %(message)s')
d1
=
i2cdirect
(
'
RECVTR_LB_TEST
'
)
d1
=
i2cdirect
(
'
RECVTR_LB_TEST
.yaml
'
)
def
RCU_off
(
d1
):
logging
.
warning
(
"
Switch RCU Power off
"
);
...
...
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