Example #1
0
 def _UpdateInfoCont(self):
     """
     Called every 100 ms to update the info container
     """
     nextLaunchTime = self.pin.GetNextLaunchTime()
     if nextLaunchTime is not None and nextLaunchTime > blue.os.GetWallclockTime(
     ):
         nextLaunchTime = util.FmtTime(nextLaunchTime -
                                       blue.os.GetWallclockTime())
     else:
         nextLaunchTime = localization.GetByLabel('UI/Common/Now')
     self.launchTimeTxt.SetSubtext(nextLaunchTime)
     self.storageGauge.SetValue(
         float(self.pin.capacityUsed) / self.pin.GetCapacity())
     self.storageGauge.SetSubText(
         localization.GetByLabel('UI/PI/Common/StorageUsed',
                                 capacityUsed=self.pin.capacityUsed,
                                 capacityMax=self.pin.GetCapacity()))
     colony = sm.GetService('planetUI').GetCurrentPlanet().GetColony(
         self.pin.ownerID)
     if colony is None or colony.colonyData is None:
         raise RuntimeError(
             'Unable to find colony to update info container')
     cpuUsage = colony.colonyData.GetColonyCpuUsage()
     cpuSupply = colony.colonyData.GetColonyCpuSupply()
     if cpuSupply > 0:
         percentage = min(1.0, float(cpuUsage) / cpuSupply)
     else:
         percentage = 0.0
     self.cpuGauge.SetValue(percentage)
     self.cpuGauge.SetText(
         localization.GetByLabel('UI/PI/Common/CPUPercentage',
                                 usedPercentage=percentage * 100))
     self.cpuGauge.SetSubText(
         localization.GetByLabel('UI/PI/Common/CPUUsed',
                                 teraFlopsUsed=int(cpuUsage),
                                 teraFlopsMax=cpuSupply))
     powerUsage = colony.colonyData.GetColonyPowerUsage()
     powerSupply = colony.colonyData.GetColonyPowerSupply()
     if powerSupply > 0:
         percentage = min(1.0, float(powerUsage) / powerSupply)
     else:
         percentage = 0.0
     self.powerGauge.SetValue(percentage)
     self.powerGauge.SetText(
         localization.GetByLabel('UI/PI/Common/PowerPercentage',
                                 usedPercentage=percentage * 100))
     self.powerGauge.SetSubText(
         localization.GetByLabel('UI/PI/Common/PowerUsed',
                                 megaWattsUsed=int(powerUsage),
                                 megaWattsMax=powerSupply))
     self.upgradeLevelGauge.SetValue(self._GetUpgradeLevelGaugeValue())
     if self.pin.lastRunTime is None or self.pin.lastRunTime <= blue.os.GetWallclockTime(
     ):
         self.cooldownTimer.SetSubtext(
             localization.GetByLabel('UI/Common/Now'))
     else:
         self.cooldownTimer.SetSubtext(
             util.FmtTime(self.pin.lastRunTime -
                          blue.os.GetWallclockTime()))
Example #2
0
 def _UpdateInfoCont(self):
     if self.pin.depositType is not None and self.pin.depositQtyPerCycle > 0:
         timeToDepletion = self.pin.GetTimeToDepletion()
         totalTimeLeft = timeToDepletion
         self.timeToDeplTxt.SetCaption(
             localization.GetByLabel('UI/PI/Common/TimeToDepletion'))
         if totalTimeLeft < DAY:
             totalTimeLeft = util.FmtTime(float(totalTimeLeft))
         else:
             totalTimeLeft = util.FmtTimeInterval(long(totalTimeLeft),
                                                  breakAt='hour')
         deposName = cfg.invtypes.Get(self.pin.depositType).name
         if self.pin.activityState < planet.STATE_IDLE:
             currCycle = 0
             currCycleProportion = 0.0
             cycleTime = 0
         else:
             currCycle = blue.os.GetWallclockTime() - self.pin.lastRunTime
             currCycleProportion = currCycle / float(
                 self.pin.GetCycleTime())
             cycleTime = self.pin.GetCycleTime()
     else:
         currCycle = 0
         totalTimeLeft = util.FmtTime(0)
         currCycleProportion = 0.0
         cycleTime = 0
         deposName = localization.GetByLabel(
             'UI/PI/Common/NothingExtracted')
     self.currDepositTxt.SetIcon(self.pin.depositType)
     self.currDepositTxt.SetSubtext(deposName)
     self.depositsLeftTxt.SetSubtext(
         localization.GetByLabel('UI/PI/Common/UnitsAmount',
                                 amount=self.pin.depositQtyRemaining))
     if self.pin.IsInEditMode():
         self.currCycleGauge.SetSubText(
             localization.GetByLabel('UI/PI/Common/InactiveEditMode'))
         self.timeToDeplTxt.SetSubtext(
             localization.GetByLabel('UI/PI/Common/InactiveEditMode'))
     else:
         self.currCycleGauge.SetValueInstantly(currCycleProportion)
         self.timeToDeplTxt.SetSubtext(totalTimeLeft)
         self.currCycleGauge.SetSubText(
             localization.GetByLabel('UI/PI/Common/CycleTimeElapsed',
                                     currTime=long(currCycle),
                                     totalTime=long(cycleTime)))
     self.amountPerCycleTxt.SetSubtext(
         localization.GetByLabel('UI/PI/Common/UnitsAmount',
                                 amount=self.pin.depositQtyPerCycle))
     attr = cfg.dgmattribs.GetIfExists(const.attributeLogisticalCapacity)
     self.amountPerHourTxt.SetSubtext(
         sm.GetService('info').GetFormatAndValue(
             attr, self.pin.GetOutputVolumePerHour()))
