My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Share.h
1 #ifndef SZA_ANTENNA_SZASHARE_H
2 #define SZA_ANTENNA_SZASHARE_H
3 
11 #include <string>
12 
13 #include <pthread.h>
14 
15 #include "gcp/util/common/TimeVal.h"
16 
17 #include "gcp/util/common/DataFrameManager.h"
18 #include "gcp/util/common/Mutex.h"
19 #include "gcp/util/common/QuadPath.h"
20 
21 #include "gcp/antenna/control/specific/PolarEncoderPos.h"
22 #include "gcp/antenna/control/specific/Site.h"
23 
24 // C header files from the array control code
25 
26 #include "gcp/control/code/unix/libunix_src/specific/specificregs.h"
27 #include "gcp/control/code/unix/libunix_src/common/astrom.h"
28 
29 namespace gcp {
30  namespace antenna {
31  namespace control {
32 
38  class SpecificShare {
39 
40  public:
41 
45  enum TimeOut {
46  NO_WAIT,
47  WAIT_FOREVER
48  };
49 
53  enum Type {
54  CHAR,
55  UCHAR,
56  SHORT,
57  USHORT,
58  INT,
59  UINT,
60  LONG,
61  ULONG,
62  FLOAT,
63  DOUBLE
64  };
65 
70  struct DataPtr {
71  Type type;
72  void* ptr_;
73  };
74 
75  //------------------------------------------------------------
76  // ExpstubRegDb Object
77  //------------------------------------------------------------
78 
83  class ExpstubRegDb {
84 
85  public:
86 
92  ExpstubRegDb();
93 
97  ~ExpstubRegDb();
98 
111  void readShadowReg(RegMapBlock *blk, unsigned first,
112  unsigned nreg, DataPtr& value);
113 
127  void writeShadowReg(RegMapBlock *blk, unsigned first,
128  unsigned nreg, Dataptr& value);
129 
135  void grabRegs(TimeOut timeout);
136 
142  void ungrabRegs();
143 
147  RegMapBoard* findRegMapBoard(std::string boardName);
148 
162 
172 
187 
188  private:
189 
193  friend class SpecificShare;
194 
198  RegMap* regmap_;
199 
203  gcp::util::Mutex guard_;
204 
208  unsigned char* shadow_;
209 
213  int nShadow_;
214 
225  unsigned* SpecificShare::ExpstubRegDb::boardStatusReg(int board);
226 
227  };
228 
229  //------------------------------------------------------------
230  // ExpstubClock Object
231  //------------------------------------------------------------
232 
236  class ExpstubClock {
237 
238  public:
239 
243  ExpstubClock();
244 
250  ~ExpstubClock();
251 
257  void setClock(unsigned long mjd, unsigned long sec,
258  unsigned long nanoSeconds);
259 
265  void setClock(gcp::util::TimeVal& time);
266 
273  void setClock();
274 
280  double getUtc();
281 
282  private:
283 
287  gcp::util::Mutex guard_;
288 
289  gcp::util::TimeVal time_;
290  };
291 
292  //----------------------------------------------------------------------
293  // ExpstubAstrom Object
294  //------------------------------------------------------------
295 
301 
302  public:
303 
309  ExpstubAstrom();
310 
314  ~ExpstubAstrom();
315 
321  void setSite(double longitude, double latitude, double altitude);
322 
329 
336  void extendUt1Utc(double utc, double ut1utc);
337 
345  void extendEqnEqx(double tt, double eqneqx);
346 
352  double getUt1Utc(double utc);
353 
360  double getEqnEqx(double tt);
361 
362  private:
363 
367  gcp::util::Mutex guard_;
368 
373 
378  gcp::util::QuadPath* ut1utc_;
379 
385  gcp::util::QuadPath* eqneqx_;
386 
387  }; // Class ExpstubAstrom
388 
389  //------------------------------------------------------------
390  // SpecificShare Methods
391  //------------------------------------------------------------
392 
397  struct HostAddress {
398  char* name;
399  char* address;
400  };
401 
402  // Static members and functions
403 
408 
413 
423  static std::string hostIpAddress(std::string host);
424 
430  SpecificShare(std::string host);
431 
435  ~SpecificShare();
436 
459  void readReg(RegMapBlock *blk, unsigned first, unsigned nreg,
460  unsigned *value);
461 
477  void readRawReg(RegMapBlock *blk, unsigned first, unsigned nreg,
478  unsigned *value);
479 
494  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
495  signed char* value);
496 
497  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
498  unsigned char* value);
499 
500  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
501  signed short* value);
502 
503  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
504  unsigned short* value);
505 
506  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
507  int* value);
508 
509  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
510  unsigned int* value);
511 
512  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
513  long* value);
514 
515  void writeReg(RegMapBlock* blk, unsigned first, unsigned nreg,
516  unsigned long* value);
517 
518  void writeReg(RegMapBlock *blk, unsigned first, unsigned nreg,
519  float* value);
520 
521  void writeReg(RegMapBlock *blk, unsigned first, unsigned nreg,
522  double* value);
523 
538  void writeRawReg(RegMapBlock* blk, unsigned first, unsigned nreg,
539  unsigned char* value);
540 
541  void writeRawReg(RegMapBlock* blk, unsigned first, unsigned nreg,
542  unsigned short* value);
543 
544  void writeRawReg(RegMapBlock* blk, unsigned first, unsigned nreg,
545  unsigned* value);
546 
547  void writeRawReg(RegMapBlock* blk, unsigned first, unsigned nreg,
548  float* value);
549 
550  void writeRawReg(RegMapBlock* blk, unsigned first, unsigned nreg,
551  double* value);
552 
564  void grabRegs(TimeOut timeout);
565 
571  void ungrabRegs();
572 
573  /*
574  * Flag a board as unreachable. Note that this is called
575  * automatically by read_regdb() and write_regdb() if their
576  * 'check' argument is true and an exception occurs. If
577  * 'check' is false then the caller is expected to perform
578  * exception handling and to call the following function if an
579  * exception occurs.
580  *
581  * @throws Exception
582  */
583  void flagBoard(int board);
584 
585  /*
586  * This function will be called by the scanner task after
587  * successfully reading all registers of a previously flagged
588  * board without incuring an exception. It marks the board as
589  * usable by other tasks.
590  *
591  * @throws Exception
592  */
593  void unflagBoard(int board);
594 
600  bool verifyBoard(int board);
601 
607  double getLst(double utc);
608 
612  double getTt(double lst);
613 
619  double getUtc();
620 
626  void setClock(unsigned long mjd, unsigned long sec,
627  unsigned long nanoSeconds);
628 
634  void setClock(gcp::util::TimeVal& time);
635 
641  void setClock();
642 
648  void setSite(double longitude, double latitude, double altitude);
649 
655  double getUt1Utc(double utc);
656 
663  double getEqnEqx(double tt);
664 
671  void extendUt1Utc(double utc, double ut1utc);
672 
680  void extendEqnEqx(double tt, double eqneqx);
681 
685  RegMapBoard* findRegMapBoard(std::string boardName);
686 
690  unsigned int getNboard();
691 
695  unsigned int getNarchived();
696 
703 
704  private:
705 
715  void packRegBoard(RegMapBoard* brd,
717 
721  unsigned char* tmpbuf_;
722 
726  std::string controlHost_;
727 
731  ExpstubRegDb *regdb_;
732 
736  ExpstubClock *clock_;
737 
741  ExpstubAstrom *astrom_;
742 
743  }; // class SpecificShare
744 
745  }; // End namespace control
746  }; // End namespace antenna
747 } // End namespace gcp
748 
749 #endif
double getTt(double lst)
Definition: SpecificShare.cc:1124
void setSite(double longitude, double latitude, double altitude)
Definition: SpecificShare.cc:1191
Definition: Site.h:33
void grabRegs(TimeOut timeout)
Definition: SpecificShare.cc:697
void extendUt1Utc(double utc, double ut1utc)
Definition: SpecificShare.cc:1200
double getUtc()
Definition: SpecificShare.cc:1140
void ungrabRegs()
Definition: SpecificShare.cc:705
static SpecificShare * share_
Definition: Share.h:407
~SpecificShare()
Definition: SpecificShare.cc:655
bool SpecificShare::ExpstubRegDb::verifyBoard(int board)
unsigned int getNarchived()
Definition: SpecificShare.cc:1225
bool verifyBoard(int board)
Definition: SpecificShare.cc:729
unsigned int getNboard()
Definition: SpecificShare.cc:1217
void extendUt1Utc(double utc, double ut1utc)
Definition: Mutex.h:16
void getSite(gcp::antenna::control::Site *site)
RegMapBoard * findRegMapBoard(std::string boardName)
void setClock()
Definition: SpecificShare.cc:1183
static HostAddress host_address[]
Definition: Share.h:412
void writeRawReg(RegMapBlock *blk, unsigned first, unsigned nreg, unsigned char *value)
RegMapBoard * findRegMapBoard(std::string boardName)
void extendEqnEqx(double tt, double eqneqx)
Definition: SpecificShare.cc:1209
void writeReg(RegMapBlock *blk, unsigned first, unsigned nreg, signed char *value)
double getUt1Utc(double utc)
Definition: SpecificShare.cc:1158
void readReg(RegMapBlock *blk, unsigned first, unsigned nreg, unsigned *value)
DataFrame * frame()
Definition: DataFrameManager.cc:384
Definition: TimeVal.h:55
double getEqnEqx(double tt)
Definition: SpecificShare.cc:1149
Definition: QuadPath.h:27
void writeShadowReg(RegMapBlock *blk, unsigned first, unsigned nreg, Dataptr &value)
void setSite(double longitude, double latitude, double altitude)
Definition: DataFrameManager.h:23
static std::string hostIpAddress(std::string host)
void packFrame(gcp::util::DataFrameManager *frame)
Definition: SpecificShare.cc:1324
void flagBoard(int board)
Definition: SpecificShare.cc:713
void SpecificShare::ExpstubRegDb::unflagBoard(int board)
void readShadowReg(RegMapBlock *blk, unsigned first, unsigned nreg, DataPtr &value)
void unflagBoard(int board)
Definition: SpecificShare.cc:721
void readRawReg(RegMapBlock *blk, unsigned first, unsigned nreg, unsigned *value)
double getLst(double utc)
Definition: SpecificShare.cc:1086
void SpecificShare::ExpstubRegDb::flagBoard(int board)