00001 #include "sinsource.h" 00002 #include <math.h> 00003 #include "simulation.h" 00004 00005 namespace DiscreteTimeSystems { 00006 00007 using namespace std; 00008 00009 SinSource::SinSource(double f, double a) : Block(), _freq(f), _amp(a) 00010 { 00011 OutputPort *op = new OutputPort(1); 00012 00013 _out_ports.push_back(op); 00014 } 00015 00016 void SinSource::updateOutput() 00017 { 00018 double curr_time = Simulation::getInstance()->getTime(); 00019 00020 double data = _amp * sin( _freq * curr_time ) ; 00021 00022 vector<double> v; 00023 v.push_back(data); 00024 00025 _out_ports[0]->setData(v); 00026 } 00027 }
1.5.1