Example #3
0
def GetPinCycleInfo(pin, cycleTime = None):
    if cycleTime is None:
        cycleTime = pin.GetCycleTime()
    if pin.IsActive() and not pin.IsInEditMode():
        currCycle = min(blue.os.GetWallclockTime() - pin.lastRunTime, cycleTime)
        currCycleProportion = currCycle / float(cycleTime)
    else:
        currCycle = currCycleProportion = 0
    if cycleTime is None:
        cycleText = localization.GetByLabel('UI/PI/Common/InactivePin')
    else:
        cycleText = '%s / %s' % (util.FmtTime(currCycle), util.FmtTime(cycleTime))
    return (cycleText, currCycleProportion)
Example #4
0
 def UpdateFpsLabel(self):
     while not self.destroyed:
         self.fpsLabel.text = '%6.2f' % self.fpsStat.value
         blue.synchro.SleepWallclock(500)
         if self.collectingFpsStats:
             deltaTime = blue.os.GetWallclockTime() - self.collectingFpsStats
             self.timeLabel.text = '%s' % util.FmtTime(deltaTime)
Example #5
0
 def UpdateFpsLabel(self):
     fpsSvc = sm.GetService('fpsMonitorSvc')
     while not self.destroyed:
         self.fpsLabel.text = '%6.2f' % fpsSvc.GetFPS()
         blue.synchro.SleepWallclock(500)
         if fpsSvc.IsCollectingStats():
             self.timeLabel.text = '%s' % util.FmtTime(
                 fpsSvc.GetStatsCollectionTime())
Example #6
0
    def PopulateScroll(self, *args):
        scrolllist = []
        for ct in base.outstandingCallTimers:
            method = ct[0]
            t = ct[1]
            label = '%s<t>%s<t>%s' % (method, util.FmtDate(t, 'nl'), util.FmtTime(blue.os.GetWallclockTimeNow() - t))
            scrolllist.append(ScrollEntryNode(decoClass=SE_GenericCore, label=label))

        self.scroll.Load(contentList=scrolllist, headers=['method', 'time', 'dt'])
Example #7
0
    def UpdateOutstanding(self):
        wnd = self.GetWnd()
        if not wnd or wnd.destroyed:
            return
        scrolllist = []
        for ct in base.outstandingCallTimers:
            method = ct[0]
            t = ct[1]
            label = '%s<t>%s<t>%s' % (method, util.FmtDate(
                t, 'nl'), util.FmtTime(blue.os.GetWallclockTimeNow() - t))
            scrolllist.append(
                uicls.ScrollEntryNode(decoClass=uicls.SE_Generic, label=label))

        wnd.sr.scroll.Load(contentList=scrolllist,
                           headers=['method', 'time', 'dt'])
Example #8
0
    def __LongCallTimer(self):
        longWarningSecs = prefs.GetValue('longOutstandingCallWarningSeconds',
                                         DEFAULTLONGWAITWARNINGSECS)
        sleepSecs = 60
        if longWarningSecs < sleepSecs:
            sleepSecs = longWarningSecs
        self.LogInfo('__LongCallTimer reporting warnings after',
                     longWarningSecs, 'seconds and checking every', sleepSecs,
                     'seconds')

        def ShouldWarn(method):
            for w in LONGWAITWARNINGMETHODS:
                if w in repr(method):
                    return True

            return False

        while self.state == service.SERVICE_RUNNING:
            if sm.GetService('machoNet').GetGlobalConfig().get(
                    'disableLongCallWarning'):
                self.LogWarn('__LongCallTimer should not be running! Exiting.')
                return
            blue.pyos.synchro.SleepWallclock(sleepSecs * 1000)
            try:
                maxDiff = 0
                for ct in base.outstandingCallTimers:
                    method = ct[0]
                    t = ct[1]
                    diff = blue.os.GetWallclockTimeNow() - t
                    if diff > maxDiff and ShouldWarn(method):
                        maxDiff = diff
                    if diff > 60 * const.SEC:
                        self.LogWarn('Have waited', util.FmtTime(diff), 'for',
                                     method)

                if maxDiff > longWarningSecs * const.SEC and self.lastLongCallTimestamp < blue.os.GetWallclockTimeNow(
                ) - longWarningSecs * const.SEC:
                    modalWnd = uicore.registry.GetModalWindow()
                    if modalWnd:
                        modalWnd.SetModalResult(uiconst.ID_CLOSE)
                    uthread.new(uicore.Message, 'LongWaitForRemoteCall',
                                {'time': int(maxDiff / const.MIN)})
                    self.lastLongCallTimestamp = blue.os.GetWallclockTimeNow()
            except:
                log.LogException()
                sys.exc_clear()