QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Thu Apr 03 17:15:29 2014 +0000
Revision:
9:da906eeac51e
Parent:
7:c75d5e5e6bfc
Child:
15:e3e03a9df89e
Fix compile errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dylanembed123 9:da906eeac51e 1 #include "dataLocation.h"
dylanembed123 7:c75d5e5e6bfc 2
dylanembed123 9:da906eeac51e 3 DataLocation* LocHolder::get(LHType type){
dylanembed123 9:da906eeac51e 4 if(type==LHType_locs){
dylanembed123 9:da906eeac51e 5 return locs;
dylanembed123 9:da906eeac51e 6 }else if(type==LHType_targ){
dylanembed123 9:da906eeac51e 7 return targ;
dylanembed123 9:da906eeac51e 8 }else if(type==LHType_base){
dylanembed123 9:da906eeac51e 9 return base;
dylanembed123 9:da906eeac51e 10 }
dylanembed123 7:c75d5e5e6bfc 11 return base;
dylanembed123 7:c75d5e5e6bfc 12 }
dylanembed123 7:c75d5e5e6bfc 13
dylanembed123 9:da906eeac51e 14 unsigned int LocHolder::getRealIndex(LHType type,int index,int offset,bool useSize){
dylanembed123 9:da906eeac51e 15 return (index+offset)%(useSize?getI(type,LHIType_size):MAXNUMLOCS);
dylanembed123 9:da906eeac51e 16 }
dylanembed123 9:da906eeac51e 17
dylanembed123 9:da906eeac51e 18 DataLocation& LocHolder::getC(LHType type,int offset){
dylanembed123 9:da906eeac51e 19 return get(type)[getRealIndex(type,offset)];
dylanembed123 7:c75d5e5e6bfc 20 }
dylanembed123 7:c75d5e5e6bfc 21
dylanembed123 9:da906eeac51e 22 unsigned int& LocHolder::getI(LHType type,LHIType indexType){
dylanembed123 9:da906eeac51e 23 if(indexType==LHIType_head){
dylanembed123 9:da906eeac51e 24 // Grab proper header
dylanembed123 9:da906eeac51e 25 if(type==LHType_locs){return headLocs;}else if(type==LHType_targ){return headTarg;}else if(type==LHType_base){return headBase;}
dylanembed123 9:da906eeac51e 26 }else if(indexType==LHIType_size){
dylanembed123 9:da906eeac51e 27 // Grab proper size
dylanembed123 9:da906eeac51e 28 if(type==LHType_locs){return sizeLocs;}else if(type==LHType_targ){return sizeTarg;}else if(type==LHType_base){return sizeBase;}
dylanembed123 9:da906eeac51e 29 }
dylanembed123 9:da906eeac51e 30 return headLocs;
dylanembed123 7:c75d5e5e6bfc 31 }
dylanembed123 9:da906eeac51e 32
dylanembed123 9:da906eeac51e 33 void LocHolder::inc(LHType type,int amount,bool abs){
dylanembed123 9:da906eeac51e 34 unsigned int& index=getI(type);
dylanembed123 9:da906eeac51e 35 index=getRealIndex(type,(abs?0:index),amount);//((abs?0:index)+amount)%getI(type,LHIType_size);
dylanembed123 9:da906eeac51e 36 getI(type)=index;
dylanembed123 7:c75d5e5e6bfc 37 }
dylanembed123 9:da906eeac51e 38
dylanembed123 9:da906eeac51e 39 void LocHolder::add(LHType type,DataLocation newLoc){
dylanembed123 9:da906eeac51e 40 getI(type)=getI(type,LHIType_size);
dylanembed123 9:da906eeac51e 41 getI(type,LHIType_size)++;
dylanembed123 9:da906eeac51e 42 getC(type)=newLoc;
dylanembed123 9:da906eeac51e 43 }