source: pacpussensors/trunk/Sick/SickComponent.cpp@ 110

Last change on this file since 110 was 61, checked in by DHERBOMEZ Gérald, 10 years ago

commit after experiments on track
Issue with GPS receiver, no data recorded

File size: 3.9 KB
RevLine 
[37]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
28using namespace std;
29
30
31namespace pacpus {
32
33DECLARE_STATIC_LOGGER("pacpus.base.SickComponent");
34
35// Construct the factory
36static ComponentFactory<SickComponent> sFactory("SickComponent");
37
38
39SickComponent::SickComponent(QString name)
40 : ComponentBase(name)
41{
42 LOG_TRACE("constructor(" << name << ")");
43
44 S_sensors = new std::vector<AbstractSickSensor*>();
45}
46
47SickComponent::~SickComponent()
48{
49 LOG_TRACE("destructor");
50}
51
[42]52
[37]53void SickComponent::startActivity()
54{
55 for(std::vector<AbstractSickSensor*>::iterator it = S_sensors->begin(); it != S_sensors->end(); ++it){
56 (*it)->startActivity();
57 }
58}
59
[42]60
[37]61void SickComponent::stopActivity()
62{
63 for(std::vector<AbstractSickSensor*>::iterator it = S_sensors->begin(); it != S_sensors->end(); ++it){
64 (*it)->stopActivity();
65 }
66}
67
[42]68
[37]69ComponentBase::COMPONENT_CONFIGURATION SickComponent::configureComponent(XmlComponentConfig config)
70{
71 /*
[42]72 * <Sick sickldmrs_0="192.168.0.1:2111" sicklms151_0="192.168.0.10:2111" sicklms511_0="192.168.1.50:2111">
[37]73 */
[42]74 // Sick LD-MRS
[37]75 int num = 0;
[61]76 while (config.getProperty("sickldmrs_"+QString::number(num)) != QString::null){
77 QString information = config.getProperty("sickldmrs_"+QString::number(num));
[37]78 QStringList list = information.split(":");
79 int recording = 0;
[61]80 if (config.getProperty("sickldmrs_"+QString::number(num)+"_recording") != QString::null)
[37]81 {
[61]82 recording = config.getProperty("sickldmrs_"+QString::number(num)+"_recording").toInt();
[37]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
[42]89 // Sick LMS 151
[37]90 num = 0;
[61]91 while (config.getProperty("sicklms151_"+QString::number(num)) != QString::null){
92 QString information = config.getProperty("sicklms151_"+QString::number(num));
[37]93 QStringList list = information.split(":");
94 int recording = 0;
[61]95 if (config.getProperty("sicklms151_"+QString::number(num)+"_recording") != QString::null)
[37]96 {
[61]97 recording = config.getProperty("sicklms151_"+QString::number(num)+"_recording").toInt();
[37]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
[42]104 // Sick LMS 511
[37]105 num = 0;
[61]106 while (config.getProperty("sicklms511_"+QString::number(num)) != QString::null){
107 QString information = config.getProperty("sicklms511_"+QString::number(num));
[37]108 QStringList list = information.split(":");
109 int recording = 0;
[61]110 if (config.getProperty("sicklms511_"+QString::number(num)+"_recording") != QString::null)
[37]111 {
[61]112 recording = config.getProperty("sicklms511_"+QString::number(num)+"_recording").toInt();
[37]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
Note: See TracBrowser for help on using the repository browser.