trikRuntime
rangeSensor.h
Go to the documentation of this file.
1 /* Copyright 2014 - 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QThread>
18 
19 #include "sensorInterface.h"
20 #include "deviceState.h"
21 
22 namespace trikKernel {
23 class TimeVal;
24 }
25 
26 namespace trikHal {
27 class HardwareAbstractionInterface;
28 }
29 
30 namespace trikKernel {
31 class Configurer;
32 }
33 
34 namespace trikControl {
35 
36 class RangeSensorWorker;
37 class ModuleLoader;
38 
41 {
42  Q_OBJECT
43 
44 public:
48  RangeSensor(const QString &port, const trikKernel::Configurer &configurer, ModuleLoader &moduleLoader
49  , const trikHal::HardwareAbstractionInterface &hardwareAbstraction);
50 
51  ~RangeSensor() override;
52 
53  Status status() const override;
54 
55  int minValue() const override;
56 
57  int maxValue() const override;
58 
59 signals:
61  void newData(int distance, int rawDistance, const trikKernel::TimeVal &eventTime);
62 
63 public slots:
65  void init();
66 
68  int read() override;
69 
71  int readRawData() override;
72 
74  void stop();
75 
76 private:
78  DeviceState mState;
79 
81  QScopedPointer<RangeSensorWorker> mSensorWorker;
82 
84  QThread mWorkerThread;
85 
87  int mMinValue = 0;
88 
90  int mMaxValue = 0;
91 };
92 
93 }
Definition: analogSensor.h:23
Generic configuration helper, parses configuration XML files and presents configuration as a set of a...
Definition: configurer.h:28
static const int port
Definition: trikCommunicatorTest.cpp:24
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Structure of a time value in a convenient format.
Definition: timeVal.h:20
TRIK range sensor.
Definition: rangeSensor.h:40
Some devices like range sensor require kernel modules to work.
Definition: moduleLoader.h:26
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
Abstract sensor, inherited by various sensor types.
Definition: sensorInterface.h:26
Definition: brickFactory.h:21
Hardware abstraction, provides devices that are used to communicate with robot hardware or emulate it...
Definition: hardwareAbstractionInterface.h:29