qdomyos-zwift icon indicating copy to clipboard operation
qdomyos-zwift copied to clipboard

Added tests for bike power functions

Open drmason789 opened this issue 11 months ago • 13 comments

To finish this PR, some thought will be needed about what it should test.

I have defined the erginterface abstract class, which acts as an interface for the powerFromResistance and resistanceFromPower functionality offered by the bike class. Currently the bikeergfunctions class implements this for bikes, by setting the bike's current cadence, using the corresponding function to get the resistance or power, then restoring the bike's original cadence.

The interface supports optionally defined (min, max) x (cadence, resistance) representing the domain the bike knows about so the tests adapt to the boundaries provided, where provided.

What is tested?

  • if there is a (minimum,maximum) (cadence,resistance) defined, if the (cadence, resistance) goes (below,above) the (minimum,maximum) for a constant (resistance, cadence), does the power stop changing?
  • if the bike::powerFromResistanceRequest function returns a power p for a specific cadence c and range of resistances rmin..rmax, does the bike::resistanceFromPowerRequest function return the rmin when called on p and c?

What is not tested?

  • effects of watt gain and offset, resistance gain and offset
  • wattsFromResistance function

drmason789 avatar Mar 01 '24 21:03 drmason789

@cagnulein is this something you want to continue with?

  • I think it would be helpful to refactor the power/resistance functions in the bike class so that are not dependent on bike state then put these functions into an implementation of erginterface (or whatever you'd like to rename it to), then make bike have a field referring to an erginterface object.
  • The power tables you have been implementing could be passed as an array into an implementation of erginterface that generically takes care of storage and searching.

drmason789 avatar Mar 01 '24 22:03 drmason789

  • I believe I can make many tests pass simply by returning 0 resistance or 0W for a negative cadence.
  • In all the cases I've looked at, the resistance from power doesn't invert the power from resistance. I wonder if you don't intend it to.

drmason789 avatar Mar 01 '24 22:03 drmason789

@drmason789 Actually I was looking to finalize the dynamic erg table for the bike where I don't have a static power table first. Do you agree?

Of course the dynamic power table will be applied only to the bike with automatic resistance and without the static power table.

cagnulein avatar Mar 02 '24 06:03 cagnulein

@drmason789 i mean this one https://github.com/cagnulein/qdomyos-zwift/pull/2175 if you want to review my code go on! (I didn't test myself yet)

cagnulein avatar Mar 02 '24 07:03 cagnulein

Actually I was looking to finalize the dynamic erg table for the bike where I don't have a static power table first. Do you agree?

Yes.

drmason789 avatar Mar 02 '24 08:03 drmason789

@drmason789 i mean this one https://github.com/cagnulein/qdomyos-zwift/pull/2175 if you want to review my code go on! (I didn't test myself yet)

Definately. I took a quick look and will have some comments about this later.

drmason789 avatar Mar 02 '24 11:03 drmason789

@cagnulein What is the intended difference between the functions wattsFromResistance and powerFromResistanceRequest?

drmason789 avatar Mar 27 '24 22:03 drmason789

@cagnulein Remember the resistance_t change? Would you be agreeable to me adding cadence_t, heartRate_t, power_t, pelotonResistance_t, inclination_t alongside it and propagating throughout the codebase, in a different PR?

drmason789 avatar Mar 27 '24 23:03 drmason789

@cagnulein What is the intended difference between the functions wattsFromResistance and powerFromResistanceRequest?

@drmason789 it was intented to use for renpho bikes but at the end powerFromResistanceRequest is a dead code

cagnulein avatar Apr 02 '24 07:04 cagnulein

@cagnulein Remember the resistance_t change? Would you be agreeable to me adding cadence_t, heartRate_t, power_t, pelotonResistance_t, inclination_t alongside it and propagating throughout the codebase, in a different PR?

@drmason789 yes sure!

cagnulein avatar Apr 02 '24 08:04 cagnulein

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 18 '24 00:04 stale[bot]

@drmason789 i added erg tables for all the bikes with the new ergtable module. Maybe it could impact also this

cagnulein avatar Apr 24 '24 12:04 cagnulein

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 10 '24 00:05 stale[bot]