Make the redundant constraint timeout a configuration value and add the config UI elements to edit that value.

pull/700/head
phkahler 2020-09-12 15:52:27 -04:00
parent 615708440f
commit 668fe6f493
7 changed files with 32 additions and 2 deletions

View File

@ -204,6 +204,11 @@ void TextWindow::ScreenChangeAutosaveInterval(int link, uint32_t v) {
SS.TW.edit.meaning = Edit::AUTOSAVE_INTERVAL;
}
void TextWindow::ScreenChangeFindConstraintTimeout(int link, uint32_t v) {
SS.TW.ShowEditControl(3, std::to_string(SS.timeoutRedundantConstr));
SS.TW.edit.meaning = Edit::FIND_CONSTRAINT_TIMEOUT;
}
void TextWindow::ShowConfiguration() {
int i;
Printf(true, "%Ft user color (r, g, b)");
@ -371,6 +376,10 @@ void TextWindow::ShowConfiguration() {
Printf(false, "%Ft autosave interval (in minutes)%E");
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
SS.autosaveInterval, &ScreenChangeAutosaveInterval);
Printf(false, "");
Printf(false, "%Ft redundant constraint timeout (in ms)%E");
Printf(false, "%Ba %d %Fl%Ll%f[change]%E",
SS.timeoutRedundantConstr, &ScreenChangeFindConstraintTimeout);
if(canvas) {
const char *gl_vendor, *gl_renderer, *gl_version;
@ -542,6 +551,17 @@ bool TextWindow::EditControlDoneForConfiguration(const std::string &s) {
}
break;
}
case Edit::FIND_CONSTRAINT_TIMEOUT: {
int timeout = atoi(s.c_str());
if(timeout) {
if(timeout >= 1) {
SS.timeoutRedundantConstr = timeout;
} else {
SS.timeoutRedundantConstr = 1000;
}
}
break;
}
default: return false;
}

View File

@ -533,6 +533,7 @@ void SolveSpaceUI::SolveGroup(hGroup hg, bool andFindFree) {
WriteEqSystemForGroup(hg);
Group *g = SK.GetGroup(hg);
g->solved.remove.Clear();
g->solved.findToFixTimeout = SS.timeoutRedundantConstr;
SolveResult how = sys.Solve(g, NULL,
&(g->solved.dof),
&(g->solved.remove),

View File

@ -189,6 +189,7 @@ public:
struct {
SolveResult how;
int dof;
int findToFixTimeout;
bool timeout;
List<hConstraint> remove;
} solved;

View File

@ -51,6 +51,8 @@ void SolveSpaceUI::Init() {
exportChordTol = settings->ThawFloat("ExportChordTolerance", 0.1);
// Max pwl segments to generate
exportMaxSegments = settings->ThawInt("ExportMaxSegments", 64);
// Timeout value for finding redundant constrains (ms)
timeoutRedundantConstr = settings->ThawInt("TimeoutRedundantConstraints", 1000);
// View units
viewUnits = (Unit)settings->ThawInt("ViewUnits", (uint32_t)Unit::MM);
// Number of digits after the decimal point
@ -231,6 +233,8 @@ void SolveSpaceUI::Exit() {
settings->FreezeFloat("ExportChordTolerance", (float)exportChordTol);
// Export Max pwl segments to generate
settings->FreezeInt("ExportMaxSegments", (uint32_t)exportMaxSegments);
// Timeout for finding which constraints to fix Jacobian
settings->FreezeInt("TimeoutRedundantConstraints", (uint32_t)timeoutRedundantConstr);
// View units
settings->FreezeInt("ViewUnits", (uint32_t)viewUnits);
// Number of digits after the decimal point

View File

@ -268,7 +268,8 @@ public:
void EvalJacobian();
void WriteEquationsExceptFor(hConstraint hc, Group *g);
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad, bool forceDofCheck);
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad,
bool forceDofCheck);
void SolveBySubstitution();
bool IsDragged(hParam p);
@ -562,6 +563,7 @@ public:
int maxSegments;
double exportChordTol;
int exportMaxSegments;
int timeoutRedundantConstr; //milliseconds
double cameraTangent;
double gridSpacing;
double exportScale;

View File

@ -361,7 +361,7 @@ void System::FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad, bo
for(a = 0; a < 2; a++) {
for(auto &con : SK.constraint) {
if((GetMilliseconds() - time) > 1500) { // todo: make timeout configurable
if((GetMilliseconds() - time) > g->solved.findToFixTimeout) {
g->solved.timeout = true;
return;
}

View File

@ -316,6 +316,7 @@ public:
G_CODE_PLUNGE_FEED = 115,
AUTOSAVE_INTERVAL = 116,
LIGHT_AMBIENT = 117,
FIND_CONSTRAINT_TIMEOUT = 118,
// For TTF text
TTF_TEXT = 300,
// For the step dimension screen
@ -488,6 +489,7 @@ public:
static void ScreenChangeExportOffset(int link, uint32_t v);
static void ScreenChangeGCodeParameter(int link, uint32_t v);
static void ScreenChangeAutosaveInterval(int link, uint32_t v);
static void ScreenChangeFindConstraintTimeout(int link, uint32_t v);
static void ScreenChangeStyleName(int link, uint32_t v);
static void ScreenChangeStyleMetric(int link, uint32_t v);
static void ScreenChangeStyleTextAngle(int link, uint32_t v);