Commit 27f54900 authored by Georgios Dagkakis's avatar Georgios Dagkakis

comments and cleanup

parent aa515ad8
...@@ -22,12 +22,12 @@ Created on 09 11 2015 ...@@ -22,12 +22,12 @@ Created on 09 11 2015
@author: George @author: George
''' '''
''' '''
models a pack of milk
''' '''
from dream.simulation.Job import Job from dream.simulation.Job import Job
class MilkPack(Job): # inherits from the Entity class class MilkPack(Job):
type='Job' type='Job'
family='Job' family='Job'
......
...@@ -22,21 +22,20 @@ Created on 09 11 2015 ...@@ -22,21 +22,20 @@ Created on 09 11 2015
@author: George @author: George
''' '''
''' '''
models a tank of packages of milk
''' '''
from dream.simulation.QueueJobShop import QueueJobShop from dream.simulation.QueueJobShop import QueueJobShop
class MilkTank(QueueJobShop): class MilkTank(QueueJobShop):
family='Buffer' family='Buffer'
def __init__(self, id=None, name=None, capacity=1,**kw):
QueueJobShop.__init__(self,id,name,capacity)
def initialize(self): def initialize(self):
# keep the ids of products that have already been gathered
self.alreadyGatheredProductIds=[] self.alreadyGatheredProductIds=[]
QueueJobShop.initialize(self) QueueJobShop.initialize(self)
# extend so that the milk cannot proceed until the whole batch is collected
def haveToDispose(self, callerObject=None): def haveToDispose(self, callerObject=None):
if len(self.getActiveObjectQueue()): if len(self.getActiveObjectQueue()):
activeEntity=self.getActiveObjectQueue()[0] activeEntity=self.getActiveObjectQueue()[0]
...@@ -49,16 +48,19 @@ class MilkTank(QueueJobShop): ...@@ -49,16 +48,19 @@ class MilkTank(QueueJobShop):
# print self.env.now, 'gathered', self.getTotalLiters(), 'liters with', self.getFat(), 'fat' # print self.env.now, 'gathered', self.getTotalLiters(), 'liters with', self.getFat(), 'fat'
self.alreadyGatheredProductIds.append(activeEntity.productId) self.alreadyGatheredProductIds.append(activeEntity.productId)
return QueueJobShop.haveToDispose(self, callerObject) return QueueJobShop.haveToDispose(self, callerObject)
# returns the average fat of the milk that is in the tank
def getFat(self): def getFat(self):
return self.getTotalFat()/float(self.getTotalLiters()) return self.getTotalFat()/float(self.getTotalLiters())
# returns the total liters of milk that is in the tank
def getTotalLiters(self): def getTotalLiters(self):
totalLiters=0 totalLiters=0
for pack in self.getActiveObjectQueue(): for pack in self.getActiveObjectQueue():
totalLiters+=pack.liters totalLiters+=pack.liters
return totalLiters return totalLiters
# returns the total fat is in the tank
def getTotalFat(self): def getTotalFat(self):
totalFat=0 totalFat=0
for pack in self.getActiveObjectQueue(): for pack in self.getActiveObjectQueue():
......
...@@ -22,7 +22,7 @@ Created on 09 11 2015 ...@@ -22,7 +22,7 @@ Created on 09 11 2015
@author: George @author: George
''' '''
''' '''
models the transport of the milk
''' '''
from dream.simulation.MachineJobShop import MachineJobShop from dream.simulation.MachineJobShop import MachineJobShop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment