RCFC |
Remote C Function Call |
by Pierre Mavrikios | rcfc@petros.it | 2010-09-01 |
How to create a
RCFC distributed application.
Fundamental node tree. |
Distributed application tree |
Fundamental node tree. | Project directory tree | |
<=> |
"rcfc_functions.def
" file example. |
/* Just an example */ // Include all needed header files #include <stdint.h> #define ARRAY_ELEMENTS 32 #define CHUNK_LEN 128 typedef struct { int handler; long array [32]; } MY_STRUCT; |
//### Call // Insert all C function prototypes, this level node calls the higher level node functions int rf_is_upper_ready ( void ); int rf_lower_says ( const char message [64] ); MY_STRUCT rf_choose ( const MY_STRUCT array [ARRAY_ELEMENTS], uint32_t num ); |
//### Called // Insert all C function prototypes, the higher level node calls this level node functions int rf_lower_is_ready ( void ); int rf_open_file ( const str file_name ); int rf_write_to_file ( int handler, const char data [CHUNK_LEN] ); int rf_close_file ( int handler ); |
Top node application template |
Mid node application template |
Term node application template |
// #include <rcfc_ta.h> //############################ //# Top //############################ // include '.h' files generated by 'rcfcbuild'. #include "rf_functions.h" // // Define the rcfc functions called by other nodes // declared in the '//#--- Called.' section // of rcfc generated included files // ("rf_functions.h") //>---------------------------------------------------- //|-- Insert function definitions here --|// //----------------------------------------------------- //----------------------------------------------------- int main ( int argc, char **argv ) { // rcfc initialization if ( !rcfc_grant_functions ( port, app_ide ) ) exit ( -1 ); // main node loop while ( rcfc_is_grant_running () ) // optional { // call the remote rcfc functions // declared in the '//#--- Call.' section // of rcfc generated included files // ("rf_functions.h") //|-- Edit here --|// sleep ( 1 ); } rcfc_wait_grant_to_exit (); // optional return 0; } |
// #include <rcfc_ta.h> //############################ //# Mid //############################ // include '.h' files generated by 'rcfcbuild'. #include "rf_functions.h" // // Define the rcfc functions called by other nodes // declared in the '//#--- Called.' section // of rcfc generated included files // ("rf_functions.h") //>---------------------------------------------------- //|-- Insert function definitions here --|// //----------------------------------------------------- //----------------------------------------------------- int main ( int argc, char **argv ) { // rcfc initialization if ( !rcfc_offer_functions ( host, port, app_ide ) ) exit ( -1 ); if ( !rcfc_grant_functions ( port, app_ide ) ) exit ( -1 ); // main node loop while ( rcfc_is_grant_running () && rcfc_is_offer_running () ) // optional { // call the remote rcfc functions // declared in the '//#--- Call.' section // of rcfc generated included files // ("rf_functions.h") //|-- Edit here --|// sleep ( 1 ); } rcfc_wait_grant_to_exit (); // optional rcfc_wait_offer_to_exit (); // optional return 0; } |
// #include <rcfc_ta.h> //############################ //# Term //############################ // include '.h' files generated by 'rcfcbuild'. #include "rf_functions.h" // // Define the rcfc functions called by other nodes // declared in the '//#--- Called.' section // of rcfc generated included files // ("rf_functions.h") //>---------------------------------------------------- //|-- Insert function definitions here --|// //----------------------------------------------------- //----------------------------------------------------- int main ( int argc, char **argv ) { // rcfc initialization if ( !rcfc_offer_functions ( host, port, app_ide ) ) exit ( -1 ); // main node loop while ( rcfc_is_offer_running () ) // optional { // call the remote rcfc functions // declared in the '//#--- Call.' section // of rcfc generated included files // ("rf_functions.h") //|-- Edit here --|// sleep ( 1 ); } rcfc_wait_offer_to_exit (); // optional return 0; } |