Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
|
Base class defining common API for high-level operations/commands/state machines. More...
#include <command_base.h>
Public Member Functions | |
virtual bool | Reset (uint8_t param)=0 |
bool | Step () |
virtual bool | StepInner ()=0 |
virtual ProgressCode | State () const |
ProgressCode | TopLevelState () const |
virtual ErrorCode | Error () const |
virtual ResultCode | Result () const |
void | Panic (ErrorCode ec) |
Static Public Member Functions | |
static void | InvalidateHoming () |
Invalidates homing state on Idler and Selector - doesn't change anything about filament load status. | |
static void | InvalidateHomingAndFilamentState () |
static void | HoldIdlerSelector () |
Put Idler and Selector on-hold - they shall not move (not even home) until ResumeIdlerSelector is called. | |
static void | ResumeIdlerSelector () |
Allow Idler and Selector to move/home again. Any move needs to be newly planned. | |
Protected Member Functions | |
bool | CheckToolIndex (uint8_t index) |
bool | WaitForModulesErrorRecovery () |
bool | WaitForOneModuleErrorRecovery (ErrorCode iState, modules::motion::MovableBase &m, uint8_t axisMask) |
void | ErrDisengagingIdler () |
Perform disengaging idler in ErrDisengagingIdler state. | |
void | GoToErrDisengagingIdler (ErrorCode deferredEC) |
Transit the state machine into ErrDisengagingIdler. | |
void | GoToErrEngagingIdler () |
Transit the state machine into ErrEngagingIdler. | |
void | FinishedOK () |
Process end of command which finished OK. | |
Protected Attributes | |
ProgressCode | state |
current progress state of the state machine | |
ErrorCode | error |
current error code | |
ErrorCode | deferredErrorCode |
planned error code - occurs when doing GoToErrDisengagingIdler - after the idler disengaged, the error is set (not before) | |
ProgressCode | stateBeforeModuleFailed |
saved state of the state machine before a common error happened | |
ErrorCode | errorBeforeModuleFailed |
saved error of the state machine before a common error happened | |
uint8_t | recoveringMovableErrorAxisMask |
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
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.
|
protected |
|
inlinevirtual |
Beware - the same rule about composite operations as with State() applies to Error() as well. Please see ErrorCode for more details
Reimplemented in logic::ToolChange, logic::EjectFilament, and logic::CutFilament.
|
static |
Invalidates homing state on Idler and Selector + resets the knowledge about filament presence according to known sensors (FINDA+FSensor)
void logic::CommandBase::Panic | ( | ErrorCode | ec | ) |
Switches the state machine into an error state of code ec. It shall be used to halt the firmware while retaining the capability of reporting the error state to the printer
|
pure virtual |
resets the automaton
param | numerical parameter that comes with some commands (e.g. T1 for tool change 1) |
Implemented in logic::StartUp, logic::NoCommand, logic::Home, logic::UnloadFilament, logic::ToolChange, logic::SetMode, logic::MoveSelector, logic::LoadFilament, logic::HWSanity, logic::EjectFilament, and logic::CutFilament.
|
inlinevirtual |
Reimplemented in logic::LoadFilament.
|
inlinevirtual |
Beware - derived automata report detailed states of underlying state machines if any E.g. Eject filament first tries to unload filament, which is a standalone automaton. Therefore until the unload is finished, this method will report the internal state of Unload filament. The reason for this is to be able to report exactly what is happening to the printer, especially loading and unloading sequences (and errors)
Reimplemented in logic::ToolChange, logic::EjectFilament, and logic::CutFilament.
bool logic::CommandBase::Step | ( | ) |
Steps the state machine. This is the preferred way of stepping the machine as it handles the global HW error states uniformly (so that the derived classes do not have to deal with these error states on their own). Each derived class then only implements its own logic via the virtual StepInner method.
|
pure virtual |
Each derived class shall implement its own state machine logic in this method It is being called from Step after the HW error states have been checked
Implemented in logic::UnloadFilament, logic::ToolChange, logic::StartUp, logic::SetMode, logic::NoCommand, logic::MoveSelector, logic::LoadFilament, logic::HWSanity, logic::Home, logic::EjectFilament, and logic::CutFilament.
|
inline |
|
protected |
Checks for errors of modules - that includes TMC errors, Idler and Selector errors and possibly more. The idea is to check blocking errors at one spot consistently. Some of the detected errors can be irrecoverable (i.e. need power cycling the MMU).
|
protected |