class Symian::IncidentGenerator

Public Class Methods

new(simulation, options={}) click to toggle source
# File lib/symian/generator.rb, line 10
def initialize(simulation, options={})
  @simulation = simulation

  @arrival_times = Sequence.create(options)
  raise ArgumentError unless @arrival_times

  # NOTE: so far we support only sequential integer iids
  @next_iid = 0
end

Public Instance Methods

generate() click to toggle source
# File lib/symian/generator.rb, line 21
def generate
  # get next incident arrival time
  next_arrival = @arrival_times.next

  # handle case where arrival times is limited source
  return nil unless next_arrival

  # increase @next_iid
  @next_iid += 1

  # generate and return incident
  i = Incident.new(@next_iid, next_arrival,
                   :category => 'normal', # not supported at the moment
                   :priority => 0)        # not supported at the moment

  @simulation.new_event(Event::ET_INCIDENT_ARRIVAL, i, next_arrival, nil)
end