source: flair-src/branches/sanscv/lib/FlairSensorActuator/src/Controller.h@ 412

Last change on this file since 412 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

File size: 2.7 KB
Line 
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
24namespace flair {
25namespace core {
26class Message;
27}
28}
29
30namespace flair {
31namespace sensor {
32
33enum class ControllerAction { SetLedOn, SetLedOff, Rumble, FlashLed, Exit };
34
35class RumbleMessage : public core::Message {
36public:
37 RumbleMessage(unsigned int leftForce, unsigned int leftTimeout,
38 unsigned int rightForce, unsigned int rightTimeout);
39 unsigned int GetLeftForce() const;
40 unsigned int GetLeftTimeout() const;
41 unsigned int GetRightForce() const;
42 unsigned int GetRightTimeout() const;
43 void SetLeftForce(unsigned int leftForce);
44 void SetLeftTimeout(unsigned int leftTimeout);
45 void SetRightForce(unsigned int rightForce);
46 void SetRightTimeout(unsigned int rightTimeout);
47
48private:
49 static const unsigned int leftForceOffset = sizeof(ControllerAction);
50 static const unsigned int leftTimeoutOffset =
51 sizeof(ControllerAction) + sizeof(unsigned int);
52 static const unsigned int rightForceOffset =
53 sizeof(ControllerAction) + 2 * sizeof(unsigned int);
54 static const unsigned int rightTimeoutOffset =
55 sizeof(ControllerAction) + 3 * sizeof(unsigned int);
56};
57
58class SwitchLedMessage : public core::Message {
59public:
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
67private:
68 static const unsigned int isOnOffset = sizeof(ControllerAction);
69 static const unsigned int ledIdOffset =
70 sizeof(ControllerAction) + sizeof(bool);
71};
72
73class FlashLedMessage : public core::Message {
74public:
75 FlashLedMessage(unsigned int ledId, unsigned int onTime,
76 unsigned int offTime);
77 unsigned int GetLedId() const;
78 unsigned int GetOnTime() const;
79 unsigned int GetOffTime() const;
80 void SetLedId(unsigned int ledId);
81 void SetOnTime(unsigned int onTime);
82 void SetOffTime(unsigned int offTime);
83
84private:
85 static const unsigned int ledIdOffset = sizeof(ControllerAction);
86 static const unsigned int onTimeOffset =
87 sizeof(ControllerAction) + sizeof(unsigned int);
88 static const unsigned int offTimeOffset =
89 sizeof(ControllerAction) + 2 * sizeof(unsigned int);
90};
91}
92}
93
94#endif // CONTROLLER_H
Note: See TracBrowser for help on using the repository browser.