1 | /*********************************************************************
|
---|
2 | // created: 2014-02-01 - 12:08
|
---|
3 | // filename: SickComponent.cpp
|
---|
4 | //
|
---|
5 | // author: Cyril Fougeray
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: The acquisition component of the Sick sensors (parent class)
|
---|
11 | //
|
---|
12 | *********************************************************************/
|
---|
13 |
|
---|
14 | #include "SickComponent.h"
|
---|
15 |
|
---|
16 | //#include "AlascaDataGenerator.h"
|
---|
17 | #include "SickSocket.h"
|
---|
18 | #include "Pacpus/kernel/ComponentFactory.h"
|
---|
19 | #include "Pacpus/kernel/DbiteException.h"
|
---|
20 | #include "Pacpus/kernel/DbiteFileTypes.h"
|
---|
21 | #include "Pacpus/kernel/Log.h"
|
---|
22 | #include "Pacpus/PacpusTools/ShMem.h"
|
---|
23 |
|
---|
24 | #include <iostream>
|
---|
25 | #include <QTcpSocket>
|
---|
26 | #include <string>
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 |
|
---|
30 |
|
---|
31 | namespace pacpus {
|
---|
32 |
|
---|
33 | DECLARE_STATIC_LOGGER("pacpus.base.SickComponent");
|
---|
34 |
|
---|
35 | // Construct the factory
|
---|
36 | static ComponentFactory<SickComponent> sFactory("SickComponent");
|
---|
37 |
|
---|
38 |
|
---|
39 | SickComponent::SickComponent(QString name)
|
---|
40 | : ComponentBase(name)
|
---|
41 | {
|
---|
42 | LOG_TRACE("constructor(" << name << ")");
|
---|
43 |
|
---|
44 | S_sensors = new std::vector<AbstractSickSensor*>();
|
---|
45 | }
|
---|
46 |
|
---|
47 | SickComponent::~SickComponent()
|
---|
48 | {
|
---|
49 | LOG_TRACE("destructor");
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | void SickComponent::startActivity()
|
---|
54 | {
|
---|
55 | for(std::vector<AbstractSickSensor*>::iterator it = S_sensors->begin(); it != S_sensors->end(); ++it){
|
---|
56 | (*it)->startActivity();
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | void SickComponent::stopActivity()
|
---|
62 | {
|
---|
63 | for(std::vector<AbstractSickSensor*>::iterator it = S_sensors->begin(); it != S_sensors->end(); ++it){
|
---|
64 | (*it)->stopActivity();
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | ComponentBase::COMPONENT_CONFIGURATION SickComponent::configureComponent(XmlComponentConfig config)
|
---|
70 | {
|
---|
71 | /*
|
---|
72 | * <Sick sickldmrs_0="192.168.0.1:2111" sicklms151_0="192.168.0.10:2111" sicklms511_0="192.168.1.50:2111">
|
---|
73 | */
|
---|
74 | // Sick LD-MRS
|
---|
75 | int num = 0;
|
---|
76 | while (config.getProperty("sickldmrs_"+QString::number(num)) != QString::null){
|
---|
77 | QString information = config.getProperty("sickldmrs_"+QString::number(num));
|
---|
78 | QStringList list = information.split(":");
|
---|
79 | int recording = 0;
|
---|
80 | if (config.getProperty("sickldmrs_"+QString::number(num)+"_recording") != QString::null)
|
---|
81 | {
|
---|
82 | recording = config.getProperty("sickldmrs_"+QString::number(num)+"_recording").toInt();
|
---|
83 | }
|
---|
84 |
|
---|
85 | S_sensors->push_back(new SickLDMRSSensor(this, "sickldmrs_"+QString::number(num), list.at(0), list.at(1).toInt(), recording));
|
---|
86 | ++num;
|
---|
87 | }
|
---|
88 |
|
---|
89 | // Sick LMS 151
|
---|
90 | num = 0;
|
---|
91 | while (config.getProperty("sicklms151_"+QString::number(num)) != QString::null){
|
---|
92 | QString information = config.getProperty("sicklms151_"+QString::number(num));
|
---|
93 | QStringList list = information.split(":");
|
---|
94 | int recording = 0;
|
---|
95 | if (config.getProperty("sicklms151_"+QString::number(num)+"_recording") != QString::null)
|
---|
96 | {
|
---|
97 | recording = config.getProperty("sicklms151_"+QString::number(num)+"_recording").toInt();
|
---|
98 | }
|
---|
99 |
|
---|
100 | S_sensors->push_back(new SickLMSSensor(this, "sicklms151_"+QString::number(num), list.at(0), list.at(1).toInt(), recording));
|
---|
101 | ++num;
|
---|
102 | }
|
---|
103 |
|
---|
104 | // Sick LMS 511
|
---|
105 | num = 0;
|
---|
106 | while (config.getProperty("sicklms511_"+QString::number(num)) != QString::null){
|
---|
107 | QString information = config.getProperty("sicklms511_"+QString::number(num));
|
---|
108 | QStringList list = information.split(":");
|
---|
109 | int recording = 0;
|
---|
110 | if (config.getProperty("sicklms511_"+QString::number(num)+"_recording") != QString::null)
|
---|
111 | {
|
---|
112 | recording = config.getProperty("sicklms511_"+QString::number(num)+"_recording").toInt();
|
---|
113 | }
|
---|
114 |
|
---|
115 | S_sensors->push_back(new SickLMSSensor(this, "sicklms511_"+QString::number(num), list.at(0), list.at(1).toInt(), recording));
|
---|
116 | ++num;
|
---|
117 | }
|
---|
118 |
|
---|
119 | return ComponentBase::CONFIGURED_OK;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | } // namespace pacpus
|
---|