''' Created on Mar 3, 2014 @author: Hovanes Egiyan ''' from crate_module_channel import crate as crate, module as module, channel as channel class CaenCrate(crate): ''' Class for the crate entries in voltage database ''' CaenCrateDict = {} classID = 0 def __init__(self, areaArg=None, rackArg=None, locArg=None, nameArg=None, hostArg=None, snArg=None): ''' Initialize the crate class using input arguments ''' self.crateid = self.incrementID() self.name = nameArg self.area = areaArg self.rack = rackArg self.location = locArg if( self.name == None ) : self.name = self.area + "-" + self.rack + "-" + self.location self.SN = snArg if( self.SN == None ) : self.SN = "CAEN" + str(self.crateid) self.Function = "HV" self.rocid = self.crateid self.host = hostArg self.IP = None self.boardDict = {} if( nameArg in crate.crateDict.keys() ): print "Crate called %s is already in the dictionary of crates, not adding" return else: crate.crateDict.update( { self.name: self } ) return def AddBoard( self, className, slot=None, sn=None ): ''' Add a bias board to this crate ''' newBoard = className( self, slot, sn ) # If there is a board in this slot of this chassis, replace the board if( slot in self.boardDict.keys( ) ): print "Replacing existing board in slot {0} with new {1} board".format(slot, className.moduleType) self.boardDict.update( { slot : newBoard } ) return class A1550NBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 24 channelType = "hv_chanid" moduleType = "A1550N" classID = 0 def __init__(self, crateArg=None, slotArg=None, snArg=None ): ''' Initialize the module class using input arguments ''' self.moduleid = self.incrementID() self.crateid = crateArg.crateid self.slot = slotArg self.SN = snArg self.type = A1550NBoard.moduleType if( self.SN == None ) : self.SN = A1550NBoard.moduleType + str(self.moduleid) self.channelMap = {} # Map of all channels on this module # Loop over channels and add them to the module for iChan in range( 0, A1550NBoard.numberOfChans ): newChannel = channel( self, iChan, A1550NBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class A1550PBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 24 channelType = "hv_chanid" moduleType = "A1550P" classID = 0 def __init__(self, crateArg=None, slotArg=None, snArg=None ): ''' Initialize the module class using input arguments ''' self.moduleid = self.incrementID() self.crateid = crateArg.crateid self.slot = slotArg self.SN = snArg self.type = A1550PBoard.moduleType if( self.SN == None ) : self.SN = A1550PBoard.moduleType + str(self.moduleid) self.channelMap = {} # Map of all channels on this module # Loop over channels and add them to the module for iChan in range( 0, A1550PBoard.numberOfChans ): newChannel = channel( self, iChan, A1550PBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class A1535SNBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 24 channelType = "hv_chanid" moduleType = "A1535SN" classID = 0 def __init__(self, crateArg=None, slotArg=None, snArg=None ): ''' Initialize the module class using input arguments ''' self.moduleid = self.incrementID() self.crateid = crateArg.crateid self.slot = slotArg self.SN = snArg self.type = A1535SNBoard.moduleType if( self.SN == None ) : self.SN = A1535SNBoard.moduleType + str(self.moduleid) self.channelMap = {} # Map of all channels on this module # Loop over channels and add them to the module for iChan in range( 0, A1535SNBoard.numberOfChans ): newChannel = channel( self, iChan, A1535SNBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class A1535NBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 24 channelType = "hv_chanid" moduleType = "A1535N" classID = 0 def __init__(self, crateArg=None, slotArg=None, snArg=None ): ''' Initialize the module class using input arguments ''' self.moduleid = self.incrementID() self.crateid = crateArg.crateid self.slot = slotArg self.SN = snArg self.type = A1535NBoard.moduleType if( self.SN == None ) : self.SN = A1535NBoard.moduleType + str(self.moduleid) self.channelMap = {} # Map of all channels on this module # Loop over channels and add them to the module for iChan in range( 0, A1535NBoard.numberOfChans ): newChannel = channel( self, iChan, A1535NBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class A7236SNBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 24 channelType = "hv_chanid" moduleType = "A7236SN" classID = 0 def __init__(self, crateArg=None, slotArg=None, snArg=None ): ''' Initialize the module class using input arguments ''' self.moduleid = self.incrementID() self.crateid = crateArg.crateid self.slot = slotArg self.SN = snArg self.type = A7236SNBoard.moduleType if( self.SN == None ) : self.SN = A7236SNBoard.moduleType + str(self.moduleid) self.channelMap = {} # Map of all channels on this module # Loop over channels and add them to the module for iChan in range( 0, A7236SNBoard.numberOfChans ): newChannel = channel( self, iChan, A7236SNBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class CaenChannel(channel): ''' Class for the slot entries in voltage database ''' classID = 0 def __init__(self, moduleArg=None, channelArg=None, typeArg=None, enableArg=1 ): ''' Initialize the channel class using input arguments ''' self.chanid = self.incrementID() self.moduleid = moduleArg.moduleid self.name = None self.channel = channelArg self.system = None self.col_name = typeArg self.enable = enableArg return