Commit 0827d69b authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

LineGenerationJSON modified in order to initiate first the Operators and then the OperatorPools

parent 1d94eb3a
...@@ -172,7 +172,7 @@ def createObjects(): ...@@ -172,7 +172,7 @@ def createObjects():
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# loop through all the model resources # loop through all the model resources
# search for repairmen 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
...@@ -197,7 +197,18 @@ def createObjects(): ...@@ -197,7 +197,18 @@ def createObjects():
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
# calling the getSuccesorList() method on the operator # calling the getSuccesorList() method on the operator
G.OperatorsList.append(O) # add the operator to the RepairmanList G.OperatorsList.append(O) # add the operator to the RepairmanList
elif resourceClass=='Dream.OperatorPool': # -----------------------------------------------------------------------
# loop through all the model resources
# search for operatorPools in order to create them
# read the data and create them
# -----------------------------------------------------------------------
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
# element itself
element['id'] = element_id # create a new entry for the element (dictionary)
# with key 'id' and value the the element_id
resourceClass = element.get('_class', 'not found') # get the class type of the element
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'
capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1' capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1'
...@@ -378,7 +389,6 @@ def createObjects(): ...@@ -378,7 +389,6 @@ def createObjects():
G.BatchScrapMachineList.append(M) G.BatchScrapMachineList.append(M)
G.ObjList.append(M) # add machine to ObjList G.ObjList.append(M) # add machine to ObjList
elif objClass=='Dream.MachineJobShop': elif objClass=='Dream.MachineJobShop':
id=element.get('id', 'not found') id=element.get('id', 'not found')
name=element.get('name', 'not found') name=element.get('name', 'not found')
...@@ -393,17 +403,54 @@ def createObjects(): ...@@ -393,17 +403,54 @@ def createObjects():
MTTF=float(failures.get('MTTF', '0')) MTTF=float(failures.get('MTTF', '0'))
MTTR=float(failures.get('MTTR', '0')) MTTR=float(failures.get('MTTR', '0'))
availability=float(failures.get('availability', '0')) availability=float(failures.get('availability', '0'))
# type of operation and related times
operationType=element.get('operationType','not found')
setupTime = element.get('setupTime',{})
setupDistribution = setupTime.get('setupDistribution','not found')
setupMean = float(setupTime.get('setupMean','0'))
setupStdev=float(setupTime.get('setupStdev', '0'))
setupMin=float(setupTime.get('setupMin', '0'))
setupMax=float(setupTime.get('setupMax', '0'))
loadTime = element.get('loadTime',{})
loadDistribution = loadTime.get('loadDistribution','not found')
loadMean = float(loadTime.get('loadMean','0'))
loadStdev = float(loadTime.get('loadStdev', '0'))
loadMin=float(loadTime.get('loadMin', '0'))
loadMax=float(loadTime.get('loadMax', '0'))
if len(G.OperatorPoolsList)>0:
for operatorPool in G.OperatorPoolsList: # find the operatorPool assigned to the machine
if(id in operatorPool.coreObjectIds): # and add it to the machine's operatorPool
machineOperatorPoolList=operatorPool # there must only one operator pool assigned to the machine,
# otherwise only one of them will be taken into account
else:
machineOperatorPoolList=[] # if there is no operatorPool assigned to the machine
else: # then machineOperatorPoolList/operatorPool is a list
machineOperatorPoolList=[] # if there are no operatorsPool created then the
# then machineOperatorPoolList/operatorPool is a list
if (type(machineOperatorPoolList) is list): # if the machineOperatorPoolList is a list
# find the operators assigned to it and add them to the list
for operator in G.OperatorsList: # check which operator in the G.OperatorsList
if(id in operator.coreObjectIds): # (if any) is assigned to operate
machineOperatorPoolList.append(operator) # the machine with ID equal to id
# if there is no operator assigned then the list will be empty
r='None' r='None'
for repairman in G.RepairmanList: for repairman in G.RepairmanList:
if(id in repairman.coreObjectIds): if(id in repairman.coreObjectIds):
r=repairman r=repairman
M=MachineJobShop(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution, M=MachineJobShop(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r, MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
mean=mean,stdev=stdev,min=min,max=max) mean=mean,stdev=stdev,min=min,max=max,
operatorPool=machineOperatorPoolList, operationType=operationType,
loadDistribution=loadDistribution, setupDistribution=setupDistribution,
setupMean=setupMean,setupStdev=setupStdev,setupMin=setupMin,setupMax=setupMax,
loadMean=loadMean,loadStdev=loadStdev,loadMin=loadMin,loadMax=loadMax,
repairman=r)
M.nextIds=getSuccessorList(id) M.nextIds=getSuccessorList(id)
G.MachineJobShopList.append(M) G.MachineJobShopList.append(M)
G.MachineList.append(M) G.MachineList.append(M)
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
G.ObjList.append(M) G.ObjList.append(M)
elif objClass=='Dream.MachinePreemptive': elif objClass=='Dream.MachinePreemptive':
......
...@@ -219,7 +219,6 @@ class Machine(CoreObject): ...@@ -219,7 +219,6 @@ class Machine(CoreObject):
# from an unidentified giver or not getting an entity at all as the giver # from an unidentified giver or not getting an entity at all as the giver
# may fall in failure mode (assignExit()?) # may fall in failure mode (assignExit()?)
self.currentEntity=self.getEntity() self.currentEntity=self.getEntity()
# TODO: the Machine receive the entity after the operator is available # TODO: the Machine receive the entity after the operator is available
# the canAcceptAndIsRequested method checks only in case of Load type of operation # the canAcceptAndIsRequested method checks only in case of Load type of operation
......
...@@ -115,6 +115,7 @@ class OperatorPool(ObjectResource): ...@@ -115,6 +115,7 @@ class OperatorPool(ObjectResource):
# ======================================================================= # =======================================================================
# returns the resource # returns the resource
# ======================================================================= # =======================================================================
# TODO: check if it is valid to use it as filter in operatorPoolBroker run()
def getResource(self,operator): def getResource(self,operator):
# have to return the resource of the first operator available # have to return the resource of the first operator available
return operator.getResource() return operator.getResource()
......
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