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 176 of file modell.c.

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

Referenced by mfCreateTAC(), 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 237 of file modell.c.

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

Referenced by parExamplePerfectBolus(), parExampleRadiowaterBolus(), 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 222 of file modell.c.

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

◆ modelNr()

unsigned int modelNr ( )

Number of listed models.

Returns
Nr of models.

Definition at line 162 of file modell.c.

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

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 205 of file modell.c.

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

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 191 of file modell.c.

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

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 256 of file modell.c.

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

Referenced by mfCreateTAC(), parExamplePerfectBolus(), parExampleRadiowaterBolus(), and parExampleTTACs().