Commit a4b1cf0e authored by Georgios Dagkakis's avatar Georgios Dagkakis

more methods moved to ManPyObject

parent b7d78ef7
......@@ -612,25 +612,7 @@ class CoreObject(ManPyObject):
activeObject.Loading.append(100*self.totalLoadTime/MaxSimtime)
activeObject.SettingUp.append(100*self.totalSetupTime/MaxSimtime)
activeObject.OffShift.append(100*self.totalOffShiftTime/MaxSimtime)
# =======================================================================
# outputs message to the trace.xls
# =======================================================================
#outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
def outputTrace(self, entityName, message):
from Globals import G
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(self.env.now))
G.traceSheet.write(G.traceIndex,1,entityName)
G.traceSheet.write(G.traceIndex,2,message)
G.traceIndex+=1 #increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation)
if(G.traceIndex==65536):
G.traceIndex=0
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
# =======================================================================
# outputs data to "output.xls"
......
......@@ -152,7 +152,7 @@ class Failure(ObjectInterruption):
self.victim.Up=False
self.victim.timeLastFailure=self.env.now
self.outputTrace("is down")
self.outputTrace(self.victim.name,"is down")
# update the failure time
failTime=self.env.now
if(self.repairman and self.repairman!="None"): # if the failure needs a resource to be fixed,
......@@ -169,7 +169,7 @@ class Failure(ObjectInterruption):
self.victim.totalFailureTime+=self.env.now-failTime
self.reactivateVictim() # since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
self.outputTrace(self.victim.name,"is up")
self.repairman.totalWorkingTime+=self.env.now-timeOperationStarted
continue
......@@ -194,4 +194,4 @@ class Failure(ObjectInterruption):
self.victim.totalFailureTime+=self.env.now-failTime
self.reactivateVictim() # since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
self.outputTrace(self.victim.name,"is up")
......@@ -113,3 +113,40 @@ class ManPyObject(object):
print phrase,arg,suffix
else:
print phrase,arg
# =======================================================================
# outputs message to the trace.xls
# outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
# =======================================================================
@staticmethod
def outputTrace(entityName, message):
from Globals import G
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(G.env.now))
G.traceSheet.write(G.traceIndex,1,entityName)
G.traceSheet.write(G.traceIndex,2,message)
G.traceIndex+=1 #increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation)
if(G.traceIndex==65536):
G.traceIndex=0
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#===========================================================================
# actions to be performed after the end of the simulation
#===========================================================================
def postProcessing(self):
pass
# =======================================================================
# outputs data to "output.xls"
# =======================================================================
def outputResultsXL(self, MaxSimtime=None):
pass
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
pass
\ No newline at end of file
......@@ -74,12 +74,6 @@ class ObjectInterruption(ManPyObject):
def invoke(self):
self.isCalled.succeed(self.env.now)
#===========================================================================
# outputs data to "output.xls"
#===========================================================================
def outputTrace(self, message):
pass
#===========================================================================
# returns the internal queue of the victim
#===========================================================================
......@@ -92,12 +86,7 @@ class ObjectInterruption(ManPyObject):
def victimQueueIsEmpty(self):
return len(self.getVictimQueue())==0
#===========================================================================
# actions to be performed after the end of the simulation
#===========================================================================
def postProcessing(self):
pass
#===========================================================================
# interrupts the victim
#===========================================================================
......@@ -124,24 +113,7 @@ class ObjectInterruption(ManPyObject):
if self.victim.dedicatedOperator:
# request allocation
self.victim.requestAllocation()
#===========================================================================
# outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
#===========================================================================
def outputTrace(self, message):
from Globals import G
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(self.env.now))
G.traceSheet.write(G.traceIndex,1, self.victim.objName)
G.traceSheet.write(G.traceIndex,2,message)
G.traceIndex+=1 #increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation)
if(G.traceIndex==65536):
G.traceIndex=0
G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#===========================================================================
# prints message to the console
#===========================================================================
......
......@@ -65,30 +65,7 @@ class ObjectResource(ManPyObject):
def checkIfResourceIsAvailable(self,callerObject=None):
return len(self.Res.users)<self.capacity
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
def postProcessing(self, MaxSimtime=None):
pass
# =======================================================================
# outputs message to the trace.xls
# =======================================================================
def outputTrace(self, message):
pass
# =======================================================================
# outputs data to "output.xls"
# =======================================================================
def outputResultsXL(self, MaxSimtime=None):
pass
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
pass
# =======================================================================
# returns the resource
# =======================================================================
......
......@@ -99,7 +99,7 @@ class ScheduledMaintenance(ObjectInterruption):
self.interruptVictim()
self.victim.Up=False
self.victim.timeLastFailure=self.env.now
self.outputTrace("is down")
self.outputTrace(self.victim.name,"is down")
except AttributeError:
print "AttributeError1"
......@@ -110,7 +110,7 @@ class ScheduledMaintenance(ObjectInterruption):
if(len(self.getVictimQueue())>0):
self.reactivateVictim() # since the maintenance is over, the victim is reactivated
self.victim.Up=True
self.outputTrace("is up")
self.outputTrace(self.victim.name,"is up")
except AttributeError:
print "AttributeError2"
......
......@@ -68,7 +68,7 @@ class ShiftScheduler(ObjectInterruption):
self.victim.onShift=False
self.interruptVictim() # interrupt processing operations if any
self.victim.timeLastShiftEnded=self.env.now
self.outputTrace("is off shift")
self.outputTrace(self.victim.name,"is off shift")
while 1:
if not self.victim.onShift:
......@@ -83,7 +83,7 @@ class ShiftScheduler(ObjectInterruption):
self.victim.totalOffShiftTime+=self.env.now-self.victim.timeLastShiftEnded
self.victim.onShift=True
self.victim.timeLastShiftStarted=self.env.now
self.outputTrace("is on shift")
self.outputTrace(self.victim.name,"is on shift")
startShift=self.env.now
else:
timeToEndShift=float(self.remainingShiftPattern[0][1]-self.env.now)
......@@ -109,7 +109,7 @@ class ShiftScheduler(ObjectInterruption):
self.interruptVictim() # interrupt the victim
self.victim.onShift=False # get the victim off-shift
self.victim.timeLastShiftEnded=self.env.now
self.outputTrace("is off shift")
self.outputTrace(self.victim.name,"is off shift")
self.remainingShiftPattern.pop(0)
if len(self.remainingShiftPattern)==0:
......
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