Giter VIP home page Giter VIP logo

gotstatemachine's Introduction

GOTStateMachine

This library implements a light weight basic State Machine. The states are implemented as State functions in your sketch to keep implementation very flexible.

STATE EXECUTION

State functions will be processed at the time interval specified when the State Machine is instaniated in milliSeconds (mS). It is important to implement the state machine as follows:

  1. Instaniate the state machine with a cycle time in milliseconds (mS).
  2. The setStartState() function should be called as the setup() function ends to initialise the State Machine parameters and enter the starting state.
  3. The execute() function should be called in the loop() function. State functions will only be executed when the set time interval is complete.

STATE FUNCTIONS

State functions should be implemented as follows:

  1. State functions should first implement the required logic for the state.
  2. Following the State logic any required transitions should be implemented.
  3. Where code is required to execute once when entering a new state, the isFirstTime function can be called in the State function. The check will return a boolean true for the first execution of a state.

TRANSITIONS

Where multiple transitions need to be implemented in a State function, the following should be considered:

  1. Consideration should be given to the priority of transitions with the highest priority transition being processed first.
  2. The transition to a new state is completed by calling the changeState function and passing the actual State function name.
  3. Following a changeState a return should be included to end the State function.
  4. Where a transition is related to a period period the state has been active the function isDelayComplete(delayPeriod) can be called. The function will return a boolean true if the delay period is completed. delayPeriod should be specified in milliseconds (mS).
  5. The State Machine will stay in the same state if changeState is not called.

gotstatemachine's People

Contributors

grumpy-old-tech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.