Commit cb1fc027 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

QueueLIFO code enhance for future demonstration of extensibility ideas

parent 2e97a98e
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
}, },
"successorList": ["E1"] "successorList": ["E1"]
}, },
{"_class": "Dream.Queue", {"_class": "Dream.QueueLIFO",
"id": "DummyQ", "id": "DummyQ",
"name": "DummyQ", "name": "DummyQ",
"isDummy": "1", "isDummy": "1",
......
...@@ -172,6 +172,17 @@ def createObjects(): ...@@ -172,6 +172,17 @@ def createObjects():
G.QueueList.append(Q) G.QueueList.append(Q)
G.ObjList.append(Q) G.ObjList.append(Q)
elif objClass=='Dream.QueueLIFO':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
successorList=element.get('successorList', 'not found')
capacity=int(element.get('capacity', '1'))
isDummy=bool(int(element.get('isDummy', '0')))
Q=QueueLIFO(id, name, capacity, isDummy)
Q.nextIds=successorList
G.QueueList.append(Q)
G.ObjList.append(Q)
elif objClass=='Dream.Assembly': elif objClass=='Dream.Assembly':
id=element.get('id', 'not found') id=element.get('id', 'not found')
name=element.get('name', 'not found') name=element.get('name', 'not found')
......
...@@ -245,9 +245,10 @@ class Machine(CoreObject): ...@@ -245,9 +245,10 @@ class Machine(CoreObject):
def removeEntity(self): def removeEntity(self):
self.timeLastEntityLeft=now() self.timeLastEntityLeft=now()
self.outputTrace("releases "+self.objName) self.outputTrace("releases "+self.objName)
self.waitToDispose=False self.waitToDispose=False
self.Res.activeQ.pop(0) self.Res.activeQ.pop(0)
self.downTimeInTryingToReleaseCurrentEntity=0 self.downTimeInTryingToReleaseCurrentEntity=0
#checks if the Machine can dispose an entity to the following object #checks if the Machine can dispose an entity to the following object
def haveToDispose(self, callerObject=None): def haveToDispose(self, callerObject=None):
......
...@@ -30,9 +30,15 @@ Models a LIFO queue where entities can wait in order to get into a server ...@@ -30,9 +30,15 @@ Models a LIFO queue where entities can wait in order to get into a server
from Queue import Queue from Queue import Queue
class QueueLIFO(Queue): class QueueLIFO(Queue):
#gets an entity from the predecessor #gets an entity from the predecessor
def getEntity(self): def getEntity(self):
self.Res.activeQ=[self.previous[0].Res.activeQ[0]]+self.Res.activeQ #get the entity from the previous object activeObject=self #use this to refer to the current object which receives the Entity
#and put it in front of the activeQ activeEntity=[self.previous[self.predecessorIndex].Res.activeQ[0]] #use this to refer to the Entity that is received
self.previous[0].removeEntity() #remove the entity from the previous object giverObject=self.previous[self.predecessorIndex] #use this to refer to the object that disposes the entity
\ No newline at end of file
activeObject.Res.activeQ=activeEntity+activeObject.Res.activeQ #get the entity from the previous object
#and put it in front of the activeQ
giverObject.removeEntity() #remove the entity from the previous object
\ No newline at end of file
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