RSeries astromech firmware
JawaEvent.h
Go to the documentation of this file.
1 #ifndef JawaEvent_h
2 #define JawaEvent_h
3 
4 #include "ReelTwo.h"
5 
6 enum JawaID
7 {
8  kJawaAll = 0,
9  kJawaTFLD = 1,
10  kJawaBFLD = 2,
11  kJawaRFLD = 3,
20  kJawaCBI = 83,
22 };
23 
31 class JawaEvent
32 {
33 public:
39  fNext(NULL)
40  {
41  if (*head() == NULL)
42  *head() = this;
43  if (*tail() != NULL)
44  (*tail())->fNext = this;
45  *tail() = this;
46  }
47 
48  static void process(int addr, char cmd, int arg = 0, int value = 0)
49  {
50  for (JawaEvent* jawa = *head(); jawa != NULL; jawa = jawa->fNext)
51  if (addr == 0 || addr == jawa->fJawaAddress)
52  jawa->jawaCommand(cmd, arg, value);
53  }
54 
55  static void process(int addr, char cmd, const char* arg)
56  {
57  for (JawaEvent* jawa = *head(); jawa != NULL; jawa = jawa->fNext)
58  if (addr == 0 || addr == jawa->fJawaAddress)
59  jawa->jawaCommand(cmd, arg);
60  }
61 
65  virtual void jawaCommand(char cmd, int arg, int value)
66  {
67  UNUSED_ARG(cmd)
68  UNUSED_ARG(arg)
69  UNUSED_ARG(value)
70  }
71 
75  virtual void jawaCommand(char cmd, const char* arg)
76  {
77  UNUSED_ARG(cmd)
78  UNUSED_ARG(arg)
79  }
80 
84  inline void setJawaAddress(int addr)
85  {
86  fJawaAddress = addr;
87  }
88 
89 protected:
91 
92 private:
93  JawaEvent* fNext;
94 
95  static JawaEvent** head()
96  {
97  static JawaEvent* sHead;
98  return &sHead;
99  }
100 
101  static JawaEvent** tail()
102  {
103  static JawaEvent* sTail;
104  return &sTail;
105  }
106 };
107 
108 #endif
kJawaFrontHolo
@ kJawaFrontHolo
Definition: JawaEvent.h:14
JawaEvent::fJawaAddress
int fJawaAddress
Definition: JawaEvent.h:90
kJawaOther
@ kJawaOther
Definition: JawaEvent.h:17
JawaID
JawaID
Definition: JawaEvent.h:6
ReelTwo.h
JawaEvent::jawaCommand
virtual void jawaCommand(char cmd, const char *arg)
Subclasses should override this method to handle commands.
Definition: JawaEvent.h:75
JawaEvent::process
static void process(int addr, char cmd, const char *arg)
Definition: JawaEvent.h:55
kJawaRearPSI
@ kJawaRearPSI
Definition: JawaEvent.h:13
kJawaFrontPSI
@ kJawaFrontPSI
Definition: JawaEvent.h:12
kJawaRFLD
@ kJawaRFLD
Definition: JawaEvent.h:11
JawaEvent::process
static void process(int addr, char cmd, int arg=0, int value=0)
Definition: JawaEvent.h:48
JawaEvent
Base class for all devices implementing JAWA lite support.
Definition: JawaEvent.h:31
JawaEvent::setJawaAddress
void setJawaAddress(int addr)
Specify the JAWA address of this device.
Definition: JawaEvent.h:84
kJawaTFLD
@ kJawaTFLD
Definition: JawaEvent.h:9
kJawaTopHolo
@ kJawaTopHolo
Definition: JawaEvent.h:16
kJawaRadarEye
@ kJawaRadarEye
Definition: JawaEvent.h:18
JawaEvent::jawaCommand
virtual void jawaCommand(char cmd, int arg, int value)
Subclasses should override this method to handle commands specifying a value.
Definition: JawaEvent.h:65
kJawaRearHolo
@ kJawaRearHolo
Definition: JawaEvent.h:15
JawaEvent::JawaEvent
JawaEvent()
Default Constructor.
Definition: JawaEvent.h:38
kJawaAll
@ kJawaAll
Definition: JawaEvent.h:8
UNUSED_ARG
#define UNUSED_ARG(arg)
Definition: ReelTwo.h:25
kJawaBFLD
@ kJawaBFLD
Definition: JawaEvent.h:10
kJawaCBI
@ kJawaCBI
Definition: JawaEvent.h:20
kJawaMagicPanel
@ kJawaMagicPanel
Definition: JawaEvent.h:19
kJawaDataPort
@ kJawaDataPort
Definition: JawaEvent.h:21