trikRuntime
deviceInterface.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 #include <QtGlobal>
17 #include <QMetaType>
18 #include "declSpec.h"
19 
20 namespace trikControl {
21 
24 {
25  Q_DISABLE_COPY(DeviceInterface)
26 
27 public:
28 public:
29  DeviceInterface() = default;
30  virtual ~DeviceInterface() = default;
31 
33  enum class Status {
36  permanentFailure
37 
40  , temporaryFailure
41 
43  , off
44 
46  , starting
47 
49  , ready
50 
52  , stopping
53  };
54 
57  static Status combine(const DeviceInterface &underlying, const DeviceInterface::Status &dependent)
58  {
59  const DeviceInterface::Status status = underlying.status();
60  if (status != DeviceInterface::Status::ready) {
61  return status;
62  }
63 
64  return dependent;
65  }
66 
68  virtual Status status() const = 0;
69 };
70 
71 }
72 
73 Q_DECLARE_METATYPE(trikControl::DeviceInterface *)
Device received command to turn off and stopping now, it may take some time.
#define TRIKCONTROL_EXPORT
Definition: declSpec.h:23
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
static Status combine(const DeviceInterface &underlying, const DeviceInterface::Status &dependent)
Helper method to return status of a device relying on other device to work.
Definition: deviceInterface.h:57
TRIK device interface, base interface for everything that can be plugged to a brick or already on boa...
Definition: deviceInterface.h:23
virtual Status status() const =0
Returns current status of the device.