forked from FRC1296/RHSRobot2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComponentBase.h
56 lines (43 loc) · 1.28 KB
/
ComponentBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* In the RhsRobot Framework, each physical subsystem has a corresponding component class.
* These component classes should inherit the ComponentBase class for access to functions that
* all components use.
*/
#ifndef COMPONENT_BASE_H
#define COMPONENT_BASE_H
#include <pthread.h> /* for pthread calls */
#include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */
#include <time.h> /* for timeout structure */
#include <errno.h>
#include <mqueue.h> /* for POSIX message queues */
#include <string>
#include <iostream>
using namespace std;
#include "WPILib.h"
//Robot
#include "RobotMessage.h" //For the RobotMessage struct
class ComponentBase
{
public:
ComponentBase(const char* componentName, const char *queueName, int priority);
virtual ~ComponentBase() {};
void DoWork();
void SendMessage(RobotMessage* robotMessage);
void ClearMessages();
char* GetComponentName();
int GetLoop() { return(iLoop); };
protected:
Task *pTask;
RobotMessage localMessage;
int iLoop;
virtual void OnStateChange() = 0;
virtual void Run() = 0;
private:
char* componentName;
string queueLocal;
int iPipeRcv;
int iPipeXmt;
void ReceiveMessage();
};
#endif //COMPONENT_BASE_H