close Warning: Can't use blame annotator:
svn blame failed on trunk/lib/FlairSensorActuator/src/SimuLaser.cpp: 200029 - Couldn't perform atomic initialization

source: flair-src/trunk/lib/FlairSensorActuator/src/SimuLaser.cpp@ 224

Last change on this file since 224 was 224, checked in by Sanahuja Guillaume, 6 years ago

maj for armv5te

File size: 2.0 KB
RevLine 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2014/02/07
6// filename: SimuUs.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class for a simulation us
14//
15//
16/*********************************************************************/
17#include "SimuLaser.h"
18#include <FrameworkManager.h>
19#include <SpinBox.h>
20#include <GroupBox.h>
21#include <Matrix.h>
22#include <SharedMem.h>
23#include <sstream>
24
25using std::string;
26using std::ostringstream;
27using namespace flair::core;
28using namespace flair::gui;
29
30namespace flair {
31namespace sensor {
32
33SimuLaser::SimuLaser(string name,
34 uint32_t modelId,uint32_t deviceId, uint8_t priority)
35 : Thread(getFrameworkManager(), name, priority), LaserRangeFinder(name) {
36 data_rate =
37 new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
38
39 shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
40 360 * sizeof(float));
41 SetIsReady(true);
42}
43
44SimuLaser::~SimuLaser() {
45 SafeStop();
46 Join();
47}
48
49string SimuLaser::ShMemName(uint32_t modelId,uint32_t deviceId) {
50 ostringstream dev_name;
51 dev_name << "simu" << modelId << "_laser_" << deviceId;
52 return dev_name.str().c_str();
53}
54
55void SimuLaser::Run(void) {
56 float z[360];
57
58 if (data_rate == NULL) {
59 Thread::Err("not applicable for simulation part.\n");
60 return;
61 }
62
63 SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
64
65 while (!ToBeStopped()) {
66 WaitPeriod();
67
68 shmem->Read((char *)z, 360 * sizeof(float));
69
70 if (data_rate->ValueChanged() == true) {
71 SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
72 }
73 for (int i = 0; i < 360; i++) {
74 output->SetValue(i, 0, z[i]); //*******
75 }
76 output->SetDataTime(GetTime());
77 ProcessUpdate(output);
78 }
79}
80
81} // end namespace sensor
82} // end namespace flair
Note: See TracBrowser for help on using the repository browser.