C++ Systems

Top  Previous  Next

Systems that have their behavior implemented in C++. Most BasicMath systems (except for GainM and GainPY) are C++ systems.

 

Example of C++-System

As an example, following is an implementation of system Cos from BasicMath Component Library:

 

//@@ ***************************************************************************

// *

// * Copyright (C) 2011-2015, Timelike Systems

// *****************************************************************************

#ifndef COS_SYSTEM_CLASS

#define COS_SYSTEM_CLASS

#include "timelike/timelike.h"

 

class Cos: public TL_PureFunction

{

public:

 // Inputs

 TL_Input< double > u;

 

 // Outputs

 TL_Output< double > y;

 

 Cos(TL_System *parent, const char *name):

         TL_PureFunction(parent, name),

         u(this, "u"),

         y(this, "y")

 {

 }

 

 void respondToOutputRequest(TL_t_Output* var, TL_tTime t)

 {

         if(var == &y)

         {

                 double v = u.get(t);

                 double val = cos(v);

                 y.set(t, val);

         }

 }

};

 

#endif // COSINE_SYSTEM_CLASS

 

Creating C++-System

 

The GUI Support for creating C++ Systems is planned to be included in the future release of TimeLike.