CARMA C++
Rx.h
Go to the documentation of this file.
1 
15 #ifndef CARMA_ANTENNA_BIMA_RX_H
16 #define CARMA_ANTENNA_BIMA_RX_H
17 
18 // C++
19 #include <vector>
20 #include <string>
21 #include <iostream>
22 #include <sstream>
23 #include <cmath>
24 
25 // System includes
26 #include <unistd.h>
27 #include <ctype.h>
28 
29 // CARMA includes
30 #include "carma/util/Program.h"
33 #include "carma/services/Table.h"
43 #include "carma/antenna/common/FocusControl.h"
44 #include "carma/antenna/common/FocusControl_skel.h"
45 #include "carma/corba/Client.h"
46 
47 namespace carma
48 {
49  namespace antenna
50  {
51  namespace bima
52  {
53  class Rx : public TelemetryClient
54  {
55 
56  public:
57  Rx( Configuration& config );
58 
59  typedef char Band;
60  typedef char SISSetMode;
61  typedef enum { NOTOK, OK } OKOrNOTState;
62  typedef enum { OFF, ON } OnOrOffState;
63 
64 
65  void turnMMOscOn();
66  void turnMMOscOff();
67  void turnMMSweepOn();
68  void turnMMSweepOff();
69 
70  bool getOscOn();
71  OnOrOffState getMMOscState();
72  OnOrOffState getSweepState();
73 
74  void setObsFreq( double freq );
75  double getObsFreq();
76 
77  void setOscFreq( double freq );
78  double getOscFreq();
79 
80  void setLO1Freq( double freq );
81  double getLO1Freq();
82 
83  float getLO10MHzOptPwr();
84  bool getLO10MHzStatus();
85  float getLO50MHzOptPwr();
86 
87  void setVop( double vop );
88  void setVopCommanded( double vop );
89  double getVopCommanded();
90  double getVop();
91  double getVopB();
92  double getVopAD();
93 
94  double getDrainCurrent(unsigned short deviceID);
95  double getGateVoltage(unsigned short deviceID);
96  double getIFCurrent();
97 
98  int bandCheck();
99  int getBimaTuneState() ; // sorry - no enums here, just 0-3
100 
101  void setPhaseLockBand();
102  void setPhaseLockBand( int band );
103 
104  int getPhaseLockBand();
105 
106  int getDewarBand();
107  void setDewarBand();
108  void setDewarBand( int band );
109 
110  void setIFSwitch();
111  void setIFSwitch( int band );
112 
113  bool checkPhaseLockRef();
114  bool alreadyTuned();
115  void saveSisTuneParameters();
116 
117  OKOrNOTState getPhaseLockRefState();
118 
119  void getTuningParameters( double &lo_ghz, unsigned short &mmosctarg,
120  unsigned short &mmbcktarg, double &voptarg,
121  double &lgaintarg );
122 
123  void lockmm( double freq );
124  void relockmm();
125  void forceRelock();
126  void tune( double freq, bool leaveAbsorber, bool optimizeReceiver );
127 
128  void cmTune();
129 
130  void setFocus( int band );
131  float loadFocusTable( std::string name );
132 
133  bool mmLockStatus();
134  int getMMLockInfo();
135  void setMMLockInfo( int value );
136 
137  void lockmmosc( int osctarget, double maxerrv );
138 
139  void setBand( Rx::Band band );
140  void selectMotorsAndMod( int iband );
141  char getBand();
142  void selectMirror( int iband );
143  void setDewarWindow( int iband );
144  int getDewarWindow();
145 
146  void setModulator( double mA );
147 
148 // float getSISMxrTemp();
149  Rx::SISSetMode getSISMode();
150 
151  void setWBAGateV( double setpoint );
152  void setWBAGateBV( double setpoint );
153  void setWBAGateDV( double setpoint );
154  double getWBAGateBV();
155  double getWBAGateDV();
156 
157  void setSIS( double setpoint, Rx::SISSetMode mode );
158 
159  void setLOpwr( double bias );
160 // void setSISBiasOut( double bias ); // what's being sent down the telem...
161  double getSISBiasOut(); // what's being sent down the telem...
162 
163  float getIFdB( void );
164  double getIFTotPower( void );
165  double getIF1TotPower( void );
166  double getIF2TotPower( void );
167  double getIF1FastPower( void );
168  double getIF2FastPower( void );
169  void startIF1FastSample();
170  void stopIF1FastSample();
171  void startIF2FastSample();
172  void stopIF2FastSample();
173 
174  double getIMxrA();
175  void setLoopGain( double lgain );
176  double getLoopGain();
177  double mmErrorVolts();
178  double getModBmA();
179  double getModADmA();
180  unsigned short modmAtoCounts( double mA );
181  void optimizeLoopGain( double defaultgain );
182  double getPhaseNoise();
183  void getSISVIBias( double& vbias, double& ibias );
184  double getInstantSISVBias();
185  double getInstantSISIBias();
186  std::string getSISMixerName();
187  double getSISMixerTemp();
188  void interpSISBiases( double& lo, double& temp,
189  double& vbias, double& ibias,
190  double& dvMinus, double& dvPlus,
191  double& dvgap, double& igap, double& ialtbias );
192 // void scanSIS( int istart, int stepsize, int nsteps,
193 // float *vmxr, float *imxr, float *ifpwr );
194 
195  static const int MAX_SCAN_STEPS = 300; // must match NMAX in AntennaIF.h
196  typedef struct{
197  float v1; // start voltage
198  float v2; // stop voltage
199  float dv; // voltage step
200  float Vj[MAX_SCAN_STEPS]; // SIS junction voltage, mV
201  float Ij[MAX_SCAN_STEPS]; // SIS junction current, uA
202  float pow[MAX_SCAN_STEPS]; // IF total power, mW
203  int npts; // number of valid points in arrays Vj,Ij,pow
204  } Scan;
205 
206  void scanSIS( Rx::Scan &Lscan, Rx::Scan &Rscan) ;
207 
208 
209  Dewar& getDewar() { return *_dewar; };
210  Motor& getMMOscAD() { return *_mmoscAD; };
211  Motor& getMMBckAD() { return *_mmbckAD; };
212  Motor& getMMOscB() { return *_mmoscB; };
213  Motor& getMMBckB() { return *_mmbckB; };
214  Motor& getAttenAD() { return *_attnD; };
215  Motor& getAttenB() { return *_attnB; };
216  double getMMIFLevel( void );
217 
218  void ifPowerAtten( unsigned short, float value );
219  void ifPowerAtten( unsigned short, short value );
220  void setLOTermRFout( float volts );
221  void setLOTermAtten( int dB );
222  void turnLOTerm( bool onoff );
223  int getLOTermAtten();
224  float getLOTermPower();
225  float getLOTermRFin();
226  float getLOTermRFout();
227  float getLOTermTemp();
228  void setHtr2( float volts );
229  void setVGate( float volts );
230  void setCMVGate( unsigned int hStage, float volts );
231  void setCMIDrain( unsigned int hStage, float mAmps );
232 
233  double getVGate();
234  double getVGateCmd();
235  double getVDrain();
236  double getIDrain();
237  double getCMIDrain( unsigned int hStage );
238  double getCMVGate( unsigned int hStage );
239  double getCMVGateCmd( unsigned int hStage );
240  double getCMIDrainCmd( unsigned int hStage );
241 
242  void setNextTuneSequenceNo( int seqno );
243  unsigned long getNextTuneSequenceNo();
244  void setCurTuneSequenceNo( int seqno );
245  unsigned long getCurTuneSequenceNo();
246 
247  void setNextOpticsSequenceNo( int seqno );
248  unsigned long getNextOpticsSequenceNo();
249  void setCurOpticsSequenceNo( int seqno );
250  unsigned long getCurOpticsSequenceNo();
251 
252  // This is mainly here to enable configuration
253  // checking.
254  carma::services::Table *loadSISTable( std::string name );
255 
256  bool isRelockEnabled();
257  void enableRelock();
258  void disableRelock();
259  void incRelock();
260  void zeroRelock();
261  int numTriesRelock();
262 
263  private:
264  Configuration &_config;
265  const char *_name;
266  std::string _dir;
267  std::ostringstream _errMsg;
268 
269  carma::services::Table *loadOscTable( std::string name );
270 
271  unsigned short _attensafe;
272  double _oscfreq;
273  double _voptarg;
274  unsigned short _mmosctarg;
275  unsigned short _mmbcktarg;
276  Dewar *_dewar;
277  CalWheel *_calwheel;
278  AntennaIFClient *_if;
279  Motor *_mmosc;
280  Motor *_mmbck;
281  Motor *_attn;
282  Motor *_mmoscAD;
283  Motor *_mmbckAD;
284  Motor *_attnD;
285  Motor *_mmoscB;
286  Motor *_mmbckB;
287  Motor *_attnB;
288  Polarizer *_pol;
289  carma::services::Table *_oscADtab;
290  carma::services::Table *_oscBtab;
291  float _cmFocusOffset;
292  bool _modulator;
293  Rx::Band _band;
294  int _iband;
295  bool _cmOpticsInstalled;
296  float _tmmFocusPosition;
297 
298  // SIS Bias handling
299  static const int MAX_HIST = 25;
300 
301  static const SISSetMode SISv = 'v';
302  static const SISSetMode SISi = 'i';
303  static const SISSetMode SISo = 'o';
304 
305  // static const int MAX_SCAN_STEPS = 40;
306 
307  }; // class Rx
308  } // namespace bima
309  } // namespace antenna
310 } // namespace carma
311 
312 ::std::ostream& operator<<( ::std::ostream& os,
313  ::carma::antenna::bima::Rx& rx );
314 
315 #endif // CARMA_ANTENNA_BIMA_RX_H
std::ostream & operator<<(::std::ostream &os, const carma::dbms::Table &table)
Class definition for Stepper Motors for BIMA systems.
Exception class for errors.
Class definition for Stepper Motors for BIMA systems.
Class definition for TelemetryClient on the BIMA antennas.
Class definition for Stepper Motors for BIMA systems.
Common table functions.
Simple ASCII Table format, fully memory based.
Definition: Table.h:126
Class definition for SharedMemory on the BIMA antennas.
Class definition for Stepper Motors for BIMA systems.
CAN Device declaration for 10m &amp; 6m SIS Receiver Control.
Class definition for TelemetryClient on the BIMA antennas.
Class definition for Stepper Motors for BIMA systems.
FileNotFoundException class.