-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #70 - Nucleus auto-recovers from non-finite outputs.
Nucleus now checks every quarter of a second or so for non-finite output. If found, Nucleus resets itself and turns the OUT knob bright pink for one second to indicate a problem. I see this problem only rarely, but it's annoying because I have to close and open the patch again, or reset Nucleus (which loses all my knob settings). Now the recovery is automatic and prompt! The user can keep fiddling around until the rebooting stops.
- Loading branch information
1 parent
6241328
commit bbc9735
Showing
6 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include "nucleus_engine.hpp" | ||
#include "nucleus_reset.hpp" | ||
|
||
namespace Sapphire | ||
{ | ||
namespace Nucleus | ||
{ | ||
class CrashChecker | ||
{ | ||
private: | ||
const int interval = 10000; | ||
int countdown = 0; | ||
|
||
public: | ||
bool check(NucleusEngine& engine) | ||
{ | ||
bool crashed = false; | ||
if (countdown > 0) | ||
{ | ||
--countdown; | ||
} | ||
else | ||
{ | ||
countdown = interval; | ||
|
||
const int nparticles = static_cast<int>(engine.numParticles()); | ||
for (int i = 0; i < nparticles; ++i) | ||
{ | ||
if (!engine.particle(i).isFinite()) | ||
crashed = true; | ||
|
||
for (int k = 0; k < 3; ++k) | ||
if (!std::isfinite(engine.output(i, k))) | ||
crashed = true; | ||
} | ||
|
||
if (crashed) | ||
{ | ||
engine.resetAfterCrash(); | ||
SetMinimumEnergy(engine); | ||
} | ||
} | ||
return crashed; | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters