''' Created on Mar 3, 2014 @author: Hovanes Egiyan ''' from crate_module_channel import crate as crate, module as module, channel as channel class MPODCrate(crate): ''' Class for the crate entries in voltage database ''' crateDict = {} 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 = "MPOD" + str(self.crateid) self.Function = "BIAS/LV" self.rocid = self.crateid self.host = hostArg self.IP = None self.boardDict = {} if( nameArg in crate.crateDict.keys() ): print "Crate called {0} is already in the dictionary of crates, not adding".format(nameArg) return else: crate.crateDict.update( { self.name: self } ) return def AddBoard(self, className, slot=None, sn=None): ''' Add a voltage 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 def AddMPV_8016Board( self, slot=None, sn=None): ''' Add a low voltage board to this crate ''' newBoard = MPV_8016Board( 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 %s with new LV board" %slot self.boardDict.update( { slot : newBoard } ) return def AddEHS_205PBoard( self, slot=None, sn=None): ''' Add a low voltage board to this crate ''' newBoard = EHS_F205PBoard( 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 %s with new BIAS board" %slot self.boardDict.update( { slot : newBoard } ) return def incrementID(self): crate.classID += 1 return crate.classID class MPV_8008Board(module): ''' Class for the module entries in voltage database ''' numberOfChans = 8 channelType = "lv_chanid" moduleType = "MPV8008L" 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 = MPV_8008Board.moduleType if( self.SN == None ) : self.SN = MPV_8008Board.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, MPV_8008Board.numberOfChans ): newChannel = channel( self, iChan, MPV_8008Board.channelType ) self.channelMap.update( {iChan:newChannel} ) return class MPV_8016Board(module): ''' Class for the module entries in voltage database ''' numberOfChans = 8 channelType = "lv_chanid" moduleType = "MPV8016" 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 = MPV_8016Board.moduleType if( self.SN == None ) : self.SN = MPV_8016Board.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, MPV_8016Board.numberOfChans ): newChannel = channel( self, iChan, MPV_8016Board.channelType ) self.channelMap.update( {iChan:newChannel} ) return class MPV_8030Board(module): ''' Class for the module entries in voltage database ''' numberOfChans = 8 channelType = "lv_chanid" moduleType = "MPV8030L" 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 = MPV_8030Board.moduleType if( self.SN == None ) : self.SN = MPV_8030Board.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, MPV_8030Board.numberOfChans ): newChannel = channel( self, iChan, MPV_8030Board.channelType ) self.channelMap.update( {iChan:newChannel} ) return class EHS_F205PBoard(module): ''' Class for the module entries in voltage database ''' numberOfChans = 16 channelType = "bias_chanid" moduleType = "ISEG" 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 = EHS_F205PBoard.moduleType if( self.SN == None ) : self.SN = EHS_F205PBoard.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, EHS_F205PBoard.numberOfChans ): newChannel = channel( self, iChan, EHS_F205PBoard.channelType ) self.channelMap.update( {iChan:newChannel} ) return class MPODChannel(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