1 | /**
|
---|
2 | @file
|
---|
3 | Purpose: 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 |
|
---|
24 | using namespace pacpus;
|
---|
25 | using namespace std;
|
---|
26 |
|
---|
27 | DECLARE_STATIC_LOGGER("pacpus.cityvip.test.testComponent1");
|
---|
28 |
|
---|
29 | const char * TestComponent1::COMPONENT_TYPE = "TestComponent1";
|
---|
30 |
|
---|
31 | /// Construct the factory
|
---|
32 | static ComponentFactory<TestComponent1> sFactory(TestComponent1::COMPONENT_TYPE);
|
---|
33 |
|
---|
34 | TestComponent1::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 |
|
---|
43 | TestComponent1::~TestComponent1()
|
---|
44 | {
|
---|
45 | LOG_TRACE("destructor");
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | ComponentBase::COMPONENT_CONFIGURATION
|
---|
50 | TestComponent1::configureComponent(XmlComponentConfig /*config*/)
|
---|
51 | {
|
---|
52 | LOG_TRACE(Q_FUNC_INFO);
|
---|
53 |
|
---|
54 | LOG_INFO("component '" << componentName << "' configured");
|
---|
55 | return ComponentBase::CONFIGURED_OK;
|
---|
56 | }
|
---|
57 |
|
---|
58 | void 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 |
|
---|
70 | void 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 |
|
---|
80 | void TestComponent1::run()
|
---|
81 | {
|
---|
82 |
|
---|
83 | OutputInterface<QImage,TestComponent1> * out1 = dynamic_cast<OutputInterface<QImage,TestComponent1> *> (output.value(QString("image")));
|
---|
84 |
|
---|
85 | unsigned int i=0;
|
---|
86 | int waitTime =5000;
|
---|
87 | FILE *fp = fopen("test1.txt","w+");
|
---|
88 |
|
---|
89 | QImage 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 | }
|
---|