Commit 0d1b0971 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Sebastien Robin

id property added to entity and its childs, global property numberOfEntities added

parent d1ae4684
......@@ -29,7 +29,7 @@ Class that acts as an abstract. It should have no instances. All the Entities sh
class Entity(object):
type="Entity"
def __init__(self, name, priority=0, dueDate=0, orderDate=0):
def __init__(self, id=None, name=None, priority=0, dueDate=0, orderDate=0):
self.name=name
# information on the object holding the entity
# initialized as None and updated every time an entity enters a new object
......
......@@ -35,8 +35,8 @@ class Frame(Entity):
type="Frame"
capacity=4 #the number of parts that the frame can take
def __init__(self, name):
Entity.__init__(self, name)
def __init__(self, id=None, name=None):
Entity.__init__(self,id=id,name = name)
self.Res=Resource(self.capacity)
#dimension data
......
......@@ -64,3 +64,4 @@ class G:
outputJSON={}
outputJSONFile=None
numberOfEntities = 0
\ No newline at end of file
......@@ -29,12 +29,12 @@ in the system and also in the processing times at each station
from Globals import G
from Entity import Entity
# ============================ The part object ==============================
# ============================ The job object ==============================
class Job(Entity): # inherits from the Entity class
type="Job"
def __init__(self, id, name, route=[], priority=0, dueDate=0, orderDate=0):
Entity.__init__(self, name, priority=priority, dueDate=dueDate, orderDate=orderDate)
def __init__(self, id=None, name=None, route=[], priority=0, dueDate=0, orderDate=0):
Entity.__init__(self, id=id,name=name, priority=priority, dueDate=dueDate, orderDate=orderDate)
# instance specific attributes
self.id=id # id
# information on the routing and the stops of the entity
......
......@@ -35,7 +35,6 @@ from Entity import Entity
class Part(Entity):
type="Part"
def __init__(self, name):
Entity.__init__(self, name)
def __init__(self, id = None, name = None):
Entity.__init__(self, id = id, name = name)
#print self.name, now()
......@@ -30,6 +30,7 @@ from SimPy.Simulation import now, Process, Resource, infinity, hold
from Part import Part
from RandomNumberGenerator import RandomNumberGenerator
from CoreObject import CoreObject
from Globals import G
#============================================================================
# The Source object is a Process
#============================================================================
......@@ -105,7 +106,8 @@ class Source(CoreObject):
while 1:
entity=self.createEntity() # create the Entity object and assign its name
self.numberOfArrivals+=1 # we have one new arrival
self.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1
entity.creationTime=now() # assign the current simulation time as the Entity's creation time
entity.startTime=now() # assign the current simulation time as the Entity's start time
entity.currentStation=self # update the current station of the Entity
......@@ -122,7 +124,7 @@ class Source(CoreObject):
# creates an Entity
#============================================================================
def createEntity(self):
return self.item(self.item.type+str(self.numberOfArrivals)) #return the newly created Entity
return self.item(id = self.item.type+str(G.numberOfEntities), name = self.item.type+str(self.numberOfArrivals)) #return the newly created Entity
#============================================================================
# calculates the processing time
#============================================================================
......
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