Skip to content

Commit e769116

Browse files
committed
2 parents 239da85 + 3936a49 commit e769116

File tree

1,405 files changed

+43873
-27929
lines changed

Some content is hidden

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

1,405 files changed

+43873
-27929
lines changed

.github/workflows/cpp-ci-serial-programs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [windows-2022, macos-13, ubuntu-24.04]
13-
qt_version: ['5.12.12', '6.7.2']
13+
qt_version: ['5.12.12', '6.8.1']
1414
include:
1515
- qt_version: '5.12.12'
1616
qt_version_major: '5'
1717
qt_modules: ''
1818

19-
- qt_version: '6.7.2'
19+
- qt_version: '6.8.1'
2020
qt_version_major: '6'
2121
qt_modules: 'qtmultimedia qtserialport'
2222

@@ -37,7 +37,7 @@ jobs:
3737
if: startsWith(matrix.os, 'mac')
3838
run: |
3939
brew install opencv
40-
- uses: jurplel/install-qt-action@v3
40+
- uses: jurplel/install-qt-action@v4
4141
with:
4242
version: ${{ matrix.qt_version }}
4343
modules: ${{ matrix.qt_modules }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SerialPrograms/bin/
55
# macOS hidden system file
66
.DS_Store
77

8-
build*/
8+
build-*/
99

1010
# Qt config file on a user basis
1111
*.pro.user
66.6 KB
Loading
35.6 KB
Loading
68.2 KB
Loading
63.4 KB
Loading

ClientSource/Connection/BotBase.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,45 @@
1414
namespace PokemonAutomation{
1515

1616

17-
BotBaseContext::BotBaseContext(BotBase& botbase)
18-
: m_botbase(botbase)
19-
{}
20-
BotBaseContext::BotBaseContext(CancellableScope& parent, BotBase& botbase)
21-
: m_botbase(botbase)
22-
{
23-
attach(parent);
24-
}
25-
BotBaseContext::~BotBaseContext(){
26-
detach();
27-
}
2817

29-
void BotBaseContext::wait_for_all_requests() const{
18+
void BotBaseControllerContext::wait_for_all_requests() const{
3019
m_lifetime_sanitizer.check_usage();
31-
m_botbase.wait_for_all_requests(this);
20+
m_controller.wait_for_all_requests(this);
3221
}
33-
void BotBaseContext::cancel_now(){
22+
void BotBaseControllerContext::cancel_now(){
3423
m_lifetime_sanitizer.check_usage();
3524
CancellableScope::cancel(nullptr);
36-
m_botbase.stop_all_commands();
25+
m_controller.stop_all_commands();
3726
}
38-
void BotBaseContext::cancel_lazy(){
27+
void BotBaseControllerContext::cancel_lazy(){
3928
m_lifetime_sanitizer.check_usage();
4029
CancellableScope::cancel(nullptr);
41-
m_botbase.next_command_interrupt();
30+
m_controller.next_command_interrupt();
4231
}
4332

44-
bool BotBaseContext::cancel(std::exception_ptr exception) noexcept{
33+
bool BotBaseControllerContext::cancel(std::exception_ptr exception) noexcept{
4534
m_lifetime_sanitizer.check_usage();
4635
if (CancellableScope::cancel(std::move(exception))){
4736
return true;
4837
}
4938
try{
50-
m_botbase.stop_all_commands();
39+
m_controller.stop_all_commands();
5140
}catch (...){}
5241
return false;
5342
}
5443

55-
bool BotBaseContext::try_issue_request(const BotBaseRequest& request) const{
44+
bool BotBaseControllerContext::try_issue_request(const BotBaseRequest& request) const{
5645
m_lifetime_sanitizer.check_usage();
57-
return m_botbase.try_issue_request(request, this);
46+
return m_controller.try_issue_request(request, this);
5847
}
59-
void BotBaseContext::issue_request(const BotBaseRequest& request) const{
48+
void BotBaseControllerContext::issue_request(const BotBaseRequest& request) const{
6049
m_lifetime_sanitizer.check_usage();
61-
m_botbase.issue_request(request, this);
50+
m_controller.issue_request(request, this);
6251
}
6352

64-
BotBaseMessage BotBaseContext::issue_request_and_wait(const BotBaseRequest& request) const{
53+
BotBaseMessage BotBaseControllerContext::issue_request_and_wait(const BotBaseRequest& request) const{
6554
m_lifetime_sanitizer.check_usage();
66-
return m_botbase.issue_request_and_wait(request, this);
55+
return m_controller.issue_request_and_wait(request, this);
6756
}
6857

6958

ClientSource/Connection/BotBase.h

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ namespace PokemonAutomation{
1515
class Logger;
1616
struct BotBaseMessage;
1717
class BotBaseRequest;
18+
class BotBaseControllerContext;
1819

1920

2021

21-
class BotBase{
22+
class BotBaseController{
2223
public:
24+
using ContextType = BotBaseControllerContext;
25+
2326
enum class State{
2427
RUNNING,
2528
STOPPING,
@@ -28,7 +31,7 @@ class BotBase{
2831
};
2932

3033
public:
31-
virtual ~BotBase() = default;
34+
virtual ~BotBaseController() = default;
3235

3336
virtual Logger& logger() = 0;
3437
virtual State state() const = 0;
@@ -70,29 +73,48 @@ class BotBase{
7073

7174

7275

76+
class ControllerContext0 : public CancellableScope{
77+
public:
78+
virtual void wait_for_all_requests() const = 0;
79+
virtual void cancel_now() = 0;
80+
virtual void cancel_lazy() = 0;
81+
};
82+
83+
7384
// A wrapper for BotBase that allows for asynchronous cancelling.
74-
class BotBaseContext final : public CancellableScope{
85+
class BotBaseControllerContext final : public ControllerContext0{
86+
public:
87+
using ControllerType = BotBaseController;
88+
7589
public:
76-
BotBaseContext(BotBase& botbase);
77-
BotBaseContext(CancellableScope& parent, BotBase& botbase);
78-
virtual ~BotBaseContext();
90+
BotBaseControllerContext(BotBaseController& botbase)
91+
: m_controller(botbase)
92+
{}
93+
BotBaseControllerContext(CancellableScope& parent, BotBaseController& botbase)
94+
: m_controller(botbase)
95+
{
96+
attach(parent);
97+
}
98+
virtual ~BotBaseControllerContext(){
99+
detach();
100+
}
79101

80102

81-
void wait_for_all_requests() const;
103+
virtual void wait_for_all_requests() const override;
82104

83-
// Don't use this unless you really need to.
84-
BotBase& botbase() const{ return m_botbase; }
105+
operator BotBaseController&() const{ return m_controller; }
106+
BotBaseController& controller() const{ return m_controller; }
85107

86108
// Stop all commands in this context now.
87-
void cancel_now();
109+
virtual void cancel_now() override;
88110

89111
// Stop the commands in this context, but do it lazily.
90112
// Still will stop new commands from being issued to the device,
91113
// and will tell the device that the next command that is issued
92114
// should replace the command queue.
93115
// This cancel is used when you need continuity from an ongoing
94116
// sequence.
95-
void cancel_lazy();
117+
virtual void cancel_lazy() override;
96118

97119

98120
virtual bool cancel(std::exception_ptr exception) noexcept override;
@@ -105,7 +127,7 @@ class BotBaseContext final : public CancellableScope{
105127

106128

107129
private:
108-
BotBase& m_botbase;
130+
BotBaseController& m_controller;
109131
LifetimeSanitizer m_lifetime_sanitizer;
110132
};
111133

ClientSource/Connection/MessageLogger.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ void MessageLogger::on_send(const BotBaseMessage& message, bool is_retransmit){
3131
if (message.type == PABB_MSG_REQUEST_CLOCK){
3232
print = false;
3333
}
34-
#if 0
34+
#if 1
3535
if (message.type == PABB_MSG_CONTROLLER_STATE){
36-
pabb_controller_state body;
37-
memcpy(&body, message.body.c_str(), sizeof(pabb_controller_state));
38-
print = body.ticks >= 5;
36+
// pabb_controller_state body;
37+
// memcpy(&body, message.body.c_str(), sizeof(pabb_controller_state));
38+
// print = body.ticks >= 5;
39+
print = false;
3940
}
4041
#endif
4142

0 commit comments

Comments
 (0)