lib/SimControl/controller.rb in SimControl-0.1.2 vs lib/SimControl/controller.rb in SimControl-0.1.3

- old
+ new

@@ -2,10 +2,11 @@ class Controller attr_reader :current_simulation def initialize(hostname, simulation_description, scenario_description, results_directory, args = {}) @hosts = args.delete(:hosts) || SimControl::Hosts.new + @scenario_klass = args.delete(:scenario_klass) || SimControl::Scenario @hostname = hostname @simulation_description = simulation_description @scenario_description = scenario_description @results_directory = results_directory @@ -14,10 +15,14 @@ @meta_seed = 13 @max_seed = 2**(32 - 1) - 1 end + def create_scenario(*args) + @scenario_klass.new(*args) + end + def run instance_eval(@simulation_description) instance_eval(@scenario_description) host_scenarios = @hosts.partition(all_scenarios, @hostname) @@ -51,11 +56,11 @@ def seeds @rng = Random.new(@meta_seed) (1..@number_of_repetitions).map { @rng.rand(@max_seed) } end - def simulate(scenario) - @scenarios << scenario + def simulate(*scenario) + @scenarios << (create_scenario *scenario) end def all_scenarios @scenarios end