Changes between Version 17 and Version 18 of ObjectDeveloperGuide

Show
Ignore:
Timestamp:
11/28/09 14:06:57 (15 years ago)
Author:
ismael (IP: 62.57.1.15)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ObjectDeveloperGuide

    v17 v18  
    1717 
    1818||'''Directory'''||'''Files'''||'''Comment'''|| 
     19||''myobj''/platform_make/||...||One directory for each platform it can be compiled. For example:[[BR]]''lnx_make'' shall contain the Makefile, ''c6000_make'' shall contain CCS' .pjt files, etc.|| 
    1920||''myobj''/interfaces/||inputs.h[[BR]]outputs.h[[BR]]stats.h||Definition of input/output interfaces, statistics variables and initialization parameters|| 
    20 ||''myobj''/src/||myobj.c[[BR]]myobj_imp.c[[BR]]xxx.c||Implementation (myobj_imp.c + xxx.c) of the algorithm and main skeleton (myobj.c)[[BR]][[BR]]See below for more information|| 
     21||''myobj''/src/||module.c[[BR]]module_imp.c[[BR]]myobj.c||myobj.c: Standalone function implementing the algorithm.[[BR]]module.c and module_imp.c is the skeleton[[BR]]See below for more information|| 
    2122||''myobj''/bin/||myobj||Binaries after compilation and linking are placed here.|| 
    2223 
     
    6566In order to facilitate objects programming an skeleton implementing some common functionalities has been defined. In this sense, the user will only have to define the interfaces in a constant structure and provide some functions to process data. The initialization and buffer management will be done by the skeleton. 
    6667 
    67 This skeleton is provided in the myobj.c file and is exactly the same for any object (so you can copy anyone provided by the example objects). The skeleton needs three header files: inputs.h, outputs.h and stats.h. Interfaces and statistics are defined in structures (defined in swapi_utils.h) which name has to be mantained (input_itfs, output_itfs, params and stats). The following figure describe these structures: 
     68This skeleton is provided in the module.c file and is exactly the same for any object (so you can copy anyone provided by the example objects). The skeleton needs three header files: inputs.h, outputs.h and stats.h. Interfaces and statistics are defined in structures (defined in swapi_utils.h) which name has to be mantained (input_itfs, output_itfs, params and stats). The following figure describe these structures: 
    6869 
    6970'''Figure 2 – Structure definitions (swapi_utils.h)''' 
     
    155156 
    156157}}} 
    157 You can read more of how to use these structures in the example objects. If you downloaded the source, they are in the example directory. 
    158  
    159 Finally, the following figure shows the file where the processing code should be written. Note that in the configuration of the structure we have provided a function to process (or generate) data for every interface. Now, the only thing we have to do is to code these functions: 
    160  
    161 '''Figure 3 – Object implementation (myobj_imp.c)''' 
     158 
     159The other skeleton file, module_imp.c, is the bridge between the skeleton and the algorithm functions. It implements de functions called after a packet is received or must be generated. Although the algorithm could be implemented here, good coding practices recommend to do it in another file so the implementation shall be used in other contexts. 
     160 
     161'''Figure 3 – Object implementation (module_imp.c)''' 
    162162 
    163163{{{ 
     
    165165 */ 
    166166#include <phal_sw_api.h> 
    167 #include <math.h> 
    168167#include <swapi_utils.h> 
    169168 
    170169#include <phal_hw_api.h> 
    171170#include <sys/resource.h> 
    172  
    173 #define PI 3.1415 
    174171 
    175172#include "inputs.h" 
     
    199196 
    200197        /* generate sinusoid */ 
     198        generate_sinusoid(output_data,fsin,fsamp); 
     199 
     200        SetStatsValue(stat_signal, output_data, len); 
     201 
     202        return 1; 
     203} 
     204 
     205int InitCustom() 
     206{ 
     207    return 1; 
     208} 
     209 
     210int RunCustom() 
     211{ 
     212    return 1; 
     213} 
     214 
     215 
     216}}} 
     217The last two functions ({{{InitCustom()}}} and {{{RunCustom()}}}) have also to be defined. The {{{InitCustom}}} function is used to implement custom initialization routines not related with interface or statistics initialization. For example, if an object has to compute a set of filter coeficients given an initialization parameter, it can be done in this function. The skeleton will get the parameter(s) value if we define it in the specific structure. After that, the {{{InitCustom}}} function will be called and we will perform the computations.  
     218 
     219Analogously, the {{{RunCustom}}} function might be useful to perform some background tasks not related directly with data processing (more formally, asyncrhonous with data flow). An example of this may be updating an internal state. 
     220 
     221Finally, the actual algorithm will be implemented in a standalone file, for example, myobj.c: 
     222{{{ 
     223/** ALOE headers 
     224 */ 
     225#include <phal_sw_api.h> 
     226#include <math.h> 
     227 
     228#define PI 3.1415 
     229 
     230void generate_sinusoid(int *output_data, float fsin, float fsamp) 
     231{ 
     232        int i; 
    201233        for (i=0;i<len;i++) { 
    202234                output_data[i] = (int) ((float) 1000.0*cosf((double) 2.0*PI*fsin*i/freq)); 
    203235        } 
    204  
    205         SetStatsValue(stat_signal, output_data, len); 
    206  
    207         return 1; 
    208 } 
    209  
    210 int InitCustom() 
    211 { 
    212     return 1; 
    213 } 
    214  
    215 int RunCustom() 
    216 { 
    217     return 1; 
    218 } 
    219  
    220  
    221 }}} 
    222 The last two functions ({{{InitCustom()}}} and {{{RunCustom()}}}) have also to be defined. The {{{InitCustom}}} function is used to implement custom initialization routines not related with interface or statistics initialization. For example, if an object has to compute a set of filter coeficients given an initialization parameter, it can be done in this function. The skeleton will get the parameter(s) value if we define it in the specific structure. After that, the {{{InitCustom}}} function will be called and we will perform the computations.  
    223  
    224 Analogously, the {{{RunCustom}}} function might be useful to perform some background tasks not related directly with data processing (more formally, asyncrhonous with data flow). An example of this may be updating an internal state. 
     236} 
     237}}} 
    225238 
    226239== Compiling and Linking == 
    227240Compiling an ALOE objects does not need any other consideration rather than linking with the ALOE SW Library and HW Library. Obviously, we have to pick the HW library of our system. Under linux, and once we have installed ALOE (binary or source), the libraries should appear at /usr/local/lib with the names libsw_api.a and libhw_api.a. 
    228241 
    229 If your prefer to use autoconf/automake tools the following attached files might be useful: 
    230  
    231  * sample configure.in 
    232  * sample Makefile.am 
     242If your prefer to use autoconf/automake tools you might find useful the example Makefile.am included in the sample modules shipped in the ALOE distribution (under lnx_make). 
     243 
    233244 
    234245[wiki:ALOE "[Back to ALOE]"]