32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import salabim as sim
|
|
import numpy as np
|
|
from math import exp
|
|
|
|
|
|
class RetryDelay(sim.Component):
|
|
"""
|
|
This class represents the human operator retry delay type of fault.
|
|
Simulated RetryDelay faults only apply to BowlFeeders.
|
|
人为操作员重试延迟类型的故障。 模拟重试延迟故障
|
|
"""
|
|
def __init__(self, module, debug=True):
|
|
super(RetryDelay, self).__init__()
|
|
self.debug = debug
|
|
self.t = 0
|
|
self.module = module
|
|
|
|
def process(self):
|
|
self.t = self.t + 1
|
|
# (poissrnd((exp(t/5)-1)/4) * 0.2 + 1)
|
|
# Note: The factor is zero-based so that it can be added as a separate delay.
|
|
delay_factor = np.random.poisson((exp(self.t/5)-1)/4) * 0.2 # 泊松分布
|
|
if self.debug:
|
|
print("FAULT: RETRY_DELAY: ", delay_factor)
|
|
yield self.add_delay(self.module.duration, delay_factor), 1
|
|
|
|
def add_delay(self, delay, delay_factor):
|
|
return delay * delay_factor
|
|
|
|
# def spawn(self):
|
|
# return self.env.process(self.process())
|