module YPetri::Transition::Type_A

Mixin for the transitions with assignment action.

Public Instance Methods

a(simulation=world.simulation) click to toggle source

Transition's assignment action under current simulation.

# File lib/y_petri/transition/A.rb, line 46
def a simulation=world.simulation
  simulation.net.State.Feature.Assignment( self ) % simulation
end
action() click to toggle source

Transition's action (before validation).

# File lib/y_petri/transition/A.rb, line 14
def action
  action_closure.( *domain_marking )
end
enabled?() click to toggle source

A transitions are always enabled.

# File lib/y_petri/transition/A.rb, line 40
def enabled?
  true
end
fire() click to toggle source

Applies action to the codomain, honoring cocking. Returns true if the transition fired, false if it wasn't cocked.

# File lib/y_petri/transition/A.rb, line 21
def fire
  cocked?.tap { |x| ( uncock; fire! ) if x }
end
fire!() click to toggle source

Assigns the action closure result to the codomain, regardless of cocking.

# File lib/y_petri/transition/A.rb, line 27
def fire!
  act = Array( action )
  fail TypeError, "Wrong output arity of the action " +
    "closure of #{self}" if act.size != codomain.size
  codomain.each_with_index { |place, index|
    # assigning action node no. index to place
    place.marking = act.fetch( index )
  }
  return nil
end
function() click to toggle source

For assignment transitions, “function” refers to their action closure.

# File lib/y_petri/transition/A.rb, line 8
def function
  action_closure
end