new object OperatorManagedJob

parent 8b548ec6
......@@ -79,6 +79,7 @@ from BatchScrapMachine import BatchScrapMachine
from LineClearance import LineClearance
from EventGenerator import EventGenerator
from Operator import Operator
from OperatorManagedJob import OperatorManagedJob
from OperatorPool import OperatorPool
from OperatedPoolBroker import Broker
from OperatedMachine import OperatedMachine
......@@ -162,6 +163,7 @@ def createObjects():
G.LineClearanceList=[]
G.EventGeneratorList=[]
G.OperatorsList = []
G.OperatorManagedJobsList = []
G.OperatorPoolsList = []
G.BrokersList = []
G.OperatedMachineList = []
......@@ -203,6 +205,16 @@ def createObjects():
# calling the getSuccesorList() method on the operator
G.OperatorsList.append(O) # add the operator to the RepairmanList
G.ModelResourceList.append(O)
elif resourceClass=='Dream.OperatorManagedJob':
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'
capacity = int(element.get('capacity', '1')) # get the capacity of the el. / defautl '1'
O = OperatorManagedJob(element_id, name, capacity) # create an operator object
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
# calling the getSuccesorList() method on the operator
G.OperatorsList.append(O) # add the operator to the RepairmanList
G.OperatorManagedJobsList.append(O)
G.ModelResourceList.append(O)
# -----------------------------------------------------------------------
# loop through all the model resources
# search for operatorPools in order to create them
......
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 13 Feb 2013
@author: Ioannis
'''
'''
models a entity/job assigned operator (manager)
'''
from SimPy.Simulation import Resource, now
from Operator import Operator
# ===========================================================================
# the resource that operates the machines
# ===========================================================================
class OperatorManagedJob(Operator):
def __init__(self, id, name, capacity=1):
Operator.__init__(self,id=id,name=name,capacity=capacity)
self.operatorAssignedTo=None
# =======================================================================
# checks if the worker is available
# it is called only by the have to dispose of a QueueManagedJob
# and its sortEntities
# =======================================================================
def checkIfResourceIsAvailable(self,callerObject=None):
activeResourceQueue = self.getResourceQueue()
# in case the operator has the flag operatorAssigned raised
# (meaning the operator will explicitly be assigned to a machine)
# return false even if he is free
# If there is no callerObject defined then do not check the operatorAssignedTo variable
if callerObject:
# if the operator is not yet assigned then return the default behaviour
if self.operatorAssignedTo==None:
return len(activeResourceQueue)<self.capacity
# otherwise, in case the operator is occupied, check if the occupier is the
# object the operator is assigned to
else:
if len(activeResourceQueue):
if self.operatorAssignedTo==activeResourceQueue[0].victim:
return self.operatorAssignedTo==callerObject
return (self.operatorAssignedTo==callerObject) and len(self.Res.activeQ)<self.capacity
# otherwise, (if the callerObject is None) check if the operator is assigned and if yes
# then perform the default behaviour
else:
# if self.operatorAssignedTo==None:
# return False
return len(self.Res.activeQ)<self.capacity
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