00001 #include "integrator.h"
00002 #include "sinsource.h"
00003 #include "simulation.h"
00004 #include <iostream>
00005
00006 using namespace std;
00007 using namespace DiscreteTimeSystems;
00008
00009 int main()
00010 {
00011 Simulation::getInstance()->setTimeStep(0.001);
00012
00013 Block * block_sequence[2];
00014
00015 block_sequence[0] = new SinSource(100, 2);
00016 block_sequence[1] = new Integrator(10);
00017
00018 InputPort *ip2 = block_sequence[1]->getInputPort(0);
00019 OutputPort *op1 = block_sequence[0]->getOutputPort(0);
00020
00021 ip2->connect(op1);
00022
00023 for(int i=0; i<1000; ++i) {
00024 for (int j=0; j<2; j++)
00025 block_sequence[j]->updateState();
00026
00027 for (int j=0; j<2; j++)
00028 block_sequence[j]->updateOutput();
00029
00030 OutputPort *op2 = block_sequence[1]->getOutputPort(0);
00031
00032 vector<double> v = op2->getData();
00033
00034 cout << "" << Simulation::getInstance()->getTime();
00035 cout << ", " << v[0] << endl;
00036
00037 Simulation::getInstance()->advance();
00038 }
00039 }