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

Last change on this file since 54 was 42, checked in by cfougera, 11 years ago

Last version

File size: 3.8 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;
76 while (param.getProperty("sickldmrs_"+QString::number(num)) != QString::null){
77 QString information = param.getProperty("sickldmrs_"+QString::number(num));
78 QStringList list = information.split(":");
79 int recording = 0;
80 if (param.getProperty("sickldmrs_"+QString::number(num)+"_recording") != QString::null)
81 {
82 recording = param.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
[42]89 // Sick LMS 151
[37]90 num = 0;
91 while (param.getProperty("sicklms151_"+QString::number(num)) != QString::null){
92 QString information = param.getProperty("sicklms151_"+QString::number(num));
93 QStringList list = information.split(":");
94 int recording = 0;
95 if (param.getProperty("sicklms151_"+QString::number(num)+"_recording") != QString::null)
96 {
97 recording = param.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
[42]104 // Sick LMS 511
[37]105 num = 0;
106 while (param.getProperty("sicklms511_"+QString::number(num)) != QString::null){
107 QString information = param.getProperty("sicklms511_"+QString::number(num));
108 QStringList list = information.split(":");
109 int recording = 0;
110 if (param.getProperty("sicklms511_"+QString::number(num)+"_recording") != QString::null)
111 {
112 recording = param.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
Note: See TracBrowser for help on using the repository browser.