CARMA C++
IFCanMaster.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_ANTENNA_BIMA_IFCANMASTER_H
11 #define CARMA_ANTENNA_BIMA_IFCANMASTER_H
12 
13 // Carma includes
14 #include "carma/corba/corba.h"
15 #include "carma/antenna/bima/CMReceiver.h"
16 #include "carma/monitor/BimaSubsystem.h"
19 #include "carma/antenna/bima/control/AntennaControlImpl.h"
20 #include "carma/antenna/bima/Rx.h"
21 #include "carma/canbus/Master.h"
23 #include "carma/canbus/Utilities.h"
25 #include "carma/util/Program.h"
26 #include "carma/util/ScopedPthreadMutexLock.h"
27 #include "carma/util/PthreadCond.h"
28 #include "carma/util/PthreadMutex.h"
30 #include "carma/antenna/bima/ProcessMonitor.h"
31 
33 
34 // NOTE, this puts itself in the carma::antenna::ovro
35 // name space to utilize ovro's written code
37 
38 // STL includes
39 #include <map>
40 
41 namespace log4cpp {
42  // Forward declaration.
43  class Category;
44 } // End namespace log4cpp
45 
46 namespace carma
47 {
48  namespace monitor
49  {
50  class BimaSubsystem; // Forward declaration.
51  }
52 
53  namespace antenna
54  {
55 
56  namespace common
57  {
58  class Varactor;
59  }
60 
61  namespace bima
62  {
63  class AntennaNameResolver;
64  class SisReceiver;
65  class CMReceiver;
66 
73 {
74  public:
75 
80  Rx &rx,
81  carma::monitor::BimaSubsystem &mon,
82  AntennaNameResolver & anr,
83  Configuration &config);
84 
101  IFCanMaster( int board, int bus,
103  Rx &rx,
104  carma::monitor::BimaSubsystem &mon,
105  AntennaNameResolver & anr,
106  Configuration &config);
107 
108  ~IFCanMaster();
109 
116  void start();
117 
124  void stop();
125 
126  static void *startWriterThread( void *arg );
127  void writerThread( void );
128 
129  AntennaIF& getAntennaIFPol1() { return *_aifPol1; };
130  AntennaIF& getAntennaIFPol2() { return *_aifPol2; };
131  AntennaControlImpl& getAntennaControl() { return *_ant; };
132  CMReceiver& getCmRxControl() { return *_cmrx; };
133  carma::antenna::ovro::Tiltmeter& getTiltmeter() { return *_tiltMeter; };
134 
139  void reset();
140 
144  void setInitialized( bool state );
145 
146  protected:
147 
155  std::map<carma::canbus::msgType, std::string> getControls() const;
156 
165  void updateStatus();
166 
171  void softReset();
172 
173 
174 private:
175 
176  // Disallow assignment and copy construction.
177  IFCanMaster(const IFCanMaster &);
178  IFCanMaster &operator=(const IFCanMaster &);
179 
180  // Run thread entry point.
181  static void *runThreadEntry(void *arg);
182 
183  // Redefine run such that it is private.
184  void run();
185 
186  // Initialize helper routine to perform common creation tasks
187  // (i.e. those common among all three constructors).
188  void initialize(Configuration &config);
189 
190  // Keep id around so that we can destroy it when need be.
191  pthread_t runThreadId_;
192  bool isRunning_;
193  carma::util::PthreadMutex isRunningGuard_;
194  carma::util::PthreadCond isRunningCond_;
195 
196  // Define the devices that will exist on this network.
197  // Also, since these aren't CORBA servants, they don't need to be
198  // allocated on the heap. This is a bit different than in the past
199  // but it avoids the mismanagement of the memory...
202 
203  // OVRO type of tiltmeter, currently only on carma7/bima1
204  // This is picked up from bima/Tiltmeter.h above!
205  // that has modifications to its interface (namely a different
206  // monitor subsystem..
208 
209  // This is used to talk to the SIS Receiver CAN module.
210  carma::antenna::bima::SisReceiver *_sisrx;
211 
213 
214  carma::antenna::bima::CMReceiver *_cmrx;
215 
216  // The sole reason for AntennaControl's existence anymore
217  // is apparently to provide a way to reset the primary
218  // CAN bus... The IF system on the BIMA antennas is
219  // the only shared system between OVRO and BIMA and
220  // it is the only class that has a copy of the "master"
221  // which provides the method to reset... Hence this is
222  // where AntennaControl ends up... Oh. My. God.
223  carma::antenna::bima::AntennaControlImpl *_ant;
224 
225  carma::monitor::BimaSubsystem& mon_;
226  log4cpp::Category& log_;
228 
229  AntennaNameResolver & anr_;
230  SharedMemory *_bimaShm;
231 
232  }; // End class IFCanMaster
233 
234  }
235 }
236 } // End namespace carma::antenna::bima
237 
238 #endif // CARMA_ANTENNA_BIMA_IFCANMASTER_H
239 
std::map< carma::canbus::msgType, std::string > getControls() const
Get a map of controls provided by the IFCanMaster Master controls correspond to global CAN Message Id...
void updateStatus()
Update the status of the Antenna CAN Master.
Class definition for TelemetryCommand on the BIMA antennas.
CAN Device implementation for Antenna IF Module.
Tiltmeter device class.
Definition: Tiltmeter.h:34
Antenna IF CAN module device class.
Definition: AntennaIF.h:48
void setInitialized(bool state)
Set initialization flag.
void start()
Start the CAN Master This routine does not block! It is responsible for kicking off a new thread whic...
Exception class for errors.
void stop()
Stop the CAN Master This routine terminates the main run thread in the CAN Master.
IFCanMaster(carma::util::IPQreader< TelemetryCommand > &ifr, Rx &rx, carma::monitor::BimaSubsystem &mon, AntennaNameResolver &anr, Configuration &config)
Constructor for emulation only.
Class definition for TelemetryClient on the BIMA antennas.
Declaration of carma::canbus::Master class.
A simple wrapper class that makes use of ::pthread_cond_t easier in a C++ world.
Definition: PthreadCond.h:43
CAN Device implementation for CARMA CANbus API No.
void reset()
Reset the canbusses via dio.
Class definition for Stepper Motors for BIMA systems.
void softReset()
Reset modules via software RESET msg.
Declarations of carma::canbus exceptions.
Class definition for SharedMemory on the BIMA antennas.
Carma Canbus Master class.
Definition: Master.h:110
Declarations of carma::canbus utility functions.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
BIMA Antenna IF canbus Master class.
Definition: IFCanMaster.h:72
Varactor CAN device class.
Definition: Varactor.h:30