LineGenerationJSON updated to requestWIP from other sources than the input...

LineGenerationJSON updated to requestWIP from other sources than the input json from the UI when WIP is provided in that
parent cf0545d0
...@@ -120,11 +120,11 @@ def createObjects(): ...@@ -120,11 +120,11 @@ def createObjects():
edges = json_data['edges'] # read from the dictionary the dicts with key 'edges' edges = json_data['edges'] # read from the dictionary the dicts with key 'edges'
# ----------------------------------------------------------------------- '''
# getSuccesorList method to get the successor getSuccesorList method to get the successor
# list of object with ID = id list of object with ID = id
# XXX slow implementation XXX slow implementation
# ----------------------------------------------------------------------- '''
def getSuccessorList(node_id, predicate=lambda source, destination, edge_data: True): def getSuccessorList(node_id, predicate=lambda source, destination, edge_data: True):
successor_list = [] # dummy variable that holds the list to be returned successor_list = [] # dummy variable that holds the list to be returned
for source, destination, edge_data in edges.values(): # for all the values in the dictionary edges for source, destination, edge_data in edges.values(): # for all the values in the dictionary edges
...@@ -135,9 +135,9 @@ def createObjects(): ...@@ -135,9 +135,9 @@ def createObjects():
# prevents Topology10 to work if this sort is not used. # prevents Topology10 to work if this sort is not used.
successor_list.sort() successor_list.sort()
return successor_list return successor_list
# ----------------------------------------------------------------------- '''
# define the lists of each object type define the lists of each object type
# ----------------------------------------------------------------------- '''
G.SourceList=[] G.SourceList=[]
G.MachineList=[] G.MachineList=[]
G.ExitList=[] G.ExitList=[]
...@@ -170,11 +170,11 @@ def createObjects(): ...@@ -170,11 +170,11 @@ def createObjects():
G.QueueManagedJobList=[] G.QueueManagedJobList=[]
G.ModelResourceList=[] G.ModelResourceList=[]
# ----------------------------------------------------------------------- '''
# loop through all the model resources loop through all the model resources
# search for repairmen and operators in order to create them search for repairmen and operators in order to create them
# read the data and create them read the data and create them
# ----------------------------------------------------------------------- '''
for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes
element['id'] = element_id # create a new entry for the element (dictionary) element['id'] = element_id # create a new entry for the element (dictionary)
...@@ -182,7 +182,7 @@ def createObjects(): ...@@ -182,7 +182,7 @@ def createObjects():
for k in ('element_id', 'top', 'left'): for k in ('element_id', 'top', 'left'):
element.pop(k, None) element.pop(k, None)
# with key 'id' and value the the element_id # with key 'id' and value the the element_id
resourceClass = element.pop('_class') # get the class type of the element resourceClass = element.pop('_class') # get the class type of the element
if resourceClass=='Dream.Repairman': # check the object type if resourceClass=='Dream.Repairman': # check the object type
id = element.get('id', 'not found') # get the id of the element id = element.get('id', 'not found') # get the id of the element
name = element.get('name', id) # get the name of the element / default 'not_found' name = element.get('name', id) # get the name of the element / default 'not_found'
...@@ -230,11 +230,11 @@ def createObjects(): ...@@ -230,11 +230,11 @@ def createObjects():
G.OperatorsList.append(O) # add the operator to the RepairmanList G.OperatorsList.append(O) # add the operator to the RepairmanList
G.OperatorManagedJobsList.append(O) G.OperatorManagedJobsList.append(O)
G.ModelResourceList.append(O) G.ModelResourceList.append(O)
# ----------------------------------------------------------------------- '''
# loop through all the model resources loop through all the model resources
# search for operatorPools in order to create them search for operatorPools in order to create them
# read the data and create them read the data and create them
# ----------------------------------------------------------------------- '''
for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes
# the key is the element_id and the second is the # the key is the element_id and the second is the
# element itself # element itself
...@@ -243,7 +243,7 @@ def createObjects(): ...@@ -243,7 +243,7 @@ def createObjects():
for k in ('element_id', 'top', 'left'): for k in ('element_id', 'top', 'left'):
element.pop(k, None) element.pop(k, None)
# with key 'id' and value the the element_id # with key 'id' and value the the element_id
resourceClass = element.pop('_class') # get the class type of the element resourceClass = element.pop('_class') # get the class type of the element
if resourceClass=='Dream.OperatorPool': if resourceClass=='Dream.OperatorPool':
id = element.get('id', 'not found') # get the id of the element / default 'not_found' id = element.get('id', 'not found') # get the id of the element / default 'not_found'
name = element.get('name', 'not found') # get the name of the element / default 'not_found' name = element.get('name', 'not found') # get the name of the element / default 'not_found'
...@@ -261,10 +261,10 @@ def createObjects(): ...@@ -261,10 +261,10 @@ def createObjects():
for operator in operatorsList: for operator in operatorsList:
operator.coreObjectIds=OP.coreObjectIds # update the list of objects that the operators operate operator.coreObjectIds=OP.coreObjectIds # update the list of objects that the operators operate
G.OperatorPoolsList.append(OP) # add the operatorPool to the RepairmanList G.OperatorPoolsList.append(OP) # add the operatorPool to the RepairmanList
# ----------------------------------------------------------------------- '''
# loop through all the elements loop through all the elements
# read the data and create them read the data and create them
# ----------------------------------------------------------------------- '''
for (element_id, element) in nodes.iteritems(): for (element_id, element) in nodes.iteritems():
element = element.copy() element = element.copy()
element['id'] = element_id element['id'] = element_id
...@@ -783,12 +783,12 @@ def createObjects(): ...@@ -783,12 +783,12 @@ def createObjects():
G.OperatedMachineList.append(MA) # add the machine to the operatedMachines List G.OperatedMachineList.append(MA) # add the machine to the operatedMachines List
G.ObjList.append(MA) G.ObjList.append(MA)
# ----------------------------------------------------------------------- '''
# loop through all the nodes to loop through all the nodes to
# search for Event Generator and create them search for Event Generator and create them
# this is put last, since the EventGenerator this is put last, since the EventGenerator
# may take other objects as argument may take other objects as argument
# ----------------------------------------------------------------------- '''
for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes for (element_id, element) in nodes.iteritems(): # use an iterator to go through all the nodes
# the key is the element_id and the second is the # the key is the element_id and the second is the
# element itself # element itself
...@@ -815,10 +815,10 @@ def createObjects(): ...@@ -815,10 +815,10 @@ def createObjects():
# calling the getSuccessorList() method on the repairman # calling the getSuccessorList() method on the repairman
G.EventGeneratorList.append(EV) # add the Event Generator to the RepairmanList G.EventGeneratorList.append(EV) # add the Event Generator to the RepairmanList
# ----------------------------------------------------------------------- '''
# loop through all the core objects loop through all the core objects
# to read predecessors to read predecessors
# ----------------------------------------------------------------------- '''
for element in G.ObjList: for element in G.ObjList:
#loop through all the nextIds of the object #loop through all the nextIds of the object
for nextId in element.nextIds: for nextId in element.nextIds:
...@@ -1294,9 +1294,23 @@ def main(argv=[], input_data=None): ...@@ -1294,9 +1294,23 @@ def main(argv=[], input_data=None):
G.Rnd=Random('%s%s' % (G.seed, i)) G.Rnd=Random('%s%s' % (G.seed, i))
else: else:
G.Rnd=Random() G.Rnd=Random()
createWIP() from readWip import checkWIP
initializeObjects() if not checkWIP():
Globals.setWIP(G.EntityList) try:
from readWip import requestWIP, WIPreadError
input_Wip=requestWIP()
if not input_Wip:
raise WIPreadError('The WIP could not be read from the external source')
except WIPreadError as wiperror:
print 'WIP definition error: {0}'.format(wiperror)
from readWip import getOrders, setStartWip
getOrders(input_Wip)
initializeObjects()
setStartWip()
else:
createWIP()
initializeObjects()
Globals.setWIP(G.EntityList)
activateObjects() activateObjects()
# if the simulation is ran until no more events are scheduled, # if the simulation is ran until no more events are scheduled,
......
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