Example of auto-generated C++ code
In fig.1 is showed a very simple application module, that performs a simple sum of two float number. One number is requested to user, and other is a constant. FBCad translate application module diagram into C++ code, ready to be compiled.
Fig. 1 - Sum application module
The C++ code auto-generated from FBCad is the follow :
//-------------------------------------------------------------------
//---
//--- This file was generated by FBCad version 1.0
//--- Target : SIMULATION
//---
//---
//--- Module : Sum
//--- File : D:\Tesi1499\Env\Appl\WWWExamp\source\sum.cpp
//---
//-------------------------------------------------------------------
#include "www.hpp"
#include "GetFloat.hpp"
#include "Add.hpp"
//--- Event queue for this module
static EventQueue ExecQueue;
//--- Event Constant ---
static Constant<EVENT> www_Constant_3 =
Constant<EVENT>( TRUE );
//--- Data Constant ---
static Constant<float> www_Constant_2 =
Constant<float>( 10.25 );
//--- FBs external references ---
extern FB_www_GetFloat www_GetFloat_0;
extern FB_www_Add www_Add_1;
//--- Data Connector ---
static Connector<float> www_Connection_5 =
Connector<float>();
static Connector<float> www_Connection_6 =
Connector<float>();
//--- Event Connector ---
Connector<EVENT> www_Connection_4 =
Connector<EVENT>(&www_Add_1, &ExecQueue);
Connector<EVENT> www_Connection_7 =
Connector<EVENT>(&www_GetFloat_0, &ExecQueue);
Connector<EVENT> *cl_www_GetFloat_0_EXO[] =
{&www_Connection_4, NULL };
Connector<float> *cl_www_GetFloat_0_Data[] =
{&www_Connection_5, NULL };
Connector<EVENT> *cl_www_Add_1_EXO[] = { NULL };
Connector<float> *cl_www_Add_1_XOUT[] = { NULL };
Connector<EVENT> *cl_www_GetFloat_0_EX[] =
{&www_Connection_7, NULL };
Connector<EVENT> *cl_www_Add_1_EX[] =
{&www_Connection_4, NULL };
//--- Basic FB ---
static char www_GetFloat_0_Text_Tmp[] = "Inserire un float
:";
FB_www_GetFloat www_GetFloat_0 = FB_www_GetFloat(&ExecQueue,
cl_www_GetFloat_0_EX, cl_www_GetFloat_0_EXO,
cl_www_GetFloat_0_Data, (char *)www_GetFloat_0_Text_Tmp,
(float)10, (float)-10, 0);
FB_www_Add www_Add_1 = FB_www_Add(&ExecQueue,
cl_www_Add_1_EX, cl_www_Add_1_EXO, &www_Connection_5,
&www_Connection_6, cl_www_Add_1_XOUT, 0);
// Initialize module
void
MODULE_www::Setup(void){
www_Connection_6.Set(www_Constant_2.Get());
www_Connection_7.Set(www_Constant_3.Get());
}
// Execute all continuos FB
void
MODULE_www::RunContBlock(void){
}
// Allocate module object
MODULE_www MODULE__www = MODULE_www(&ExecQueue);
Back to Index ---- Last update : 22 Jan 1998 ---- Creator : Roberto Fabbri