Пример #1
0
    def create(self):
        recvNodes = std.vector('std::string')()
        strmNodes = std.vector('std::string')()
        for i in self.recvNodes:
            recvNodes.push_back(i)
        for i in self.strmNodes:
            strmNodes.push_back(i)
        dm = self.manager.deviceMgr()
        typ = self.manager.typeMgr().type('StreamControl')
        device = dm.createDevice(self.name, typ, 1)
        if device.get() is None:
            Utils.warning('Failed to create device "' + self.name + '"',
                          timestamp=1)
        partitions = PVSS.DpIDVector()
        errs = 0
        self.dps.clear()
        infos = []
        for i in xrange(self.numPartition):
            slice = '_Slice%02X' % (i, )
            p = PartitionInfo.create(self.manager, self.system + slice,
                                     self.system + 'Config' + slice)
            if p:
                partitions.push_back(p[0].id())
                infos.append(p)
            else:
                Utils.error("Errors occurred during device creation.",
                            timestamp=1)
                return

        self.set('Command', '')
        self.set('State', 'UNKNOWN')
        self.set('PartitionDesc', partitions)
        self.set('InUse', std.vector('int')(16, 0))
        self.set('ActivePartitions', std.vector('std::string')())
        slices = std.vector('std::string')(self.numRecvSlices, '')
        nodes = {}
        for i in xrange(self.numRecvSlices):
            node = self.recvNodes[i % len(self.recvNodes)]
            if not nodes.has_key(node): nodes[node] = 0
            nodes[node] = nodes[node] + 1
            slices[i] = node + ":%02d" % nodes[node]
        self.set('RecvNodes', recvNodes)
        self.set('RecvSlices', slices)
        slices.resize(self.numStreamSlices, '')
        nodes = {}
        for i in xrange(self.numStreamSlices):
            node = self.strmNodes[i % len(self.strmNodes)]
            if not nodes.has_key(node): nodes[node] = 0
            nodes[node] = nodes[node] + 1
            slices[i] = node + ":%02d" % nodes[node]
        self.set('StreamNodes', strmNodes)
        self.set('StreamSlices', slices)
        self.set('Setup.NumRecvNodes', len(self.recvNodes))
        self.set('Setup.NumRecvSlices',
                 self.numRecvSlices / len(self.recvNodes))
        self.set('Setup.NumStrmNodes', len(self.strmNodes))
        self.set('Setup.NumStrmSlices',
                 self.numStreamSlices / len(self.strmNodes))
        return self.write(prefix='StreamControl(' + self.name + '): ')
Пример #2
0
 def __init__(self, manager, partition):
     Utils.load('LHCbStatusDict')
     self.manager = manager
     self.partition = partition
     self.rdr = self.manager.devReader()
     self.typ = self.manager.typeMgr().type('_FwFsmObject')
     self.srv = Utils.gbl.LHCbStatus.Server()
     self.runInfo = {}
Пример #3
0
    def create(self):
        relayNodes = std.vector('std::string')()
        monNodes = std.vector('std::string')()
        for i in self.relayNodes:
            relayNodes.push_back(i)
        for i in self.monNodes:
            monNodes.push_back(i)
        dm = self.manager.deviceMgr()
        typ = self.manager.typeMgr().type('StreamControl')
        device = dm.createDevice(self.name, typ, 1)
        if device.get() is None:
            Utils.warning('Failed to create device "' + self.name + '"')
        partitions = PVSS.DpIDVector()
        errs = 0
        self.dps.clear()
        infos = []
        for i in xrange(self.numPartition):
            slice = '_Slice%02X' % (i, )
            p = PartitionInfo.create(self.manager, self.system + slice,
                                     self.system + slice + '_Config')
            if p:
                partitions.push_back(p[0].id())
                infos.append(p)
            else:
                Utils.error("Errors occurred during device creation.")
                return
        self.set('Command', 'unload')
        self.set('State', 'NOT_READY')
        self.set('PartitionDesc', partitions)
        self.set('InUse', std.vector('int')(16, 0))
        self.set('ActivePartitions', std.vector('std::string')())
        length = len(self.monNodes) * self.numStreams
        relay_slices = std.vector('std::string')(length, '')
        nodes = {}
        for i in xrange(length):
            node = self.relayNodes[i % len(self.relayNodes)]
            if not nodes.has_key(node): nodes[node] = 0
            nodes[node] = nodes[node] + 1
            relay_slices[i] = node + ":%02d" % nodes[node]
        self.set('RecvNodes', relayNodes)
        self.set('RecvSlices', relay_slices)

        length = len(self.monNodes) * self.numWorkersPerNode
        worker_slices = std.vector('std::string')(length, '')
        nodes = {}
        for i in xrange(length):
            node = self.monNodes[i % len(self.monNodes)]
            if not nodes.has_key(node): nodes[node] = 0
            nodes[node] = nodes[node] + 1
            worker_slices[i] = node + ":%02d" % nodes[node]
        self.set('StreamNodes', monNodes)
        self.set('StreamSlices', worker_slices)
        self.set('Setup.NumRecvNodes', len(self.relayNodes))
        self.set('Setup.NumRecvSlices', self.numStreams)
        self.set('Setup.NumStrmNodes', len(self.monNodes))
        self.set('Setup.NumStrmSlices', self.numWorkersPerNode)
        return self.write(prefix='StreamControl(' + self.name + '): ')
Пример #4
0
 def handleDevice(self):
     "Callback once per item in the device sensor list on datapoint change."
     import traceback
     cmd = ''
     try:
         nam = self.dp().name()
         cmd = self.dp().value().data()
         Utils.log('Command received:' + nam[:nam.find(':')] + ' -> ' + cmd,
                   timestamp=1)
         itms = cmd.split('/')
         if len(itms) == self.numParam:
             command = itms[0]
             sysName = itms[1]
             answer = ''
             for i in xrange(len(itms)):
                 if i > 0: answer = answer + '/' + itms[i]
             result = None
             if sysName == self.sysname:
                 try:
                     result = self.handle(itms, answer)
                     if result is None:
                         error('The command:"' + cmd +
                               '" failed. [Internal Error] ',
                               timestamp=1)
                         return self.makeAnswer('ERROR', answer)
                     return result
                 except Exception, X:
                     error('The command:"' + cmd + '" failed:' + str(X),
                           timestamp=1)
                     traceback.print_exc()
                     return self.makeAnswer('ERROR', answer)
                 except:
                     error('The command:"' + cmd +
                           '" failed (Unknown exception)',
                           timestamp=1)
                     traceback.print_exc()
                     return self.makeAnswer('ERROR', answer)
Пример #5
0
def fatal(message, timestamp=None, type=default_error_type):
    "Fatal printout to logger window. kill the program instance!"
    Utils.fatal(message, timestamp=timestamp)
    logger.fatal(type, message)
Пример #6
0
def fatal_banner(message, timestamp=None, type=default_error_type):
    "Sever error printout to logger window"
    Utils.fatal(132 * '*', timestamp=timestamp)
    Utils.fatal('** ', timestamp=timestamp)
    if isinstance(message, str):
        Utils.fatal('** ' + message, timestamp=timestamp)
    elif isinstance(message, list) or isinstance(message, tuple):
        for m in message:
            Utils.fatal('** ' + m, timestamp=timestamp)
    else:
        Utils.fatal('** ' + str(message), timestamp=timestamp)
    Utils.fatal('** ', timestamp=timestamp)
    Utils.fatal(132 * '*', timestamp=timestamp)
    if isinstance(message, str):
        logger.error(type, message)
    elif isinstance(message, list) or isinstance(message, tuple):
        for m in message:
            logger.error(type, m)
    else:
        logger.error(type, str(message))
Пример #7
0
def error(message, timestamp=None, type=default_error_type):
    "Sever error printout to logger window"
    Utils.error(message, timestamp=timestamp)
    logger.error(type, message)
Пример #8
0
def warning(message, timestamp=None, type=default_error_type):
    "Warning printout to PVSS logger window"
    Utils.warning(message, timestamp=timestamp)
    logger.warning(type, message)
Пример #9
0
def info(message, timestamp=None, type=default_error_type):
    "Informational printout to PVSS logger window"
    Utils.log(message, timestamp=timestamp)
    logger.info(type, message)