Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Command.h@0:4bc34a5fcc29, 2015-11-21 (annotated)
- Committer:
- Xiaofei
- Date:
- Sat Nov 21 17:17:41 2015 +0000
- Revision:
- 0:4bc34a5fcc29
- Child:
- 1:13c4bf8989d5
ghghg
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Xiaofei | 0:4bc34a5fcc29 | 1 | #pragma once |
| Xiaofei | 0:4bc34a5fcc29 | 2 | #include <cstdint> |
| Xiaofei | 0:4bc34a5fcc29 | 3 | |
| Xiaofei | 0:4bc34a5fcc29 | 4 | class Command |
| Xiaofei | 0:4bc34a5fcc29 | 5 | { |
| Xiaofei | 0:4bc34a5fcc29 | 6 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 7 | Command():_speed(0){} |
| Xiaofei | 0:4bc34a5fcc29 | 8 | Command(const Command&); |
| Xiaofei | 0:4bc34a5fcc29 | 9 | virtual ~Command(){} |
| Xiaofei | 0:4bc34a5fcc29 | 10 | virtual void execute() = 0; |
| Xiaofei | 0:4bc34a5fcc29 | 11 | void setSpeed(const std::int8_t& sp){_speed = sp;} |
| Xiaofei | 0:4bc34a5fcc29 | 12 | |
| Xiaofei | 0:4bc34a5fcc29 | 13 | protected: |
| Xiaofei | 0:4bc34a5fcc29 | 14 | float _speed; |
| Xiaofei | 0:4bc34a5fcc29 | 15 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 16 | |
| Xiaofei | 0:4bc34a5fcc29 | 17 | class LedCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 18 | { |
| Xiaofei | 0:4bc34a5fcc29 | 19 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 20 | LedCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 21 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 22 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 23 | |
| Xiaofei | 0:4bc34a5fcc29 | 24 | class TurnLeftCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 25 | { |
| Xiaofei | 0:4bc34a5fcc29 | 26 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 27 | TurnLeftCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 28 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 29 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 30 | |
| Xiaofei | 0:4bc34a5fcc29 | 31 | class TurnRightCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 32 | { |
| Xiaofei | 0:4bc34a5fcc29 | 33 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 34 | TurnRightCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 35 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 36 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 37 | |
| Xiaofei | 0:4bc34a5fcc29 | 38 | class MoveForwardCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 39 | { |
| Xiaofei | 0:4bc34a5fcc29 | 40 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 41 | MoveForwardCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 42 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 43 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 44 | |
| Xiaofei | 0:4bc34a5fcc29 | 45 | class MoveBackwardCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 46 | { |
| Xiaofei | 0:4bc34a5fcc29 | 47 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 48 | MoveBackwardCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 49 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 50 | }; |
| Xiaofei | 0:4bc34a5fcc29 | 51 | |
| Xiaofei | 0:4bc34a5fcc29 | 52 | class StopCommand : public Command |
| Xiaofei | 0:4bc34a5fcc29 | 53 | { |
| Xiaofei | 0:4bc34a5fcc29 | 54 | public: |
| Xiaofei | 0:4bc34a5fcc29 | 55 | StopCommand(){} |
| Xiaofei | 0:4bc34a5fcc29 | 56 | virtual void execute(); |
| Xiaofei | 0:4bc34a5fcc29 | 57 | }; |