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
057a82bf
Commit
057a82bf
authored
4 years ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
unb2 switch
parent
6a539712
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Pypcc2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
i2cserv/i2c_array.py
+1
-1
1 addition, 1 deletion
i2cserv/i2c_array.py
i2cserv/i2c_array2.py
+1
-8
1 addition, 8 deletions
i2cserv/i2c_array2.py
i2cserv/i2c_switch.py
+7
-0
7 additions, 0 deletions
i2cserv/i2c_switch.py
testUNB2.py
+6
-0
6 additions, 0 deletions
testUNB2.py
with
15 additions
and
9 deletions
i2cserv/i2c_array.py
+
1
−
1
View file @
057a82bf
...
@@ -144,7 +144,7 @@ class i2c_array(hwdev):
...
@@ -144,7 +144,7 @@ class i2c_array(hwdev):
self
.
conf
[
'
parentcls
'
].
i2csetget
(
*
args
,
**
kwargs
)
self
.
conf
[
'
parentcls
'
].
i2csetget
(
*
args
,
**
kwargs
)
def
SetSwitch
(
self
,
RCUi
):
def
SetSwitch
(
self
,
RCUi
):
self
.
conf
[
'
parentcls
'
].
Set
Channel
(
1
<<
self
.
RCU_Switch1
[
RCUi
]);
self
.
conf
[
'
parentcls
'
].
Set
SW1
(
self
.
RCU_Switch1
[
RCUi
]);
def
SetSwitchMask
(
self
,
mask
):
def
SetSwitchMask
(
self
,
mask
):
m
=
0
;
m
=
0
;
...
...
This diff is collapsed.
Click to expand it.
i2cserv/i2c_array2.py
+
1
−
8
View file @
057a82bf
...
@@ -3,15 +3,10 @@ from .i2c_array import i2c_array;
...
@@ -3,15 +3,10 @@ from .i2c_array import i2c_array;
from
.hwdev
import
hwdev
from
.hwdev
import
hwdev
class
i2c_array2
(
i2c_array
):
class
i2c_array2
(
i2c_array
):
def
__init__
(
self
,
config
):
def
__init__
(
self
,
config
):
hwdev
.
__init__
(
self
,
config
);
hwdev
.
__init__
(
self
,
config
);
# self.Qout=Qout;
# self.Qin=Qin;
# self.I2Ccallback=I2Ccallback
# self.SWcallback=Switchcallback
# self.previousHBA=np.zeros([number,3,32],dtype='int')
# Make array of switch states
# Make array of switch states
pars
=
config
[
'
parameters
'
];
pars
=
config
[
'
parameters
'
];
self
.
Nswitch
=
(
len
(
pars
)
+
1
)
//
2
;
self
.
Nswitch
=
(
len
(
pars
)
+
1
)
//
2
;
...
@@ -28,9 +23,7 @@ class i2c_array2(i2c_array):
...
@@ -28,9 +23,7 @@ class i2c_array2(i2c_array):
self
.
sw1
=
[
x
for
x
in
sw1
for
i
in
range
(
self
.
N
//
len
(
sw1
))]
self
.
sw1
=
[
x
for
x
in
sw1
for
i
in
range
(
self
.
N
//
len
(
sw1
))]
self
.
sw2
=
[
x
for
x
in
sw2
for
i
in
range
(
self
.
N
//
len
(
sw1
)
//
len
(
sw2
))]
*
len
(
sw1
)
self
.
sw2
=
[
x
for
x
in
sw2
for
i
in
range
(
self
.
N
//
len
(
sw1
)
//
len
(
sw2
))]
*
len
(
sw1
)
self
.
sw3
=
[
x
for
x
in
sw3
]
*
len
(
sw1
)
*
len
(
sw2
)
self
.
sw3
=
[
x
for
x
in
sw3
]
*
len
(
sw1
)
*
len
(
sw2
)
# self.devregs,RCU_storeReg=DevRegList(yaml)
logging
.
debug
(
str
((
"
Init
"
,
config
[
'
name
'
],
'
len=
'
,
self
.
N
,
'
Nswitch=
'
,
self
.
Nswitch
,
self
.
sw1
,
self
.
sw2
,
self
.
sw3
)))
logging
.
debug
(
str
((
"
Init
"
,
config
[
'
name
'
],
'
len=
'
,
self
.
N
,
'
Nswitch=
'
,
self
.
Nswitch
,
self
.
sw1
,
self
.
sw2
,
self
.
sw3
)))
# self.previous =np.zeros([self.N,RCU_storeReg],dtype='int')
def
SetSwitch
(
self
,
RCUi
):
def
SetSwitch
(
self
,
RCUi
):
#print("Set switch element",RCUi,'=',self.sw1[RCUi],self.sw2[RCUi],(self.sw3[RCUi] if len(self.sw3)<0 else 'x'))
#print("Set switch element",RCUi,'=',self.sw1[RCUi],self.sw2[RCUi],(self.sw3[RCUi] if len(self.sw3)<0 else 'x'))
...
...
This diff is collapsed.
Click to expand it.
i2cserv/i2c_switch.py
+
7
−
0
View file @
057a82bf
...
@@ -10,6 +10,13 @@ class i2c_switch(i2c):
...
@@ -10,6 +10,13 @@ class i2c_switch(i2c):
self
.
CurrentChannel
=
0
self
.
CurrentChannel
=
0
logging
.
info
(
"
i2c switch at address
"
+
str
(
self
.
SWaddr
))
logging
.
info
(
"
i2c switch at address
"
+
str
(
self
.
SWaddr
))
def
SetSW1
(
self
,
channelbit
):
channel
=
1
<<
(
channelbit
)
if
(
channel
)
==
self
.
CurrentChannel
:
return
True
;
logging
.
debug
(
"
SetChannel=%i
"
%
channelbit
)
self
.
CurrentChannel
=
channel
return
self
.
i2csetget
(
self
.
SWaddr
,[
channel
])
def
SetChannel
(
self
,
channel
):
def
SetChannel
(
self
,
channel
):
if
(
channel
)
==
self
.
CurrentChannel
:
return
True
;
if
(
channel
)
==
self
.
CurrentChannel
:
return
True
;
logging
.
debug
(
"
SetChannel=%i
"
%
channel
)
logging
.
debug
(
"
SetChannel=%i
"
%
channel
)
...
...
This diff is collapsed.
Click to expand it.
testUNB2.py
+
6
−
0
View file @
057a82bf
...
@@ -31,6 +31,12 @@ I2Cclients.append(RCU_I2C)
...
@@ -31,6 +31,12 @@ I2Cclients.append(RCU_I2C)
#Load yaml so that we know the variable names
#Load yaml so that we know the variable names
RCU_conf
=
yamlreader
.
yamlreader
(
RCU_I2C
,
yamlfile
=
name
)
RCU_conf
=
yamlreader
.
yamlreader
(
RCU_I2C
,
yamlfile
=
name
)
var1
=
RCU_conf
.
getvarid
(
'
UNB2_EEPROM_Unique_ID
'
);
N
=
2
;
mask
=
[
i
<
1
for
i
in
range
(
N
)];
print
(
"
mask=
"
,
mask
);
RCU_I2C
.
readvar
(
var1
,
mask
);
var1
=
RCU_conf
.
getvarid
(
'
UNB2_DC_DC_48V_12V_VIN
'
);
var1
=
RCU_conf
.
getvarid
(
'
UNB2_DC_DC_48V_12V_VIN
'
);
N
=
2
;
N
=
2
;
...
...
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