Skip to content

Commit 8291f06

Browse files
committed
Move ConsoleHandle into NintendoSwitch.
1 parent 4a77d41 commit 8291f06

File tree

135 files changed

+395
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+395
-421
lines changed

Common/Cpp/CancellableScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Cancellable{
6161

6262
// If object has not been cancelled, return false.
6363
// If object has been cancelled with no exception, return true.
64-
// If object has been cancelled with exception, rethrow the exception.
64+
// If object has been cancelled with an exception, rethrow the exception.
6565
bool throw_if_cancelled_with_exception() const;
6666

6767
// Returns true if it was already cancelled.

SerialPrograms/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,6 @@ file(GLOB MAIN_SOURCES
531531
Source/CommonFramework/Tools/BlackBorderCheck.h
532532
Source/CommonFramework/Tools/BotBaseHandle.cpp
533533
Source/CommonFramework/Tools/BotBaseHandle.h
534-
Source/CommonFramework/Tools/ConsoleHandle.cpp
535-
Source/CommonFramework/Tools/ConsoleHandle.h
536534
Source/CommonFramework/Tools/DebugDumper.cpp
537535
Source/CommonFramework/Tools/DebugDumper.h
538536
Source/CommonFramework/Tools/ErrorDumper.cpp
@@ -799,7 +797,6 @@ file(GLOB MAIN_SOURCES
799797
Source/NintendoSwitch/DevPrograms/TestProgramComputer.h
800798
Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp
801799
Source/NintendoSwitch/DevPrograms/TestProgramSwitch.h
802-
Source/NintendoSwitch/FixedInterval.h
803800
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramOption.cpp
804801
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramOption.h
805802
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp
@@ -836,6 +833,9 @@ file(GLOB MAIN_SOURCES
836833
Source/NintendoSwitch/Inference/NintendoSwitch_DateReader.h
837834
Source/NintendoSwitch/Inference/NintendoSwitch_DetectHome.cpp
838835
Source/NintendoSwitch/Inference/NintendoSwitch_DetectHome.h
836+
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.cpp
837+
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.h
838+
Source/NintendoSwitch/NintendoSwitch_FixedInterval.h
839839
Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.cpp
840840
Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.h
841841
Source/NintendoSwitch/NintendoSwitch_Panels.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ SOURCES += \
279279
Source/CommonFramework/SetupSettings.cpp \
280280
Source/CommonFramework/Tools/BlackBorderCheck.cpp \
281281
Source/CommonFramework/Tools/BotBaseHandle.cpp \
282-
Source/CommonFramework/Tools/ConsoleHandle.cpp \
283282
Source/CommonFramework/Tools/DebugDumper.cpp \
284283
Source/CommonFramework/Tools/ErrorDumper.cpp \
285284
Source/CommonFramework/Tools/FileDownloader.cpp \
@@ -417,6 +416,7 @@ SOURCES += \
417416
Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp \
418417
Source/NintendoSwitch/Inference/NintendoSwitch_DateReader.cpp \
419418
Source/NintendoSwitch/Inference/NintendoSwitch_DetectHome.cpp \
419+
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.cpp \
420420
Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.cpp \
421421
Source/NintendoSwitch/NintendoSwitch_Panels.cpp \
422422
Source/NintendoSwitch/NintendoSwitch_Settings.cpp \
@@ -1378,7 +1378,6 @@ HEADERS += \
13781378
Source/CommonFramework/SetupSettings.h \
13791379
Source/CommonFramework/Tools/BlackBorderCheck.h \
13801380
Source/CommonFramework/Tools/BotBaseHandle.h \
1381-
Source/CommonFramework/Tools/ConsoleHandle.h \
13821381
Source/CommonFramework/Tools/DebugDumper.h \
13831382
Source/CommonFramework/Tools/ErrorDumper.h \
13841383
Source/CommonFramework/Tools/FileDownloader.h \
@@ -1520,7 +1519,8 @@ HEADERS += \
15201519
Source/NintendoSwitch/DevPrograms/BoxDraw.h \
15211520
Source/NintendoSwitch/DevPrograms/TestProgramComputer.h \
15221521
Source/NintendoSwitch/DevPrograms/TestProgramSwitch.h \
1523-
Source/NintendoSwitch/FixedInterval.h \
1522+
Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.h \
1523+
Source/NintendoSwitch/NintendoSwitch_FixedInterval.h \
15241524
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramOption.h \
15251525
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.h \
15261526
Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchSystemOption.h \

SerialPrograms/Source/CommonFramework/InferenceInfra/InferenceRoutines.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ int run_until(
6666
std::chrono::milliseconds default_video_period = std::chrono::milliseconds(50),
6767
std::chrono::milliseconds default_audio_period = std::chrono::milliseconds(20)
6868
);
69-
template <typename ContextType>
69+
template <typename CommandContext>
7070
int run_until(
71-
VideoStream& stream, ContextType& context,
72-
std::function<void(ContextType& context)>&& command,
71+
VideoStream& stream, CommandContext& context,
72+
std::function<void(CommandContext& context)>&& command,
7373
const std::vector<PeriodicInferenceCallback>& callbacks,
7474
std::chrono::milliseconds default_video_period = std::chrono::milliseconds(50),
7575
std::chrono::milliseconds default_audio_period = std::chrono::milliseconds(20)
7676
){
7777
return run_until(
7878
stream, context,
7979
[&](CancellableScope& scope){
80-
ContextType subcontext(scope, context);
80+
CommandContext subcontext(scope, context);
8181
if (command){
8282
command(subcontext);
8383
}

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Routines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_NintendoSwitch_Commands_Routines_H
99

1010
#include "ClientSource/Connection/BotBase.h"
11-
#include "CommonFramework/Tools/ConsoleHandle.h"
11+
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1212

1313
namespace PokemonAutomation{
1414
namespace NintendoSwitch{

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void MultiSwitchProgramSession::internal_run_program(){
149149
handles.emplace_back(
150150
c,
151151
session.logger(),
152-
session.sender().botbase(),
152+
*session.sender().botbase(),
153153
session.video(),
154154
session.overlay(),
155155
session.audio(),

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void SingleSwitchProgramSession::internal_run_program(){
110110
*this,
111111
current_stats_tracker(), historical_stats_tracker(),
112112
m_system.logger(),
113-
m_system.sender().botbase(),
113+
*m_system.sender().botbase(),
114114
m_system.video(),
115115
m_system.overlay(),
116116
m_system.audio(),

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_DateReader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
#include "CommonFramework/Tools/ErrorDumper.h"
1616
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1717
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
18-
#include "CommonFramework/Tools/ConsoleHandle.h"
1918
#include "CommonFramework/OCR/OCR_RawOCR.h"
2019
#include "CommonFramework/OCR/OCR_NumberReader.h"
2120
#include "CommonFramework/OCR/OCR_StringNormalization.h"
22-
#include "PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.h"
2321
#include "NintendoSwitch/NintendoSwitch_Settings.h"
24-
#include "NintendoSwitch/Inference/NintendoSwitch_DetectHome.h"
2522
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
2623
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
24+
#include "NintendoSwitch/Inference/NintendoSwitch_DetectHome.h"
25+
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
2726
#include "NintendoSwitch_DateReader.h"
27+
#include "PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.h"
2828

29-
#include <iostream>
30-
using std::cout;
31-
using std::endl;
29+
//#include <iostream>
30+
//using std::cout;
31+
//using std::endl;
3232

3333
namespace PokemonAutomation{
3434
namespace NintendoSwitch{

SerialPrograms/Source/CommonFramework/Tools/ConsoleHandle.cpp renamed to SerialPrograms/Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.cpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
/* Console Handle
2-
*
3-
* From: https://github.com/PokemonAutomation/Arduino-Source
4-
*
5-
*/
6-
7-
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
8-
#include "CommonFramework/VideoPipeline/Stats/ThreadUtilizationStats.h"
9-
#include "CommonFramework/InferenceInfra/VisualInferencePivot.h"
10-
#include "CommonFramework/InferenceInfra/AudioInferencePivot.h"
11-
#include "CommonFramework/Recording/StreamHistorySession.h"
12-
#include "ConsoleHandle.h"
13-
14-
//#include <iostream>
15-
//using std::cout;
16-
//using std::endl;
17-
18-
namespace PokemonAutomation{
19-
20-
21-
ConsoleHandle::ConsoleHandle(ConsoleHandle&& x) = default;
22-
ConsoleHandle::~ConsoleHandle(){
23-
overlay().remove_stat(*m_thread_utilization);
24-
}
25-
26-
27-
ConsoleHandle::ConsoleHandle(
28-
size_t index,
29-
Logger& logger,
30-
BotBase* botbase,
31-
VideoFeed& video,
32-
VideoOverlay& overlay,
33-
AudioFeed& audio,
34-
const StreamHistorySession& history
35-
)
36-
: VideoStream(logger, audio, video, history, overlay)
37-
, m_index(index)
38-
, m_botbase(botbase)
39-
, m_thread_utilization(new ThreadUtilizationStat(current_thread_handle(), "Program Thread:"))
40-
{
41-
overlay.add_stat(*m_thread_utilization);
42-
}
43-
44-
45-
46-
47-
48-
49-
}
1+
/* Console Handle
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
8+
#include "CommonFramework/VideoPipeline/Stats/ThreadUtilizationStats.h"
9+
#include "CommonFramework/InferenceInfra/VisualInferencePivot.h"
10+
#include "CommonFramework/InferenceInfra/AudioInferencePivot.h"
11+
#include "CommonFramework/Recording/StreamHistorySession.h"
12+
#include "NintendoSwitch_ConsoleHandle.h"
13+
14+
//#include <iostream>
15+
//using std::cout;
16+
//using std::endl;
17+
18+
namespace PokemonAutomation{
19+
20+
21+
ConsoleHandle::ConsoleHandle(ConsoleHandle&& x) = default;
22+
ConsoleHandle::~ConsoleHandle(){
23+
overlay().remove_stat(*m_thread_utilization);
24+
}
25+
26+
27+
ConsoleHandle::ConsoleHandle(
28+
size_t index,
29+
Logger& logger,
30+
BotBase& botbase,
31+
VideoFeed& video,
32+
VideoOverlay& overlay,
33+
AudioFeed& audio,
34+
const StreamHistorySession& history
35+
)
36+
: VideoStream(logger, audio, video, history, overlay)
37+
, m_index(index)
38+
, m_botbase(botbase)
39+
, m_thread_utilization(new ThreadUtilizationStat(current_thread_handle(), "Program Thread:"))
40+
{
41+
overlay.add_stat(*m_thread_utilization);
42+
}
43+
44+
45+
46+
47+
48+
49+
}

SerialPrograms/Source/CommonFramework/Tools/ConsoleHandle.h renamed to SerialPrograms/Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.h

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
/* Console Handle
2-
*
3-
* From: https://github.com/PokemonAutomation/Arduino-Source
4-
*
5-
*/
6-
7-
#ifndef PokemonAutomation_ConsoleHandle_H
8-
#define PokemonAutomation_ConsoleHandle_H
9-
10-
#include <memory>
11-
#include "VideoStream.h"
12-
13-
namespace PokemonAutomation{
14-
15-
class ThreadHandle;
16-
class BotBase;
17-
class ThreadUtilizationStat;
18-
19-
20-
class ConsoleHandle : public VideoStream{
21-
public:
22-
ConsoleHandle(ConsoleHandle&& x);
23-
void operator=(ConsoleHandle&& x) = delete;
24-
ConsoleHandle(const ConsoleHandle& x) = delete;
25-
void operator=(const ConsoleHandle& x) = delete;
26-
~ConsoleHandle();
27-
28-
public:
29-
ConsoleHandle(
30-
size_t index,
31-
Logger& logger,
32-
BotBase* botbase,
33-
VideoFeed& video,
34-
VideoOverlay& overlay,
35-
AudioFeed& audio,
36-
const StreamHistorySession& history
37-
);
38-
39-
size_t index() const{ return m_index; }
40-
41-
BotBase& botbase(){ return *m_botbase; }
42-
43-
44-
operator Logger&(){ return logger(); }
45-
operator VideoFeed&(){ return video(); }
46-
operator VideoOverlay&(){ return overlay(); }
47-
operator AudioFeed&() { return audio(); }
48-
operator const StreamHistorySession&() const{ return history(); }
49-
50-
51-
private:
52-
size_t m_index;
53-
BotBase* m_botbase;
54-
55-
std::unique_ptr<ThreadUtilizationStat> m_thread_utilization;
56-
};
57-
58-
59-
60-
61-
62-
}
63-
#endif
64-
65-
1+
/* Console Handle
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_NintendoSwitch_ConsoleHandle_H
8+
#define PokemonAutomation_NintendoSwitch_ConsoleHandle_H
9+
10+
#include <memory>
11+
#include "CommonFramework/Tools/VideoStream.h"
12+
13+
namespace PokemonAutomation{
14+
15+
class ThreadHandle;
16+
class BotBase;
17+
class ThreadUtilizationStat;
18+
19+
20+
class ConsoleHandle : public VideoStream{
21+
public:
22+
ConsoleHandle(ConsoleHandle&& x);
23+
void operator=(ConsoleHandle&& x) = delete;
24+
ConsoleHandle(const ConsoleHandle& x) = delete;
25+
void operator=(const ConsoleHandle& x) = delete;
26+
~ConsoleHandle();
27+
28+
public:
29+
ConsoleHandle(
30+
size_t index,
31+
Logger& logger,
32+
BotBase& botbase,
33+
VideoFeed& video,
34+
VideoOverlay& overlay,
35+
AudioFeed& audio,
36+
const StreamHistorySession& history
37+
);
38+
39+
size_t index() const{ return m_index; }
40+
41+
BotBase& botbase(){ return m_botbase; }
42+
43+
44+
operator Logger&(){ return logger(); }
45+
operator VideoFeed&(){ return video(); }
46+
operator VideoOverlay&(){ return overlay(); }
47+
operator AudioFeed&() { return audio(); }
48+
operator const StreamHistorySession&() const{ return history(); }
49+
50+
51+
private:
52+
size_t m_index;
53+
BotBase& m_botbase;
54+
55+
std::unique_ptr<ThreadUtilizationStat> m_thread_utilization;
56+
};
57+
58+
59+
60+
61+
62+
}
63+
#endif
64+
65+

0 commit comments

Comments
 (0)