Skip to content
Snippets Groups Projects
Commit 057a82bf authored by Paulus Kruger's avatar Paulus Kruger
Browse files

unb2 switch

parent 6a539712
Branches
Tags
1 merge request!11Pypcc2
...@@ -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'].SetChannel(1<<self.RCU_Switch1[RCUi]); self.conf['parentcls'].SetSW1(self.RCU_Switch1[RCUi]);
def SetSwitchMask(self,mask): def SetSwitchMask(self,mask):
m=0; m=0;
......
...@@ -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'))
......
...@@ -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)
......
...@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment