Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Are onNew… events triggered only when there is new data?

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

As an example, AntPlusBikePowerPcc.IPedalPowerBalanceReceiver contains onNewPedalPowerBalance() and the documentation for the class states:
Receiver for the PedalPowerBalance event, which is: The pedal power data field provides the user's power contribution (as a percentage) between the left and right pedals, as measured by a pedal power sensor. This data field should be interpreted with the power-only update event count field to determine if the sensor data is new. This data is optional and may not be sent by all sensors.

Do we need to monitor the event count and only treat events as new data when it has changed? Or is this done already and the events only occur on new data?      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

For the most part yes, you must monitor the event count to determine if the data is new or changed as described in the Bike Power Device Profile. Only some events such as the calculated events or the instantaneous cadence event take the event count into account before firing because an unchanging event count typically indicates that the user has stopped pedalling in event based power meters.      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

To clear up any confusion for anyone reading this.

Q: Are onNew… events triggered only when there is new data?
A: No. Raw data events will be triggered even when there is no new data, and event count must be checked. However, calculated data events only occur when there is new data.

The question in the thread title is opposite to the one in my post (which harrison answered).      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

How do we monitor event count for events which does not include it? A similar question, how do we correlate data from different events?

Both of these come down to; will events occur in a known order?

The ANT+ Bike Power profile shows that the power-only message contains event count, pedal power and accumulated/instantaneous power.
2 related cases to consider:
1) To know if any of the data fields are new, we need to check if the event count has changed.
2) To calculate the amount of power generated by each pedal, we need to apply the pedal contributions to the power value.

but, the onNewPedalPowerBalance() event does not contain event count or power. The onNewRawPowerOnlyData() does. It has been said (http://www.thisisant.com/forum/viewreply/5244/) that the estTimestamp of each will match if they are from the same message. We can check estTimestamp and build the data we need, but do we know that we will always get onNewRawPowerOnlyData() before onNewPedalPowerBalance()?      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

At this time there are no plans to change the order in which events fire and should remain consistent although there is always a minimal risk it may change in the future.      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

As the order of events is undefined, my planned workaround is to create a class to store the data from each of the received events together and rebuild the original data page, triggering my own event once it is complete. As previously commented on
ifor - 29 March 2014 03:01 PM
To be honest I can not see why you are splitting the data up into the various different messages it just makes life really hard if you want all the data for an event having to register for multiple events then marry them back up together is really pain full and inefficient when at the underlying ANT+ level they all come together.


The response was
ShaneG - 31 March 2014 10:52 AM
we will probably also be refactoring the events to be more friendly (specifically I believe we will be combining the heartRate and timestamp into the same event). We are expecting to add this in our next release by May. Watch the forums for announcements of a public beta.

Is this still planned? I am assuming this would be for all device types.

Thanks.
R      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

The combining of the data for heart rate was specifically for the RR use-case which was broken by a bug with the Page 4 data which has all been fixed. This was not referencing all profiles and there is no further plans to combine other events.

Assuming delivering all the events on a single ANT+ data page is 'easier to understand' only makes sense from the point of view of someone who is working directly off the profile or has previous experience doing the manual encoding.

In this specific case with Bike Power, you are going to have occasions where the values remain the same even when the event count changes, so you are going to have to cache and compare the last seen values in any case if you never want to process repeat values.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Referring back to reply #3, but asking a more focused question: How do we calculate the power generated by each pedal, and know whether that data is current?      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

1) The per pedal power can be derived using the IPedalPowerBalanceReceiver using the pedalPowerPercentage which is received on the same data page as the IRawPowerOnlyDataReceiver (which contains the instantaneousPower field you must multiply with). Left and right can only be derived if the power meter is sending right pedal data, indicated by the rightPedalIndicator.

2) Both of these events share the same powerOnlyUpdateEventCount as they are received on the same page (which will both share the same estTimestamp so if one of these events fire they will both fire). If the powerOnlyUpdateEventCount changes between events, that indicates the sensor has updated its data, if not then it is simply repeating previous data.

Unfortunately there is no time correlation between torque calculated power and power-only data sent by the sensor. Power only data events must be considered as their own data points in time interwoven with torque data. Torque calculated power always represents the average power over the time between the last 2 received torque data pages.      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

I feel like I am going around in circles trying to get to the bottom of this. ShaneG says to not consider anything as pages as per the profile, and harrison says that events are from the same page. I have a few questions scattered below, but one consistent explanation should cover them all.

ShaneG - 30 June 2014 11:04 AM
Assuming delivering all the events on a single ANT+ data page is 'easier to understand' only makes sense from the point of view of someone who is working directly off the profile or has previous experience doing the manual encoding.

harrison - 02 July 2014 03:15 PM
Both of these events share the same powerOnlyUpdateEventCount as they are received on the same page (which will both share the same estTimestamp so if one of these events fire they will both fire).

How do we know "these events share the same powerOnlyUpdateEventCount as they are received on the same page" without being "someone who is working directly off the profile"? It would be great to not to have to be reading the ANT+ profile documents to understand how the API works, but I don't think the required information is available.

arrgh - 30 June 2014 09:16 PM
How do we calculate the power generated by each pedal, and know whether that data is current?

harrison - 02 July 2014 03:15 PM
1) The per pedal power can be derived using the IPedalPowerBalanceReceiver using the pedalPowerPercentage which is received on the same data page as the IRawPowerOnlyDataReceiver (which contains the instantaneousPower field you must multiply with). Left and right can only be derived if the power meter is sending right pedal data, indicated by the rightPedalIndicator.

2) Both of these events share the same powerOnlyUpdateEventCount as they are received on the same page (which will both share the same estTimestamp so if one of these events fire they will both fire). If the powerOnlyUpdateEventCount changes between events, that indicates the sensor has updated its data, if not then it is simply repeating previous data.

There is no such thing as "received on the same data page" in the API, which is why I believe I need to build back up a "data page".

Straight from harrisons reply #8, this is the data we need to use:
IPedalPowerBalanceReceiver: estTimestamp, rightPedalIndicator, pedalPowerPercentage
IRawPowerOnlyDataReceiver: estTimestamp, powerOnlyUpdateEventCount, instantaneousPower

arrgh - 18 June 2014 01:41 PM
will events occur in a known order?

harrison - 27 June 2014 12:27 PM
there is always a minimal risk it may change in the future.

Meaning we don't know if we will always receive IPedalPowerBalanceReceiver before IRawPowerOnlyDataReceiver, or vice-versa.

So, to calculate pedal power contribution we need to store IPedalPowerBalanceReceiver and IRawPowerOnlyDataReceiver until we have both with the same estTimestamp. This is what I refer to as "rebuild the original data page". Additionally the previous powerOnlyUpdateEventCount must be stored, so we only report new data if this has changed. Is there an alternative?
     

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

The bike power profile is one of the most complicated ANT+ profiles. Although it is our goal to have the ANT+ Plugins interface easy to understand, we realize that for some of the more advanced usages may require more explanation. Additionally, we are not opposed to making changes to improve the interface, so feel free to suggest specific things that could make your use-case better and we will consider them.

This specific case looks like it may be a candidate for adding to or merging the events, or another solution. Also, it is in our plans to come up with a solution to help those who want to aggregate data over multiple events.

For now, if you want to do advanced calculations over multiple events, you need to save the data from each page until you have the other one to perform the calculation. It should be fairly straightforward.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

I would like to add to the list that calculating stride length requires combining both the speed and cadence events from a footpod.      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 235

Joined 2012-08-31

PM

Wouldn't it be simpler to get stride length from the distance and stride count fields?      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Yes it would - and it would give more accurate values! smile      

Signature

blackramlabs.com