[4] | 1 | // %flair:license{
|
---|
| 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %flair:license}
|
---|
| 5 | // created: 2015/05/27
|
---|
| 6 | // filename: Controller.h
|
---|
| 7 | //
|
---|
| 8 | // author: Gildas Bayard
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Utility classes for controllers
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #ifndef CONTROLLER_H
|
---|
| 19 | #define CONTROLLER_H
|
---|
| 20 |
|
---|
| 21 | #include <Object.h>
|
---|
| 22 | #include <string.h>
|
---|
| 23 |
|
---|
| 24 | namespace flair {
|
---|
| 25 | namespace core {
|
---|
| 26 | class Message;
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | namespace flair { namespace sensor {
|
---|
| 31 |
|
---|
| 32 | enum class ControllerAction {
|
---|
| 33 | SetLedOn,
|
---|
| 34 | SetLedOff,
|
---|
| 35 | Rumble,
|
---|
| 36 | FlashLed,
|
---|
| 37 | Exit
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 | class RumbleMessage: public core::Message {
|
---|
| 41 | public:
|
---|
| 42 | RumbleMessage(unsigned int leftForce,unsigned int leftTimeout,unsigned int rightForce,unsigned int rightTimeout);
|
---|
| 43 | unsigned int GetLeftForce() const;
|
---|
| 44 | unsigned int GetLeftTimeout() const;
|
---|
| 45 | unsigned int GetRightForce() const;
|
---|
| 46 | unsigned int GetRightTimeout() const;
|
---|
| 47 | void SetLeftForce(unsigned int leftForce);
|
---|
| 48 | void SetLeftTimeout(unsigned int leftTimeout);
|
---|
| 49 | void SetRightForce(unsigned int rightForce);
|
---|
| 50 | void SetRightTimeout(unsigned int rightTimeout);
|
---|
| 51 | private:
|
---|
| 52 | static const unsigned int leftForceOffset=sizeof(ControllerAction);
|
---|
| 53 | static const unsigned int leftTimeoutOffset=sizeof(ControllerAction)+sizeof(unsigned int);
|
---|
| 54 | static const unsigned int rightForceOffset=sizeof(ControllerAction)+2*sizeof(unsigned int);
|
---|
| 55 | static const unsigned int rightTimeoutOffset=sizeof(ControllerAction)+3*sizeof(unsigned int);
|
---|
| 56 | };
|
---|
| 57 |
|
---|
| 58 | class SwitchLedMessage: public core::Message {
|
---|
| 59 | public:
|
---|
| 60 | SwitchLedMessage(bool isOn,unsigned int ledId);
|
---|
| 61 | bool IsOn() const;
|
---|
| 62 | unsigned int GetLedId() const;
|
---|
| 63 | void SetOn();
|
---|
| 64 | void SetOff();
|
---|
| 65 | void SetLedId(unsigned int ledId);
|
---|
| 66 | private:
|
---|
| 67 | static const unsigned int isOnOffset=sizeof(ControllerAction);
|
---|
| 68 | static const unsigned int ledIdOffset=sizeof(ControllerAction)+sizeof(bool);
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 | class FlashLedMessage: public core::Message {
|
---|
| 72 | public:
|
---|
| 73 | FlashLedMessage(unsigned int ledId,unsigned int onTime,unsigned int offTime);
|
---|
| 74 | unsigned int GetLedId() const;
|
---|
| 75 | unsigned int GetOnTime() const;
|
---|
| 76 | unsigned int GetOffTime() const;
|
---|
| 77 | void SetLedId(unsigned int ledId);
|
---|
| 78 | void SetOnTime(unsigned int onTime);
|
---|
| 79 | void SetOffTime(unsigned int offTime);
|
---|
| 80 | private:
|
---|
| 81 | static const unsigned int ledIdOffset=sizeof(ControllerAction);
|
---|
| 82 | static const unsigned int onTimeOffset=sizeof(ControllerAction)+sizeof(unsigned int);
|
---|
| 83 | static const unsigned int offTimeOffset=sizeof(ControllerAction)+2*sizeof(unsigned int);
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | }}
|
---|
| 87 |
|
---|
| 88 | #endif // CONTROLLER_H
|
---|