Commit Graph

69 Commits

Author SHA1 Message Date
Alejandro Martinez
aee176baf1 Added vdottime(VDOT, distance) to formulas
Computes the equivalent time (in seconds) for distance (in km)
at VDOT, tipically used with VDOT metric as first parameter.
2015-10-30 13:36:43 -03:00
Mark Liversedge
9e833d4a04 QStringList::contains returns QBool on QT4
.. yuk. no wonder they deprecated it in QT5. A daft idea
   that adds not value. We compare to true to avoid issues.
2015-09-05 16:33:19 +01:00
Mark Liversedge
44c0f0a9b5 Formula isset(field)
.. returns true if the user has overridden a
   metric, or a metadata tag is set.
2015-09-05 10:03:33 +01:00
Mark Liversedge
ac402756aa Formula unset(field, condition)
.. allow users to use an unset command to remove
   an override or metadata.

   e.g. unset(Old_Metadata, 1)
        unset(TSS, TSS < 0)
2015-09-05 08:20:30 +01:00
Mark Liversedge
48fe226b22 Formula set(field, value, condition)
.. allow users to use a set command to add
   an override or set metadata under certain
   conditions.

   e.g. set(Workout_Code, "HT", IF>0.9)
        set(TSS, 65, TSS <= 0 && Route = "Fave Loop")

.. we should probably add an unset() command
   to do the reverse and clear values under
   conditions too.

   USE WITH CAUTION -- TAKE A BACKUP BEFORE
   MAKING ANY RADICAL CHANGES TO YOUR DATA
2015-09-04 21:12:14 +01:00
Mark Liversedge
cddf18d58f Syntax highlight data series symbols
.. they were missed in last commit
2015-08-25 13:44:26 +01:00
Mark Liversedge
60b1562d55 Formulas support Ride Data
.. passed to eval and symbols now recongised.

.. sample data is referenced using symbol names
   in all caps to make it clear you are referencing
   ride dample data.

.. the next commits will add defining formulas and plotting
   the derived data series in allplot.
2015-08-25 13:30:07 +01:00
Mark Liversedge
cb65205b42 Formula which() function
.. To select in a vector. The notation
   is a selection criteria followed by
   a list of values / vectors

   e.g. which(x>0, TSS[date:date])

   will create a vector where TSS is non
   zero for the day.

   "x" is replaced with the vector values
   and as such is a special symbol.

.. also fixed a bug with the snip cache.
2015-08-22 17:18:54 +01:00
Mark Liversedge
069342f6f5 Formula Microcache 'snips'
.. when running a formula it may use a vector
   operation to calculate e.g. an average for the
   date range.

.. these get called for every ride, but actually they
   perform the same calculation over and over

.. we cache the vector operation and result to avoid
   repeated calculations; these are only cached whilst
   a datafilter is being evaluated, so we do not need
   to worry about stale/refreshing.
2015-08-22 11:34:58 +01:00
Mark Liversedge
17bf55c40d Formula estimate function
.. estimate(model, duration) or to get the model
   parameters estimate(model, parameter) always
   for the date of the ride.

   e.g. estimate(2p, cp) gets the estimated CP
   for the date of the ride using the classic
   2 parameter model

   Models are one of;
   2p - classic monod scherrer
   3p - morton 3p
   ext - gc extended
   ws - ward-smith
   velo - veloclinic

   Parameters are one of;
   w' - W'
   cp - critical power
   ftp - functional threshold power
   pmax - max power

   For watts per kilo just add / config(weight)
   or Athlete_Weight to take into account ride
   specific weight settings / overrides.
2015-08-21 19:58:27 +01:00
Mark Liversedge
e9a7ff434d DataFilter in PMC - Part 3 of 3
.. can now use a formula in the lts, sts
   sb, rr functions.

.. e.g lts(TSS/2) evaluates to the "CTL"
   value for the ride if using TSS/2 as
   the input.

