cpphlib.PPSTATEMACHINE Class Reference

- Main Page
- Namespaces
- Classes

- Class List
- Class Members

Public Member Functions | Public Attributes
cpphlib.PPSTATEMACHINE Class Reference

The statemachine. More...

List of all members.

## Public Member Functions
def | __init__
| Documentation for method.
def | additemtostatetable
| Documentation for method.
def | inputchange
| Documentation for method.
def | getactualstate
| Documentation for method.
def | run
| Documentation for method.
def | stop
## Public Attributes
| RunFlag
| OutActions
| InputBlocks
| StateTable
| State
| prevSearchStateChange
| SilentMode

## Detailed Description

The statemachine.

This class is a general purpose state machine, what is able to run independently from the main thread of the controller program. It must be stopped before quitting from the main thread using stop method, because this class is defined by a different thread. Output changes caused by state changes can be described using methods. These methods must be collected in a separate class, and must be implemented, and this new class's instance is used by the statemachine.(fx. see how SM implemented in PPKMREHANDLER uses methods implemented in PPRENCOUTACTIONS.) State machine can be awaken using method run, but before starting, its temporary table must be loaded with method additemtostatetable. Definig table, strings must be used when defining input lists, states, new states, and names of change handling methods. Inputs must be given in lists, this way it is easy to change changed values of inputs with the position of the list index. The operation of the statemachine: The statemachine adds the jointed input list, and the actual state together. If this string is not the same as calculated in the previous cycle, then changes occured on the inputs, which causes changes on the outputs, and output action starting, if an element can be found in the state table with the jointed input list, and the actual state's result, as key. This element is a dicionary, which contains the name of the new state, where we became, and also contains the name of the executable action's method. We can execute the executable action, and we can make actual state equal to the new state. From this point, the process restarts from the beginig. The statemachine is running in an endless cycle, until we stop it using method stop.

## Constructor & Destructor Documentation

def cpphlib.PPSTATEMACHINE.__init__ | ( |  | self,
|  |  | InitState,
|  |  | InitInputs,
|  |  | OutActionsObject,
|  |  | SilentMode = `True`
| ) |  |

Documentation for method.

It is the PPSTATEMACHINE's constructor. In this costructor, the starting state of the statemachine, the valid input combination at the start, and the object class instance, which contains the method collection of the output changes must be given. Defining inputs can be done using lists, fx. binary (["1","0","1"]), it can be one, or more complete byte (["0A"] or ["01","F8"]), word, or long sting as well. In case of changes of certain input channels, we can send the input changes into the state machine with the help of the index of list given at initialising, with the help of method inputchange

Parameters:

  InitState | The initial state
  InitInputs | The valid input combination at the start given in list
  OutActionsObject | Is the object class instance, which contains the method collection of the output changes
  SilentMode | If SilentMode is set to False then you can follow on the console how the statemachine works
      Short description: Constructs PPSTATEMACHINE class

## Member Function Documentation

def cpphlib.PPSTATEMACHINE.additemtostatetable | ( |  | self,
|  |  | state,
|  |  | input,
|  |  | outaction,
|  |  | newstate
| ) |  |

Documentation for method.

It gives state change to the state table of the state machine. It shows us from what state, with which input combination, and what output action brings us to which state.

Parameters:

  state | Starting state, what the state machine is in
  input | The changed input combination (must be given, if it was a jointed list)
  outaction | The outaction method's name to run
  newstate | The new state, what the statemachine came into
      Short description: It gives state change to the state table

def cpphlib.PPSTATEMACHINE.getactualstate | ( |  | self | ) |

Documentation for method.

Inquiring actual state of the state machine It returns with the actual state of the state machine.

    Short description: Inquiring actual state of the state machine

def cpphlib.PPSTATEMACHINE.inputchange | ( |  | self,
|  |  | inputblock,
|  |  | input
| ) |  |

Documentation for method.

Telling input changes to the state machine.

Parameters:

  inputblock | The index of the list given at initialising, what points to the input
  input | The changed input value
      Short description: Telling input changes to the state machine

def cpphlib.PPSTATEMACHINE.run | ( |  | self | ) |

Documentation for method.

The working loop of the state machine. It is an endless cycle, until we stop it using method stop.

    Short description: The working loop of the state machine

def cpphlib.PPSTATEMACHINE.stop | ( |  | self | ) |

    Short description: It stops the state machine

The documentation for this class was generated from the following file:

- cpphlib.py