31 lines
859 B
Python
31 lines
859 B
Python
from math import exp
|
|
import salabim as sim
|
|
|
|
|
|
class WearAndTear(sim.Component):
|
|
|
|
def __init__(self, module, debug=True):
|
|
super(WearAndTear, self).__init__()
|
|
self.debug = debug
|
|
self.t = 0
|
|
self.module = module
|
|
|
|
def process(self):
|
|
# with self.request() as req:
|
|
# yield req
|
|
# yield self.request()
|
|
self.t = self.t + 1
|
|
# ((exp(t / 5.0) - 1) / 30 + 1)
|
|
# Note: The factor is zero-based so that it can be added as a separate delay.
|
|
delay_factor = (exp(self.t / 5.0) - 1) / 30
|
|
extra_delay = delay_factor * self.module.duration
|
|
if self.debug:
|
|
print("FAULT: WEAR_AND_TEAR ", extra_delay)
|
|
yield self.hold(extra_delay)
|
|
return
|
|
|
|
def spawn(self):
|
|
return self.process()
|
|
|
|
|
|
# wear_and_tear = sim.Resource("wear_and_tear",10) |