2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbstdMathOperation.h"
5 #include "bbstdPackage.h"
15 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation)
16 BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox);
18 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
20 void MathOperation::Process()
23 // THE MAIN PROCESSING METHOD BODY
24 // Here we simply set the input 'In' value to the output 'Out'
25 // And print out the output value
26 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
27 // void bbSet{Input|Output}NAME(const TYPE&)
28 // const TYPE& bbGet{Input|Output}NAME() const
30 // * NAME is the name of the input/output
31 // (the one provided in the attribute 'name' of the tag 'input')
32 // * TYPE is the C++ type of the input/output
33 // (the one provided in the attribute 'type' of the tag 'input')
39 /* initialize random seed: */
41 if (bbGetInputType()==7) acum=bbGetInputIn1();
44 if (bbGetInputType()==0)
46 bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
48 if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() );
49 if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() );
51 if (bbGetInputType()==3)
53 if (bbGetInputIn2()!=0) bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() );
54 else bbSetOutputOut( 99999999 );
57 if (bbGetInputType()==4) bbSetOutputOut( sqrt( bbGetInputIn1() ) );
59 if (bbGetInputType()==5)
61 if (bbGetInputIn1()>0) bbSetOutputOut( log( bbGetInputIn1() ) );
62 else bbSetOutputOut( -99999999 );
65 if (bbGetInputType()==6) bbSetOutputOut( exp( bbGetInputIn1() ) );
67 if (bbGetInputType()==7)
69 if ( back_acum_In1!=bbGetInputIn1() ) acum=bbGetInputIn1();
70 if (acum<bbGetInputIn1()) acum=bbGetInputIn1();
71 bbSetOutputOut( acum );
73 if (acum>bbGetInputIn2()) acum=bbGetInputIn1();
74 back_acum_In1=bbGetInputIn1();
76 if (bbGetInputType()==8 ) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() );
77 if (bbGetInputType()==9 ) bbSetOutputOut( sin( bbGetInputIn1() ) );
78 if (bbGetInputType()==10) bbSetOutputOut( cos( bbGetInputIn1() ) );
79 if (bbGetInputType()==11) bbSetOutputOut( tan( bbGetInputIn1() ) );
80 if (bbGetInputType()==12) bbSetOutputOut( asin( bbGetInputIn1() ) );
81 if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) );
82 if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) );
83 if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),bbGetInputIn2() ) );
84 if (bbGetInputType()==16) bbSetOutputOut( std::min( bbGetInputIn1(),bbGetInputIn2() ) );
85 if (bbGetInputType()==17) bbSetOutputOut( std::max( bbGetInputIn1(),bbGetInputIn2() ) );
86 if (bbGetInputType()==18) bbSetOutputOut( fabs( bbGetInputIn1() ) );
87 if (bbGetInputType()==19) bbSetOutputOut( (int)bbGetInputIn1() % (int)bbGetInputIn2() );
88 if (bbGetInputType()==20) if (bbGetInputIn1()<(int)bbGetInputIn2()) { bbSetOutputOut(1); } else { bbSetOutputOut(0); } ;
89 if (bbGetInputType()==21) if (bbGetInputIn1()>(int)bbGetInputIn2()) { bbSetOutputOut(1); } else { bbSetOutputOut(0); } ;
90 if (bbGetInputType()==22) bbSetOutputOut( round( bbGetInputIn1() ) );
91 if (bbGetInputType()==23) bbSetOutputOut( rint( bbGetInputIn1() ) );
92 if (bbGetInputType()==24) bbSetOutputOut( floor( bbGetInputIn1() ) );
93 if (bbGetInputType()==25) bbSetOutputOut( ceil( bbGetInputIn1() ) );
94 if (bbGetInputType()==26) bbSetOutputOut( trunc( bbGetInputIn1() ) );
95 if (bbGetInputType()==30) if (bbGetInputIn1()==(int)bbGetInputIn2()) { bbSetOutputOut(1); } else { bbSetOutputOut(0); } ;
98 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
100 void MathOperation::bbUserSetDefaultValues()
103 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
104 // Here we initialize the input 'In' to 0
114 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
116 void MathOperation::bbUserInitializeProcessing()
119 // THE INITIALIZATION METHOD BODY :
121 // but this is where you should allocate the internal/output pointers
126 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
128 void MathOperation::bbUserFinalizeProcessing()
130 // THE FINALIZATION METHOD BODY :
132 // but this is where you should desallocate the internal/output pointers
136 }// EO namespace bbstd