camera/Bicam.h

Go to the documentation of this file.
00001 #ifndef _BICAM_H_
00002 #define _BICAM_H_
00003 
00008 /****************************************************************************/
00009 /* Copyright (c) 2008 MBARI                                                 */
00010 /* MBARI Proprietary Information. All rights reserved.                      */
00011 /****************************************************************************/
00012 /* Summary  :                                                               */
00013 /* Filename : Bicam.h                                                       */
00014 /* Author   : K Headley                                                     */
00015 /* Project  : Benthic Imaging AUV                                           */
00016 /* Created  : 04/01/2008                                                    */
00017 /****************************************************************************/
00018 /* Modification History:                                                    */
00019 /*  $Id: Bicam.h,v 1.1 2008/07/15 18:39:29 headley Exp $   */
00020 /*  $Name:  $ */
00021 /****************************************************************************/
00022 
00023 #include <signal.h>
00024 //#include <sys/msg.h>
00025 //#include <sys/ipc.h>
00026 //#include <sys/fcntl.h>
00027 #include <errno.h>
00028 #include "XPort.h"
00029 #include "NMEA.h"
00030 #include "Utils.h"
00031 #include "qnx_port.h"
00032 #include "BicamConsts.h"
00033 /* 
00034    Function Declarations
00035 */
00036 
00037 
00050 class BicamTrigger{
00051  private:
00052  protected:
00054   XPort *xport;
00056   unsigned int cameraSelectMask;
00058   unsigned int cameraOnMask;
00060   unsigned int cameraOffMask;
00061 
00062  public:
00063   BicamTrigger();
00064   BicamTrigger(XPort *pXPort,
00065                unsigned int selMask, 
00066                unsigned int camOnMask, 
00067                unsigned int camOffMask);
00068   /*
00069   BicamTrigger(char *host,
00070                int gpioIPPort, 
00071                unsigned int dirMask,
00072                unsigned int dirValues,
00073                unsigned int levelMask,
00074                unsigned int levelValues,
00075                unsigned int selMask, 
00076                unsigned int camOnMask, 
00077                unsigned int camOffMask);
00078   */
00079   BicamTrigger(unsigned int selMask,
00080                unsigned int camOnMask, 
00081                unsigned int camOffMask);
00082 
00083   ~BicamTrigger();
00084   XPort *connect(char *host,
00085                  int gpioIPPort, 
00086                  unsigned int dirMask,
00087                  unsigned int dirValues,
00088                  unsigned int levelMask,
00089                  unsigned int levelValues);
00090  
00091   int configure(XPort *pXPort,
00092                 unsigned int selMask, 
00093                 unsigned int camOnMask, 
00094                 unsigned int camOffMask); 
00095   XPort *getXPort();
00096   void setXPort(XPort *);
00097   int triggerCamera();
00098   unsigned int getCamOnMask();
00099   unsigned int getCamOffMask();
00100   unsigned int getCamSelectMask();
00101   void setCamOnMask(unsigned int mask);
00102   void setCamOffMask(unsigned int mask);
00103   void setCamSelectMask(unsigned int mask);
00104 
00105 };
00106 
00119 class BicamGPS{
00120  private:
00121  protected:
00123   XPort *xport; 
00127   GPGGA gpgga;
00131   GPRMC gprmc;
00133   double latitude;
00135   double longitude;
00137   double altitude;
00139   boolean initialized;
00140   int initNMEA();
00141   int degrees(double value);
00142   double decimalMinutes(double value);
00143  public:
00144   BicamGPS();
00145   BicamGPS(XPort *pXPort);
00146   BicamGPS(char *host, int serialIPPort);
00147   ~BicamGPS();
00148   int configure(XPort *pXPort);
00149   GPGGA *getGPGGA();
00150   GPRMC *getGPRMC();
00151   XPort *getXPort();
00152   void setXPort(XPort *xp);
00153   XPort *connect(char *host, int serialIPPort);
00154   int initialize();
00155   int writeNMEA();
00156   int update(time_t timaVal,double lat, double lon, double alt);
00157   double getLat();
00158   double getLon();
00159   double getAlt();
00160 };
00161 
00162 /*
00163   Under Cygwin, message queues require special support using cygserver:
00164   - run cygserver-config; accept option to install as service (generates /etc/cygserver.conf)
00165   - set CYGWIN=server (or add server to existing CYGWIN definition)
00166   - start cygserver as a service
00167      $ net start cygserver
00168      OR
00169      $ cygrunsrv -S cygserver
00170   - for more info see /usr/share/doc/cygserver.README
00171   Under QNX, the MQueue server must be run (as root):
00172 
00173      $ MQueue &
00174 */
00175 /*
00176 class CamIF{
00177  private:
00178  protected:
00179   enum boolean{FALSE=0,TRUE};
00180   XPort xport;
00181   GPGGA gpgga;
00182   GPRMC gprmc;
00183   int gpsLoop();
00184   boolean gpsInitialized;  
00185   int gpsPID;
00186   key_t mqKey;
00187   int mqID;
00188   struct MQ_Msg{
00189     long mtype;
00190     char gpggaStr[MAX_NMEA_LEN+1];
00191     char gprmcStr[MAX_NMEA_LEN+1];
00192   }mqMsg;
00193   int checkMessages();
00194   int processMessage(long int mType);
00195   int setmsg(long type, const char *gpgga, const char *gprmc );
00196 
00197  public:
00198   enum MQ_MSG_TYPE {START=100,STOP,UPDATE_GPGGA,UPDATE_GPRMC,UPDATE_ALL};
00199 
00200   CamIF();
00201   XPort *connectCamera( char *host,
00202                        int gpioIPPort, 
00203                        int serialIPPort,
00204                        unsigned int dirMask,
00205                        unsigned int levelMask);
00206   XPort *getXPort();
00207   GPGGA *getGPGGA();
00208   GPRMC *getGPRMC();
00209   int initNMEA();
00210   int triggerCamera(int latd,  double latm,
00211                     int lond, double lonm, 
00212                     double alt, 
00213                     time_t time);
00214   //void sig_handler(int sig);
00215   void run();
00216   int initGPS();
00217   int getGPSPID();
00218   int startmq(int flags);
00219   int stopmq();
00220   int sendmsg(long type);
00221   int sendmsg(long type, const char *gpgga, const char *gprmc);
00222 };
00223 */
00224 #endif /*_BICAM_H_*/

Generated on Tue Jul 15 13:10:21 2008 for Benthic Imaging AUV by  doxygen 1.5.4