epoc-gps.hpp

Go to the documentation of this file.
00001 #ifndef __epoc_gps_hpp__
00002 #define __epoc_gps_hpp__
00003 
00004 #include "application_config.h"
00005 
00006 #if __GPS_ENABLED__
00007 
00008 #include "epoc-gps-observer.hpp"
00009 
00010 #include "ac_app_context.h"
00011 #include "epoc-ao-gerror.hpp"
00012 #include "ld_log_db.h"
00013 #include "ut_retry_epoc.hpp"
00014 #include "utils_cl2.h"
00015 
00016 #include <e32std.h>
00017 #include <lbs.h> // link against lbs.lib
00018 #include <lbssatellite.h>
00019 
00020 #include <glib.h>
00021 
00022 class CPositioner_gps;
00023 class CPosModuleStatAo;
00024 
00025 NONSHARABLE_CLASS(CSensor_gps) :
00026   public CBase,
00027   public MObserverPosMod,
00028   public MObserver_gps,
00029   public MRetryAoObserver
00030 {
00031  public:
00032   static CSensor_gps* NewL(ac_AppContext* aAppContext);
00033   virtual ~CSensor_gps();
00034 
00035  private:
00036   CSensor_gps(ac_AppContext* aAppContext);
00037   void ConstructL();
00038 
00039  private: // MObserverPosMod
00040   virtual void PosModChangeL();
00041   virtual void PosModErrorL(TInt errCode);
00042   virtual void PosModLeave(TInt errCode);
00043   virtual TBool PosModIsCurrent(TPositionModuleId id) const;
00044 
00045  private: // MObserver_gps
00046   virtual gboolean PositionerEventL(GError** error);
00047 
00048  private: // MRetryAoObserver
00049   virtual void RetryTimerExpired(CRetryAo* src, TInt errCode);
00050 
00051  private:
00052   ac_AppContext* iAppContext; // not owned
00053   LogDb* iLogDb; // not owned
00054 
00055   CPosModuleStatAo* iModuleAo; // owned
00056 
00057   // Used for positioning when a suitable positioning module is
00058   // available. When nothing suitable is available, this is NULL.
00059   CPositioner_gps* iPositioner; // owned
00060 
00061   CRetryAo* iRetryAo; // owned
00062 
00063   TInt iPositionUpdateIntervalSecs;
00064 
00065   enum TState {
00066     EInactive = 0, // not started
00067     EActive // module status query outstanding
00068   };
00069   TState iState;
00070 
00071   TPositionModuleId iModuleId; // current one, or KPositionNullModuleId
00072 
00073  private:
00074   void RefreshPositionUpdateIntervalSecs();
00075   void CreateSpecifiedPositionerL(TPositionModuleId bestId);
00076 
00077  public:
00078   void StartL();
00079   void Stop();
00080   TBool IsActive() const { return iState != EInactive; }
00081   void Reconfigure(const gchar* name, const gchar* value);
00082 };
00083 
00084 #endif // __GPS_ENABLED__
00085 
00086 // --------------------------------------------------
00087 // sensor array integration
00088 // --------------------------------------------------
00089 
00090 #if defined(SA_ARRAY_INTEGRATION)
00091 #if __GPS_ENABLED__
00092 #define DECLARE_SENSOR_gps CSensor_gps* iSensor_gps
00093 #define SENSOR_GPS_DESTROY DELETE_Z(self->iSensor_gps)
00094 #define SENSOR_GPS_CREATE sa_typical_symbian_sensor_create(self->iSensor_gps = CSensor_gps::NewL(self->ac), "gps sensor initialization")
00095 #define SENSOR_GPS_START sa_trap_symbian_sensor_start(self->iSensor_gps, "failed to start gps scanning")
00096 #define SENSOR_GPS_STOP { self->iSensor_gps->Stop(); }
00097 #define SENSOR_GPS_IS_RUNNING (self->iSensor_gps->IsActive())
00098 #define SENSOR_GPS_RECONFIGURE(key,value) sa_typical_symbian_sensor_reconfigure(gps)
00099 #else
00100 #define DECLARE_SENSOR_gps
00101 #endif
00102 #endif /* SA_ARRAY_INTEGRATION */
00103 
00104 #endif /* __epoc_gps_hpp__ */
00105 
00106 /**
00107 
00108 epoc-gps.hpp
00109 
00110 Copyright 2009 Helsinki Institute for Information Technology (HIIT)
00111 and the authors. All rights reserved.
00112 
00113 Authors: Tero Hasu <tero.hasu@hut.fi>
00114 
00115 Permission is hereby granted, free of charge, to any person
00116 obtaining a copy of this software and associated documentation files
00117 (the "Software"), to deal in the Software without restriction,
00118 including without limitation the rights to use, copy, modify, merge,
00119 publish, distribute, sublicense, and/or sell copies of the Software,
00120 and to permit persons to whom the Software is furnished to do so,
00121 subject to the following conditions:
00122 
00123 The above copyright notice and this permission notice shall be
00124 included in all copies or substantial portions of the Software.
00125 
00126 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00127 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00128 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00129 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00130 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00131 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00132 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00133 SOFTWARE.
00134 
00135  **/

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1