Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
handle/dataLocation.h@27:db73f8ac6c75, 2014-04-22 (annotated)
- Committer:
- dylanembed123
- Date:
- Tue Apr 22 14:56:03 2014 +0000
- Revision:
- 27:db73f8ac6c75
- Parent:
- 15:e3e03a9df89e
- Child:
- 28:4e608589d787
Add documentation examples to the top of datalocation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dylanembed123 | 9:da906eeac51e | 1 | /** |
dylanembed123 | 9:da906eeac51e | 2 | * \brief Data location data holder |
dylanembed123 | 9:da906eeac51e | 3 | **/ |
dylanembed123 | 27:db73f8ac6c75 | 4 | // Example Usage |
dylanembed123 | 27:db73f8ac6c75 | 5 | // Looping: for(int i=0;i<DH::locs().getI(LHType_locs);i++){DataLocation thisData=DH::locs().getC(LHType_locs,i);} |
dylanembed123 | 27:db73f8ac6c75 | 6 | // Appending: DH::locs().add(LHType_locs,DataLocation(4.0f,5.0f,6.0f)); |
dylanembed123 | 27:db73f8ac6c75 | 7 | // ResetStart: DH::locs().inc(LHType_locs,0,true); |
dylanembed123 | 27:db73f8ac6c75 | 8 | // ResetEnd: DH::locs().inc(LHType_locs,-1,true); |
dylanembed123 | 27:db73f8ac6c75 | 9 | // Increment: DH::locs().inc(LHType_locs); |
dylanembed123 | 27:db73f8ac6c75 | 10 | // GetCurrent: DH::locs().getC(LHType_locs,DH::locs().getI()); |
dylanembed123 | 15:e3e03a9df89e | 11 | #ifndef _DATA_LOCATION_H_ |
dylanembed123 | 15:e3e03a9df89e | 12 | #define _DATA_LOCATION_H_ |
dylanembed123 | 14:6be57da62283 | 13 | #define MAXNUMLOCS 64 |
dylanembed123 | 14:6be57da62283 | 14 | |
dylanembed123 | 15:e3e03a9df89e | 15 | #include "usb.h" |
dylanembed123 | 15:e3e03a9df89e | 16 | |
dylanembed123 | 14:6be57da62283 | 17 | typedef struct DataLocS{ |
dylanembed123 | 15:e3e03a9df89e | 18 | double lat; |
dylanembed123 | 15:e3e03a9df89e | 19 | double lon; |
dylanembed123 | 15:e3e03a9df89e | 20 | double alt; |
dylanembed123 | 14:6be57da62283 | 21 | double timestamp; |
dylanembed123 | 15:e3e03a9df89e | 22 | double heading; |
dylanembed123 | 15:e3e03a9df89e | 23 | double tilt; |
dylanembed123 | 14:6be57da62283 | 24 | }DataLoc; |
dylanembed123 | 7:c75d5e5e6bfc | 25 | |
dylanembed123 | 7:c75d5e5e6bfc | 26 | // Storage of data location |
dylanembed123 | 7:c75d5e5e6bfc | 27 | class DataLocation{ |
dylanembed123 | 7:c75d5e5e6bfc | 28 | private: |
dylanembed123 | 7:c75d5e5e6bfc | 29 | // Current value of lat lon and alt |
dylanembed123 | 15:e3e03a9df89e | 30 | DataLoc loc; |
dylanembed123 | 7:c75d5e5e6bfc | 31 | public: |
dylanembed123 | 9:da906eeac51e | 32 | DataLocation(){} |
dylanembed123 | 15:e3e03a9df89e | 33 | DataLocation(double latA,double lonA,double altA,double timestampA=0){ |
dylanembed123 | 15:e3e03a9df89e | 34 | loc.lat=latA; |
dylanembed123 | 15:e3e03a9df89e | 35 | loc.lon=lonA; |
dylanembed123 | 15:e3e03a9df89e | 36 | loc.alt=altA; |
dylanembed123 | 15:e3e03a9df89e | 37 | loc.timestamp=timestampA; |
dylanembed123 | 15:e3e03a9df89e | 38 | } |
dylanembed123 | 15:e3e03a9df89e | 39 | double& getLat(){return loc.lat;} |
dylanembed123 | 15:e3e03a9df89e | 40 | double& getLon(){return loc.lon;} |
dylanembed123 | 15:e3e03a9df89e | 41 | double& getAlt(){return loc.alt;} |
dylanembed123 | 15:e3e03a9df89e | 42 | double& getTime(){return loc.timestamp;} |
dylanembed123 | 15:e3e03a9df89e | 43 | double& getHeading(){return loc.heading;} |
dylanembed123 | 15:e3e03a9df89e | 44 | double& getTilt(){return loc.tilt;} |
dylanembed123 | 15:e3e03a9df89e | 45 | DataLoc& getLoc(){return loc;} |
dylanembed123 | 9:da906eeac51e | 46 | }; |
dylanembed123 | 9:da906eeac51e | 47 | |
dylanembed123 | 9:da906eeac51e | 48 | /// \brief Location holder type |
dylanembed123 | 9:da906eeac51e | 49 | enum LHType{ |
dylanembed123 | 9:da906eeac51e | 50 | LHType_locs=0, |
dylanembed123 | 9:da906eeac51e | 51 | LHType_targ, |
dylanembed123 | 9:da906eeac51e | 52 | LHType_base |
dylanembed123 | 9:da906eeac51e | 53 | }; |
dylanembed123 | 9:da906eeac51e | 54 | |
dylanembed123 | 9:da906eeac51e | 55 | /// \brief Location holder index type |
dylanembed123 | 9:da906eeac51e | 56 | enum LHIType{ |
dylanembed123 | 9:da906eeac51e | 57 | LHIType_head=0, |
dylanembed123 | 9:da906eeac51e | 58 | LHIType_size |
dylanembed123 | 9:da906eeac51e | 59 | }; |
dylanembed123 | 7:c75d5e5e6bfc | 60 | |
dylanembed123 | 7:c75d5e5e6bfc | 61 | // Singleton location holder |
dylanembed123 | 7:c75d5e5e6bfc | 62 | class LocHolder{ |
dylanembed123 | 7:c75d5e5e6bfc | 63 | private: |
dylanembed123 | 7:c75d5e5e6bfc | 64 | // Actual Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 65 | DataLocation locs[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 66 | // Target Locations (relative to base station -> base station is at 0,0,0) |
dylanembed123 | 9:da906eeac51e | 67 | DataLocation targ[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 68 | // Base Station Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 69 | DataLocation base[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 70 | // Index of the head of the circular buffers |
dylanembed123 | 9:da906eeac51e | 71 | unsigned int headLocs,headTarg,headBase; |
dylanembed123 | 9:da906eeac51e | 72 | // Number of locations |
dylanembed123 | 9:da906eeac51e | 73 | unsigned int sizeLocs,sizeTarg,sizeBase; |
dylanembed123 | 7:c75d5e5e6bfc | 74 | public: |
dylanembed123 | 9:da906eeac51e | 75 | /// \brief Default constructor |
dylanembed123 | 9:da906eeac51e | 76 | LocHolder():headLocs(0),headTarg(0),headBase(0),sizeLocs(0),sizeTarg(0),sizeBase(0){} |
dylanembed123 | 9:da906eeac51e | 77 | |
dylanembed123 | 9:da906eeac51e | 78 | /// \brief Get locations type |
dylanembed123 | 15:e3e03a9df89e | 79 | DataLocation* get(LHType type=LHType_locs); |
dylanembed123 | 9:da906eeac51e | 80 | |
dylanembed123 | 9:da906eeac51e | 81 | /// \brief Get Current value |
dylanembed123 | 27:db73f8ac6c75 | 82 | // Set the offset to a positive number to start from beg |
dylanembed123 | 27:db73f8ac6c75 | 83 | // Set the offset to a negative number to start from end |
dylanembed123 | 15:e3e03a9df89e | 84 | DataLocation& getC(LHType type=LHType_locs,int offset=0); |
dylanembed123 | 9:da906eeac51e | 85 | |
dylanembed123 | 9:da906eeac51e | 86 | /// \brief Get Index |
dylanembed123 | 27:db73f8ac6c75 | 87 | // Set type to head to find get the index of the current incremeter. |
dylanembed123 | 27:db73f8ac6c75 | 88 | // Set type to size to find the size |
dylanembed123 | 15:e3e03a9df89e | 89 | unsigned int& getI(LHType type=LHType_locs,LHIType indexType=LHIType_head); |
dylanembed123 | 7:c75d5e5e6bfc | 90 | |
dylanembed123 | 9:da906eeac51e | 91 | /// \brief Fix an index that might be out of bounds; |
dylanembed123 | 9:da906eeac51e | 92 | unsigned int getRealIndex(LHType type,int index,int offset=0,bool useSize=true); |
dylanembed123 | 9:da906eeac51e | 93 | |
dylanembed123 | 27:db73f8ac6c75 | 94 | /// \brief Increment index (loop on overflow) |
dylanembed123 | 15:e3e03a9df89e | 95 | void inc(LHType type=LHType_locs,int amount=1,bool abs=false); |
dylanembed123 | 7:c75d5e5e6bfc | 96 | |
dylanembed123 | 9:da906eeac51e | 97 | /// \brief Append a location to the end. |
dylanembed123 | 9:da906eeac51e | 98 | void add(LHType type,DataLocation newLoc); |
dylanembed123 | 15:e3e03a9df89e | 99 | |
dylanembed123 | 9:da906eeac51e | 100 | }; |
dylanembed123 | 15:e3e03a9df89e | 101 | class DH{ |
dylanembed123 | 15:e3e03a9df89e | 102 | public: |
dylanembed123 | 15:e3e03a9df89e | 103 | static LocHolder& Locs(); |
dylanembed123 | 15:e3e03a9df89e | 104 | }; |
dylanembed123 | 15:e3e03a9df89e | 105 | #endif |