ReadyValidChannelActivity.burst constructor

ReadyValidChannelActivity.burst({
  1. required int length,
  2. required int period,
  3. int startCycle = 0,
})

Creates a periodic burst beginning at startCycle.

Implementation

factory ReadyValidChannelActivity.burst(
    {required int length, required int period, int startCycle = 0}) {
  if (startCycle < 0) {
    throw ArgumentError.value(
        startCycle, 'startCycle', 'Must not be negative.');
  }
  if (length < 1) {
    throw ArgumentError.value(length, 'length', 'Must be at least one.');
  }
  if (period < length) {
    throw ArgumentError.value(
        period, 'period', 'Must be at least the burst length.');
  }

  return ReadyValidChannelActivity._(
      (cycle) =>
          cycle >= startCycle && (cycle - startCycle) % period < length,
      'burst($startCycle,$length,$period)');
}