fdhwlib  2.0.25
/home/kopmann/git-mirror/fdhwlib/fdhwlib/Pbus/pbusproxy.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     pbusproxy.h  -  description
00003 
00004     begin                : Wed Oct 22 2003
00005     copyright            : (C) 2003 by A Kopmann
00006     email                : kopmann@ipe.fzk.de
00007     status               :
00008     test                 :
00009     history              :
00010  ***************************************************************************/
00011 
00012 
00013 #ifndef PBUSPROXY_H
00014 #define PBUSPROXY_H
00015 
00016 #include <fdhwlib.h>
00017 #define PBUS_IP_MAX       FD_TELESCOPES
00018 //#define PBUS_IP_MAX       6 // Only six telescopes available at a time?!
00019 
00020 #ifdef PBUS_IP
00021 
00022 #include <string>
00023 #include "pbusimp.h"
00024 
00025 
00026 class SimpleSocket;
00027 
00035 class PbusProxy : public PbusImp {
00036 public:
00037   PbusProxy();
00038 
00039   ~PbusProxy();
00040 
00041   const char *getMode();
00042 
00043   int getModeId();
00044 
00045   const char *getLibName();
00046 
00047   int get(std::string item, std::string *value);
00048 
00050   int getRemote(std::string item, std::string *value);
00051   
00052   int set(std::string item, std::string value);
00053 
00055   int setRemote(std::string item, std::string value);
00056   
00058   void setTimeout(unsigned long mstimeout);
00059 
00061   unsigned long getTimeout();
00062 
00074   int init(char *inifile, int host=0);
00075 
00076   int free(int host=0);
00077 
00078   void reset();
00079 
00080   unsigned long getState();
00081 
00082   unsigned long getState(unsigned long addr);
00083 
00084   int waitForIR(int timeout);
00085 
00086   int checkIR();
00087 
00088   unsigned long getIRvector();
00089 
00090   unsigned long readIRvector();
00091 
00092   void writeIRvector(unsigned long vector);
00093 
00094   unsigned long read(unsigned long addr);
00095 
00096   unsigned long rawRead(unsigned long addr);
00097 
00098   void write(unsigned long addr, unsigned long data);
00099 
00100   void rawWrite(unsigned long addr, unsigned long data);
00101 
00102   void writeBits(unsigned long addr, unsigned long data,
00103                  unsigned long mask, int shift);
00104 
00105   void setBitsToHigh(unsigned long addr, unsigned long mask);
00106 
00107   void setBitsToLow(unsigned long addr, unsigned long mask);
00108 
00109   void readBlock(unsigned long addr, unsigned long * data,
00110                  unsigned long n, unsigned long incr=1);
00111 
00112   void writeBlock(unsigned long addr, unsigned long * data,
00113                unsigned long n, unsigned long incr=1);
00114 
00115   void clearBlock(unsigned long addr, unsigned long data,
00116                       unsigned long n, unsigned long incr);
00117 
00118   void readRegisterBlock(unsigned long addr, unsigned long *data,
00119                       unsigned long nPix, unsigned long incrPix,
00120                       unsigned long nSlots=1, unsigned long incrSlots=0);
00121 
00122   void connect(std::string ipaddr, int port);
00123 
00124   void remoteCall(short cmdid, unsigned long *args, short argc,
00125                       unsigned long *data, short ndata,
00126                       unsigned long *ackn, short len);
00127 
00130   void selectTelescope(int id);
00131 
00134   int getTelescope();
00135   
00137   int getNTelescopes();
00138 
00146   bool isConnected(int id=0);
00147 
00151   static SimpleSocket *sock[PBUS_IP_MAX];
00152 
00154   static bool connected[PBUS_IP_MAX];
00155 
00157   static int telescopeId;
00158 
00159   void shutdown();
00160 
00161   int startBackgroundLoop(int eyeId, char *host, int telId);
00162   
00163   char *getHostName(int tel);
00164 
00165   unsigned long getPCTime();
00166 
00167 private:
00168 
00170   struct timeval timeout;  
00171 
00172   int test;
00173 
00174 };
00175 
00176 #endif // of PBUS_IP
00177 
00178 #endif