Class: YPetri::Simulation::PlaceRepresentation

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

Instance Attribute Summary collapse

Attributes inherited from NodeRepresentation

#source

Instance Method Summary collapse

Methods inherited from NodeRepresentation

#to_s

Constructor Details

#initialize(net_place) ⇒ PlaceRepresentation

Expect a single YPetri place as an argument.



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

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.



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

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

#clamped?Boolean

Is the place clamped in the current simulation?

Returns:

  • (Boolean)


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

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

#free?Boolean

Is the place free in the current simulation?

Returns:

  • (Boolean)


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

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

#initial_markingObject

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



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

def initial_marking
  simulation.initial_marking( self ) if free?
end

#initial_marking=(value) ⇒ Object

Setter of initial marking.



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

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

#mObject Also known as: marking

Get the current marking of this place in the simulation.



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

def m
  m_vector[ self ]
end

#m=(value) ⇒ Object

Set the marking of this place in the simulation.



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

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

#m_vector_indexObject

Index.



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

def m_vector_index
  places.index( self )
end

#marking=(value) ⇒ Object

Alias of #m=



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

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

#marking_clampObject Also known as: clamp

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



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

def marking_clamp
  simulation.marking_clamp( self ) if clamped?
end