#include #include "motor.hpp" #include // ---------------------------------------------------------------------------- // Motor states // class Stopped : public Motor { void entry() override { std::cout << "Motor: stopped" << std::endl; direction = 0; }; }; class Up : public Motor { void entry() override { std::cout << "Motor: moving up" << std::endl; direction = 1; }; }; class Down : public Motor { void entry() override { std::cout << "Motor: moving down" << std::endl; direction = -1; }; }; // ---------------------------------------------------------------------------- // Base State: default implementations // void Motor::react(MotorStop const &) { transit(); } void Motor::react(MotorUp const &) { transit(); } void Motor::react(MotorDown const &) { transit(); } int Motor::direction{0}; // ---------------------------------------------------------------------------- // Initial state definition // FSM_INITIAL_STATE(Motor, Stopped)