Commit bd7b85f5 authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugin to create CapacityStationBuffer and CapacityStationExit added

parent 06b4a8e6
from copy import copy
import json
import time
import random
import operator
import datetime
from dream.plugins import plugin
class CreateCapacityStations(plugin.InputPreparationPlugin):
""" Input preparation
creates the CapacityStationBuffer and CapacityStationExit for each CapacityStation
"""
def preprocess(self, data):
nodes=copy(data['graph']['node'])
for (stationId, node) in nodes.iteritems():
_class=node['_class']
if _class=='dream.simulation.applications.CapacityStations.CapacityStation.CapacityStation':
nextCapacityStationBufferId=self.getSuccessor(data,stationId)
stationName=node['name']
# create the CapacityStationBuffer
bufferName=stationName+'_Buffer'
bufferId=stationId+'_B'
data['graph']['node'][bufferId]={
"_class": "dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer",
"name": bufferName,
"wip": [],
'requireFullProject':data['graph']['node'][stationId].pop('requireFullProject',None)
}
# create an edge that connects the CapacityStationBuffer to the CapacityStation
data['graph']['edge'][bufferId+'_to_'+stationId]={
"source": bufferId,
"destination": stationId,
"data": {},
"_class": "Dream.Edge"
}
# create the CapacityStationExit
exitName=stationName+'_Exit'
exitId=stationId+'_E'
data['graph']['node'][exitId]={
"_class": "dream.simulation.applications.CapacityStations.CapacityStationExit.CapacityStationExit",
"name": exitName,
"nextCapacityStationBufferId": nextCapacityStationBufferId
}
# create an edge that connects the CapacityStationBuffer to the CapacityStation
data['graph']['edge'][stationId+'_to_'+exitId]={
"source": stationId,
"destination": exitId,
"data": {},
"_class": "Dream.Edge"
}
print '--->',(data['graph']['node'])
return data
# gets the data and the stationId
# returns the successorId and erases the edge
def getSuccessor(self, data,stationId):
successorId=None
edgeToErase=None
for (edgeId, edge) in data['graph']['edge'].iteritems():
if data['graph']['edge'][edgeId]['source']==stationId:
successorId=data['graph']['edge'][edgeId]['destination']
edgeToErase=edgeId
break
if edgeToErase:
data['graph']['edge'].pop(edgeToErase,None)
return successorId
\ No newline at end of file
......@@ -378,7 +378,7 @@
],
"description": "Connect stations together"
},
"Dream.Dream.AbstractCapacityStation": {
"dream.simulation.applications.CapacityStations.CapacityStation.CapacityStation": {
"name": "Machine",
"description": "A station processing items for some time given by a distribution",
"_class": "node",
......@@ -403,9 +403,9 @@
"default": "M",
"required": true
},
"Is an assembly station?": {
"requireFullProject": {
"_default": 0,
"description": "Is this station an assembly ? Yes: 1, No: 0",
"description": "Is this station an assembly? Yes: 1, No: 0",
"type": "number",
"required": true
}
......@@ -647,6 +647,10 @@
{
"_class": "dream.plugins.CapacityProjectSpreadsheet.CapacityProjectSpreadsheet",
"input_id": "capacityProject"
},
{
"_class": "dream.plugins.CreateCapacityStations.CreateCapacityStations",
"input_id": "createCapacityStations"
}
]
},
......
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