schedule update; every steps of the operator now holds the task_id (if...

schedule update; every steps of the operator now holds the task_id (if defined) and the entity that is processed
parent 3d99a809
......@@ -1092,7 +1092,10 @@ class Machine(CoreObject):
# get an entity from the giver
# =======================================================================
def getEntity(self):
activeEntity=CoreObject.getEntity(self) # run the default method
activeEntity=CoreObject.getEntity(self) # run the default method
# update the entity attribute of the operator's schedule
if self.currentOperator:
self.currentOperator.schedule[-1]["entity"] = activeEntity
# after the machine receives an entity, it must be removed from the pendingEntities list
from Globals import G
if G.RouterList:
......@@ -1164,7 +1167,7 @@ class Machine(CoreObject):
# If yes the time that he was set off-shift should be updated
operator=self.currentOperator
operator.schedule[-1]["exitTime"] = self.env.now
operator.schedule[-1]["entity"] = self.getActiveObjectQueue()[0]
# operator.schedule[-1]["entity"] = self.getActiveObjectQueue()[0]
if not self.currentOperator.onShift:
operator.timeLastShiftEnded=self.env.now
operator.unAssign() # set the flag operatorAssignedTo to None
......
......@@ -60,6 +60,11 @@ class MachineJobShop(Machine):
self.stpRng=RandomNumberGenerator(self, setupTime)
# check if there is a need for manual processing
self.checkForManualOperation(type='Setup',entity=activeEntity)
# if there is currentOperator then update the taskId of corresponding step of their schedule according to the task_id of the first remaining route step
if self.currentOperator:
taskId = activeEntity.remainingRoute[0].get("task_id", None)
if taskId:
self.currentOperator.schedule[-1]["task_id"] = taskId
removedStep = activeEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
return activeEntity
......
......@@ -160,6 +160,30 @@ class Broker(ObjectInterruption):
# update the schedule of the operator
self.victim.currentOperator.schedule.append({"station": self.victim,
"entranceTime": self.env.now})
# if the victim holds an entity (load is already performed)
if self.victim.getActiveObjectQueue():
# update the entity value of the schedule current step dict
if self.victim.currentOperator.schedule[-1].get("entity", None) == None:
self.victim.currentOperator.schedule[-1]["entity"] = self.victim.getActiveObjectQueue()[0]
# update the task_id of the current schedule step dict
currentStep = None
# if the task_id of the last step is not already updated
if self.victim.currentOperator.schedule[-1].get("task_id", None) == None:
# find the currentStep within the entity's route
try:
if self.victim.getActiveObjectQueue()[0].remainingRoute:
nextStep = self.victim.getActiveObjectQueue()[0].remainingRoute[0]
# if the steps have a task_id key
if nextStep.get("task_id", None):
for step in self.victim.getActiveObjectQueue()[0].route:
if step["task_id"] == nextStep["task_id"] and\
step.get("technology", None) != None:
currentStep = step
break
except:
pass
if currentStep:
self.victim.currentOperator.schedule[-1]["task_id"] = currentStep["task_id"]
# wait till the processing is over
self.expectedSignals['isCalled']=1
......
......@@ -297,15 +297,13 @@ class Operator(ObjectResource):
stationId=record["station"].id
except AttributeError:
stationId=record["station"]['id']
json['results']['schedule'].append({
'stationId':stationId,
'entranceTime':record["entranceTime"]})
if record.get("exitTime", None) != None:
json['results']['schedule'].append({
'stationId':stationId,
'entranceTime':record["entranceTime"],
'exitTime':record["exitTime"]})
else:
json['results']['schedule'].append({
'stationId':stationId,
'entranceTime':record["entranceTime"]})
json['results']['schedule'][-1]["exitTime"] = record["exitTime"]
# if record.get("entity", None):
# json['results']['schedule'][-1]["entityId"] = record["entity"].id
G.outputJSON['elementList'].append(json)
#===========================================================================
......
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