Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { ConnectionState *State // The state it is connected to ReasonToMove func() bool // The "reason to move" test function: code that tests if the transition is possible Transition func() // The transition function : code that is executed during a transition }
Connection Represents a Connection ( a transition) between states. It is strictly directional,
- if you want bidirectionnality you need 2 Connections.
type Moves ¶
type Moves interface { Get_transition_to(State) func() Get_reason_for(State) func() State_function() func() }
Moves The interface Moves declares functions available for a State object
type State ¶
type State struct { Name string // Name of the State CoreFunction func() // user-defined Function that gets executed when you enter that state. Connected []Connection // List of connections from that state }
State Represents a State.
func ParseAndInstall ¶
func ParseAndInstall(stateFile string, transitionFile string, mapFunctions map[string]func(), mapReasons map[string]func() bool) (*State, error)
ParseAndInstall Parses the "state" csv file and the "transition" csv file to construct the model in state machine go objects and structures. * Takes in parameter maps with the callback functions to introduce in the model, and their names as a String. * Maps are separated between "map_function" for void functions * and "map_reasons" that have to return a bool * Returns the first state of the SM, otherwise an error.
func (State) GetReasonFor ¶
GetReasonFor Implementation of the interface Moves
- return the "reason_to_move" function from a state to another one
func (State) GetTransitionTo ¶
GetTransitionTo Implementation of the interface Moves
- return the transition function from a state to another one
func (State) StateFunction ¶
StateFunction State function : it is the underlying function that makes it all work.
- It manages the transitions, given the results of reason to move.
- Returns the next state.