Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
handle/dataLocation.h@15:e3e03a9df89e, 2014-04-10 (annotated)
- Committer:
- dylanembed123
- Date:
- Thu Apr 10 05:38:45 2014 +0000
- Revision:
- 15:e3e03a9df89e
- Parent:
- 14:6be57da62283
- Child:
- 27:db73f8ac6c75
Demo prep - The GPS, camera and XBEE stream with packet work.
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 | 15:e3e03a9df89e | 4 | #ifndef _DATA_LOCATION_H_ |
dylanembed123 | 15:e3e03a9df89e | 5 | #define _DATA_LOCATION_H_ |
dylanembed123 | 14:6be57da62283 | 6 | #define MAXNUMLOCS 64 |
dylanembed123 | 14:6be57da62283 | 7 | |
dylanembed123 | 15:e3e03a9df89e | 8 | #include "usb.h" |
dylanembed123 | 15:e3e03a9df89e | 9 | |
dylanembed123 | 14:6be57da62283 | 10 | typedef struct DataLocS{ |
dylanembed123 | 15:e3e03a9df89e | 11 | double lat; |
dylanembed123 | 15:e3e03a9df89e | 12 | double lon; |
dylanembed123 | 15:e3e03a9df89e | 13 | double alt; |
dylanembed123 | 14:6be57da62283 | 14 | double timestamp; |
dylanembed123 | 15:e3e03a9df89e | 15 | double heading; |
dylanembed123 | 15:e3e03a9df89e | 16 | double tilt; |
dylanembed123 | 14:6be57da62283 | 17 | }DataLoc; |
dylanembed123 | 7:c75d5e5e6bfc | 18 | |
dylanembed123 | 7:c75d5e5e6bfc | 19 | // Storage of data location |
dylanembed123 | 7:c75d5e5e6bfc | 20 | class DataLocation{ |
dylanembed123 | 7:c75d5e5e6bfc | 21 | private: |
dylanembed123 | 7:c75d5e5e6bfc | 22 | // Current value of lat lon and alt |
dylanembed123 | 15:e3e03a9df89e | 23 | DataLoc loc; |
dylanembed123 | 7:c75d5e5e6bfc | 24 | public: |
dylanembed123 | 9:da906eeac51e | 25 | DataLocation(){} |
dylanembed123 | 15:e3e03a9df89e | 26 | DataLocation(double latA,double lonA,double altA,double timestampA=0){ |
dylanembed123 | 15:e3e03a9df89e | 27 | loc.lat=latA; |
dylanembed123 | 15:e3e03a9df89e | 28 | loc.lon=lonA; |
dylanembed123 | 15:e3e03a9df89e | 29 | loc.alt=altA; |
dylanembed123 | 15:e3e03a9df89e | 30 | loc.timestamp=timestampA; |
dylanembed123 | 15:e3e03a9df89e | 31 | } |
dylanembed123 | 15:e3e03a9df89e | 32 | double& getLat(){return loc.lat;} |
dylanembed123 | 15:e3e03a9df89e | 33 | double& getLon(){return loc.lon;} |
dylanembed123 | 15:e3e03a9df89e | 34 | double& getAlt(){return loc.alt;} |
dylanembed123 | 15:e3e03a9df89e | 35 | double& getTime(){return loc.timestamp;} |
dylanembed123 | 15:e3e03a9df89e | 36 | double& getHeading(){return loc.heading;} |
dylanembed123 | 15:e3e03a9df89e | 37 | double& getTilt(){return loc.tilt;} |
dylanembed123 | 15:e3e03a9df89e | 38 | DataLoc& getLoc(){return loc;} |
dylanembed123 | 9:da906eeac51e | 39 | }; |
dylanembed123 | 9:da906eeac51e | 40 | |
dylanembed123 | 9:da906eeac51e | 41 | /// \brief Location holder type |
dylanembed123 | 9:da906eeac51e | 42 | enum LHType{ |
dylanembed123 | 9:da906eeac51e | 43 | LHType_locs=0, |
dylanembed123 | 9:da906eeac51e | 44 | LHType_targ, |
dylanembed123 | 9:da906eeac51e | 45 | LHType_base |
dylanembed123 | 9:da906eeac51e | 46 | }; |
dylanembed123 | 9:da906eeac51e | 47 | |
dylanembed123 | 9:da906eeac51e | 48 | /// \brief Location holder index type |
dylanembed123 | 9:da906eeac51e | 49 | enum LHIType{ |
dylanembed123 | 9:da906eeac51e | 50 | LHIType_head=0, |
dylanembed123 | 9:da906eeac51e | 51 | LHIType_size |
dylanembed123 | 9:da906eeac51e | 52 | }; |
dylanembed123 | 7:c75d5e5e6bfc | 53 | |
dylanembed123 | 7:c75d5e5e6bfc | 54 | // Singleton location holder |
dylanembed123 | 7:c75d5e5e6bfc | 55 | class LocHolder{ |
dylanembed123 | 7:c75d5e5e6bfc | 56 | private: |
dylanembed123 | 7:c75d5e5e6bfc | 57 | // Actual Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 58 | DataLocation locs[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 59 | // Target Locations (relative to base station -> base station is at 0,0,0) |
dylanembed123 | 9:da906eeac51e | 60 | DataLocation targ[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 61 | // Base Station Locations (absolute) |
dylanembed123 | 9:da906eeac51e | 62 | DataLocation base[MAXNUMLOCS]; |
dylanembed123 | 7:c75d5e5e6bfc | 63 | // Index of the head of the circular buffers |
dylanembed123 | 9:da906eeac51e | 64 | unsigned int headLocs,headTarg,headBase; |
dylanembed123 | 9:da906eeac51e | 65 | // Number of locations |
dylanembed123 | 9:da906eeac51e | 66 | unsigned int sizeLocs,sizeTarg,sizeBase; |
dylanembed123 | 7:c75d5e5e6bfc | 67 | public: |
dylanembed123 | 9:da906eeac51e | 68 | /// \brief Default constructor |
dylanembed123 | 9:da906eeac51e | 69 | LocHolder():headLocs(0),headTarg(0),headBase(0),sizeLocs(0),sizeTarg(0),sizeBase(0){} |
dylanembed123 | 9:da906eeac51e | 70 | |
dylanembed123 | 9:da906eeac51e | 71 | /// \brief Get locations type |
dylanembed123 | 15:e3e03a9df89e | 72 | DataLocation* get(LHType type=LHType_locs); |
dylanembed123 | 9:da906eeac51e | 73 | |
dylanembed123 | 9:da906eeac51e | 74 | /// \brief Get Current value |
dylanembed123 | 15:e3e03a9df89e | 75 | DataLocation& getC(LHType type=LHType_locs,int offset=0); |
dylanembed123 | 9:da906eeac51e | 76 | |
dylanembed123 | 9:da906eeac51e | 77 | /// \brief Get Index |
dylanembed123 | 15:e3e03a9df89e | 78 | unsigned int& getI(LHType type=LHType_locs,LHIType indexType=LHIType_head); |
dylanembed123 | 7:c75d5e5e6bfc | 79 | |
dylanembed123 | 9:da906eeac51e | 80 | /// \brief Fix an index that might be out of bounds; |
dylanembed123 | 9:da906eeac51e | 81 | unsigned int getRealIndex(LHType type,int index,int offset=0,bool useSize=true); |
dylanembed123 | 9:da906eeac51e | 82 | |
dylanembed123 | 9:da906eeac51e | 83 | /// \brief Increment index |
dylanembed123 | 15:e3e03a9df89e | 84 | void inc(LHType type=LHType_locs,int amount=1,bool abs=false); |
dylanembed123 | 7:c75d5e5e6bfc | 85 | |
dylanembed123 | 9:da906eeac51e | 86 | /// \brief Append a location to the end. |
dylanembed123 | 9:da906eeac51e | 87 | void add(LHType type,DataLocation newLoc); |
dylanembed123 | 15:e3e03a9df89e | 88 | |
dylanembed123 | 9:da906eeac51e | 89 | }; |
dylanembed123 | 15:e3e03a9df89e | 90 | class DH{ |
dylanembed123 | 15:e3e03a9df89e | 91 | public: |
dylanembed123 | 15:e3e03a9df89e | 92 | static LocHolder& Locs(); |
dylanembed123 | 15:e3e03a9df89e | 93 | }; |
dylanembed123 | 15:e3e03a9df89e | 94 | #endif |