Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
handle/dataLocation.h@66:5d43988d100c, 2014-05-05 (annotated)
- Committer:
- dylanembed123
- Date:
- Mon May 05 13:20:35 2014 +0000
- Revision:
- 66:5d43988d100c
- Parent:
- 32:9cb7bc3fc9e0
Final Project;
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 |
krobertson | 32:9cb7bc3fc9e0 | 5 | // Looping: for(int i=0;i<DH::Locs().getI(LHType_locs,LHIType_size);i++){DataLocation thisData=DH::Locs().getC(LHType_locs,i);} |
krobertson | 32:9cb7bc3fc9e0 | 6 | // Appending: DH::Locs().add(LHType_locs,DataLocation(4.0f,5.0f,6.0f)); |
krobertson | 32:9cb7bc3fc9e0 | 7 | // ResetStart: DH::Locs().inc(LHType_locs,0,true); |
krobertson | 32:9cb7bc3fc9e0 | 8 | // ResetEnd: DH::Locs().inc(LHType_locs,-1,true); |
krobertson | 32:9cb7bc3fc9e0 | 9 | // Increment: DH::Locs().inc(LHType_locs); |
krobertson | 32:9cb7bc3fc9e0 | 10 | // GetCurrent: DH::Locs().getC(LHType_locs,DH::Locs().getI(LHType_locs)); |
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 | 66:5d43988d100c | 33 | DataLocation(double latA,double lonA,double altA,double timestampA=0,double headingA=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 | 66:5d43988d100c | 38 | loc.heading=headingA; |
dylanembed123 | 15:e3e03a9df89e | 39 | } |
dylanembed123 | 15:e3e03a9df89e | 40 | double& getLat(){return loc.lat;} |
dylanembed123 | 15:e3e03a9df89e | 41 | double& getLon(){return loc.lon;} |
dylanembed123 | 15:e3e03a9df89e | 42 | double& getAlt(){return loc.alt;} |
dylanembed123 | 15:e3e03a9df89e | 43 | double& getTime(){return loc.timestamp;} |
dylanembed123 | 15:e3e03a9df89e | 44 | double& getHeading(){return loc.heading;} |
dylanembed123 | 15:e3e03a9df89e | 45 | double& getTilt(){return loc.tilt;} |
dylanembed123 | 15:e3e03a9df89e | 46 | DataLoc& getLoc(){return loc;} |
dylanembed123 | 9:da906eeac51e | 47 | }; |
dylanembed123 | 9:da906eeac51e | 48 | |
dylanembed123 | 9:da906eeac51e | 49 | /// \brief Location holder type |
dylanembed123 | 9:da906eeac51e | 50 | enum LHType{ |
dylanembed123 | 9:da906eeac51e | 51 | LHType_locs=0, |
dylanembed123 | 9:da906eeac51e | 52 | LHType_targ, |
dylanembed123 | 9:da906eeac51e | 53 | LHType_base |
dylanembed123 | 9:da906eeac51e | 54 | }; |
dylanembed123 | 9:da906eeac51e | 55 | |
dylanembed123 | 9:da906eeac51e | 56 | /// \brief Location holder index type |
dylanembed123 | 9:da906eeac51e | 57 | enum LHIType{ |
dylanembed123 | 9:da906eeac51e | 58 | LHIType_head=0, |
dylanembed123 | 9:da906eeac51e | 59 | LHIType_size |
dylanembed123 | 9:da906eeac51e | 60 | }; |
dylanembed123 | 7:c75d5e5e6bfc | 61 | |
dylanembed123 | 7:c75d5e5e6bfc | 62 | // Singleton location holder |
dylanembed123 | 7:c75d5e5e6bfc | 63 | class LocHolder{ |
dylanembed123 | 7:c75d5e5e6bfc | 64 | private: |
dylanembed123 | 7:c75d5e5e6bfc | 65 | // Actual Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 66 | DataLocation locs[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 67 | // Target Locations (relative to base station -> base station is at 0,0,0) |
dylanembed123 | 9:da906eeac51e | 68 | DataLocation targ[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 69 | // Base Station Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 70 | DataLocation base[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 71 | // Index of the head of the circular buffers |
dylanembed123 | 9:da906eeac51e | 72 | unsigned int headLocs,headTarg,headBase; |
dylanembed123 | 9:da906eeac51e | 73 | // Number of locations |
dylanembed123 | 9:da906eeac51e | 74 | unsigned int sizeLocs,sizeTarg,sizeBase; |
dylanembed123 | 7:c75d5e5e6bfc | 75 | public: |
dylanembed123 | 9:da906eeac51e | 76 | /// \brief Default constructor |
dylanembed123 | 9:da906eeac51e | 77 | LocHolder():headLocs(0),headTarg(0),headBase(0),sizeLocs(0),sizeTarg(0),sizeBase(0){} |
dylanembed123 | 9:da906eeac51e | 78 | |
dylanembed123 | 9:da906eeac51e | 79 | /// \brief Get locations type |
dylanembed123 | 15:e3e03a9df89e | 80 | DataLocation* get(LHType type=LHType_locs); |
dylanembed123 | 9:da906eeac51e | 81 | |
dylanembed123 | 9:da906eeac51e | 82 | /// \brief Get Current value |
dylanembed123 | 27:db73f8ac6c75 | 83 | // Set the offset to a positive number to start from beg |
dylanembed123 | 27:db73f8ac6c75 | 84 | // Set the offset to a negative number to start from end |
dylanembed123 | 15:e3e03a9df89e | 85 | DataLocation& getC(LHType type=LHType_locs,int offset=0); |
dylanembed123 | 9:da906eeac51e | 86 | |
dylanembed123 | 9:da906eeac51e | 87 | /// \brief Get Index |
dylanembed123 | 27:db73f8ac6c75 | 88 | // Set type to head to find get the index of the current incremeter. |
dylanembed123 | 27:db73f8ac6c75 | 89 | // Set type to size to find the size |
dylanembed123 | 15:e3e03a9df89e | 90 | unsigned int& getI(LHType type=LHType_locs,LHIType indexType=LHIType_head); |
dylanembed123 | 7:c75d5e5e6bfc | 91 | |
dylanembed123 | 9:da906eeac51e | 92 | /// \brief Fix an index that might be out of bounds; |
dylanembed123 | 9:da906eeac51e | 93 | unsigned int getRealIndex(LHType type,int index,int offset=0,bool useSize=true); |
dylanembed123 | 9:da906eeac51e | 94 | |
dylanembed123 | 27:db73f8ac6c75 | 95 | /// \brief Increment index (loop on overflow) |
dylanembed123 | 15:e3e03a9df89e | 96 | void inc(LHType type=LHType_locs,int amount=1,bool abs=false); |
dylanembed123 | 7:c75d5e5e6bfc | 97 | |
dylanembed123 | 9:da906eeac51e | 98 | /// \brief Append a location to the end. |
dylanembed123 | 9:da906eeac51e | 99 | void add(LHType type,DataLocation newLoc); |
dylanembed123 | 15:e3e03a9df89e | 100 | |
dylanembed123 | 9:da906eeac51e | 101 | }; |
dylanembed123 | 15:e3e03a9df89e | 102 | class DH{ |
dylanembed123 | 15:e3e03a9df89e | 103 | public: |
dylanembed123 | 15:e3e03a9df89e | 104 | static LocHolder& Locs(); |
dylanembed123 | 15:e3e03a9df89e | 105 | }; |
dylanembed123 | 15:e3e03a9df89e | 106 | #endif |