lib/y_petri/simulation/timed.rb in y_petri-2.1.42 vs lib/y_petri/simulation/timed.rb in y_petri-2.1.44

- old
+ new

@@ -151,10 +151,11 @@ # parametrized subclasses +@Core+ and +@Recorder+, and initializes the # +@recorder+ attribute. # def init **settings method = settings[:method] # the simulation method + features_to_record = settings[:record] if settings.has? :time, syn!: :time_range then # time range given case settings[:time] when Range then time_range = settings[:time] @initial_time, @target_time = time_range.begin, time_range.end @@ -175,10 +176,22 @@ init_core_and_recorder_subclasses reset_time! @step = settings[:step] || time_unit @default_sampling = settings[:sampling] || step @core = Core().new( method: method, guarded: guarded ) - @recorder = Recorder().new sampling: settings[:sampling] + @recorder = if features_to_record then + # we'll have to figure out features + ff = case features_to_record + when Array then + net.State.Features + .infer_from_elements( features_to_record ) + when Hash then + net.State.features( features_to_record ) + end + Recorder().new( sampling: settings[:sampling], features: ff ) + else + Recorder().new( sampling: settings[:sampling] ) + end end # Sets up subclasses of +Core+ (the simulator) and +Recorder+ (the sampler) # for timed simulations. #