====== Custom Blocks ====== If a certain functionality cannot be found in the [[eeros_architecture:control_system:available_blocks|]] you have to implement it in your own block. This is also the case if you want to create a [[eeros_architecture:control_system:subsystem|Subsystem]]. ==== How Many Inputs and Outputs? ==== You should design your block as an extension of ''Blockio''. Choose the template parameters so that you get the desired number of input and output signals together with their types. If signals carry different types, you have will have to define the necessary inputs and outputs as fields of your new block class. As a example we take a look at a new block template < typename T = double > // make it available for many types class MyBlock : public Blockio<1,2,T,T> { // has 1 input, 2 outputs public: MyBlock() { ... } // constructor virtual void run() { ... } // do what must be done in this block }; ==== What Kind of Signals? ==== Depending on the type of the signals you will design your class as a template class or you will define it with a given type. ==== How to Handle the Timestamp ==== If your block is not time dependent, you will simply set the timestamp of the output to the same value as the timestamp of the input. If sampling time matters, you will have to calculate the timestamp of the output from the timestamp of the input and inner workings of your block. \\ There are cases that your blocks produces signals which do not depend on input signals from other blocks. It might generate its output signals from various other sources and will set its timestamp to a actual system time, or the time the original source signal was generated.