trikRuntime
soundSensorWorker.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/QObject>
18 #include <QtCore/QString>
19 #include <QtCore/QReadWriteLock>
20 #include <QtCore/QVector>
21 
23 
24 namespace trikControl {
25 
29 {
30  Q_OBJECT
31 
32 public:
37  SoundSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile, DeviceState &state
38  , trikHal::HardwareAbstractionInterface &hardwareAbstraction);
39 
40  ~SoundSensorWorker() override;
41 
42 public slots:
45  void init(bool showOnDisplay);
46 
49  void detect();
50 
52  void volume(int volCoeff);
53 
55  QVector<int> read();
56 
57 private:
58  QString sensorName() const override;
59 
60  void onNewData(QString const &dataLine) override;
61 
63  QVector<int> mReading;
64 
66  bool mShowOnDisplay = true;
67 
69  QReadWriteLock mLock;
70 };
71 
72 }
QVector< int > read()
Returns angle and volume for both channels. Can be accessed directly from other thread.
Definition: soundSensorWorker.cpp:45
SoundSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction)
Constructor.
Definition: soundSensorWorker.cpp:19
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Worker object that processes sound sensor output and updates stored reading.
Definition: soundSensorWorker.h:28
~SoundSensorWorker() override
Definition: soundSensorWorker.cpp:25
Definition: trikCommunicator.h:27
void init()
Launch sensor.
Definition: abstractVirtualSensorWorker.cpp:61
Base class for all virtual sensor workers.
Definition: abstractVirtualSensorWorker.h:38
void detect()
Not use.
Definition: soundSensorWorker.cpp:35
script
Definition: system.py:83
Hardware abstraction, provides devices that are used to communicate with robot hardware or emulate it...
Definition: hardwareAbstractionInterface.h:29
void volume(int volCoeff)
Sets volume coefficient.
Definition: soundSensorWorker.cpp:40