Commit a7b17789 authored by Georgios Dagkakis's avatar Georgios Dagkakis

first version of ManPyObject. All abstract classes inherit from it

parent 0302f672
...@@ -27,15 +27,16 @@ Class that acts as an abstract. It should have no instances. All the core-object ...@@ -27,15 +27,16 @@ Class that acts as an abstract. It should have no instances. All the core-object
# from SimPy.Simulation import Process, Resource, now, SimEvent, waitevent # from SimPy.Simulation import Process, Resource, now, SimEvent, waitevent
import simpy import simpy
from ManPyObject import ManPyObject
# =========================================================================== # ===========================================================================
# the core object # the core object
# =========================================================================== # ===========================================================================
class CoreObject(object): class CoreObject(ManPyObject):
class_name = 'Dream.CoreObject' class_name = 'Dream.CoreObject'
def __init__(self, id, name, inputsDict={}, **kw): def __init__(self, id, name, inputsDict={}, **kw):
self.id = id ManPyObject.__init__(self,id,name)
self.objName = name self.objName = name
# lists that hold the previous and next objects in the flow # lists that hold the previous and next objects in the flow
self.next=[] #list with the next objects in the flow self.next=[] #list with the next objects in the flow
......
...@@ -27,17 +27,17 @@ Class that acts as an abstract. It should have no instances. All the Entities sh ...@@ -27,17 +27,17 @@ Class that acts as an abstract. It should have no instances. All the Entities sh
# from SimPy.Simulation import now # from SimPy.Simulation import now
import simpy import simpy
from ManPyObject import ManPyObject
# =========================================================================== # ===========================================================================
# The entity object # The entity object
# =========================================================================== # ===========================================================================
class Entity(object): class Entity(ManPyObject):
type="Entity" type="Entity"
def __init__(self, id=None, name=None, priority=0, dueDate=0, orderDate=0, def __init__(self, id=None, name=None, priority=0, dueDate=0, orderDate=0,
isCritical=False, remainingProcessingTime=0,currentStation=None,**kw): isCritical=False, remainingProcessingTime=0,currentStation=None,**kw):
self.name=name ManPyObject.__init__(self,id,name)
self.id=id
# information on the object holding the entity # information on the object holding the entity
# initialized as None and updated every time an entity enters a new object # initialized as None and updated every time an entity enters a new object
# information on the lifespan of the entity # information on the lifespan of the entity
......
...@@ -34,10 +34,9 @@ from ObjectInterruption import ObjectInterruption ...@@ -34,10 +34,9 @@ from ObjectInterruption import ObjectInterruption
class Failure(ObjectInterruption): class Failure(ObjectInterruption):
def __init__(self, victim=None, distribution=None, index=0, repairman=None, offshift=False, def __init__(self, id='',name='',victim=None, distribution=None, index=0, repairman=None, offshift=False,
deteriorationType='constant',**kw): deteriorationType='constant',**kw):
#Process.__init__(self) ObjectInterruption.__init__(self,id,name,victim=victim)
ObjectInterruption.__init__(self,victim)
if distribution: if distribution:
self.distType=distribution.get('distributionType','No') # the distribution that the failure duration follows self.distType=distribution.get('distributionType','No') # the distribution that the failure duration follows
self.MTTF=distribution.get('MTTF',60) # the MTTF self.MTTF=distribution.get('MTTF',60) # the MTTF
...@@ -146,8 +145,7 @@ class Failure(ObjectInterruption): ...@@ -146,8 +145,7 @@ class Failure(ObjectInterruption):
self.victimStartsProcess=self.env.event() self.victimStartsProcess=self.env.event()
else: else:
failureNotTriggered=False failureNotTriggered=False
# interrupt the victim only if it was not previously interrupted # interrupt the victim only if it was not previously interrupted
if not self.victim.interruptionStart.triggered: if not self.victim.interruptionStart.triggered:
self.interruptVictim() # interrupt the victim self.interruptVictim() # interrupt the victim
......
...@@ -297,7 +297,7 @@ def createObjectInterruptions(): ...@@ -297,7 +297,7 @@ def createObjectInterruptions():
else: else:
victim=Globals.findObjectById(element['id']) victim=Globals.findObjectById(element['id'])
deteriorationType=failure.get('deteriorationType', 'constant') deteriorationType=failure.get('deteriorationType', 'constant')
F=Failure(victim, distribution=failure, repairman=victim.repairman, deteriorationType=deteriorationType) F=Failure(victim=victim, distribution=failure, repairman=victim.repairman, deteriorationType=deteriorationType)
G.ObjectInterruptionList.append(F) G.ObjectInterruptionList.append(F)
G.FailureList.append(F) G.FailureList.append(F)
# if there is a shift pattern defined # if there is a shift pattern defined
...@@ -317,7 +317,7 @@ def createObjectInterruptions(): ...@@ -317,7 +317,7 @@ def createObjectInterruptions():
shiftPattern.remove(next) shiftPattern.remove(next)
endUnfinished=bool(int(shift.get('endUnfinished', 0))) endUnfinished=bool(int(shift.get('endUnfinished', 0)))
receiveBeforeEndThreshold=float(shift.get('receiveBeforeEndThreshold', 0)) receiveBeforeEndThreshold=float(shift.get('receiveBeforeEndThreshold', 0))
SS=ShiftScheduler(victim, shiftPattern=shiftPattern, endUnfinished=endUnfinished, SS=ShiftScheduler(victim=victim, shiftPattern=shiftPattern, endUnfinished=endUnfinished,
receiveBeforeEndThreshold=receiveBeforeEndThreshold) receiveBeforeEndThreshold=receiveBeforeEndThreshold)
G.ObjectInterruptionList.append(SS) G.ObjectInterruptionList.append(SS)
G.ShiftSchedulerList.append(SS) G.ShiftSchedulerList.append(SS)
......
...@@ -254,7 +254,7 @@ class Machine(CoreObject): ...@@ -254,7 +254,7 @@ class Machine(CoreObject):
def createBroker(self): def createBroker(self):
# initiate the Broker and the router # initiate the Broker and the router
if (self.operatorPool!='None'): if (self.operatorPool!='None'):
self.broker=Broker(self) self.broker=Broker(operatedMachine=self)
#=========================================================================== #===========================================================================
# create router if needed # create router if needed
......
...@@ -59,13 +59,7 @@ class MachineManagedJob(MachineJobShop): ...@@ -59,13 +59,7 @@ class MachineManagedJob(MachineJobShop):
from Globals import G from Globals import G
G.OperatorPoolsList.append(self.operatorPool) G.OperatorPoolsList.append(self.operatorPool)
#===========================================================================
# create broker if needed
#===========================================================================
def createBroker(self):
#create a Broker
self.broker = Broker(self)
#=========================================================================== #===========================================================================
# create router if needed # create router if needed
#=========================================================================== #===========================================================================
......
# ===========================================================================
# 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 08 Sep 2014
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All ManPy objects inherit from it
Also only abstract ManPy classes inherit directly (CoreObject, Entity, ObjectResource, ObjectInterruption)
'''
# ===========================================================================
# the ManPy object
# ===========================================================================
class ManPyObject(object):
def __init__(self, id, name,**kw):
self.id=id
self.name=name
...@@ -28,13 +28,15 @@ Class that acts as an abstract. It should have no instances. All object interrup ...@@ -28,13 +28,15 @@ Class that acts as an abstract. It should have no instances. All object interrup
# from SimPy.Simulation import Process, Resource, reactivate, now # from SimPy.Simulation import Process, Resource, reactivate, now
import simpy import simpy
from ManPyObject import ManPyObject
#=============================================================================== #===============================================================================
# The ObjectInterruption process # The ObjectInterruption process
#=============================================================================== #===============================================================================
class ObjectInterruption(object): class ObjectInterruption(ManPyObject):
def __init__(self, victim=None,**kw): def __init__(self, id='',name='',victim=None,**kw):
ManPyObject.__init__(self,id,name)
self.victim=victim self.victim=victim
# variable used to hand in control to the objectInterruption # variable used to hand in control to the objectInterruption
self.call=False self.call=False
......
...@@ -26,13 +26,15 @@ Class that acts as an abstract. It should have no instances. All the Resources s ...@@ -26,13 +26,15 @@ Class that acts as an abstract. It should have no instances. All the Resources s
''' '''
# from SimPy.Simulation import Resource # from SimPy.Simulation import Resource
import simpy import simpy
from ManPyObject import ManPyObject
# =========================================================================== # ===========================================================================
# the resource that repairs the machines # the resource that repairs the machines
# =========================================================================== # ===========================================================================
class ObjectResource(object): class ObjectResource(ManPyObject):
def __init__(self,**kw): def __init__(self,id='',name='',**kw):
ManPyObject.__init__(self,id,name)
self.initialized = False self.initialized = False
# list that holds the objectInterruptions that have this element as victim # list that holds the objectInterruptions that have this element as victim
self.objectInterruptions=[] self.objectInterruptions=[]
......
...@@ -41,8 +41,8 @@ class Broker(ObjectInterruption): ...@@ -41,8 +41,8 @@ class Broker(ObjectInterruption):
# The Broker is initiated within the Machine and considered as # The Broker is initiated within the Machine and considered as
# black box for the ManPy end Developer # black box for the ManPy end Developer
# ======================================================================= # =======================================================================
def __init__(self, operatedMachine): def __init__(self, id='',name='', operatedMachine=None):
ObjectInterruption.__init__(self,operatedMachine) ObjectInterruption.__init__(self,id,name,victim=operatedMachine)
self.type = "Broker" self.type = "Broker"
# variables that have to do with timing # variables that have to do with timing
self.timeOperationStarted = 0 self.timeOperationStarted = 0
......
...@@ -38,14 +38,14 @@ class ScheduledMaintenance(ObjectInterruption): ...@@ -38,14 +38,14 @@ class ScheduledMaintenance(ObjectInterruption):
# ======================================================================= # =======================================================================
# the __init__() method of the class # the __init__() method of the class
# ======================================================================= # =======================================================================
def __init__(self, victim=None, start=0, duration=1, endStatus='interrupted',**kw): def __init__(self, id='',name='',victim=None, start=0, duration=1, endStatus='interrupted',**kw):
''' '''
interrupted : the maintenance starts immediately interrupted : the maintenance starts immediately
loaded : the maintenance starts as soon as the victim has ended processing loaded : the maintenance starts as soon as the victim has ended processing
emptied : the maintenance starts as soon as the victim is empty emptied : the maintenance starts as soon as the victim is empty
''' '''
self.type="ScheduledMaintenance" self.type="ScheduledMaintenance"
ObjectInterruption.__init__(self,victim) ObjectInterruption.__init__(self,victim=victim)
self.start=start self.start=start
self.duration=duration self.duration=duration
# the victim can be 'interrupted', 'loaded' or 'emptied' when the maintenance interruption happens # the victim can be 'interrupted', 'loaded' or 'emptied' when the maintenance interruption happens
......
...@@ -39,8 +39,8 @@ class ShiftScheduler(ObjectInterruption): ...@@ -39,8 +39,8 @@ class ShiftScheduler(ObjectInterruption):
# ======================================================================= # =======================================================================
# the __init__() method of the class # the __init__() method of the class
# ======================================================================= # =======================================================================
def __init__(self, victim=None, shiftPattern=[], endUnfinished=False, receiveBeforeEndThreshold=0.0,**kw): def __init__(self, id='', name='', victim=None, shiftPattern=[], endUnfinished=False, receiveBeforeEndThreshold=0.0,**kw):
ObjectInterruption.__init__(self,victim) ObjectInterruption.__init__(self,victim=victim)
self.type='ShiftScheduler' self.type='ShiftScheduler'
self.shiftPattern=shiftPattern self.shiftPattern=shiftPattern
self.endUnfinished=endUnfinished #flag that shows if half processed Jobs should end after the shift ends self.endUnfinished=endUnfinished #flag that shows if half processed Jobs should end after the shift ends
......
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