Sha256: 0bdf790dadda8167f0d7d81dcc8c417301f17356998cc77ba26a45822561ae8e

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

#encoding: utf-8

# Representation of a YPetri::Place inside a YPetri::Simulation instance.
# 
class YPetri::Simulation
  class PlaceRepresentation < ElementRepresentation
    # Index
    def m_vector_index
      places.index( self )
    end

    # Expect a single YPetri place as an argument.
    # 
    def initialize net_place
      super
    end

    # Setter of clamp.
    # 
    def clamp=( value )
      simulation.set_marking_clamp( of: self, to: value )
    end

    # Setter of initial marking.
    # 
    def initial_marking=( value )
      simulation.set_initial_marking( of: self, to: value )
    end

    # Marking clamp value (or nil, if the place is clamped).
    # 
    def marking_clamp
      simulation.marking_clamp of: self if clamped?
    end
    alias clamp marking_clamp

    # Initial marking value (or nil, if the place is free).
    # 
    def initial_marking
      simulation.initial_marking[ self ] if free?
    end

    # Is the place free in the current simulation?
    # 
    def free?
      simulation.initial_marking.places.include? self
    end

    # Is the place clamped in the current simulation?
    # 
    def clamped?
      simulation.marking_clamps.places.include? self
    end

    # Set the marking of this place in the simulation.
    # 
    def m=( value )
      m_vector.set self, value
    end

    # Alias of #m=
    # 
    def marking=( value )
      m=( value )
    end

    # Get the current marking of this place in the simulation.
    # 
    def m
      m_vector[ self ]
    end
    alias marking m
  end # class PlaceRepresentation
end # class YPetri::Simulation

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
y_petri-2.1.26 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.25 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.24 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.22 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.21 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.20 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.18 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.17 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.16 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.12 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.11 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.10 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.9 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.7 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.6 lib/y_petri/simulation/place_representation.rb
y_petri-2.1.3 lib/y_petri/simulation/place_representation.rb