Commit 9f6c2402 authored by Georgios Dagkakis's avatar Georgios Dagkakis

cleanup. addEdge method added to generic InputPreparationPlugin

parent ecd02eab
...@@ -42,19 +42,9 @@ class AddBatchStations(plugin.InputPreparationPlugin): ...@@ -42,19 +42,9 @@ class AddBatchStations(plugin.InputPreparationPlugin):
# remove the edge # remove the edge
data['graph']['edge'].pop(edge_id,None) data['graph']['edge'].pop(edge_id,None)
# add an edge from source to batchDecomposition # add an edge from source to batchDecomposition
data['graph']['edge'][source+'_to_'+batchDecompositionId]={ self.addEdge(data, source, batchDecompositionId)
"source": source,
"destination": batchDecompositionId,
"data": {},
"_class": "Dream.Edge"
}
# add an edge from batchDecomposition machine # add an edge from batchDecomposition machine
data['graph']['edge'][batchDecompositionId+'_to_'+node_id]={ self.addEdge(data, batchDecompositionId, node_id)
"source": batchDecompositionId,
"destination": node_id,
"data": {},
"_class": "Dream.Edge"
}
#create a batchReassembly #create a batchReassembly
batchReassemblyId=node_id+'_R' batchReassemblyId=node_id+'_R'
data['graph']['node'][batchReassemblyId]={ data['graph']['node'][batchReassemblyId]={
...@@ -76,20 +66,10 @@ class AddBatchStations(plugin.InputPreparationPlugin): ...@@ -76,20 +66,10 @@ class AddBatchStations(plugin.InputPreparationPlugin):
destination=edge['destination'] destination=edge['destination']
# remove the edge # remove the edge
data['graph']['edge'].pop(edge_id,None) data['graph']['edge'].pop(edge_id,None)
# add an edge from node to destination # add an edge from machine to batchReassembly
data['graph']['edge'][node_id+'_to_'+batchReassemblyId]={ self.addEdge(data, node_id, batchReassemblyId)
"source": node_id, # add an edge from batchReassembly to destination
"destination": batchReassemblyId, self.addEdge(data, batchReassemblyId, destination)
"data": {},
"_class": "Dream.Edge"
}
# add an edge from batchDecomposition machine
data['graph']['edge'][batchReassemblyId+'_to_'+destination]={
"source": batchReassemblyId,
"destination": destination,
"data": {},
"_class": "Dream.Edge"
}
# dataString=json.dumps(data['graph']['edge'], indent=5) # dataString=json.dumps(data['graph']['edge'], indent=5)
# print dataString # print dataString
return data return data
......
...@@ -31,6 +31,16 @@ class InputPreparationPlugin(Plugin): ...@@ -31,6 +31,16 @@ class InputPreparationPlugin(Plugin):
""" """
return data return data
# adds an edge with the given source and destination
def addEdge(self, data, source, destination, nodeData={}):
data['graph']['edge'][source+'_to_'+destination]={
"source": source,
"destination": destination,
"data": {},
"_class": "Dream.Edge"
}
return data
class OutputPreparationPlugin(Plugin): class OutputPreparationPlugin(Plugin):
def postprocess(self, data): def postprocess(self, data):
"""Postprocess the data after simulation run. """Postprocess the data after simulation run.
......
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