Added postprocess(processor, filter) function to formulas

to run an specific Data Processor, even if not configured to run
automatically on import, over existing activities which pass the
filter expression using configured parameters.
Fixes #2037
This commit is contained in:
Alejandro Martinez
2016-08-07 17:30:17 -03:00
parent 54162f4b38
commit 5cf9802a17
2 changed files with 37 additions and 3 deletions

View File

@@ -75,6 +75,7 @@ daterange(stop)
DATA PROCESSOR FUNCTIONS
autoprocess(filter)
postprocess(processor, filter)
RIDE SAMPLE DATA

View File

@@ -107,8 +107,9 @@ static struct {
// print to qDebug for debugging
{ "print", 1 }, // print(..) to qDebug for debugging
// autoprocess to run automatic data processors
{ "autoprocess", 1 }, // autoprocess(filter)
// Data Processor functions on filtered activiies
{ "autoprocess", 1 }, // autoprocess(filter) to run auto data processors
{ "postprocess", 2 }, // postprocess(processor, filter) to run processor
// add new ones above this line
{ "", -1 }
@@ -2369,7 +2370,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
if (!f) return Result(0); // eek!
// now remove the override
// now run auto data processors
if (DataProcessorFactory::instance().autoProcess(f)) {
// rideFile is now dirty!
m->setDirty(true);
@@ -2379,6 +2380,38 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
}
break;
case 40 :
{ // POSTPROCESS (processor, expression ) run processor
Result returning(0);
if (leaf->fparms.count() < 2) return returning;
else returning = eval(df, leaf->fparms[1], x, m, p, c);
if (returning.number) {
// processor we are running
QString dp_name = *(leaf->fparms[0]->lvalue.n);
// lookup processor
DataProcessor* dp = DataProcessorFactory::instance().getProcessors().value(dp_name, NULL);
if (!dp) return Result(0); // No such data processor
// ack ! we need to autoprocess, so open the ride
RideFile *f = m->ride();
if (!f) return Result(0); // eek!
// now run the data processor
if (dp->postProcess(f)) {
// rideFile is now dirty!
m->setDirty(true);
}
}
return returning;
}
break;
default:
return Result(0);
}