TSP: The Transport Sample Protocol



ASCII Writer Library
[ASCII WriterTSP Libraries]

Collaboration diagram for ASCII Writer Library:The TSP ascii writer consumer library API. More...

Defines

#define TSP_STATUS_ERROR_AW_CONFIG_FILE_INVALID   TSP_STATUS_ERROR_CUSTOM_BEGIN+1
 Defines Ascii writer specific error codes.

Typedefs

typedef enum OutputFileFormat OutputFileFormat_t
 Output file format handled by the ascii_writer.

Enumerations

enum  OutputFileFormat { SimpleAsciiTabulated_FileFmt = 0 }
 Output file format handled by the ascii_writer. More...

Functions

char * new_array_label (const char *libelle, const char *profil, const char *ordre, const int recursif)
 edit the column title for the array.
int32_t tsp_ascii_writer_add_var (char *symbol_name)
 Add a variable to the global symbols array used by the Lex+Yacc lexer+parser.
int32_t tsp_ascii_writer_display_value (FILE *sfile, TSP_sample_t sample)
 display the value of the sample.
int32_t tsp_ascii_writer_finalise ()
 Finalise TSP consumer.
int32_t tsp_ascii_writer_initialise (int *argc, char **argv[])
 Initialise ascii TSP consumer.
int32_t tsp_ascii_writer_load_config (const char *conffilename, TSP_sample_symbol_info_t **tsp_symbols, uint32_t *nb_symbols)
 Load a configuration file and build the array of of requested symbol in config file.
int32_t tsp_ascii_writer_make_unique (TSP_sample_symbol_info_t **tsp_symbols, uint32_t *nb_symbols)
 Make the requested symbol unique in the provided list.
int32_t tsp_ascii_writer_start (FILE *sfile, int32_t nb_sample_max_infile, OutputFileFormat_t file_format, TSP_sample_symbol_info_list_t *validatedSSIL)
 Start TSP data receive and archive.
int32_t tsp_ascii_writer_stop ()
 Stop data archiving.
void * tsp_ascii_writer_thread (void *sfile)
 Function to be used with pthread_create(3).
int32_t tsp_ascii_writer_validate_symbols (TSP_sample_symbol_info_list_t *requestedSSIL, const char *tsp_url, TSP_sample_symbol_info_list_t *validatedSSIL)
 Validate the requested symbol against the TSP provider specified by tsp_url.
int32_t TSP_asciiwriter_read_sample (TSP_provider_t provider, TSP_sample_t *sample, int *new_sample)
 Read a sample symbol.


Detailed Description

The TSP ascii writer consumer library API.


Define Documentation

#define TSP_STATUS_ERROR_AW_CONFIG_FILE_INVALID   TSP_STATUS_ERROR_CUSTOM_BEGIN+1

Defines Ascii writer specific error codes.


Typedef Documentation

typedef enum OutputFileFormat OutputFileFormat_t

Output file format handled by the ascii_writer.


Enumeration Type Documentation

enum OutputFileFormat

Output file format handled by the ascii_writer.

Enumerator:
SimpleAsciiTabulated_FileFmt  The simple ASCII file format.


Function Documentation

char* new_array_label ( const char *  libelle,
const char *  profil,
const char *  ordre,
const int  recursif 
)

edit the column title for the array.

Parameters:
[in] libelle libelle to display
[in] profil profil of the array (5*3*2)
[in] ordre order of the indice (2,1) or (1,2)
[in] recursif if it's recursif or no
Returns:
pinter on the different label

int32_t tsp_ascii_writer_add_var ( char *  symbol_name  ) 

Add a variable to the global symbols array used by the Lex+Yacc lexer+parser.

Parameters:
symbol_name IN, the symbol name to add to the list of requested symbol.

int32_t tsp_ascii_writer_display_value ( FILE *  sfile,
TSP_sample_t  sample 
)

display the value of the sample.

Parameters:
sfile [in] print file.
sample [in] sample value to display
Returns:
0 OK -1 otherwise.

int32_t tsp_ascii_writer_finalise (  ) 

Finalise TSP consumer.

Returns:
0 if OK -1 otherwise.

