Fix doxygen documentation for the logic layer
parent
c15b1d59c4
commit
3f98ec03ca
|
|
@ -3,14 +3,15 @@
|
||||||
#include "error_codes.h"
|
#include "error_codes.h"
|
||||||
#include "progress_codes.h"
|
#include "progress_codes.h"
|
||||||
|
|
||||||
/// Base class defining common API for high-level operations/commands/state machines
|
/// The logic namespace handles the application logic on top of the modules.
|
||||||
|
namespace logic {
|
||||||
|
|
||||||
|
/// @brief Base class defining common API for high-level operations/commands/state machines
|
||||||
///
|
///
|
||||||
/// Which state machines are high-level? Those which are being initiated either by a command over the serial line or from a button
|
/// Which state machines are high-level? Those which are being initiated either by a command over the serial line or from a button
|
||||||
/// - they report their progress to the printer
|
/// - they report their progress to the printer
|
||||||
/// - they can be composed of other sub automata
|
/// - they can be composed of other sub automata
|
||||||
|
///
|
||||||
namespace logic {
|
|
||||||
|
|
||||||
/// Tasks derived from this base class are the top-level operations inhibited by the printer.
|
/// Tasks derived from this base class are the top-level operations inhibited by the printer.
|
||||||
/// These tasks report their progress and only one of these tasks is allowed to run at once.
|
/// These tasks report their progress and only one of these tasks is allowed to run at once.
|
||||||
class CommandBase {
|
class CommandBase {
|
||||||
|
|
@ -50,12 +51,12 @@ public:
|
||||||
/// @returns status of the operation - e.g. RUNNING, OK, or an error code if the operation failed.
|
/// @returns status of the operation - e.g. RUNNING, OK, or an error code if the operation failed.
|
||||||
///
|
///
|
||||||
/// Beware - the same rule about composite operations as with State() applies to Error() as well.
|
/// Beware - the same rule about composite operations as with State() applies to Error() as well.
|
||||||
/// Please see @ErrorCode for more details
|
/// Please see ErrorCode for more details
|
||||||
virtual ErrorCode Error() const { return error; }
|
virtual ErrorCode Error() const { return error; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ProgressCode state;
|
ProgressCode state; ///< current progress state of the state machine
|
||||||
ErrorCode error;
|
ErrorCode error; ///< current error code
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A high-level command state machine
|
/// @brief A high-level command state machine - handles the complex logic of cutting filament
|
||||||
/// Handles the complex logic of cutting filament
|
|
||||||
class CutFilament : public CommandBase {
|
class CutFilament : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline CutFilament()
|
inline CutFilament()
|
||||||
: CommandBase() {}
|
: CommandBase() {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
|
/// @param param index of filament slot to perform cut onto
|
||||||
void Reset(uint8_t param) override;
|
void Reset(uint8_t param) override;
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
|
|
@ -32,6 +32,7 @@ private:
|
||||||
void SelectFilamentSlot();
|
void SelectFilamentSlot();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of CutFilament state machine in the FW
|
||||||
extern CutFilament cutFilament;
|
extern CutFilament cutFilament;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,22 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A high-level command state machine
|
/// @brief A high-level command state machine - handles the complex logic of ejecting filament
|
||||||
/// Handles the complex logic of ejecting filament:
|
|
||||||
///
|
///
|
||||||
|
/// The eject operation consists of:
|
||||||
/// - Move selector sideways and push filament forward a little bit, so that the user can catch it
|
/// - Move selector sideways and push filament forward a little bit, so that the user can catch it
|
||||||
/// - Unpark idler at the end so that the user can pull filament out.
|
/// - Unpark idler at the end so that the user can pull filament out.
|
||||||
/// - If there is still some filament detected by PINDA unload it first.
|
/// - If there is still some filament detected by PINDA unload it first.
|
||||||
/// - If we want to eject fil 0-2, move selector to position 4 (right).
|
/// - If we want to eject fil 0-2, move selector to position 4 (right).
|
||||||
/// - If we want to eject fil 3-4, move selector to position 0 (left)
|
/// - If we want to eject fil 3-4, move selector to position 0 (left)
|
||||||
/// Optionally, we can also move the selector to its service position in the future.
|
/// Optionally, we can also move the selector to its service position in the future.
|
||||||
/// @param filament filament 0 to 4
|
|
||||||
|
|
||||||
class EjectFilament : public CommandBase {
|
class EjectFilament : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline EjectFilament()
|
inline EjectFilament()
|
||||||
: CommandBase() {}
|
: CommandBase() {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
|
/// @param param index of filament slot to eject
|
||||||
void Reset(uint8_t param) override;
|
void Reset(uint8_t param) override;
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
|
|
@ -38,6 +37,7 @@ private:
|
||||||
void MoveSelectorAside();
|
void MoveSelectorAside();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of EjectFilament state machine in the FW
|
||||||
extern EjectFilament ejectFilament;
|
extern EjectFilament ejectFilament;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
/// A complete set of error codes which may be a result of a high-level command/operation
|
/// A complete set of error codes which may be a result of a high-level command/operation
|
||||||
/// This header file shall be included in the printer's firmware as well as a reference,
|
/// This header file shall be included in the printer's firmware as well as a reference,
|
||||||
/// therefore the error codes have been extracted to one place
|
/// therefore the error codes have been extracted to one place
|
||||||
|
|
||||||
enum class ErrorCode : int_fast8_t {
|
enum class ErrorCode : int_fast8_t {
|
||||||
RUNNING = 0, ///< the operation is still running
|
RUNNING = 0, ///< the operation is still running
|
||||||
OK, ///< the operation finished OK
|
OK, ///< the operation finished OK
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace logic {
|
||||||
|
|
||||||
/// @brief Feed filament to Bondtech gears of the printer
|
/// @brief Feed filament to Bondtech gears of the printer
|
||||||
///
|
///
|
||||||
/// Continuously feed filament until the printer detects the filament in its filament sensor
|
/// Continuously feed filament until the printer detects the filament in its filament sensor
|
||||||
|
|
||||||
namespace logic {
|
|
||||||
|
|
||||||
struct FeedToBondtech {
|
struct FeedToBondtech {
|
||||||
|
/// internal states of the state machine
|
||||||
enum {
|
enum {
|
||||||
EngagingIdler,
|
EngagingIdler,
|
||||||
PushingFilament,
|
PushingFilament,
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace logic {
|
||||||
|
|
||||||
/// @brief Feed filament to FINDA
|
/// @brief Feed filament to FINDA
|
||||||
///
|
///
|
||||||
/// Continuously feed filament until FINDA is not switched ON
|
/// Continuously feed filament until FINDA is not switched ON
|
||||||
/// and than retract to align filament 600 steps away from FINDA.
|
/// and than retract to align filament 600 steps away from FINDA.
|
||||||
|
|
||||||
namespace logic {
|
|
||||||
|
|
||||||
struct FeedToFinda {
|
struct FeedToFinda {
|
||||||
|
/// internal states of the state machine
|
||||||
enum {
|
enum {
|
||||||
EngagingIdler,
|
EngagingIdler,
|
||||||
PushingFilament,
|
PushingFilament,
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A high-level command state machine
|
/// @brief A high-level command state machine - handles the complex logic of loading filament into a filament slot.
|
||||||
/// Handles the complex logic of loading filament
|
|
||||||
class LoadFilament : public CommandBase {
|
class LoadFilament : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline LoadFilament()
|
inline LoadFilament()
|
||||||
: CommandBase() {}
|
: CommandBase() {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
|
/// @param param index of filament slot to load
|
||||||
void Reset(uint8_t param) override;
|
void Reset(uint8_t param) override;
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
|
|
@ -24,6 +24,7 @@ private:
|
||||||
FeedToBondtech james; // bond ;)
|
FeedToBondtech james; // bond ;)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of LoadFilament state machine in the FW
|
||||||
extern LoadFilament loadFilament;
|
extern LoadFilament loadFilament;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A dummy No-command operation just to make the init of the firmware consistent (and cleaner code during processing)
|
/// @brief A dummy No-command operation just to make the init of the firmware consistent (and cleaner code during processing).
|
||||||
class NoCommand : public CommandBase {
|
class NoCommand : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline NoCommand()
|
inline NoCommand()
|
||||||
|
|
@ -18,6 +18,7 @@ public:
|
||||||
bool Step() override { return true; }
|
bool Step() override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of NoCommand state machine in the FW
|
||||||
extern NoCommand noCommand;
|
extern NoCommand noCommand;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
/// A complete set of progress codes which may be reported while running a high-level command/operation
|
/// A complete set of progress codes which may be reported while running a high-level command/operation
|
||||||
/// This header file shall be included in the printer's firmware as well as a reference,
|
/// This header file shall be included in the printer's firmware as well as a reference,
|
||||||
/// therefore the progress codes have been extracted to one place
|
/// therefore the progress codes have been extracted to one place
|
||||||
|
|
||||||
enum class ProgressCode : uint_fast8_t {
|
enum class ProgressCode : uint_fast8_t {
|
||||||
OK = 0, ///< finished ok
|
OK = 0, ///< finished ok
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A high-level command state machine
|
/// @brief A high-level command state machine - handles the complex logic of tool change - which is basically a chain of an Unload and a Load operation.
|
||||||
/// Handles the complex logic of tool change
|
|
||||||
class ToolChange : public CommandBase {
|
class ToolChange : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline ToolChange()
|
inline ToolChange()
|
||||||
: CommandBase() {}
|
: CommandBase() {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
|
/// @param param index of filament slot to change to - i.e. to load
|
||||||
void Reset(uint8_t param) override;
|
void Reset(uint8_t param) override;
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
|
|
@ -29,6 +29,7 @@ private:
|
||||||
uint8_t plannedSlot;
|
uint8_t plannedSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of ToolChange state machine in the FW
|
||||||
extern ToolChange toolChange;
|
extern ToolChange toolChange;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
/// A high-level command state machine
|
/// @brief A high-level command state machine - handles the complex logic of unloading filament
|
||||||
/// Handles the complex logic of unloading filament
|
|
||||||
class UnloadFilament : public CommandBase {
|
class UnloadFilament : public CommandBase {
|
||||||
public:
|
public:
|
||||||
inline UnloadFilament()
|
inline UnloadFilament()
|
||||||
|
|
@ -14,7 +13,7 @@ public:
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
/// @param param is not used, always unloads from the active slot
|
/// @param param is not used, always unloads from the active slot
|
||||||
void Reset(uint8_t /*param*/) override;
|
void Reset(uint8_t param) override;
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
bool Step() override;
|
bool Step() override;
|
||||||
|
|
@ -24,6 +23,7 @@ private:
|
||||||
UnloadToFinda unl;
|
UnloadToFinda unl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The one and only instance of UnloadFilament state machine in the FW
|
||||||
extern UnloadFilament unloadFilament;
|
extern UnloadFilament unloadFilament;
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/// Unload to FINDA "small" state machine
|
namespace logic {
|
||||||
|
|
||||||
|
/// @brief Unload to FINDA "small" state machine
|
||||||
|
///
|
||||||
/// "small" state machines will serve as building blocks for high-level commands/operations
|
/// "small" state machines will serve as building blocks for high-level commands/operations
|
||||||
/// - engage/disengage idler
|
/// - engage/disengage idler
|
||||||
/// - rotate pulley to some direction as long as the FINDA is on/off
|
/// - rotate pulley to some direction as long as the FINDA is on/off
|
||||||
/// - rotate some axis to some fixed direction
|
/// - rotate some axis to some fixed direction
|
||||||
/// - load/unload to finda
|
/// - load/unload to finda
|
||||||
|
|
||||||
namespace logic {
|
|
||||||
|
|
||||||
/// A "small" automaton example - Try to unload filament to FINDA and if it fails try to recover several times.
|
/// A "small" automaton example - Try to unload filament to FINDA and if it fails try to recover several times.
|
||||||
/// \dot
|
/// \dot
|
||||||
/// digraph example {
|
/// digraph example {
|
||||||
|
|
@ -20,6 +20,7 @@ namespace logic {
|
||||||
///}
|
///}
|
||||||
///\enddot
|
///\enddot
|
||||||
struct UnloadToFinda {
|
struct UnloadToFinda {
|
||||||
|
/// internal states of the state machine
|
||||||
enum {
|
enum {
|
||||||
EngagingIdler,
|
EngagingIdler,
|
||||||
WaitingForFINDA,
|
WaitingForFINDA,
|
||||||
|
|
@ -30,11 +31,13 @@ struct UnloadToFinda {
|
||||||
: maxTries(3) {}
|
: maxTries(3) {}
|
||||||
|
|
||||||
/// Restart the automaton
|
/// Restart the automaton
|
||||||
|
/// @param maxTries maximum number of retried attempts before reporting a fail
|
||||||
void Reset(uint8_t maxTries);
|
void Reset(uint8_t maxTries);
|
||||||
|
|
||||||
/// @returns true if the state machine finished its job, false otherwise
|
/// @returns true if the state machine finished its job, false otherwise
|
||||||
bool Step();
|
bool Step();
|
||||||
|
|
||||||
|
/// @returns internal state of the state machine
|
||||||
inline uint8_t State() const { return state; }
|
inline uint8_t State() const { return state; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue