Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
application.h
Go to the documentation of this file.
1 #pragma once
3 #include <stdint.h>
4 #include "modules/timebase.h"
5 #include "modules/protocol.h"
6 #include "logic/error_codes.h"
7 
8 namespace logic {
9 class CommandBase;
10 }
11 
12 class Application {
13 public:
14  Application();
15 
16  inline void CommandFinishedCorrectly() {
17  lastCommandProcessedMs = mt::timebase.Millis();
18  }
19 
21  void Panic(ErrorCode ec);
22 
24  void Step();
25 
26  uint8_t CurrentProgressCode();
27  uint16_t CurrentErrorCode();
28 
30  enum class ResetTypes : uint8_t {
31  Software = 0,
32  EEPROMAndSoftware = 42,
33  };
34 
37  void ProcessReset(ResetTypes resetType);
38 
39 #ifndef UNITTEST
40 private:
41 #endif
44  void CheckManualOperation();
45 
47  bool CheckMsgs();
48 
50  void PlanCommand(const mp::RequestMsg &rq);
51 
52  mp::ResponseCommandStatus RunningCommandStatus() const;
53  void ReportCommandAccepted(const mp::RequestMsg &rq, mp::ResponseMsgParamCodes status);
54  void ReportFINDA(const mp::RequestMsg &rq);
55  void ReportRunningCommand();
56  void ReportReadRegister(const mp::RequestMsg &rq);
57  void ReportWriteRegister(const mp::RequestMsg &rq);
58  void ProcessRequestMsg(const mp::RequestMsg &rq);
59 
60  uint16_t lastCommandProcessedMs;
61 
63  logic::CommandBase *currentCommand;
64 
71  mp::RequestMsg currentCommandRq;
72 };
73 
74 extern Application application;
Definition: application.h:12
void ProcessReset(ResetTypes resetType)
Definition: application.cpp:217
ResetTypes
Types of Reset parameters.
Definition: application.h:30
void Step()
Perform one step of top level.
Definition: application.cpp:295
void Panic(ErrorCode ec)
Perform firmware panic handling.
Definition: application.cpp:291
Base class defining common API for high-level operations/commands/state machines.
Definition: command_base.h:29
uint16_t Millis() const
Definition: timebase.cpp:29
ErrorCode
Definition: error_codes.h:17
The logic namespace handles the application logic on top of the modules.
Definition: application.h:8
ResponseMsgParamCodes
Definition of response message parameter codes.
Definition: protocol.h:36
Timebase timebase
The one and only instance of Selector in the FW.
Definition: timebase.cpp:9
A request message - requests are being sent by the printer into the MMU.
Definition: protocol.h:47
Combined commandStatus and its value into one data structure (optimization purposes)
Definition: protocol.h:115