Commit fc01c77b authored by Georgios Dagkakis's avatar Georgios Dagkakis

Machine to be able to read inputs from dict

parent 73edfef0
...@@ -292,53 +292,54 @@ def createObjects(): ...@@ -292,53 +292,54 @@ def createObjects():
G.ObjList.append(S) G.ObjList.append(S)
elif objClass=='Dream.Machine': elif objClass=='Dream.Machine':
id=element.get('id', 'not found') # id=element.get('id', 'not found')
name=element.get('name', 'not found') # name=element.get('name', 'not found')
processingTime=element.get('processingTime',{}) # processingTime=element.get('processingTime',{})
canDeliverOnInterruption=bool(element.get('canDeliverOnInterruption') or 0) # canDeliverOnInterruption=bool(element.get('canDeliverOnInterruption') or 0)
failures=element.get('failures', {}) # failures=element.get('failures', {})
failureDistribution=failures.get('failureDistribution', 'not found') # failureDistribution=failures.get('failureDistribution', 'not found')
MTTF=float(failures.get('MTTF') or 0) # MTTF=float(failures.get('MTTF') or 0)
MTTR=float(failures.get('MTTR') or 0) # MTTR=float(failures.get('MTTR') or 0)
availability=float(failures.get('availability') or 0) # availability=float(failures.get('availability') or 0)
# type of operation and related times # # type of operation and related times
operationType=element.get('operationType','not found') # operationType=element.get('operationType','not found')
setupTime = element.get('setupTime', None) # setupTime = element.get('setupTime', None)
loadTime = element.get('loadTime', None) # loadTime = element.get('loadTime', None)
preemption=element.get('preemption',{}) # preemption=element.get('preemption',{})
isPreemptive=resetOnPreemption=False # isPreemptive=resetOnPreemption=False
if len(preemption)>0: # if len(preemption)>0:
isPreemptive=bool(int(preemption.get('isPreemptive') or 0)) # isPreemptive=bool(int(preemption.get('isPreemptive') or 0))
resetOnPreemption=bool(int(preemption.get('resetOnPreemption', 0))) # resetOnPreemption=bool(int(preemption.get('resetOnPreemption', 0)))
#
if len(G.OperatorPoolsList)>0: # if len(G.OperatorPoolsList)>0:
for operatorPool in G.OperatorPoolsList: # find the operatorPool assigned to the machine # 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 # 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, # machineOperatorPoolList=operatorPool # there must only one operator pool assigned to the machine,
# otherwise only one of them will be taken into account # # otherwise only one of them will be taken into account
else: # else:
machineOperatorPoolList=[] # if there is no operatorPool assigned to the machine # machineOperatorPoolList=[] # if there is no operatorPool assigned to the machine
else: # then machineOperatorPoolList/operatorPool is a list # else: # then machineOperatorPoolList/operatorPool is a list
machineOperatorPoolList=[] # if there are no operatorsPool created then the # machineOperatorPoolList=[] # if there are no operatorsPool created then the
# then machineOperatorPoolList/operatorPool is a list # # then machineOperatorPoolList/operatorPool is a list
if (type(machineOperatorPoolList) is list): # if the machineOperatorPoolList 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 # # find the operators assigned to it and add them to the list
for operator in G.OperatorsList: # check which operator in the G.OperatorsList # for operator in G.OperatorsList: # check which operator in the G.OperatorsList
if(id in operator.coreObjectIds): # (if any) is assigned to operate # if(id in operator.coreObjectIds): # (if any) is assigned to operate
machineOperatorPoolList.append(operator) # the machine with ID equal to id # machineOperatorPoolList.append(operator) # the machine with ID equal to id
# if there is no operator assigned then the list will be empty # # if there is no operator assigned then the list will be empty
r='None' # r='None'
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList # for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(id in repairman.coreObjectIds): # (if any) is assigned to repair # if(id in repairman.coreObjectIds): # (if any) is assigned to repair
r=repairman # the machine with ID equal to id # r=repairman # the machine with ID equal to id
M=Machine(id, name, 1, processingTime, failureDistribution=failureDistribution, # M=Machine(id, name, 1, processingTime, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r, # MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
operatorPool=machineOperatorPoolList, operationType=operationType, # operatorPool=machineOperatorPoolList, operationType=operationType,
setupTime=setupTime, # setupTime=setupTime,
loadTime=loadTime, # loadTime=loadTime,
repairman=r, isPreemptive=isPreemptive, resetOnPreemption=resetOnPreemption, # repairman=r, isPreemptive=isPreemptive, resetOnPreemption=resetOnPreemption,
canDeliverOnInterruption=canDeliverOnInterruption) # canDeliverOnInterruption=canDeliverOnInterruption)
M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine M=Machine(inputsDict=element)
M.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the machine
G.MachineList.append(M) # add machine to global MachineList G.MachineList.append(M) # add machine to global MachineList
if M.operatorPool!="None": if M.operatorPool!="None":
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
......
This diff is collapsed.
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