NOTE: you only get a value where a ride
exists. We may want to think about the
way we scope formulas; are they iterating
over rides or dates ?
2015-08-21 11:23:05 +01:00
Mark Liversedge
dbe92eec27 Formula Leaf Signature
.. to use when e.g. using a data filter as an input
   into the PMC functions. The data series is stored
   against a signature for the function as opposed to
   the metric symbol.

.. we need to do it for an expr not the data filter
2015-08-20 22:56:51 +01:00
Mark Liversedge
10b5f75a47 Formula Signature
.. to use when e.g. using a data filter as an input
   into the PMC functions. The data series is stored
   against a signature for the function as opposed to
   the metric symbol.
2015-08-20 18:35:45 +01:00
Mark Liversedge
a57a6e683e FilterEdit Colors
.. time to move on now, this is slightly
   embarassing.
2015-08-20 07:18:47 +01:00
Mark Liversedge
d13b396663 FilterEditor Tweak Cosmetics
.. courier font

.. syntax coloring follows common "windows IDE"
   conventions (comments green, symbols blue etc)
2015-08-20 07:14:11 +01:00
Mark Liversedge
90ac02e3c9 Add brace balancing in Filter Editor
.. for finding partner parenthesis
.. for showing unbalance parenthesis
2015-08-19 22:23:30 +01:00
Mark Liversedge
7f6991520c Fix Syntax Highlighting
.. distinct from parser now, so not susceptible
   to parsing / syntax errors in formula.

.. still need to do brace matching.
2015-08-19 21:02:08 +01:00
Mark Liversedge
bf4c37f7b2 Deprecate parser syntax highlighting
.. but do continue to highlight bad symbols etc
   with a red wavy line.

.. still need to;
   a) syntax highlight in the formula edit (just symbols
      and literals, not parsing content)

   b) add an error navigator to click on errors and have the
      text highlighted that incurred that error.
