fdhwlib  2.0.25
/home/kopmann/git-mirror/fdhwlib/fdhwlib/gpsoncore/gpsunit.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           gpsunit.h  -  description
00003                              -------------------
00004     begin                : Mon Dec 16 2002
00005     copyright            : (C) 2002 by Andreas Kopmann
00006     email                : kopmann@ipe.fzk.de
00007  ***************************************************************************/
00008 
00009 
00010 #ifndef GPSUNIT_H
00011 #define GPSUNIT_H
00012 
00013 #include <cstdio>
00014 #include <string>
00015 #include <stdexcept>
00016 
00017 #include "gpsserver.h"
00018 
00019 class SimpleSocket;
00020 
00021 
00122 class GpsUnit {
00123 
00124 public:
00127   enum Status {
00128            Ok,                 
00129            Failed,             
00130            Unknown,            
00131            NoConnection,       
00132            OutdatedTimeStamp,  
00134            FutureTimeStamp,    
00136            MissingData,        
00139            OncoreError,        
00141            OncoreStartup,      
00143            AugerSecondError,   
00145            VersionMismatch,    
00147            SiteSurvey,         
00149            PositionNotFix,     
00151            OncoreSecondError,  
00153            OncoreTimezoneError,
00155            NoLeapSeconds,      
00157            BadAlmanac,         
00159            BadSatellites       
00161 };
00162 
00163 
00164   Status lastStat;
00165 
00166   struct pulseGen {
00167     unsigned int startSec; //< Start second of the generator [s]
00168     int startSubSec;        //< Rising edge [us]
00169     int stopSubSec;         //< Falling edge [us]
00170     int period;             //< Period length of the signal [s]
00171     int period2;            //< Period length of the signal [min]
00172     int n;                  //< Number of pulses
00173     int type;               //< Meaning of the signal: 0 veto signal, 1 external trigger
00174     int stat;               //< Status: 0 stopped, 1 started
00175   };
00176 
00177 
00178 public:
00189   GpsUnit(const char *inifile = "FE.ini");
00190   GpsUnit(const char *inifile, const char *host, int port=0);
00191   ~GpsUnit();
00192 
00193 
00215   Status getTimeCorrection(unsigned int gpsSec, unsigned int *count,
00216             int *phase, int *lastSawtooth, int *nextSawtooth);
00217 
00218 
00225   Status getTimeCorrection(unsigned int gpsSec, double *T10, double *offset);
00226 
00233   unsigned int getTime(unsigned int *augerSec=0);
00234 
00245   Status checkTime(int *tOncoreDiff = 0 , int *tAugerDiff = 0);
00246 
00247 
00248   Status checkActalTime();
00249   
00252   int getLeapSeconds();
00253 
00254 
00257   void setInhibit();
00258 
00261   void releaseInhibit();
00262 
00264   bool isInhibit();
00265 
00267   void setAdjustMode(int mode);
00268 
00270   bool isAdjustActive();
00271 
00279   void setPulseGeneratorParameter(int ch, struct pulseGen parameter);
00280 
00285   void getPulseGeneratorParameter(int ch, struct pulseGen *parameter);
00286 
00287 
00295   void setInputMode(int ch, int mode, int state=-1);
00296 
00297 
00307   int getInputMode(int ch, int *mode=0, int *state=0);
00308 
00314   void setLidarTriggerFrequency(int freq);
00315 
00316 
00322   int getLidarTriggerFrequency();
00323 
00324 
00350   Status getStatus();
00351 
00352 
00355   int getVersion(enum deviceId dev, int len=0, char *buildnote=0);
00356 
00357 
00362   void init();
00363 
00368   Status shutdown();
00369 
00375   Status connect(char *host = 0, int port = 0);
00376 
00381   Status disconnect();
00382 
00383 
00390   void setCommunicationWindow(int begin, int end);
00391 
00392 
00395   //static std::string getVerboseStatus(GpsUnit::Status status);
00396   std::string getVerboseStatus(GpsUnit::Status status);
00397 
00398 
00401   void getPosition(std::string *name,
00402        int *latitude=0, int *longitude=0, int *height=0);
00403 
00404 
00418   void getPosition(int *id, std::string *name,
00419                                    int *latitude=0, int *longitude=0, int *height=0);
00420 
00421        
00423   void getCapturedInputs(FILE *fout, int n = 1, int ch = 0);
00424 
00425   
00427   const char *getServerHostname();
00428   
00430   int getServerPort();
00431 
00432   
00434   void displayRawData(FILE *fout);
00435 
00437   void sendMsg(unsigned char *msg, int n);
00438   
00439 private:
00440 
00442   SimpleSocket *sock;
00443 
00444   bool connected;
00445 
00446   std::string host;
00447   int port;
00448 
00449 
00450   unsigned int status;
00451 };
00452 
00453 #endif