DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/AppOrchestrator.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 * © 2023 Peter Cole
4 *
5 * This is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * It is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this code. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef APPORCHESTRATOR_H
20#define APPORCHESTRATOR_H
21
23#include "ConnectionManager.h"
24#include "DisplayInterface.h"
25#include "ErrorScreen.h"
26#include "EventListener.h"
27#include "MenuManager.h"
28#include "ProgressScreen.h"
29#include "StartupScreen.h"
30#include "ThrottleScreen.h"
33
44
48public:
57 AppOrchestrator(DisplayInterface *displayInterface, ConnectionManager *connectionManager, MenuManager *menuManager,
58 CommandStationClient *commandStationClient, UserConfirmationInterface *userConfirmationInterface,
59 UserSelectionInterface *userSelectionInterface, ThrottleScreen *throttleScreen);
60
62 void begin();
63
66 void update();
67
70 void onEvent(Event &event);
71
74
77 void setThrottleLoco(Loco *loco);
78
81 void updateThrottleLoco(LocoBroadcast locoBroadcast);
82
85 void updateThrottleTrackPower(TrackPower trackPower);
86
87private:
95
100
102 void _handleStartupState();
103
106
109
112
115
118
120 void _handleErrorState();
121
124 void _switchState(AppState appState);
125
128 void _displayMenu(BaseMenu *menu);
129
132
135 void _handleSetTrackPower(Event event);
136
138 void _readLoco();
139
142
145 void _handleReceivedReadLoco(int address);
146};
147
148#endif // APPORCHESTRATOR_H
AppState
Definition AppOrchestrator.h:34
@ ReadLocoAddress
@ ConnectCommandStation
@ SelectCommandStation
This class is for the overall application orchestration to coordinate all the user interactions,...
Definition AppOrchestrator.h:47
void _handleReadLocoState()
Show the read loco progress screen until it is read or times out.
Definition AppOrchestrator.cpp:354
UserConfirmationInterface * _userConfirmationInterface
Definition AppOrchestrator.h:92
void _handleStartupState()
Show the startup screen and wait for user interaction before continuing.
Definition AppOrchestrator.cpp:177
void _handleErrorState()
Show any errors on screen and process user interaction to recover.
Definition AppOrchestrator.cpp:291
ThrottleScreen * _throttleScreen
Definition AppOrchestrator.h:97
void _handleSelectCommandStationState()
Display the CommandStation menu and process user interaction to select one.
Definition AppOrchestrator.cpp:195
void _handleSelectActionState()
Show the select action menu and process user interaction to select one.
Definition AppOrchestrator.cpp:272
void _handleThrottleState()
Show the throttle screen and process user interaction with the throttle.
Definition AppOrchestrator.cpp:248
ProgressScreen * _progressScreen
Definition AppOrchestrator.h:99
AppState _currentAppState
Definition AppOrchestrator.h:94
void updateThrottleLoco(LocoBroadcast locoBroadcast)
Notify the throttle screen an update has been received for the associated loco.
Definition AppOrchestrator.cpp:165
void _handleReceivedReadLoco(int address)
Set throttle to the received loco address when reading, or return to the select screen if failed.
Definition AppOrchestrator.cpp:362
void _handleSetTrackPower(Event event)
Set track power according to the provided Event details.
Definition AppOrchestrator.cpp:342
void begin()
Anything required to be initiated when the orchestrator starts is called here.
Definition AppOrchestrator.cpp:35
void _switchState(AppState appState)
Switch application states.
Definition AppOrchestrator.cpp:300
void _handleJoinProgTrack()
Join programming track to main and return to the Select Loco menu.
Definition AppOrchestrator.cpp:337
void updateThrottleTrackPower(TrackPower trackPower)
Notify the throttle screen of a track power update.
Definition AppOrchestrator.cpp:171
void onEvent(Event &event)
Implementation of the EventListener to respond to subscribed events.
Definition AppOrchestrator.cpp:96
ErrorScreen * _errorScreen
Definition AppOrchestrator.h:98
StartupScreen * _startupScreen
Definition AppOrchestrator.h:96
void _displayMenu(BaseMenu *menu)
Display a menu.
Definition AppOrchestrator.cpp:332
void _readLoco()
Send read loco command to CommandStation client and set ReadLoco state for progress.
Definition AppOrchestrator.cpp:347
CommandStationClient * _commandStationClient
Definition AppOrchestrator.h:91
void _handleSelectLocoState()
Show the loco selection menu and process user interaction to select one.
Definition AppOrchestrator.cpp:229
ConnectionManager * _connectionManager
Definition AppOrchestrator.h:89
void update()
Call this method at least once per main loop iteration to monitor for user interactions,...
Definition AppOrchestrator.cpp:37
MenuManager * _menuManager
Definition AppOrchestrator.h:90
void _handleConnectCommandStationState()
Show the connection progress screen until a connection is made.
Definition AppOrchestrator.cpp:213
UserSelectionInterface * _userSelectionInterface
Definition AppOrchestrator.h:93
DisplayInterface * _displayInterface
Definition AppOrchestrator.h:88
void setThrottleLoco(Loco *loco)
Set the loco being managed by the throttle screen.
Definition AppOrchestrator.cpp:158
void setupSelectLocoMenu()
Method to setup the roster list in the SelectLocoMenu when the roster has been received.
Definition AppOrchestrator.cpp:147
Class for maintaining a linked list of menu items to form a menu.
Definition BaseMenu.h:31
Definition CommandStationClient.h:27
Class to manage all WiFi and serial connections used to connect to a CommandStation.
Definition ConnectionManager.h:30
Interface class to abstract construction of what is displayed on screen from the physical implementat...
Definition DisplayInterface.h:29
Definition ErrorScreen.h:24
Class to extend for all other classes that need to respond to events For example: Class <MyClass> : p...
Definition EventListener.h:26
Definition MenuManager.h:30
Definition ProgressScreen.h:24
Class to display startup information on screen and respond to user interactions Displays the DCC-EX S...
Definition StartupScreen.h:27
Definition ThrottleScreen.h:26
Interface class to abstract user confirmation actions from physical implementations All physical user...
Definition UserConfirmationInterface.h:29
Interface class to abstract user selection actions from physical implementations All physical user se...
Definition UserSelectionInterface.h:31
Structure for each Event that is published.
Definition EventStructure.h:102
Structure for data from a Loco broadcast.
Definition EventStructure.h:42