@node: auto
This is the prefered way of writing nodes. The following example will define two nodes with the names "auto_struct" and "auto_func":
//@node: auto
struct auto_struct{
double in;
double out;
double param_faktor = 2;
void tick(){
out = param_faktor*in;
}
};
//@node: auto
inline double auto_func(double in_func_input){
return in_func_input*2;
}
Inputs
Outputs
All member variables with the prefix "out_" will be output pins.
Parameters
All member variables with the prefix "param_" will be parameters, that can be chaned in model.
Special methods
tick()
Tick will called ervery time a raster is execuded
init()
Init will be called once, before the first tick() call. This means all inputs are set to the fist value.
final()
Final will be called after the last call of tick, when the execution ends.
Special member variables
node_name
Contains the name of the node
raster_interval
Containts the raster interval. This forces the node into synchronous raster. Type abmt::time
#include <abmt/time.h>
...
abmt::time raster_interval;
@raster: [time] | auto | source
[time]
Specifies the interval. Example: 10ms, 1s, 200usauto
The raster is determined by connected pins or 10mssource
The node has its own raster. You have to specify a poll() function that returns 0 when the raster should be called or a abmt::time how long the runtime should sleep. The poll() function is called in an infinite loop.@link: [lib]
With @link annotation you can specify a library to link to. This annotation applies to every node in a header.
@compile: [file]
With @compile annotation you can instruct ABMT to also compile and another file in your nodes folder. This annotation applies to every node in a header.
@node: function
The node type function can be used to define a node without owning the declaration:
/**
* @node: function;
* @input: input_var_name; type: double; default: 0;
* @output: output_var_name; type: double;
* @tick: function_name(input_var_name) -> output_var_name;
*/
You have put the node definition in a namespace when the function is in a namespace. See example/math.
@node: class
The node type function can be used to define a node without owning the declaration of the class:
// clase can also be declared in another header
class indirect_class_node{
public:
double inp;
double o;
double p;
void calc(){
o = inp *2;
}
};
//@node:class; class: indirect_class_node;
//@input: inp; type: double;
//@output: o; type: double;
//@parameter: p; type: double; default: 3;
//@tick: calc();