CARMA C++
Encoder.h
Go to the documentation of this file.
1 
9 #ifndef CARMA_ANTENNA_OVRO_CANBUS_ENCODER_H
10 #define CARMA_ANTENNA_OVRO_CANBUS_ENCODER_H
11 
14 #include "carma/services/Angle.h"
15 #include "carma/util/PthreadMutex.h"
16 
17 namespace log4cpp {
18  class Category;
19 } // namespace log4cpp
20 
21 namespace carma {
22 
23 namespace monitor {
24  class Encoder;
25  class OvroSubsystem;
26  class StateMonitorPointEnum;
27 } // namespace monitor
28 
29 namespace antenna {
30 namespace ovro {
31 
32 
37  public:
38 
39  enum Axis {
40  AZIMUTH = 1,
41  ELEVATION = 2 };
42 
47  explicit Encoder( Axis axis,
48  carma::canbus::CanOutput & canOut,
49  carma::monitor::OvroSubsystem & mon,
51 
55  virtual ~Encoder( );
56 
57  struct TimestampedPosition {
58  TimestampedPosition( );
59  double mjd;
60  carma::services::Angle position;
61  };
62 
70  TimestampedPosition getMostRecentPosition( ) const;
71 
76 
81 
86  void processMsg( carma::canbus::msgType messageId,
87  ::std::vector< carma::canbus::byteType > & data,
88  bool sim );
89 
95 
96  static const carma::canbus::msgType FAKE_AZ_ENCODER_PACKET = 0x114;
97  static const carma::canbus::msgType FAKE_EL_ENCODER_PACKET = 0x115;
98 
99  protected:
100 
101  private:
102 
103  struct Shared {
104  mutable carma::util::PthreadMutex mutex;
105  struct TimestampedPosition position;
106  Shared( );
107  } shared_;
108 
109  void updateFrameData( );
110 
111  void processBlankingFramePacket1( carma::canbus::DataVector & data );
112  void processBlankingFramePacket2( carma::canbus::DataVector & data );
113  void processBlankingFramePacket3( carma::canbus::DataVector & data );
114 
115  // Simulation of the encoder module is shared by the ovro::Drive
116  // module. Since rates and voltages are sent to the drive module,
117  // it maintains simulated encoder readings based on these rates.
118  // This is all handled by using the FAKE_AZ and EL message id for sims.
119  friend carma::canbus::Message
121  static carma::canbus::Message
122  simulateBlankingFramePacket1( Axis axis, double positionInDeg );
123 
124  carma::canbus::Message simulateBlankingFramePacket2( );
125  carma::canbus::Message simulateBlankingFramePacket3( );
126 
127  const Axis axis_;
128 
129  const carma::canbus::MsgIdInfoMap halfSecMIDs_;
130 
131  carma::monitor::StateMonitorPointEnum & state_;
132  carma::monitor::Encoder & encoderMon_;
133  carma::monitor::Xac & xacMon_;
135 
136  }; // class Encoder
137 
138 }}} // namespace carma::antenna::ovro
139 #endif
Encoder(Axis axis, carma::canbus::CanOutput &canOut, carma::monitor::OvroSubsystem &mon, carma::antenna::ovro::Drive &drive)
Constructor.
CAN Device implementation for 10-m Antenna Drive Module.
::std::map< ::carma::canbus::msgType,::std::string > MsgIdInfoMap
Alias for an ::std::map containing a string description of a message id, keyed by the described carma...
Definition: Device.h:30
TimestampedPosition getMostRecentPosition() const
Retrieve position and MJD of message retrieval.
Class to encapsulate a CAN message.
Definition: Message.h:21
Representation of an angle, return values are always modulo 2PI radians.
10-m Antenna Encoder Module CAN Implementation (API No.
Definition: Encoder.h:36
carma::canbus::MsgIdInfoMap getSlowMonitors() const
Get map of slow monitor points processed by this class.
XacDevice canbus::device class implementation.
Definition: XacDevice.h:37
carma::canbus::Message simulateMsg(carma::canbus::msgType messageId)
Simulate CAN message.
virtual ~Encoder()
Destructor.
::std::vector< ::carma::canbus::byteType > DataVector
Alias for CAN data.
Definition: Types.h:72
The Angle class can represent any angle in any units.
Definition: Angle.h:38
void processMsg(carma::canbus::msgType messageId,::std::vector< carma::canbus::byteType > &data, bool sim)
Process CAN message.
10-m Antenna Drive Module CAN Implementation (API No.
Definition: Drive.h:33
carma::canbus::devices::XacDevice class declaration.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
unsigned short msgType
Carma Message id type.
Definition: Types.h:69
carma::canbus::MsgIdInfoMap getHalfSecMonitors() const
Get map of half second monitor points processed by this class.
carma::canbus::Message simulateMsg(carma::canbus::msgType messageId)
Simulate CAN message.
CanOutput interface.
Definition: CanOutput.h:26