CARMA C++
CanInstruction.h
Go to the documentation of this file.
1 #ifndef SZA_ANTENNA_CANBUS_CANINSTRUCTION_H
2 #define SZA_ANTENNA_CANBUS_CANINSTRUCTION_H
3 
11 namespace sza {
12  namespace antenna {
13  namespace canbus {
14 
15  class CanCommand;
16 
17  class CanInstruction {
18  public:
19 
20  // Instructions can be either CAN messages or monitor
21  // conditions
22 
23  enum Type {
24  NONE,
25  MESSAGE,
26  CONDITION
27  };
28 
32  CanInstruction(); // Needed so that we can do
33  // vector<CanInstruction>::resize()
34  CanInstruction(const CanInstruction& instruction);
35 
36  CanInstruction(CanDevice* device,
37  std::vector<carma::canbus::Message> messages);
38 
39  CanInstruction(CanMonitorPoint* monitor,
40  CanMonitorCondition& condition,
41  char* message,
42  sza::util::Coord* coord=0);
43 
47  virtual ~CanInstruction();
48 
49  // Set methods, corresponding to each constructor type
50 
51  void setTo(const CanInstruction& instruction);
52 
53  void setTo(CanDevice* device,
54  std::vector<carma::canbus::Message> messages);
55 
56  void setTo(CanMonitorPoint* monitor,
57  CanMonitorCondition& condition,
58  char* message, sza::util::Coord* coord=0);
59 
60  // Convenience methods
61 
62  Type execute(CanCommand* command);
63 
64  private:
65 
66  friend class CanCommand;
67 
73  Type type_; // The type of instruction
74 
75  //------------------------------------------------------------
76  // Instruction for a CAN command
77  //------------------------------------------------------------
78 
79  // The CAN device for whom this intruction is intended
80 
81  CanDevice* device_;
82 
83  // The vector of node messages to send
84 
85  std::vector<carma::canbus::Message> messages_;
86 
87  //------------------------------------------------------------
88  // Instruction for a monitor point condition
89  //------------------------------------------------------------
90 
91  CanMonitorPoint* monitor_; // The monitor point to test
92  CanMonitorCondition condition_; // The monitor condition to be met
93  sza::util::Coord coord_; // The coordinate of the monitor point
94  std::string message_; // A message to report if the
95  // condition times out
96 
97  }; // End class CanInstruction
98 
99  } // End namespace canbus
100  } // End namespace antenna
101 } // End namespace sza
102 
103 
104 
105 #endif // End #ifndef SZA_ANTENNA_CANBUS_CANINSTRUCTION_H
A class for specifying a coordinate in a multi-dimensional space.
Definition: Coord.h:21