trikRuntime
incorrectStateChangeException.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 
18 
19 #include "deviceInterface.h"
20 
21 #include <QsLog.h>
22 
23 namespace trikControl {
24 
27 {
28 public:
34  {
35  QLOG_ERROR() << deviceName << QString(": incorrect device state change from \"%1\" to \"%2\"")
36  .arg(statusToString(from)).arg(statusToString(to));
37  }
38 
42  IncorrectStateChangeException(const QString &deviceName, DeviceInterface::Status from)
43  {
44  QLOG_ERROR() << deviceName << QString(": incorrect attempt to reset failure from \"%1\"")
45  .arg(statusToString(from));
46  }
47 
48 private:
50  static QString statusToString(DeviceInterface::Status status) {
51  switch (status) {
53  return "permanent failure";
55  return "temporary failure";
57  return "off";
59  return "ready";
61  return "starting";
63  return "stopping";
64  }
65 
66  return "";
67  }
68 };
69 
70 }
#define QLOG_ERROR()
Definition: QsLog.h:104
Device can not be turned on due to hardware or configuration failure that will likely not be fixed at...
Device received command to turn on, but is starting now, and it may take some time.
Base class for all exceptions in TRIKRuntime.
Definition: trikRuntimeException.h:22
Device received command to turn off and stopping now, it may take some time.
IncorrectStateChangeException(const QString &deviceName, DeviceInterface::Status from, DeviceInterface::Status to)
Constructor.
Definition: incorrectStateChangeException.h:33
Exception for incorrect device state change, for example, from "off" to "stopping".
Definition: incorrectStateChangeException.h:26
IncorrectStateChangeException(const QString &deviceName, DeviceInterface::Status from)
Constructor, used to report incorrect resetting of failure state.
Definition: incorrectStateChangeException.h:42
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
Device is ready and working properly.