trikRuntime
fifo.h
Go to the documentation of this file.
1 /* Copyright 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/QScopedPointer>
19 
20 #include "fifoInterface.h"
21 #include "deviceState.h"
22 
23 namespace trikKernel {
24 class Configurer;
25 }
26 
27 namespace trikHal {
28 class HardwareAbstractionInterface;
29 class FifoInterface;
30 }
31 
32 namespace trikControl {
33 
35 class Fifo: public FifoInterface
36 {
37  Q_OBJECT
38 
39 public:
44  Fifo(const QString &virtualPort, const trikKernel::Configurer &configurer
45  , const trikHal::HardwareAbstractionInterface &hardwareAbstraction);
46 
50  Fifo(const QString &fileName, const trikHal::HardwareAbstractionInterface &hardwareAbstraction);
51 
52  ~Fifo() override;
53 
54  Status status() const override;
55 
56 public slots:
58  QString read() override;
59 
61  bool hasData() const override;
62 
63 private slots:
64  void onNewData(const QString &data);
65  void onReadError();
66 
67 private:
68  QScopedPointer<trikHal::FifoInterface> mFifo;
69 
71  QString mCurrent;
72 
74  mutable QReadWriteLock mCurrentLock;
75 
77  DeviceState mState;
78 };
79 
80 }
Definition: analogSensor.h:23
Generic configuration helper, parses configuration XML files and presents configuration as a set of a...
Definition: configurer.h:28
Interface that represents linux FIFO file, which is commonly used by various sensors.
Definition: fifoInterface.h:26
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Class that represents linux FIFO file, which is commonly used by various sensors. ...
Definition: fifo.h:35
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
Definition: brickFactory.h:21
Hardware abstraction, provides devices that are used to communicate with robot hardware or emulate it...
Definition: hardwareAbstractionInterface.h:29