EasyLink
EasyLink is a C++ software development kit for developing blocks for SIMULINK (S-functions)
/Users/guillaume.laurent/Documents/Prog/easylinkEigen/easylink/sfunTimesTwo.cpp
1 /*
2  * C++ S-function for multiplying an input by 2
3  *
4  * y = 2*u
5  *
6  * Input and output ports are dynamically sized.
7  *
8  * To compile this C++ S-function, enter the following command in MATLAB:
9  *
10  * >>make sfunTimesTwo.cpp
11  *
12  * Then open the file "testTimesTwo.mdl/slx" and start the simulation.
13  */
14 
15 //------------------------------------------------------------------------------
16 
17 #define S_FUNCTION_NAME sfunTimesTwo
18 
19 #include "EasyLink.h"
20 
21 //------------------------------------------------------------------------------
22 
23 class Block : public BaseBlock {
24 public:
25 
26  static void initializeInputPortSizes() {
28  setInputPort(0, -1, -1, SS_DOUBLE);
29  }
30 
31  static void initializeOutputPortSizes() {
33  setOutputPort(0, -1, -1, SS_DOUBLE);
34  }
35 
36  static void checkInputPortFinalSizes(int port, int nRows, int nCols) {
37  if (port == 0) {
38  setOutputPortFinalSizes(0, nRows, nCols);
39  }
40  }
41 
42  void outputs() {
43  Array<double> in = getInputArray<double>(0);
44  Array<double> out = getOutputArray<double>(0);
45  out = in * 2.0;
46  }
47 
48 };
49 
50 //------------------------------------------------------------------------------
51 
52 #include "sfunDefinitions.h"
53 
54 //------------------------------------------------------------------------------
static void setInputPortsCount(int portsCount)
Definition: BaseBlock.h:104
static void setOutputPortsCount(int portsCount)
Definition: BaseBlock.h:152
void outputs()
Definition: BaseBlock.h:340
static void setInputPort(int port, int nRows, int nCols, DTypeId type=SS_DOUBLE, bool directFeedThrough=true)
Definition: BaseBlock.h:116
static void initializeInputPortSizes()
Definition: BaseBlock.h:145
static void checkInputPortFinalSizes(int port, int nRows, int nCols)
Definition: BaseBlock.h:273
static void initializeOutputPortSizes()
Definition: BaseBlock.h:189
static void setOutputPortFinalSizes(int port, int nRows, int nCols)
Definition: BaseBlock.h:279
static void setOutputPort(int port, int nRows, int nCols, DTypeId type=SS_DOUBLE)
Definition: BaseBlock.h:164

Copyright (c) 2014 FEMTO-ST / ENSMM / UFC / UTBM, Besançon, France. Generated by Doxygen.