CARMA C++
LOReferenceControlImpl.h
1 #ifndef LOREFERENCECONTROLIMPL_H
2 #define LOREFERENCECONTROLIMPL_H
3 
15 // Provides auto_ptr
16 #include <memory>
17 #include <string>
18 
19 #include "carma/util/UserException.h"
20 #include "carma/monitor/LoRefSubsystem.h"
21 
22 namespace log4cpp {
23  class Category;
24 } // end namespace log4cpp
25 
26 namespace carma {
27 namespace loref {
28 
29 class LOReferenceControlImpl
30 {
31  public:
32 
33  // Ctor/dtor
34  LOReferenceControlImpl(
35  int counter_gpib,
36  int switch_gpib,
37  int synth_gpib[],
38  int synth_8662[],
39  int synth_mux[],
40  bool emulate,
41  double autoWriteDelayInS );
42 
43  virtual ~LOReferenceControlImpl();
44 
45  // This is the entry point method for the GPIB monitoring thread
46  static void monitorGPIB(LOReferenceControlImpl & self);
47 
48  //
49  // IDL:carma/loref/LOReferenceControl/setFrequencyPower:1.0
50  //
51  virtual void setFrequencyPower(
52  ::CORBA::ULong synthesizerIndex,
53  ::CORBA::Double frequency,
54  ::CORBA::Double power);
55 
56  //
57  // IDL:carma/loref/LOReferenceControl/setFrequency:1.0
58  //
59  virtual void setFrequency(
60  ::CORBA::ULong synthesizerIndex,
61  ::CORBA::Double frequency);
62 
63  //
64  // IDL:carma/loref/LOReferenceControl/setPower:1.0
65  //
66  virtual void setPower(
67  ::CORBA::ULong synthesizerIndex,
68  ::CORBA::Double power);
69 
70  //
71  // IDL:carma/loref/LOReferenceControl/setPower:1.0
72  //
73  virtual void setRFOutput(
74  ::CORBA::ULong synthesizerIndex,
75  ::CORBA::Boolean power);
76 
77  //
78  // IDL:carma/loref/LOReferenceControl/getFrequency:1.0
79  //
80  virtual ::CORBA::Double getFrequency(
81  ::CORBA::ULong synthesizerIndex);
82 
83  //
84  // IDL:carma/loref/LOReferenceControl/getPower:1.0
85  //
86  virtual ::CORBA::Double getPower(
87  ::CORBA::ULong synthesizerIndex);
88 
89  //
90  // TODO Add to IDL so that this is real...
91  // IDL:carma/loref/LOReferenceControl/getStatus:1.0
92  //
93  virtual std::string getStatus(::CORBA::ULong synthesizerIndex);
94 
95  //
96  // IDL:carma/loref/LOReferenceControl/gpib:1.0
97  //
98  static char* gpib(
99  ::CORBA::ULong minor,
100  ::CORBA::ULong address,
101  const char* command);
102 
103  protected:
104 
105  virtual void closeMux( int mux );
106 
107  virtual double getCounterFrequency( double expectedValue );
108 
109  void setFrequency(::CORBA::ULong synthesizerIndex,
110  ::CORBA::Double frequency, bool log);
111 
112 
113  // Common logging
114  void logError(const std::string & msg) const;
115  static void logError(log4cpp::Category& log,const std::string& msg);
116  static void logMonitoringException(
117  log4cpp::Category& log, const std::string& msg);
118 
119  ::std::auto_ptr< ::carma::monitor::LoRefSubsystem > monitor_;
120  log4cpp::Category & log_;
121 
122  int counter_gpib_;
123  int switch_gpib_;
124  int synth_gpib_[3];
125  int synth_8662_[3];
126  int synth_mux_[3];
127  double commandedFreq[3];
128  bool commandedFreqValid[3];
129  bool emulate_;
130 
131  // Used for bounds checking
132  unsigned int synthCount_;
133  unsigned int boxCount_;
134 
135 }; // end class LOReferenceControlImpl
136 
137 } // end namespace loref
138 } // end namespace carma
139 
140 #endif // LOREFERENCECONTROLIMPL_H
141 
142 // vim: set expandtab sw=4 ts=4 :