GithubHelp home page GithubHelp logo

vfsmbundle's Introduction

VfsmBundle

Installation

Composer

Add the following dependencies to your projects composer.json file:

     "repositories": [
         {
             "type": "git",
             "url": "https://github.com/kaywalker/VfsmBundle.git"
         }
     ],
     "require": {
         "hn/vfsm-bundle": "dev-master"
     }

Usage

Useless Machine

The "Useless Machine" is a machine that does no other task, but switching itself off. It has two states: "on" and "off". the initial state is the "off" state. when the switch is set to the on position the machine change from "off" to "on". On entering the "on" state, a timer of 1s is being started. When the timers timeout is reached, the switch is put back to the off position and the machine is set from "on" to "off" state

class UselessMachine
{

    const STATE_OFF = 'off';
    const STATE_ON = 'on';

    const INPUT_SWITCH_IS_OFF = 'switch_is_off';
    const INPUT_SWITCH_IS_ON = 'switch_is_on';
    const INPUT_TIMEOUT = 'timeout';

    const ACTION_START_TIMER = 'start_timer';
    const ACTION_SWITCH_OFF = 'switch_off';

     public function __construct()
     {
         $specification = array(
             'specification' => array(
                 self::STATE_OFF => array(
                     'transitions' => array(
                         array(
                             'to_state' => self::STATE_ON,
                             'condition' => array(array(self::INPUT_SWITCH_IS_ON)),
                         )
                     )
                 ),
                 self::STATE_ON => array(
                     'enter_action' => self::ACTION_START_TIMER,
                     'input_actions' => array(
                         'action' => self::ACTION_SWITCH_OFF,
                         'condition' => array(array(self::INPUT_TIMEOUT))
                     ),
                     'transitions' => array(
                         array(
                             'to_state' => self::STATE_OFF,
                             'condition' => array(
                                 array(self::INPUT_SWITCH_IS_OFF)
                             ),
                         )
                     )
                 )
             )
         );

         $this->executer = new SpecificationExecutor($specification, self::STATE_OFF);
     }
 }

vfsmbundle's People

Contributors

kaywalker 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.