Skip to content

Commit a1072c0

Browse files
authored
add sandwich maker stats (#566)
1 parent 2622838 commit a1072c0

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
#include "PokemonSV/Programs/Farming/PokemonSV_TournamentFarmer.h"
120120
#include "NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.h"
121121
#include "PokemonSV/Inference/ItemPrinter/PokemonSV_ItemPrinterMenuDetector.h"
122+
#include "PokemonSV/Inference/Picnics/PokemonSV_SandwichHandDetector.h"
122123

123124

124125
#include <QPixmap>
@@ -316,8 +317,17 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
316317
// std::terminate();
317318

318319
#if 1
319-
// ImageRGB32 image(IMAGE_PATH);
320-
auto image = feed.snapshot();
320+
ImageRGB32 image(IMAGE_PATH);
321+
// auto image = feed.snapshot();
322+
323+
SandwichHandLocator hand(SandwichHandType::FREE, {0, 0, 1, 1});
324+
std::pair<double, double> location = hand.locate_sandwich_hand(image, {0,0,1,1});
325+
cout << location.first << ", " << location.second << endl;
326+
#endif
327+
328+
#if 0
329+
ImageRGB32 image(IMAGE_PATH);
330+
// auto image = feed.snapshot();
321331

322332
ItemPrinterMaterialDetector detector(COLOR_RED, Language::English);
323333

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include "CommonFramework/Notifications/ProgramNotifications.h"
8+
#include "CommonFramework/ProgramStats/StatsTracking.h"
89
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
910
#include "Pokemon/Pokemon_Strings.h"
1011
#include "PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.h"
@@ -32,6 +33,22 @@ SandwichMaker_Descriptor::SandwichMaker_Descriptor()
3233
)
3334
{}
3435

36+
struct SandwichMaker_Descriptor::Stats : public StatsTracker{
37+
Stats()
38+
: sandwiches(m_stats["Sandwiches"])
39+
, errors(m_stats["Errors"])
40+
{
41+
m_display_order.emplace_back("Sandwiches");
42+
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
43+
}
44+
std::atomic<uint64_t>& sandwiches;
45+
std::atomic<uint64_t>& errors;
46+
};
47+
48+
std::unique_ptr<StatsTracker> SandwichMaker_Descriptor::make_stats() const{
49+
return std::unique_ptr<StatsTracker>(new Stats());
50+
}
51+
3552
SandwichMaker::SandwichMaker()
3653
: SANDWICH_OPTIONS(
3754
"Sandwich Options",
@@ -59,9 +76,12 @@ SandwichMaker::SandwichMaker()
5976

6077
void SandwichMaker::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
6178
assert_16_9_720p_min(env.logger(), env.console);
79+
SandwichMaker_Descriptor::Stats& stats = env.current_stats<SandwichMaker_Descriptor::Stats>();
6280

6381
for (int i = 0; i < NUM_SANDWICHES; i++){
6482
env.console.log("Making sandwich number: " + std::to_string(i+1), COLOR_ORANGE);
83+
stats.sandwiches++;
84+
env.update_stats();
6585
make_sandwich_option(env, env.console, context, SANDWICH_OPTIONS);
6686
enter_sandwich_recipe_list(env.program_info(), env.console, context);
6787
}

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace PokemonSV{
2121
class SandwichMaker_Descriptor : public SingleSwitchProgramDescriptor{
2222
public:
2323
SandwichMaker_Descriptor();
24+
struct Stats;
25+
virtual std::unique_ptr<StatsTracker> make_stats() const override;
2426
};
2527

2628
class SandwichMaker : public SingleSwitchProgramInstance{

0 commit comments

Comments
 (0)