tableLookup.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EXTERN   extern

Functions

EXTERN unsigned short lookupTwoDTableUS (twoDTableUS *, unsigned short) FIXEDCONF2
EXTERN unsigned short lookupPagedMainTableCellValue (mainTable *, unsigned short, unsigned short, unsigned char) FIXEDCONF2
EXTERN unsigned short setPagedMainTableCellValue (mainTable *, unsigned short, unsigned short, unsigned short, unsigned char)
EXTERN unsigned short setPagedMainTableRPMValue (mainTable *, unsigned short, unsigned short, unsigned char)
EXTERN unsigned short setPagedMainTableLoadValue (mainTable *, unsigned short, unsigned short, unsigned char)
EXTERN unsigned short validateMainTable (mainTable *)
EXTERN unsigned short validateTwoDTable (twoDTableUS *)


Define Documentation

#define EXTERN   extern

Definition at line 32 of file tableLookup.h.


Function Documentation

EXTERN unsigned short lookupPagedMainTableCellValue ( mainTable ,
unsigned  short,
unsigned  short,
unsigned  char 
)

Definition at line 157 of file tableLookup.c.

References lookupMainTable(), and RPAGE.

Referenced by generateDerivedVars().

00157                                                                                                                                          {
00158         unsigned char oldRPage = RPAGE;
00159         RPAGE = RPageValue;
00160         unsigned short returnValue = lookupMainTable(Table, realRPM, realLoad);
00161         RPAGE = oldRPage;
00162         return returnValue;
00163 }

Here is the call graph for this function:

EXTERN unsigned short lookupTwoDTableUS ( twoDTableUS ,
unsigned  short 
)

Definition at line 123 of file tableLookup.c.

References twoDTableUS::Axis, and twoDTableUS::Values.

Referenced by generateDerivedVars().

00123                                                                            {
00124 
00125         /* Find the bounding axis indices, axis values and lookup values */
00126         unsigned char lowIndex = 0;
00127         unsigned char highIndex = 15;
00128         /* If never set in the loop, low value will equal high value and will be on the edge of the map */
00129         unsigned short lowAxisValue = Table->Axis[0];
00130         unsigned short highAxisValue = Table->Axis[15];
00131         unsigned short lowLookupValue = Table->Values[0];
00132         unsigned short highLookupValue = Table->Values[15];
00133 
00134         unsigned char Index;
00135         for(Index=0;Index<16;Index++){
00136                 if(Table->Axis[Index] < Value){
00137                         lowIndex = Index;
00138                         lowAxisValue = Table->Axis[Index];
00139                         lowLookupValue = Table->Values[Index];
00140                 }else if(Table->Axis[Index] > Value){
00141                         highIndex = Index;
00142                         highAxisValue = Table->Axis[Index];
00143                         highLookupValue = Table->Values[Index];
00144                         break;
00145                 }else if(Table->Axis[Index] == Value){
00146                         return Table->Values[Index]; // If right on, just return the value
00147                 }
00148         }
00149 
00150 
00151         /* Interpolate and return the value */
00152         return lowLookupValue + (((signed long)((signed long)highLookupValue - lowLookupValue) * (Value - lowAxisValue))/ (highAxisValue - lowAxisValue));
00153 }

EXTERN unsigned short setPagedMainTableCellValue ( mainTable ,
unsigned  short,
unsigned  short,
unsigned  short,
unsigned  char 
)

Definition at line 166 of file tableLookup.c.

References invalidMainTableLoadIndex, invalidMainTableRPMIndex, mainTable::LoadLength, NO_ERROR_ALL_A_OK, RPAGE, and mainTable::Table.

Referenced by decodePacketAndBuildResponse().

00166                                                                                                                                                                   {
00167         unsigned char oldRPage = RPAGE;
00168         unsigned short errorID = NO_ERROR_ALL_A_OK;
00169         RPAGE = RPageValue;
00170         if(RPMIndex < Table->RPMLength){
00171                 if(LoadIndex < Table->LoadLength){
00172                         Table->Table[(Table->LoadLength * RPMIndex) + LoadIndex] = cellValue;
00173                 }else{
00174                         errorID = invalidMainTableLoadIndex;
00175                 }
00176         }else{
00177                 errorID = invalidMainTableRPMIndex;
00178         }
00179         RPAGE = oldRPage;
00180         return errorID;
00181 }

