RSeries astromech firmware
InterchangeArm.h
Go to the documentation of this file.
1 #ifndef InterchangeArm_h
2 #define InterchangeArm_h
3 
4 #include "core/AnimatedEvent.h"
5 #include "core/CommandEvent.h"
6 
17 {
18 public:
19  InterchangeArm(byte idPin) :
20  fID(idPin),
21  fArmed(false)
22  {
23  disarm();
24  }
25 
26  inline bool isArmed()
27  {
28  return fArmed;
29  }
30 
34  void arm()
35  {
36  fArmed = true;
37  }
38 
42  void disarm()
43  {
44  fArmed = false;
45  off();
46  }
47 
48  virtual void on() = NULL;
49  virtual void off() = NULL;
50 
54  virtual void handleCommand(const char* cmd) override
55  {
56  if (*cmd++ == 'X' && *cmd++ == 'C')
57  {
58  // Cannot arm/disarm zapper using commands. Zapper should be automatically
59  // armed after opening door and raising arm. As soon as arm starts lowering
60  // the zapper should be disarmed.
61  if (cmd[0] == 'O' && cmd[1] == 'N' && cmd[2] == '\0')
62  {
63  on();
64  }
65  else if (cmd[0] == 'O' && cmd[1] == 'F' && cmd[2] == 'F' && cmd[3] == '\0')
66  {
67  off();
68  }
69  }
70  }
71 
72 protected:
73  bool fArmed;
74 };
75 
77 
78 #endif
CommandEvent
Base class for all command enabled devices. CommandEvent::handleCommand() is called for each device e...
Definition: CommandEvent.h:17
InterchangeArm::disarm
void disarm()
Disarm.
Definition: InterchangeArm.h:42
AnimatedEvent
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
InterchangeArm::on
virtual void on()
AnimatedEvent.h
InterchangeArm::arm
void arm()
Arm.
Definition: InterchangeArm.h:34
InterchangeArm::InterchangeArm
InterchangeArm(byte idPin)
Definition: InterchangeArm.h:19
InterchangeArm::fArmed
bool fArmed
Definition: InterchangeArm.h:73
InterchangeArm::isArmed
bool isArmed()
Definition: InterchangeArm.h:26
InterchangeArm::off
virtual void off()
InterchangeArm
Base class for Zapper, Gripper, and Welder.
Definition: InterchangeArm.h:15
CommandEvent.h
InterchangeArm::handleCommand
virtual void handleCommand(const char *cmd) override
Interchangable Arm Commands start with 'XC'.
Definition: InterchangeArm.h:54