Class: YPetri::Simulation::Timed::Recorder
- Defined in:
- lib/y_petri/simulation/timed/recorder.rb
Overview
Timed aspect of the recorder.
Constant Summary collapse
- TIME_DECIMAL_PLACES =
5
Constants inherited from Recorder
Recorder::SAMPLING_DECIMAL_PLACES
Instance Attribute Summary collapse
-
#next_time ⇒ Object
readonly
Returns the value of attribute next_time.
-
#sampling ⇒ Object
Returns the value of attribute sampling.
Attributes inherited from Recorder
Instance Method Summary collapse
-
#alert ⇒ Object
Hook to be called by simulators whenever the state changes (every time that simulation
time
is incremented). -
#initialize(sampling: default_sampling, next_time: time, **nn) ⇒ Recorder
constructor
Apart from the vanilla version arguments, timed recorder takes
:sampling
argument. -
#new_recording ⇒ Object
Construct a new recording based on
features
. -
#reset!(sampling: default_sampling, next_time: time, **nn) ⇒ Object
Like YPetri::Simulation::Recorder#reset, but allowing for an additional named argument
:next_time
that sets the next sampling time, and +:sampling:, resetting the sampling period.
Methods inherited from Recorder
Constructor Details
#initialize(sampling: default_sampling, next_time: time, **nn) ⇒ Recorder
Apart from the vanilla version arguments, timed recorder takes :sampling
argument.
16 17 18 19 20 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 16 def initialize sampling: default_sampling, next_time: time, **nn super @sampling = sampling @next_time = next_time end |
Instance Attribute Details
#next_time ⇒ Object (readonly)
Returns the value of attribute next_time.
7 8 9 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 7 def next_time @next_time end |
#sampling ⇒ Object
Returns the value of attribute sampling.
8 9 10 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 8 def sampling @sampling end |
Instance Method Details
#alert ⇒ Object
Hook to be called by simulators whenever the state changes (every time that simulation time
is incremented).
41 42 43 44 45 46 47 48 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 41 def alert t = time.round( 9 ) t2 = next_time.round( 9 ) if t >= t2 then # it's time to sample sample! @next_time += sampling end end |
#new_recording ⇒ Object
Construct a new recording based on features
.
24 25 26 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 24 def new_recording features.new_dataset type: :timed end |
#reset!(sampling: default_sampling, next_time: time, **nn) ⇒ Object
Like YPetri::Simulation::Recorder#reset, but allowing for an additional named argument :next_time
that sets the next sampling time, and +:sampling:, resetting the sampling period.
32 33 34 35 36 |
# File 'lib/y_petri/simulation/timed/recorder.rb', line 32 def reset! sampling: default_sampling, next_time: time, **nn super @sampling = sampling @next_time = next_time end |