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

plugin to work with SelectiveQueue is routingOut is set to priority

parent 745a5805
from copy import copy
import json
import time
import random
import operator
from datetime import datetime
from dream.plugins import plugin
class SetRoutingOut(plugin.InputPreparationPlugin):
""" Input preparation
takes a model and if the queue is set to priority sets the class to selectiveQueue
"""
def preprocess(self, data):
nodes=data['graph']['node']
for node_id,node in nodes.iteritems():
if node.get('_class',None)=='Dream.Queue':
if node.get('routingOut',None)=='Priority':
node['_class']="dream.simulation.Examples.SelectiveQueue.SelectiveQueue"
return data
\ No newline at end of file
......@@ -236,6 +236,10 @@
{
"_class": "dream.plugins.WIPSpreadsheet.WIPSpreadsheet",
"input_id": "WIPdata"
},
{
"_class": "dream.plugins.SetRoutingOut.SetRoutingOut",
"input_id": "routingOut"
}
]
},
......
from dream.simulation.imports import Queue
#the custom queue
class SelectiveQueue(Queue):
#override so that it chooses receiver according to priority
def selectReceiver(self,possibleReceivers=[]):
# sort the receivers according to their priority
possibleReceivers.sort(key=lambda x: x.priority, reverse=True)
if possibleReceivers[0].canAccept():
return possibleReceivers[0]
elif possibleReceivers[1].canAccept():
return possibleReceivers[1]
return None
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