2015-08-19 12:50:38 +01:00
Mark Liversedge
4f570d8106 Fix DataFilter regression
.. the daterange() commit broke almost every builtin
   function ! (it converted them to integers due to
   and if/else logic error.

.. also tidied parser to separate literals and symbols
   whilst making builtin functions expr elements to
   look more closely at precedence
2015-08-17 22:00:15 +01:00
Mark Liversedge
e1f2c1b48b Fixup unary '-'
.. so date-9 is not treated as "date" "-9" but
   instead as "date" "-" "9"
2015-08-17 15:21:24 +01:00
Mark Liversedge
4941dacd8c Syntax highlighting from parser
.. oopsie on binary expression.

NOTE: it may be better to highlight tokens rather than
      via the parser as errors make it impossible to
      highlight the "intention" of the user
2015-08-16 22:24:49 +01:00
Mark Liversedge
2e949b13bf Formula sum, mean, max, min, count functions
Particularly useful when working with a vector
but can be used with other things.

e.g. max(xPower, BikeScore)

Or, for getting a ride's TSS expressed as a percentage
of the average TSS for the currently selected daterange.

e.g. TSS / mean(TSS[daterange(start):daterange(stop)])
2015-08-16 19:49:16 +01:00
Mark Liversedge
99845aa12a Formula Editor error highlighting
.. using red wiggly line

.. still need to find a way of providing the
   parsing errors messages and navigating to
   the part they are complaining about.
2015-08-16 18:32:32 +01:00
Mark Liversedge
a9b50af7a1 Formula Vectors
You can create a vector using the notation:

   expr [ from : to ]

   Where 'expr' will be evaluated for every activity
   between the dates from and to.

   e.g. TSS[today - 90 : today]

   will evaluate to TSS for the last 90 days

   e.g. Activities [ date:date ] > 1

   Will find all days with more than one workout.

.. when using a vector in any arithmetic expression it
   will be evaluated to a sum; this will be fixed shortly
   to enable the use of sum/mean/max/min functions.

.. If needed we can add vector operations but this will
   likely confuse many users (hell, they confuse developers)
   so we will need a good reason to add them !

Lastly, I have also added daterange(from) and daterange(to)
literals to get access to the currently selected daterange
when working in the trends view.
2015-08-16 17:23:46 +01:00
Mark Liversedge
22bc70cd1a Formula Editor Improvements 1 of 2
.. update the editor to do some basic syntax
   highlighting; literals in red, comments in
   blue and so on.

.. next commit will focus on highlighting errors
   with a wavy line and some form of error list.
2015-08-15 23:47:04 +01:00
Alejandro Martinez
06c1546a05 Minor changes for DataFilter to compile on MinGW 2015-08-15 11:46:32 -03:00
Mark Liversedge
aa3e3102f9 DataFilter Functions and "math"
.. updated the datafilter to handle general functions
   and parse them without needing them declared in the lexer

.. makes it much easier to add new functions in the future

.. did this to add core math functions;
   *  sin, cos, tan, asin, acos, atan,
   *  sinh, cosh, tanh, asinh, acosh, atanh
   *  exp, log, log10, ceil, floor, round
   *  fabs, isinf, isnan

.. we can add more later; erf/gamma spring to mind !
2015-08-15 14:17:53 +01:00
Mark Liversedge
58e2c88c9a Formula const()
.. for pi and e, we can add more later
   i.e. const(pi) and const(e) return high
   precision values for both
2015-08-15 10:33:09 +01:00
Mark Liversedge
7bc1537f30 Formula config() function and test charts
.. added config(cv) .. config(pmax) etc

.. also added some test charts including one that
   just displays configuration
2015-08-14 22:10:29 +01:00
Mark Liversedge
06a41f4583 LTM Plot Formula Part 2 of 2
.. added to LTMPlot and DataFilter methods

.. very rough and ready, but works.

.. can refine and enhance now basics are in place.
2015-08-13 12:35:17 +01:00
Mark Liversedge
53670707e6 DataFilter Conditional Expression
.. uses the C/C++ notation:

   expr ? expr2 : expr3

   Where expr is the condition e.g. X>2
   and expr2 is what to evaluate to if expr is true
   and expr3 is what to evaluate to if expr is false

   e.g.

   (Workout_Code = "1L3") ? 1 : 0

   Will evaluate as 1 for all workouts where the
   workout code is 1L3 and 0 for all other workouts.
2015-08-13 09:24:26 +01:00
Mark Liversedge
706d2ad206 Refactor DataFilter
.. get rid of terrible cut and paste code, duplicating
   eval for particular leafs

.. eval returns a Result() object which can be numeric
   or textual (date strings are parsed to numeric)

.. can now add formulas to LTM as well as adding more
   functions that may be useful (conditionals, maths
   spring to mind first).
2015-08-12 10:07:11 +01:00
Claus Assmann
9c057191b5 Fix comment typos 2015-06-07 16:31:56 +01:00
Mark Liversedge
b18d1a1b46 Added isSwim
.. to RideItem and DataFilter
2015-01-07 10:14:53 +00:00
Mark Liversedge
17fecc41c7 Reinstate Ramp Rate (RR)
.. on LTM plots

.. and rr(metric) function in datafilter
2015-01-02 12:05:41 +00:00
Mark Liversedge
d80a326d66 DataFilter Dynamic Bug
.. leaf traversal returned parent dynamic not ours.
2015-01-01 20:04:27 +00:00
Mark Liversedge
b3dbeb2517 Leaf::isDynamic SEGV
.. traversing null branches.
2015-01-01 19:30:34 +00:00
Mark Liversedge
4d381b877c Dynamic DataFilter Query
.. will rerun as ride selection changes.

.. but will never stop until cleared so use at your
   own risk, as will run EVERY time you select a
   different ride.
2015-01-01 17:57:36 +00:00
Mark Liversedge
fb5c6a2bcf Datafilter date 'current' to complement 'today'
.. but need to think how we can refresh when current ride changes.
2015-01-01 16:40:40 +00:00
Mark Liversedge
5692d362d0 ConfigChanged Part 1 of 3
.. introduce concept of configChanged(what) to
   pass details of what config has been changed

.. fixed zones changes to re-read after write
   to correct the save twice to get changes to
   zones bug.

.. next parts need to spot changes (part 2) and
   then action appropriately (part 3)
2014-12-29 13:41:50 +00:00
Mark Liversedge
f88a85b244 Add Date strings to datafilter
.. to enable queries such as;

   Date > "2014/02/28"
   for rides since 28th February 2014

.. might be useful to allow localised dates
   but using this makes it easier to document !

.. a query like today > "1900/01/01" will pass
   on all rides, but user being an idiot.
2014-12-25 09:49:42 +00:00
Mark Liversedge
da679d3f20 Add Date arithmetic to DataFilter
.. use "Date" and "Today" which evaluate to the number
   of days since 1st Jan 1900.

.. so a filter for the last 90 days would be:
   (Today - Date) < 30

.. will add date strings next.
2014-12-25 09:12:34 +00:00
Mark Liversedge
b11c750ae8 Add ATL, CTL, TSB aliases to DataFilter
.. for sts(TSS), lts(TSS) and sb(TSS)
2014-12-21 19:01:02 +00:00
Mark Liversedge
118a5fc4e4 Add PMC data filter functions
lts(metric), sts(metric), sb(metric) all return the PMC
value for the metric in question for the date of the ride
and therefore allow you to select rides based upon PMC data.

e.g. sb(TSS) > -5

could be considered a way of looking for rides when you were
in a well tapered state, or at least, when you should be able
to perform well.

or, e.g. lts(TSS) > 100

could be a way of looking for rides at peak form (if 100 is
a peak CTL for you).
2014-12-21 17:34:21 +00:00
Mark Liversedge
b737dcbebd Introduce Specification class
.. used to create a 'specification' against which we match
   a rideitem when plotting etc.

.. so rather than passing an array/vector/list of data when
   calling a plot, we pass the 'specification' to use instead.

.. the plots themselves should now iterate across the shared
   ride cache only plotting the items that pass the specification.

.. this should reduce memory usage and increase performance.
2014-12-17 10:57:57 +00:00
Mark Liversedge
ead01c69e9 Migrate DataFilter to use RideCache
.. no longer uses metricDB but traverses in memory cache
   and should be a lot faster.

NOTE: the line endings for DataFilter.{cpp,h} have been
     changed from dos to unix format which has resulted in
     the entire file being changed, apologies but needed to
     clean that up anyway.
2014-12-16 10:57:22 +00:00
Mark Liversedge
27f23fe4f9 Allow isRun in Filter
.. isRun is a bool, so isRun = 0 or isRun = 1
   will filter for runs.

.. note isRun does more than just look at sport
   it also checks if there are running data series
   in the file and may extend to more over time
2014-09-26 14:33:26 +01:00
Mark Liversedge
42ad13f848 DataFilter handle metadata numerics
.. code assumed numeric fields always metrics when they
   could also be metadata.

.. this also fixes checkbox tests too
2014-06-19 21:25:58 +01:00
Mark Liversedge
0fce4b27e8 Use w/kg units always, not wpk
.. and also allow lrbalance in data filter
2014-06-15 09:26:45 +01:00
Joern
fd61805bd7 Bikescore (TM) unique Handling (Part 2)
... have the same consistent handling for (TM) at all visible places
... do not allow Translation of BikeScore (since it's a TM and might
cause unexpected behavior)
... Have (TM) sign everwhere visible - only in Searches just use
"BikeScore" as Symbol
2014-06-11 18:55:23 +02:00