Class: YPetri::Simulation::MarkingClamps

Inherits:
PlaceMapping
  • Object
show all
Defined in:
lib/y_petri/simulation/marking_clamps/access.rb,
lib/y_petri/simulation/marking_clamps.rb

Overview

Simulation mixin providing access to the marking clamps.

Defined Under Namespace

Modules: Access

Instance Method Summary collapse

Methods inherited from PlaceMapping

#delete, #fetch, #keys_to_source_places, #load, load, #vector

Instance Method Details

#set(place_id, to: (fail ArgumentError, "No :to value!")) ⇒ Object

Sets the clamp for a given place to a given value.



7
8
9
10
11
12
13
14
# File 'lib/y_petri/simulation/marking_clamps.rb', line 7

def set place_id, to: (fail ArgumentError, "No :to value!")
  pl = place( place_id )
  # free places change into clamped ones.
  initial_marking.delete pl if begin # fails if initial marking not set yet
                                 pl.free?
                               rescue TypeError, NoMethodError; end
  super
end