# ===========================================================================# 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 18 Aug 2013@author: George""""""Class that acts as an abstract. It should have no instances. All the Entities should inherit from it"""# from SimPy.Simulation import nowfrommanpy.simulation.ManPyObjectimportManPyObjectfrommanpy.simulation.core.GlobalsimportG
[docs]classEntity(ManPyObject):"""The entity object."""type="Entity"def__init__(self,id=None,name=None,priority=0,dueDate=0,orderDate=0,isCritical=False,remainingProcessingTime=0,remainingSetupTime=0,currentStation=None,status="Good",**kw):ManPyObject.__init__(self,id,name)# information on the object holding the entity# initialized as None and updated every time an entity enters a new object# information on the lifespan of the entityself.creationTime=0self.startTime=0# holds the startTime for the lifespan# dimension data of the entityself.width=1.0self.height=1.0self.length=1.0# information concerning the sorting of the entities inside (for example) queuesself.priority=float(priority)self.dueDate=float(dueDate)self.orderDate=float(orderDate)# a list that holds information about the schedule# of the entity (when it enters and exits every station)self.schedule=[]# the current station of the entityself.currentStation=currentStation# values to be used in the internal processing of compoundObjectsself.internal=False# informs if the entity is being processed internallyifisinstance(isCritical,str):self.isCritical=bool(int(isCritical))elifisinstance(isCritical,int):self.isCritical=bool(isCritical)# flag to inform weather the entity is critical -> preemptionelse:self.isCritical=isCriticalself.manager=None# default valueself.numberOfUnits=1# default value# variable used to differentiate entities with and entities without routesself.family="Entity"# variables to be used by OperatorRouterself.proceed=False# boolean that is used to check weather the entity can proceed to the candidateReceiverself.candidateReceivers=([])# list of candidateReceivers of the entity (those stations that can receive the entityself.candidateReceiver=(None# the station that is finaly chosen to receive the entity)# alias used for printing the Routeself.alias=Noneself.remainingProcessingTime=remainingProcessingTimeself.remainingSetupTime=remainingSetupTimeself.status=status# setup lists for features and timeseriesself.labels=[None]*len(G.ftr_st)self.features=[None]*len(G.ftr_st)self.feature_times=[None]*len(G.ftr_st)self.timeseries=[None]*len(G.ts_st)self.timeseries_times=[None]*len(G.ts_st)self.result=Noneself.cost=0
[docs]defresponsibleForCurrentStep(self):"""return the responsible operator for the current step, not implemented for entities"""returnNone
[docs]defoutputResultsJSON(self):"""outputs results to JSON File"""pass
[docs]definitialize(self):"""initializes all the Entity for a new simulation replication"""pass
[docs]defprintRoute(self):"""print the route (the different stations the entity moved through)"""pass
[docs]defcheckIfRequiredPartsReady(self):"""method not implemented yet"""returnTrue
[docs]defgetRequiredParts(self):"""method not implemented yet"""return[]
[docs]defset_feature(self,feature,label,time,indexing):"""sets internal feature values to passed values"""self.labels[G.ftr_st.index(indexing)]=labelself.features[G.ftr_st.index(indexing)]=featureself.feature_times[G.ftr_st.index(indexing)]=time
[docs]defset_timeseries(self,timeseries,label,time,indexing):"""sets internal timeseries values to passed values"""self.labels[G.ts_st.index(indexing)]=labelself.timeseries[G.ts_st.index(indexing)]=timeseriesself.timeseries_times[G.ts_st.index(indexing)]=time