HumHub Documentation (unofficial)

AbstractFSM
in package

AbstractYes

Abstract Finite State Machine

Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine

Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM. process() methods invokes a specified actions which may construct FSM output. Actions may be also used to signal, that we have reached Accept State

Tags
category

Zend

Table of Contents

Properties

$_currentState  : int|string
Current state
$_entryActions  : array<string|int, mixed>
List of entry actions Each action executes when entering the state
$_exitActions  : array<string|int, mixed>
List of exit actions Each action executes when exiting the state
$_inputActions  : array<string|int, mixed>
List of input actions Each action executes when entering the state
$_inputAphabet  : array<string|int, mixed>
Input alphabet
$_rules  : array<string|int, mixed>
State transition table
$_states  : array<string|int, mixed>
Machine States alphabet
$_transitionActions  : array<string|int, mixed>
List of input actions Each action executes when entering the state

Methods

__construct()  : mixed
Finite State machine constructor
addEntryAction()  : void
Add state entry action.
addExitAction()  : void
Add state exit action.
addInputAction()  : void
Add input action (defined by {state, input} pair).
addInputSymbol()  : void
Add symbol to the input alphabet
addInputSymbols()  : void
Add symbols to the input alphabet
addRule()  : void
Add symbol to the input alphabet
addRules()  : void
Add transition rules
addState()  : void
Add state to the state machine
addStates()  : void
Add states to the state machine
addTransitionAction()  : void
Add transition action (defined by {state, input} pair).
getState()  : int|string
Get FSM state.
process()  : void
Process an input
reset()  : void
setState()  : void
Set FSM state.

Properties

$_currentState

Current state

private int|string $_currentState = null

$_entryActions

List of entry actions Each action executes when entering the state

private array<string|int, mixed> $_entryActions = array()

[state] => action

$_exitActions

List of exit actions Each action executes when exiting the state

private array<string|int, mixed> $_exitActions = array()

[state] => action

$_inputActions

List of input actions Each action executes when entering the state

private array<string|int, mixed> $_inputActions = array()

[state][input] => action

$_inputAphabet

Input alphabet

private array<string|int, mixed> $_inputAphabet = array()

$_rules

State transition table

private array<string|int, mixed> $_rules = array()

[sourceState][input] => targetState

$_states

Machine States alphabet

private array<string|int, mixed> $_states = array()

$_transitionActions

List of input actions Each action executes when entering the state

private array<string|int, mixed> $_transitionActions = array()

[state1][state2] => action

Methods

__construct()

Finite State machine constructor

public __construct([array<string|int, mixed> $states = array() ][, array<string|int, mixed> $inputAphabet = array() ][, array<string|int, mixed> $rules = array() ]) : mixed

$states is an array of integers or strings with a list of possible machine states constructor treats fist list element as a sturt state (assignes it to $_current state). It may be reassigned by setState() call. States list may be empty and can be extended later by addState() or addStates() calls.

$inputAphabet is the same as $states, but represents input alphabet it also may be extended later by addInputSymbols() or addInputSymbol() calls.

$rules parameter describes FSM transitions and has a structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... ) Rules also can be added later by addRules() and addRule() calls.

FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), addInputAction() and addTransitionAction() calls.

Parameters
$states : array<string|int, mixed> = array()
$inputAphabet : array<string|int, mixed> = array()
$rules : array<string|int, mixed> = array()

addEntryAction()

Add state entry action.

public addEntryAction(int|string $state, FSMAction $action) : void

Several entry actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters
$state : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addExitAction()

Add state exit action.

public addExitAction(int|string $state, FSMAction $action) : void

Several exit actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters
$state : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addInputAction()

Add input action (defined by {state, input} pair).

public addInputAction(int|string $state, int|string $inputSymbol, FSMAction $action) : void

Several input actions are allowed. Action execution order is defined by addInputAction() calls

Parameters
$state : int|string
$inputSymbol : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addInputSymbol()

Add symbol to the input alphabet

public addInputSymbol(int|string $inputSymbol) : void
Parameters
$inputSymbol : int|string

addInputSymbols()

Add symbols to the input alphabet

public addInputSymbols(array<string|int, mixed> $inputAphabet) : void
Parameters
$inputAphabet : array<string|int, mixed>

addRule()

Add symbol to the input alphabet

public addRule(int|string $sourceState, int|string $input, int|string $targetState[, FSMAction|null $inputAction = null ]) : void
Parameters
$sourceState : int|string
$input : int|string
$targetState : int|string
$inputAction : FSMAction|null = null
Tags
throws
InvalidArgumentException
throws
RuntimeException

addRules()

Add transition rules

public addRules(array<string|int, mixed> $rules) : void

array structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... )

Parameters
$rules : array<string|int, mixed>

addState()

Add state to the state machine

public addState(int|string $state) : void
Parameters
$state : int|string

addStates()

Add states to the state machine

public addStates(array<string|int, mixed> $states) : void
Parameters
$states : array<string|int, mixed>

addTransitionAction()

Add transition action (defined by {state, input} pair).

public addTransitionAction(int|string $sourceState, int|string $targetState, FSMAction $action) : void

Several transition actions are allowed. Action execution order is defined by addTransitionAction() calls

Parameters
$sourceState : int|string
$targetState : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

getState()

Get FSM state.

public getState() : int|string
Return values
int|string

$state|null


        
On this page

Search results