source: flair-src/trunk/lib/FlairIpc/src/IpcPressureSensor.cpp@ 435

Last change on this file since 435 was 397, checked in by Sanahuja Guillaume, 4 years ago

add ipc lib

  • Property svn:eol-style set to native
File size: 1.6 KB
RevLine 
[397]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: 2021/03/03
6// filename: IpcPressureSensor.cpp
7//
8// author: Sébastien Ambroziak
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class for an ipc pressure sensor
14//
15//
16/*********************************************************************/
17
18#include "IpcPressureSensor.h"
19#include "shm_receive.h"
20#include <FrameworkManager.h>
21#include <SpinBox.h>
22#include <GroupBox.h>
23#include <Matrix.h>
24
25
26using namespace flair::core;
27using namespace flair::gui;
28
29namespace flair {
30namespace sensor {
31
32IpcPressureSensor::IpcPressureSensor(string name,
33 uint8_t priority, const char* ipc_name, int ipc_channel)
34 : Thread(getFrameworkManager(), name, priority), PressureSensor( name) {
35 data_rate =
36 new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
37
38 receiver = new ShmReceiver<float>(ipc_name,ipc_channel);
39
40 SetIsReady(true);
41}
42
43
44IpcPressureSensor::~IpcPressureSensor() {
45 SafeStop();
46 Join();
47}
48
49
50void IpcPressureSensor::Run(void) {
51
52 SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
53
54 while (!ToBeStopped()) {
55 WaitPeriod();
56
57 receiver->receive();
58 //shmem->Read((char *)&p, sizeof(float));
59
60 if (data_rate->ValueChanged() == true) {
61 SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
62 }
63
64 output->SetValue(0, 0, receiver->getValue());
65 output->SetDataTime(receiver->getTimestamp().toNanosec());
66 ProcessUpdate(output);
67 }
68}
69
70} // end namespace sensor
71} // end namespace flair
Note: See TracBrowser for help on using the repository browser.