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 eb1a75c3
...@@ -1078,6 +1078,9 @@ class Machine(CoreObject): ...@@ -1078,6 +1078,9 @@ class Machine(CoreObject):
# ======================================================================= # =======================================================================
def getEntity(self): 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 # after the machine receives an entity, it must be removed from the pendingEntities list
from Globals import G from Globals import G
if G.Router: if G.Router:
...@@ -1149,7 +1152,7 @@ class Machine(CoreObject): ...@@ -1149,7 +1152,7 @@ class Machine(CoreObject):
# If yes the time that he was set off-shift should be updated # If yes the time that he was set off-shift should be updated
operator=self.currentOperator operator=self.currentOperator
operator.schedule[-1]["exitTime"] = self.env.now 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: if not self.currentOperator.onShift:
operator.timeLastShiftEnded=self.env.now operator.timeLastShiftEnded=self.env.now
operator.unAssign() # set the flag operatorAssignedTo to None operator.unAssign() # set the flag operatorAssignedTo to None
......
...@@ -60,6 +60,11 @@ class MachineJobShop(Machine): ...@@ -60,6 +60,11 @@ class MachineJobShop(Machine):
self.stpRng=RandomNumberGenerator(self, setupTime) self.stpRng=RandomNumberGenerator(self, setupTime)
# check if there is a need for manual processing # check if there is a need for manual processing
self.checkForManualOperation(type='Setup',entity=activeEntity) 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 removedStep = activeEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
return activeEntity return activeEntity
......
...@@ -161,6 +161,30 @@ class Broker(ObjectInterruption): ...@@ -161,6 +161,30 @@ class Broker(ObjectInterruption):
# update the schedule of the operator # update the schedule of the operator
self.victim.currentOperator.schedule.append({"station": self.victim, self.victim.currentOperator.schedule.append({"station": self.victim,
"entranceTime": self.env.now}) "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 # wait till the processing is over
self.expectedSignals['isCalled']=1 self.expectedSignals['isCalled']=1
......
...@@ -297,15 +297,13 @@ class Operator(ObjectResource): ...@@ -297,15 +297,13 @@ class Operator(ObjectResource):
stationId=record["station"].id stationId=record["station"].id
except AttributeError: except AttributeError:
stationId=record["station"]['id'] stationId=record["station"]['id']
if record.get("exitTime", None) != None:
json['results']['schedule'].append({
'stationId':stationId,
'entranceTime':record["entranceTime"],
'exitTime':record["exitTime"]})
else:
json['results']['schedule'].append({ json['results']['schedule'].append({
'stationId':stationId, 'stationId':stationId,
'entranceTime':record["entranceTime"]}) 'entranceTime':record["entranceTime"]})
if record.get("exitTime", None) != None:
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) 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