int32_t tsp_ascii_writer_initialise ( int *  argc,
char **  argv[] 
)

Initialise ascii TSP consumer.

We must pass main arguments to TSP lib for specific TSP arg handling. Parameter unknown to TSP are unchanged on return.

Parameters:
argc The main 'argc' argument
argv The main 'argv' argument
Returns:
TSP_STATUS_OK on success TSP_STATUS_ERROR_xxx otherwise.

int32_t tsp_ascii_writer_load_config ( const char *  conffilename,
TSP_sample_symbol_info_t **  tsp_symbols,
uint32_t *  nb_symbols 
)

Load a configuration file and build the array of of requested symbol in config file.

Parameters:
[in] conffilename the name of the config file.
[out] tsp_symbols pointer to the array of symbols found in config file. the array is allocated by the function.
[out] nb_symbols the number of symbols found in file
Returns:
TSP_STATUS_OK if config file loaded properly (no syntax TSP_STATUS_ERROR_xxx otherwise.

int32_t tsp_ascii_writer_make_unique ( TSP_sample_symbol_info_t **  tsp_symbols,
uint32_t *  nb_symbols 
)

Make the requested symbol unique in the provided list.

The unicity may be enforced by reducing the number of requested symbols if ever duplicate symbols have same name, period and phase.

Parameters:
[in,out] tsp_symbols pointer to the array of symbols to be checked for unicity on entry, the array of unique symbols on return.
[in,out] nb_symbols the number of symbols in the provided array on entry the number of remaining (unique) symbols on return. If ERROR nb_symbols contains the rank of the first wrong duplicate.
Returns:
TSP_STATUS_OK if uniticy may be enforced or TSP_STATUS_ERROR_AW_DUPLICATE_SYMBOLS.

int32_t tsp_ascii_writer_start ( FILE *  sfile,
int32_t  nb_sample_max_infile,
OutputFileFormat_t  file_format,
TSP_sample_symbol_info_list_t validatedSSIL 
)

Start TSP data receive and archive.

Should have called tsp_ascii_writer_validate_symbols first.

Parameters:
[in] sfile the stream file used for data saving.
[in] nb_sample_max_infile the maximum number of sample stored in the file if 0<= then no limit, if >0 then when about to save the nb_sample_max_infile-th sample we rewind the file.
[in] file_format the header style to be used for the output.
[in] validatedSSIL the validated list of symbols to retrieve
Returns:
0 OK -1 otherwise.

int32_t tsp_ascii_writer_stop (  ) 

Stop data archiving.

Returns:
0 if OK -1 otherwise.

void* tsp_ascii_writer_thread ( void *  sfile  ) 

Function to be used with pthread_create(3).

Parameters:
sfile pointer to an opened stdio file stream (FILE*).
Returns:
0 if OK -1 otherwise.

int32_t tsp_ascii_writer_validate_symbols ( TSP_sample_symbol_info_list_t requestedSSIL,
const char *  tsp_url,
TSP_sample_symbol_info_list_t validatedSSIL 
)

Validate the requested symbol against the TSP provider specified by tsp_url.

If symbol name match an array symbol all element aoff the array are requested.

Parameters:
[in] requestedSSIL the requested symbols list to be validated.
[in] tsp_url The TSP url of the provider to be used for validating symbols.
[out] validatedSSIL the validated symbol list.
Returns:
TSP_STATUS_OK on success TSP_STATUS_ERROR_xxx otherwise.

int32_t TSP_asciiwriter_read_sample ( TSP_provider_t  provider,
TSP_sample_t sample,
int *  new_sample 
)

Read a sample symbol.

Parameters:
provider The provider handle
sample The returned symbol if there is one
new_sample When TRUE, there is a new sample, else the sample value is meaningless
Returns:
TSP_STATUS_OK on success TSP_STATUS_ERROR_xxx on error.
Todo:
  • Some kind of get_last_error func must be implemented to read the error codes (EOF, RECONF ... ).
  • When the other types will be implemented (RAW, STRING) the TSP_sample_t type will not work anymore as it is double specific for now.

Framework Home Page.


Beware !! TSP wave is coming...