Commit 1fed1ece authored by Georgios Dagkakis's avatar Georgios Dagkakis

patch in capacity instance made generic

parent 24f39181
from copy import copy from copy import copy, deepcopy
import json import json
import time import time
import random import random
...@@ -14,10 +14,11 @@ class CreateCapacityStations(plugin.InputPreparationPlugin): ...@@ -14,10 +14,11 @@ class CreateCapacityStations(plugin.InputPreparationPlugin):
def preprocess(self, data): def preprocess(self, data):
nodes=copy(data['graph']['node']) nodes=copy(data['graph']['node'])
originalData=deepcopy(data)
for (stationId, node) in nodes.iteritems(): for (stationId, node) in nodes.iteritems():
_class=node['_class'] _class=node['_class']
if _class=='dream.simulation.applications.CapacityStations.CapacityStation.CapacityStation': if _class=='dream.simulation.applications.CapacityStations.CapacityStation.CapacityStation':
nextCapacityStationBufferId=self.getSuccessor(data,stationId) nextCapacityStationBufferId=self.getNextCapacityStationBufferId(data,stationId)
# the nextCapacityStationBufferId should point to the buffer # the nextCapacityStationBufferId should point to the buffer
if nextCapacityStationBufferId: if nextCapacityStationBufferId:
nextCapacityStationBufferId+='_B' nextCapacityStationBufferId+='_B'
...@@ -25,19 +26,23 @@ class CreateCapacityStations(plugin.InputPreparationPlugin): ...@@ -25,19 +26,23 @@ class CreateCapacityStations(plugin.InputPreparationPlugin):
# create the CapacityStationBuffer # create the CapacityStationBuffer
bufferName=stationName+'_Buffer' bufferName=stationName+'_Buffer'
bufferId=stationId+'_B' bufferId=stationId+'_B'
requireFullProject=data['graph']['node'][stationId].pop('requireFullProject',None)
data['graph']['node'][bufferId]={ data['graph']['node'][bufferId]={
"_class": "dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer", "_class": "dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer",
"name": bufferName, "name": bufferName,
"wip": [], "wip": [],
'requireFullProject':data['graph']['node'][stationId].pop('requireFullProject',None) 'requireFullProject':requireFullProject
} }
if requireFullProject:
data['graph']['node'][bufferId]['notRequiredOperations']=self.findNotRequiredOperations(originalData,stationId)
# create an edge that connects the CapacityStationBuffer to the CapacityStation # create an edge that connects the CapacityStationBuffer to the CapacityStation
data['graph']['edge'][bufferId+'_to_'+stationId]={ data['graph']['edge'][bufferId+'_to_'+stationId]={
"source": bufferId, "source": bufferId,
"destination": stationId, "destination": stationId,
"data": {}, "data": {},
"_class": "Dream.Edge" "_class": "Dream.Edge"
} }
# create the CapacityStationExit # create the CapacityStationExit
exitName=stationName+'_Exit' exitName=stationName+'_Exit'
exitId=stationId+'_E' exitId=stationId+'_E'
...@@ -53,11 +58,8 @@ class CreateCapacityStations(plugin.InputPreparationPlugin): ...@@ -53,11 +58,8 @@ class CreateCapacityStations(plugin.InputPreparationPlugin):
"destination": exitId, "destination": exitId,
"data": {}, "data": {},
"_class": "Dream.Edge" "_class": "Dream.Edge"
} }
# XXX Patch just for this model to be made more generic
if stationId=='PPASB':
data['graph']['node'][bufferId]['notRequiredOperations']=["EEP", "PAINT", "ASBTST"]
# XXX another patch, these should be inputted # XXX another patch, these should be inputted
if stationId=='PPASB': if stationId=='PPASB':
data['graph']['node'][stationId]['sharedResources']={ data['graph']['node'][stationId]['sharedResources']={
...@@ -87,7 +89,7 @@ class CreateCapacityStations(plugin.InputPreparationPlugin): ...@@ -87,7 +89,7 @@ class CreateCapacityStations(plugin.InputPreparationPlugin):
# gets the data and the stationId # gets the data and the stationId
# returns the successorId and erases the edge # returns the successorId and erases the edge
def getSuccessor(self, data,stationId): def getNextCapacityStationBufferId(self,data,stationId):
successorId=None successorId=None
edgeToErase=None edgeToErase=None
for (edgeId, edge) in data['graph']['edge'].iteritems(): for (edgeId, edge) in data['graph']['edge'].iteritems():
...@@ -98,3 +100,28 @@ class CreateCapacityStations(plugin.InputPreparationPlugin): ...@@ -98,3 +100,28 @@ class CreateCapacityStations(plugin.InputPreparationPlugin):
if edgeToErase: if edgeToErase:
data['graph']['edge'].pop(edgeToErase,None) data['graph']['edge'].pop(edgeToErase,None)
return successorId return successorId
# for an assembly station finds which are the not required operations
def findNotRequiredOperations(self,data,stationId):
requiredOperations=[]
nodes=data['graph']['node']
notRequiredOperations=nodes.keys()
for node_id, node in nodes.iteritems():
currentId=node_id
while 1:
successorList = self.getSuccessors(data, currentId)
if not successorList:
break
successorId=successorList[0]
if successorId==stationId:
requiredOperations.append(node_id)
break
currentId=successorId
for element in deepcopy(notRequiredOperations):
if element in requiredOperations:
notRequiredOperations.remove(element)
return notRequiredOperations
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