TPCCLIB
Loading...
Searching...
No Matches
modell.c File Reference

Model and function codes and descriptions for other libraries. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpcextensions.h"
#include "tpcmodels.h"

Go to the source code of this file.

Functions

unsigned int modelNr ()
 
char * modelCode (const unsigned int i)
 
unsigned int modelOldId (const unsigned int i)
 
unsigned int modelOld2New (const unsigned int i)
 
char * modelDesc (const unsigned int i)
 
unsigned int modelCodeIndex (const char *s)
 
unsigned int modelParNr (const unsigned int code)
 

Detailed Description

Model and function codes and descriptions for other libraries.

Definition in file modell.c.

Function Documentation

◆ modelCode()

char * modelCode ( const unsigned int i)

Get string representation of a model code.

Returns
pointer to string representation of the code, or NULL if not identified.
Author
Vesa Oikonen
See also
modelDesc, modelCodeIndex, modelNr
Parameters
imodel list index.

Definition at line 175 of file modell.c.

178 {
179 if(i>=modelNr()) return((char*)NULL);
180 return(tpc_model[i].code);
181}
unsigned int modelNr()
Definition modell.c:161

Referenced by parWriteCSV(), and parWriteXML().

◆ modelCodeIndex()

unsigned int modelCodeIndex ( const char * s)

Get model index for the string representation of model code.

Returns
index number, 0, if unknown model code.
Author
Vesa Oikonen
See also
modelCode, modelDesc
Parameters
smodel code as a string; code is case-insensitive, but otherwise exact match is required.

Definition at line 236 of file modell.c.

239 {
240 if(s==NULL || *s=='\0') return(0);
241 unsigned int i=0;
242 while(tpc_model[i].code[0]!='\0') {
243 if(!strcasecmp(tpc_model[i].code, s)) return(i);
244 i++;
245 }
246 return(0);
247}

Referenced by parExamplePerfectBolus(), parExampleTTACs(), and parReadCSV().

◆ modelDesc()

char * modelDesc ( const unsigned int i)

Get description of a model.

Returns
pointer to string, or NULL if not identified.
Author
Vesa Oikonen
See also
modelCode
Parameters
imodel list index.

Definition at line 221 of file modell.c.

224 {
225 if(i>=modelNr()) return((char*)NULL);
226 return(tpc_model[i].desc);
227}

◆ modelNr()

unsigned int modelNr ( )

Number of listed models.

Returns
Nr of models.

Definition at line 161 of file modell.c.

162{
163 unsigned int i=0;
164 while(tpc_model[i].code[0]!='\0') i++;
165 return(i);
166}

Referenced by modelCode(), modelDesc(), modelOld2New(), and modelParNr().

◆ modelOld2New()

unsigned int modelOld2New ( const unsigned int i)

Convert the deprecated function id to the model list index.

Returns
model/function list index, or 0 if not identified.
Author
Vesa Oikonen
See also
modelOldId, modelCode, modelCodeIndex, modelNr
Parameters
iDeprecated function id.

Definition at line 204 of file modell.c.

207 {
208 unsigned int n=modelNr();
209 if(i==0) return(0);
210 for(unsigned int j=1; j<n; j++) if(tpc_model[j].id==i) return(j);
211 return(0);
212}

Referenced by parReadFIT().

◆ modelOldId()

unsigned int modelOldId ( const unsigned int i)

Get the deprecated function id for working with older file formats.

Returns
function id, or 0 if not identified.
Author
Vesa Oikonen
See also
modelOld2New, modelCode, modelCodeIndex, modelNr
Parameters
imodel list index.

Definition at line 190 of file modell.c.

193 {
194 return(tpc_model[i].id);
195}

Referenced by parWriteFIT().

◆ modelParNr()

unsigned int modelParNr ( const unsigned int code)

Get model parameter number.

Returns
parameter number, or 0 if invalid model code.
Author
Vesa Oikonen
Parameters
codemodel code; can be retrieved using modelCodeIndex().

Definition at line 255 of file modell.c.

258 {
259 if(code<1 || code>=modelNr()) return(0);
260 return(tpc_model[code].parNr);
261}

Referenced by parExamplePerfectBolus(), and parExampleTTACs().