blob: a55caac2ef3374351d89923cd769ee2a02d7ba21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/*
* GCodeResult.h
*
* Created on: 1 Oct 2017
* Author: David
*/
#ifndef SRC_GCODES_GCODERESULT_H_
#define SRC_GCODES_GCODERESULT_H_
#include <cctype>
#include <Platform/MessageType.h>
// Enumeration to specify the result of attempting to process a GCode command
// These are ordered such that errors > warnings > ok
// *** Do not change the order! These must be the same for the main board and all CAN expansion boards! ***
enum class GCodeResult : uint8_t
{
notFinished, // we haven't finished processing this command
ok, // we have finished processing this code
warning,
warningNotSupported,
error,
errorNotSupported,
notSupportedInCurrentMode,
badOrMissingParameter,
remoteInternalError
};
// Convert a true/false error/no-error indication to a GCodeResult
inline GCodeResult GetGCodeResultFromError(bool err) noexcept
{
return (err) ? GCodeResult::error : GCodeResult::ok;
}
// Convert a true/false success/failure indication to a GCodeResult
inline GCodeResult GetGCodeResultFromSuccess(bool ok) noexcept
{
return (ok) ? GCodeResult::ok : GCodeResult::error;
}
// Convert a true/false finished/not-finished indication to a GCodeResult
inline GCodeResult GetGCodeResultFromFinished(bool finished) noexcept
{
return (finished) ? GCodeResult::ok : GCodeResult::notFinished;
}
// Convert an error or warning result into a suitable generic message type. Should only be called with GCodeResult::warning or GCodeResult::error.
inline MessageType GetGenericMessageType(GCodeResult rslt)
{
return (rslt == GCodeResult::warning) ? WarningMessage : ErrorMessage;
}
#endif /* SRC_GCODES_GCODERESULT_H_ */
|