source: pacpusframework/branches/2.0-beta1/src/TestComponents/test/testComponent1.cpp@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1/**
2@file
3Purpose: Lidar Detection
4
5@date created 2010-06-03 16:13
6@author Julien Moras
7@author Sergio Rodriguez
8@version $Id: $
9*/
10
11#include "testComponent1.h"
12
13#include "kernel/ComponentFactory.h"
14#include "kernel/Log.h"
15
16#include "kernel/ComponentManager.h"
17#include "testComponent2.h"
18
19#include <stdio.h>
20
21#include <QColor>
22
23
24using namespace pacpus;
25using namespace std;
26
27DECLARE_STATIC_LOGGER("pacpus.cityvip.test.testComponent1");
28
29const char * TestComponent1::COMPONENT_TYPE = "TestComponent1";
30
31/// Construct the factory
32static ComponentFactory<TestComponent1> sFactory(TestComponent1::COMPONENT_TYPE);
33
34TestComponent1::TestComponent1(QString name)
35 : ComponentBase(name)
36{
37
38 output.insert(QString("image"),new OutputInterface<QImage,TestComponent1>(QString("image"),this));
39
40 LOG_TRACE("constructor(" << name << ")");
41}
42
43TestComponent1::~TestComponent1()
44{
45 LOG_TRACE("destructor");
46
47}
48
49ComponentBase::COMPONENT_CONFIGURATION
50TestComponent1::configureComponent(XmlComponentConfig /*config*/)
51{
52 LOG_TRACE(Q_FUNC_INFO);
53
54 LOG_INFO("component '" << componentName << "' configured");
55 return ComponentBase::CONFIGURED_OK;
56}
57
58void TestComponent1::startActivity()
59{
60 LOG_TRACE(Q_FUNC_INFO);
61
62 //Q_ASSERT(input);
63
64 start();
65 THREAD_ALIVE = true;
66 setState(MONITOR_OK);
67 LOG_INFO("started component '" << componentName << "'");
68}
69
70void TestComponent1::stopActivity()
71{
72 LOG_TRACE(Q_FUNC_INFO);
73
74 THREAD_ALIVE = false;
75
76 setState(STOPPED);
77 LOG_INFO("stopped component '" << componentName << "'");
78}
79
80void TestComponent1::run()
81{
82
83OutputInterface<QImage,TestComponent1> * out1 = dynamic_cast<OutputInterface<QImage,TestComponent1> *> (output.value(QString("image")));
84
85unsigned int i=0;
86int waitTime =5000;
87FILE *fp = fopen("test1.txt","w+");
88
89QImage mat(10000,1000,QImage::Format_RGB32);
90//mat.fill( qRgb(189, 149, 39));
91
92 while(THREAD_ALIVE)
93 {
94 //mat.setPixel(0,0,i);
95 LOG_INFO("Size " << mat.size().width()<< " x " << mat.size().height());
96 out1->send(mat);
97
98 LOG_INFO("Send data " << i << " time " << get_timestamp());
99 fprintf(fp,"%u %lld \n",i, get_timestamp());
100 usleep(waitTime);
101 i++;
102 setState(MONITOR_OK);
103 }
104 fclose(fp);
105
106}
Note: See TracBrowser for help on using the repository browser.