EXTERN unsigned short setPagedMainTableLoadValue ( mainTable ,
unsigned  short,
unsigned  short,
unsigned  char 
)

Definition at line 198 of file tableLookup.c.

References invalidMainTableLoadIndex, mainTable::Load, NO_ERROR_ALL_A_OK, and RPAGE.

Referenced by decodePacketAndBuildResponse().

00198                                                                                                                                          {
00199         unsigned char oldRPage = RPAGE;
00200         unsigned short errorID = NO_ERROR_ALL_A_OK;
00201         RPAGE = RPageValue;
00202         if(LoadIndex < Table->LoadLength){
00203                 Table->Load[LoadIndex] = LoadValue;
00204         }else{
00205                 errorID = invalidMainTableLoadIndex;
00206         }
00207         RPAGE = oldRPage;
00208         return errorID;
00209 }

EXTERN unsigned short setPagedMainTableRPMValue ( mainTable ,
unsigned  short,
unsigned  short,
unsigned  char 
)

Definition at line 184 of file tableLookup.c.

References invalidMainTableRPMIndex, NO_ERROR_ALL_A_OK, RPAGE, and mainTable::RPM.

Referenced by decodePacketAndBuildResponse().

00184                                                                                                                                       {
00185         unsigned char oldRPage = RPAGE;
00186         unsigned short errorID = NO_ERROR_ALL_A_OK;
00187         RPAGE = RPageValue;
00188         if(RPMIndex < Table->RPMLength){
00189                 Table->RPM[RPMIndex] = RPMValue;
00190         }else{
00191                 errorID = invalidMainTableRPMIndex;
00192         }
00193         RPAGE = oldRPage;
00194         return errorID;
00195 }

EXTERN unsigned short validateMainTable ( mainTable  ) 

Definition at line 213 of file tableLookup.c.

References invalidMainTableLoadLength, invalidMainTableLoadOrder, invalidMainTableMainLength, invalidMainTableRPMLength, invalidMainTableRPMOrder, mainTable::Load, mainTable::LoadLength, MAINTABLE_MAX_LOAD_LENGTH, MAINTABLE_MAX_MAIN_LENGTH, MAINTABLE_MAX_RPM_LENGTH, mainTable::RPM, and mainTable::RPMLength.

Referenced by decodePacketAndBuildResponse().

00213                                                   {
00214         if(Table->RPMLength > MAINTABLE_MAX_RPM_LENGTH){
00215                 return invalidMainTableRPMLength;
00216         }else if(Table->LoadLength > MAINTABLE_MAX_LOAD_LENGTH){
00217                 return invalidMainTableLoadLength;
00218         }else if((Table->RPMLength * Table->LoadLength) > MAINTABLE_MAX_MAIN_LENGTH){
00219                 return invalidMainTableMainLength;
00220         }else{
00221                 /* Check the order of the RPM axis */
00222                 unsigned char i;
00223                 for(i=0;i<(Table->RPMLength - 1);i++){
00224                         if(Table->RPM[i] > Table->RPM[i+1]){
00225                                 return invalidMainTableRPMOrder;
00226                         }
00227                 }
00228                 /* Check the order of the Load axis */
00229                 unsigned char j;
00230                 for(j=0;j<(Table->LoadLength - 1);j++){
00231                         if(Table->Load[j] > Table->Load[j+1]){
00232                                 return invalidMainTableLoadOrder;
00233                         }
00234                 }
00235                 /* If we made it this far all is well */
00236                 return NO_ERROR_ALL_A_OK;
00237         }
00238 }

EXTERN unsigned short validateTwoDTable ( twoDTableUS  ) 

Definition at line 241 of file tableLookup.c.

References twoDTableUS::Axis, invalidTwoDTableAxisOrder, and TWODTABLEUS_LENGTH.

Referenced by decodePacketAndBuildResponse().

00241                                                     {
00242         /* Check the order of the axis */
00243         unsigned char i;
00244         for(i=0;i<(TWODTABLEUS_LENGTH - 1);i++){
00245                 if(Table->Axis[i] > Table->Axis[i+1]){
00246                         return invalidTwoDTableAxisOrder;
00247                 }
00248         }
00249         return NO_ERROR_ALL_A_OK;
00250 }


Generated on Mon Nov 10 21:19:16 2008 for freeems by  doxygen 1.5.2