CARMA C++
YigPll.h
Go to the documentation of this file.
1 
11 #ifndef CARMA_ANTENNA_OVRO_YIGPLL_H
12 #define CARMA_ANTENNA_OVRO_YIGPLL_H
13 
14 // Carma includes
16 #include "carma/canbus/Types.h"
17 #include "carma/monitor/OvroSubsystem.h"
18 #include "carma/util/PthreadCond.h"
19 #include "carma/util/PthreadMutex.h"
20 
21 namespace log4cpp {
22  // Forward dec
23  class Category;
24 } // End namespace log4cpp
25 
26 namespace carma {
27 namespace antenna {
28 namespace ovro {
29 
34 public:
35 
44  carma::monitor::OvroSubsystem & mon );
45 
49  ~YigPll();
50 
58  std::map<carma::canbus::msgType, std::string> getHalfSecMonitors() const;
59 
67  std::map<carma::canbus::msgType, std::string> getSlowMonitors() const;
68 
79  std::vector<carma::canbus::byteType> &data,
80  bool sim);
81 
92 
100  void updateFrameData();
101 
102  // Public control commands.
103 
107  typedef enum LockResult {
111  } LockResultType;
112 
120  void setYigFrequencyAndLockNoBlock( double freqInGhz );
121 
131  LockResultType setYigFrequencyAndLock( double freqInGhz );
132 
140  void setYigFrequencyWithoutLock( double freqInGhz );
141 
147  void extractTuneTable();
148 
155  void toggleSweep(bool on);
156 
162  void setDampingResistance(unsigned short damping);
163 
164 protected:
165 
166  // There are no protected methods.
167 
168 private:
169 
170  // Disable assignment and copy construction.
171  YigPll(const YigPll &);
172  YigPll &operator=(const YigPll &);
173 
174  // Routines to process individual blanking frame CAN packets.
175  // These routines are called by processMsg.
176  void processBlankingFramePacket1(carma::canbus::DataVector &data);
177  void processBlankingFramePacket2(carma::canbus::DataVector &data);
178  void processBlankingFramePacket3(carma::canbus::DataVector &data);
179  void processBlankingFramePacket4(carma::canbus::DataVector &data);
180  void processBlankingFramePacket5(carma::canbus::DataVector &data);
181  void processBlankingFramePacket6(carma::canbus::DataVector &data);
182 
183  // Routine to process state change broadcast message.
184  void processLockStateChangePacket(carma::canbus::DataVector &data);
185 
186  // Routines to produce individual simulated blanking frame CAN packets.
187  // These routines are called by simulateMsg.
188  carma::canbus::Message simBlankingFramePacket1();
189  carma::canbus::Message simBlankingFramePacket2();
190  carma::canbus::Message simBlankingFramePacket3();
191  carma::canbus::Message simBlankingFramePacket4();
192  carma::canbus::Message simBlankingFramePacket5();
193  carma::canbus::Message simBlankingFramePacket6();
194 
195  // Member variables
196  log4cpp::Category &log_; // Reference to the system logger
197  carma::monitor::AntennaCommon &common_; // Reference to common MPs.
198  carma::monitor::OvroSubsystem::Yig &mon_;
199 
200  typedef enum { // For internal state machine
201  IDLE,
202  WAITING,
203  UNLOCKED,
204  LOCKED
205  } SequenceStateType;
206 
207  // To cause the lockYigFrequency command to block while waiting for
208  // the yig to lock, we incorporate a condition variable which is wrapped
209  // up in the below structure (along with the state (contains predicate data)
210  // and associated mutex). The processLockStateChange command is responsible
211  // for updating the state and signalling to lockYigFrequency (the waiter),
212  // when finished.
213  struct {
214  volatile SequenceStateType state; // Predicate state LOCKED || UNLOCKED
215  carma::util::PthreadMutex mutex; // Mutex to wait on lock
216  carma::util::PthreadCond cond; // Condition variable to signal lock
217  } lockSequence_;
218 
219 }; // End class YigPll
220 }}} // End namespace carma::antenna::ovro
221 #endif
Yig did not lock (error)
Definition: YigPll.h:109
YIG PLL CAN module device class.
Definition: YigPll.h:33
void setYigFrequencyWithoutLock(double freqInGhz)
Set the Yig frequency but don&#39;t lock - Engineering only.
void setYigFrequencyAndLockNoBlock(double freqInGhz)
Set the YIG lock frequency and lock.
Declarations of carma::canbus types.
Yig locked successfully.
Definition: YigPll.h:108
Class to encapsulate a CAN message.
Definition: Message.h:21
enum carma::antenna::ovro::YigPll::LockResult LockResultType
Indicates the result of the lockYigFrequency command.
void processMsg(carma::canbus::msgType mid, std::vector< carma::canbus::byteType > &data, bool sim)
Process a CAN message addressed from the YigPll module.
void extractTuneTable()
Extract the tune table.
std::map< carma::canbus::msgType, std::string > getSlowMonitors() const
Return a map of this devices slow monitor points.
A simple wrapper class that makes use of ::pthread_cond_t easier in a C++ world.
Definition: PthreadCond.h:43
LockResult
Indicates the result of the lockYigFrequency command.
Definition: YigPll.h:107
XacDevice canbus::device class implementation.
Definition: XacDevice.h:37
void updateFrameData()
Update Frame Data.
unsigned short nodeType
Carma Node Type id type.
Definition: Types.h:66
void toggleSweep(bool on)
Toggle sweep - Engineering only.
::std::vector< ::carma::canbus::byteType > DataVector
Alias for CAN data.
Definition: Types.h:72
YigPll(carma::canbus::nodeType node, carma::canbus::CanOutput &io, carma::monitor::OvroSubsystem &mon)
Constructor.
std::map< carma::canbus::msgType, std::string > getHalfSecMonitors() const
Retrieve a map of this devices half second monitor points.
carma::canbus::Message simulateMsg(carma::canbus::msgType mid)
Produce a simulated CAN message for a given msgType.
void setDampingResistance(unsigned short damping)
Set damping resistance - Engineering only.
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
lockYigFrequency command timed out (error)
Definition: YigPll.h:110
CanOutput interface.
Definition: CanOutput.h:26
LockResultType setYigFrequencyAndLock(double freqInGhz)
Set the YIG lock frequency and lock.