Class: YPetri::Simulation::PlaceRepresentation

Inherits:
ElementRepresentation show all
Defined in:
lib/y_petri/simulation/place_representation.rb

Instance Attribute Summary collapse

Attributes inherited from ElementRepresentation

#source

Instance Method Summary collapse

Constructor Details

#initialize(net_place) ⇒ PlaceRepresentation

Expect a single YPetri place as an argument.



16
17
18
19
# File 'lib/y_petri/simulation/place_representation.rb', line 16

def initialize net_place
  super
  @quantum = source.quantum
end

Instance Attribute Details

#quantumObject (readonly)

Returns the value of attribute quantum.



7
8
9
# File 'lib/y_petri/simulation/place_representation.rb', line 7

def quantum
  @quantum
end

Instance Method Details

#clamp=(value) ⇒ Object

Setter of clamp.



23
24
25
# File 'lib/y_petri/simulation/place_representation.rb', line 23

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

#clamped?Boolean

Is the place clamped in the current simulation?

Returns:

  • (Boolean)


54
55
56
# File 'lib/y_petri/simulation/place_representation.rb', line 54

def clamped?
  simulation.marking_clamps.places.include? self
end

#free?Boolean

Is the place free in the current simulation?

Returns:

  • (Boolean)


48
49
50
# File 'lib/y_petri/simulation/place_representation.rb', line 48

def free?
  simulation.initial_marking.places.include? self
end

#initial_markingObject

Initial marking value (or nil, if the place is free).



42
43
44
# File 'lib/y_petri/simulation/place_representation.rb', line 42

def initial_marking
  simulation.initial_marking[ self ] if free?
end

#initial_marking=(value) ⇒ Object

Setter of initial marking.



29
30
31
# File 'lib/y_petri/simulation/place_representation.rb', line 29

def initial_marking=( value )
  simulation.set_initial_marking( of: self, to: value )
end

#mObject Also known as: marking

Get the current marking of this place in the simulation.



72
73
74
# File 'lib/y_petri/simulation/place_representation.rb', line 72

def m
  m_vector[ self ]
end

#m=(value) ⇒ Object

Set the marking of this place in the simulation.



60
61
62
# File 'lib/y_petri/simulation/place_representation.rb', line 60

def m=( value )
  m_vector.set self, value
end

#m_vector_indexObject

Index



10
11
12
# File 'lib/y_petri/simulation/place_representation.rb', line 10

def m_vector_index
  places.index( self )
end

#marking=(value) ⇒ Object

Alias of #m=



66
67
68
# File 'lib/y_petri/simulation/place_representation.rb', line 66

def marking=( value )
  m=( value )
end

#marking_clampObject Also known as: clamp

Marking clamp value (or nil, if the place is clamped).



35
36
37
# File 'lib/y_petri/simulation/place_representation.rb', line 35

def marking_clamp
  simulation.marking_clamp of: self if clamped?
end