def GetOutputVolumePerHour(self): cycleTime = self.GetCycleTime() if not self.IsProducer() or not cycleTime: return 0.0 volumePerCycle = planetCommon.GetCommodityTotalVolume(self.GetProducts()) volumePerHour = planetCommon.GetBandwidth(volumePerCycle, cycleTime) return volumePerHour
def FindRoutableQuantityOfResource(self, colony, path, typeID, quantity, cycleTime): """ Effectively, this method finds the minimum available bandwidth on each link in the path and then converts that to a quantity of transportable commodities of the given typeID (i.e. volume). If there's enough bandwidth to route the entire package, then the initial quantity value is returned untouched. """ minimumBandwidth = None prevPinID = None for pinID in path: if prevPinID is None: prevPinID = pinID continue link = colony.colonyData.GetLink(prevPinID, pinID) availableBandwidth = link.GetTotalBandwidth() - link.GetBandwidthUsage() if minimumBandwidth is None or availableBandwidth < minimumBandwidth: minimumBandwidth = availableBandwidth prevPinID = pinID baseVolume = cfg.invtypes.Get(typeID).volume requiredBandwidth = planetCommon.GetBandwidth(baseVolume * quantity, cycleTime) if requiredBandwidth > minimumBandwidth: quantity = int(minimumBandwidth * float(cycleTime) / (const.HOUR * baseVolume)) return quantity
def GetSchematicData(processorTypeID): schematicsData = cfg.schematicsByPin[processorTypeID] if len(schematicsData) == 0: log.LogTraceback( 'Authoring error: No schematics found for processor pin with typeID %s' % processorTypeID) schematics = [] for s in schematicsData: try: schematic = cfg.schematics.Get(s.schematicID) except: log.LogTraceback('Authoring error: No schematic found with id=%s' % s.schematicID) raise inputs, outputs = _GetSchematicInputsAndOutputs(schematic.schematicID) outputsDict = {} for o in outputs: outputsDict[o.typeID] = o.quantity volumePerCycle = planetCommon.GetCommodityTotalVolume(outputsDict) volumePerHour = planetCommon.GetBandwidth( volumePerCycle, schematic.cycleTime * const.SEC) sData = util.KeyVal(name=schematic.schematicName, schematicID=schematic.schematicID, cycleTime=schematic.cycleTime, outputs=outputs, inputs=inputs, outputVolume=volumePerHour) schematics.append((sData.name, sData)) return uiutil.SortListOfTuples(schematics)
def GetBandwidthUsage(self): bwth = evetypes.GetVolume(self.GetType()) * self.GetQuantity() cycleTime = self.GetRouteCycleTime() if cycleTime == 0.0 or cycleTime is None: return bwth else: return planetCommon.GetBandwidth(bwth, cycleTime)
def GetBandwidthUsage(self): """ Gets the bandwidth usage of the route in cubic-meters-per-hour. """ bwth = cfg.invtypes.Get(self.GetType()).volume * self.GetQuantity() cycleTime = self.GetRouteCycleTime() if cycleTime == 0.0 or cycleTime is None: return bwth else: return planetCommon.GetBandwidth(bwth, cycleTime)
def OnRouteAmountEditChanged(self, newVal): try: routeAmount = int(newVal) except ValueError: return if not self.currRouteCycleTime: return routeAmount = min(routeAmount, self.routeMaxAmount) routeAmount = max(routeAmount, 0.0) volume = planetCommon.GetCommodityTotalVolume( {self.commodityToRoute: routeAmount}) volumePerHour = planetCommon.GetBandwidth(volume, self.currRouteCycleTime) sm.GetService('planetUI').myPinManager.OnRouteVolumeChanged( volumePerHour)
def GetSchematicData(processorTypeID): """ Returns an alphabetically sorted list of all schematics that the specified processor pin type can produce RETURN: a list of util.KeyVal( name [string] schematicID [int] cycleTime [int] (in seconds) outputs [list of util.KeyVal(name, typeID, quantity)] inputs [list of util.KeyVal(name, typeID, quantity)] ) """ schematicsData = cfg.schematicsByPin[processorTypeID] if len(schematicsData) == 0: log.LogTraceback( 'Authoring error: No schematics found for processor pin with typeID %s' % processorTypeID) schematics = [] for s in schematicsData: try: schematic = cfg.schematics.Get(s.schematicID) except: log.LogTraceback('Authoring error: No schematic found with id=%s' % s.schematicID) raise inputs, outputs = _GetSchematicInputsAndOutputs(schematic.schematicID) outputsDict = {} for o in outputs: outputsDict[o.typeID] = o.quantity volumePerCycle = planetCommon.GetCommodityTotalVolume(outputsDict) volumePerHour = planetCommon.GetBandwidth( volumePerCycle, schematic.cycleTime * const.SEC) sData = util.KeyVal(name=schematic.schematicName, schematicID=schematic.schematicID, cycleTime=schematic.cycleTime, outputs=outputs, inputs=inputs, outputVolume=volumePerHour) schematics.append((sData.name, sData)) return uiutil.SortListOfTuples(schematics)
def FindRoutableQuantityOfResource(self, colony, path, typeID, quantity, cycleTime): minimumBandwidth = None prevPinID = None for pinID in path: if prevPinID is None: prevPinID = pinID continue link = colony.colonyData.GetLink(prevPinID, pinID) availableBandwidth = link.GetTotalBandwidth( ) - link.GetBandwidthUsage() if minimumBandwidth is None or availableBandwidth < minimumBandwidth: minimumBandwidth = availableBandwidth prevPinID = pinID baseVolume = evetypes.GetVolume(typeID) requiredBandwidth = planetCommon.GetBandwidth(baseVolume * quantity, cycleTime) if requiredBandwidth > minimumBandwidth: quantity = int(minimumBandwidth * float(cycleTime) / (const.HOUR * baseVolume)) return quantity