Colin Stearns / Mbed 2 deprecated dgps

Dependencies:   mbed

handle/dataLocation.h

Committer:
dylanembed123
Date:
2014-04-03
Revision:
6:f0248eb6714d
Parent:
5:eef5ea6a9916

File content as of revision 6:f0248eb6714d:

/**
  *  \brief Camera interface
  **/

#define MAXNUMLOCS 256

// Storage of data location
class DataLocation{
private:
    // Current value of lat lon and alt
    double lat,lon,alt;
    double timestamp;
public:
    DataLocation(){}
    DataLocation(double latA,double lonA,double altA,double t=0):lat(latA),lon(lonA),alt(altA),timestamp(t){}
    double& getLat(){return lat;}
    double& getLon(){return lon;}
    double& getAlt(){return alt;}
};

/// \brief Location holder type
enum LHType{
    LHType_locs=0,
    LHType_targ,
    LHType_base
};

/// \brief Location holder index type
enum LHIType{
    LHIType_head=0,
    LHIType_size
};

// Singleton location holder
class LocHolder{
private:
    // Actual Locations (absolute)
    DataLocation locs[MAXNUMLOCS];
    // Target Locations (relative to base station -> base station is at 0,0,0)
    DataLocation targ[MAXNUMLOCS];
    // Base Station Locations (absolute)
    DataLocation base[MAXNUMLOCS];
    // Index of the head of the circular buffers
    unsigned int headLocs,headTarg,headBase;
    // Number of locations
    unsigned int sizeLocs,sizeTarg,sizeBase;
    LocHolder():headLocs(0),headTarg(0),headBase(0),sizeLocs(0),sizeTarg(0),sizeBase(0){}
public:
    /// \brief Get locations type
    DataLocation* get(LHType type);
    
    /// \brief Get Current value
    DataLocation& getC(LHType type,int offset=0);
    
    /// \brief Get Index
    unsigned int& getI(LHType type,LHIType indexType=LHIType_head);
    
    /// \brief Fix an index that might be out of bounds;
    unsigned int getRealIndex(LHType type,int index,int offset=0,bool useSize=true);
    
    /// \brief Increment index
    void inc(LHType type,int amount=1,bool abs=false);
    
    void add(LHType type,DataLocation newLoc);
};