trikRuntime
deviceState.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/QReadWriteLock>
18 #include <QtCore/QString>
19 
20 #include "deviceInterface.h"
21 
22 namespace trikControl {
23 
27 {
28 public:
31  DeviceState(const QString &deviceName);
32 
35 
37  bool isReady() const;
38 
40  bool isFailed() const;
41 
45  void fail();
46 
48  void start();
49 
51  void ready();
52 
54  void stop();
55 
57  void off();
58 
60  void resetFailure();
61 
63  QString deviceName() const;
64 
65 private:
68 
70  QReadWriteLock mLock;
71 
73  QString mDeviceName;
74 };
75 
76 }
void fail()
Set "failure" state.
Definition: deviceState.cpp:44
void start()
Set "starting" state. Possible only from "off" state.
Definition: deviceState.cpp:51
void ready()
Set "ready" state. Possible only from "off" and "starting" states.
Definition: deviceState.cpp:69
void resetFailure()
Clears "failed" state and returns state to "off".
Definition: deviceState.cpp:123
Device received command to turn on, but is starting now, and it may take some time.
bool isFailed() const
Returns true if device is in "failure" state.
Definition: deviceState.cpp:38
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
void off()
Set "off" state. Possible only from "ready" and "stopping" states.
Definition: deviceState.cpp:105
DeviceState(const QString &deviceName)
Constructor.
Definition: deviceState.cpp:21
void stop()
Set "stopping" state. Possible only from "ready" state.
Definition: deviceState.cpp:87
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
QString deviceName() const
Returns name of the device for debug purposes.
Definition: deviceState.cpp:137
bool isReady() const
Returns true if device is in "ready" state.
Definition: deviceState.cpp:32
DeviceInterface::Status status() const
Returns current device state.
Definition: deviceState.cpp:26