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 "testComponent2.h"
|
---|
12 |
|
---|
13 | #include "kernel/ComponentFactory.h"
|
---|
14 | #include "kernel/Log.h"
|
---|
15 |
|
---|
16 | #include "testComponent1.h"
|
---|
17 |
|
---|
18 | using namespace pacpus;
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | DECLARE_STATIC_LOGGER("pacpus.cityvip.test.TestComponent2");
|
---|
22 |
|
---|
23 | const char * TestComponent2::COMPONENT_TYPE = "TestComponent2";
|
---|
24 |
|
---|
25 | /// Construct the factory
|
---|
26 | static ComponentFactory<TestComponent2> sFactory(TestComponent2::COMPONENT_TYPE);
|
---|
27 |
|
---|
28 | TestComponent2::TestComponent2(QString name)
|
---|
29 | : ComponentBase(name)
|
---|
30 | {
|
---|
31 | LOG_TRACE("constructor(" << name << ")");
|
---|
32 |
|
---|
33 | addInputOutput();
|
---|
34 | moveToThread(&thread);
|
---|
35 | LOG_INFO("Thread " << thread.currentThread());
|
---|
36 | LOG_INFO("Current Thread " << QThread::currentThread());
|
---|
37 | }
|
---|
38 |
|
---|
39 | TestComponent2::~TestComponent2()
|
---|
40 | {
|
---|
41 | LOG_TRACE("destructor");
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | void TestComponent2::addInputOutput()
|
---|
46 | {
|
---|
47 | input.insert("image",new InputInterface<QImage,TestComponent2> ("image",this,&TestComponent2::process2));
|
---|
48 | }
|
---|
49 |
|
---|
50 | ComponentBase::COMPONENT_CONFIGURATION
|
---|
51 | TestComponent2::configureComponent(XmlComponentConfig /*config*/)
|
---|
52 | {
|
---|
53 | LOG_TRACE(Q_FUNC_INFO);
|
---|
54 |
|
---|
55 | // load XML parameters
|
---|
56 |
|
---|
57 | LOG_INFO("component '" << componentName << "' configured");
|
---|
58 | return ComponentBase::CONFIGURED_OK;
|
---|
59 | }
|
---|
60 |
|
---|
61 | void TestComponent2::startActivity()
|
---|
62 | {
|
---|
63 | LOG_TRACE(Q_FUNC_INFO);
|
---|
64 |
|
---|
65 | //Q_ASSERT(input);
|
---|
66 | fp = fopen("test2.txt","w+");
|
---|
67 | i=0;
|
---|
68 | thread.start();
|
---|
69 | THREAD_ALIVE = true;
|
---|
70 |
|
---|
71 | setState(MONITOR_OK);
|
---|
72 | LOG_INFO("started component '" << componentName << "'");
|
---|
73 | }
|
---|
74 |
|
---|
75 | void TestComponent2::stopActivity()
|
---|
76 | {
|
---|
77 | LOG_TRACE(Q_FUNC_INFO);
|
---|
78 |
|
---|
79 | THREAD_ALIVE = false;
|
---|
80 | thread.quit();
|
---|
81 | fclose(fp);
|
---|
82 | setState(STOPPED);
|
---|
83 | LOG_INFO("stopped component '" << componentName << "'");
|
---|
84 | }
|
---|
85 |
|
---|
86 | void TestComponent2::process2(const QImage& matrix)
|
---|
87 | {
|
---|
88 | LOG_INFO("Size " << matrix.size().width()<< " x " << matrix.size().height());
|
---|
89 | //QImage matrix = a.value<QImage>();
|
---|
90 | unsigned int k;
|
---|
91 |
|
---|
92 | // for(int i=0;i<100;i++){
|
---|
93 | // for(int j=0;j<100;j++){
|
---|
94 | // //k=matrix.pixel(0,0);
|
---|
95 | // }
|
---|
96 | // }
|
---|
97 | fprintf(fp,"%u %lld \n",i++, get_timestamp());
|
---|
98 |
|
---|
99 | setState(MONITOR_OK);
|
---|
100 | LOG_INFO("Processed " << k << " time " << get_timestamp());
|
---|
101 | }
|
---|