class YPetri::Simulation::Places
Place collection for YPetri::Simulation
.
Simulation mixin providing access to places.
A mixin for collections of free places.
A mixin for collections of free places.
A mixin with place type selectors.
Public Instance Methods
marking()
click to toggle source
Marking of the place collection in the current simulation.
# File lib/y_petri/simulation/places.rb, line 21 def marking simulation.M self end
push(place)
click to toggle source
Pushes a place to the collection.
Calls superclass method
# File lib/y_petri/simulation/places.rb, line 12 def push place p = begin; net.place( place ); rescue NameError, TypeError return super place( place ) end super p.name ? PlacePS().new( p, name: p.name ) : PlacePS().new( p ) end
Private Instance Methods
complete_initial_marking( use_default_marking: true )
click to toggle source
Ensures that all the places that are not clamped have their initial marking set. Optional argument :use_default_marking is set to true by default, in which case own default marking of the source places is used if it was not specified when constructing the simulation. If set to false, then presence of places with missing initial marking simply raises errors.
# File lib/y_petri/simulation/places.rb, line 33 def complete_initial_marking( use_default_marking: true ) offenders = reject { |place| ( free + clamped ).include? place } fail TypeError, "All places must have default marking or clamp!" unless use_default_marking unless offenders.empty? offenders.each { |place| dm = place.source.default_marking fail TypeError, "#{place.source} has no default marking!" if dm.nil? simulation.send( :set_initial_marking, place, to: dm ) } end