Calculated Fields

by camel

Downloads: 23,628 (9) • Reviews: 4

Version:

1.2.9.4

Updated:

Apr 11, 2011

RANGEELAPSED for HR with no Data in Range

RANGEELAPSED for HR with no Data in Range

Postby GErnenputsch » Sat Jul 23, 2011 3:28 am

If I use {RANGEELAPSED(HR,Low,High)} and there is no HR-Data between "low" and "high" I would expect a result of "0" just because I spent 0 seconds in this range but this seems not to be true. A calculated field doesn't contain any value in this cases. The problem is now that I can't calculate anythin with these results.
My next thought was that in these cases a "null" will be returned but even
Code: Select all
({RANGEELAPSED(HR,Low,High)} == null) ? 0 : {RANGEELAPSED(HR,Low,High)}

or
Code: Select all
({RANGEELAPSED(HR,Low,High)} == null) ? 0 : Convert.ToInt32({RANGEELAPSED(HR,Low,High)})

don't work. :?

Any suggestions?

Regard
GErnenputsch
GErnenputsch
 
Posts: 4
Joined: Fri Jul 22, 2011 1:00 am

Re: RANGEELAPSED for HR with no Data in Range

Postby GErnenputsch » Mon Jul 25, 2011 7:03 am

OK I did some more testing. I created a custom textfield. After that I assigned the following expression:

Code: Select all
({RANGEELAPSED(HR,a_low_value,a_high_value)}).GetType().ToString()


When there is HR Data between "low" and "high" limit I get System.Int32 (looks OK to me, and was expected).
If there is HR Data but no data in the range between "low" and "high" limits I get nothing (nothing means no "null", no "object", no string, no empty string ... simply nothing) as if the expression never gets evaluated.

The problem here is, there seems to be no way around. You can't work with conditional expressions (a?b:c) and you can't calculate with this result 'cause any further calculation results in "nothing" too. :?:

Greets Gordon
GErnenputsch
 
Posts: 4
Joined: Fri Jul 22, 2011 1:00 am

Re: RANGEELAPSED for HR with no Data in Range

Postby camel » Mon Jul 25, 2011 2:33 pm

I will get an look into code, what is happening in this case. Just give me some time please :)

Probably calculation is stopped because it will throw exception if nothing was there. But I can imagine that I can return something more useful at least null in that case. Or something
camel
Donated!
Donated!
 
Posts: 363
Joined: Tue May 18, 2010 7:14 am
Location: Slovakia

Re: RANGEELAPSED for HR with no Data in Range

Postby camel » Mon Jul 25, 2011 3:19 pm

Ok I see it, I'm returning null as a result. But null or empty strings are just ignores as nothing was calculated for many reasons.

Now question for discuss, what is correct to return in this case.

If I will return for example string "EMPTY" many users will have problems with exceptions... Now all is ok because nothins is calculated.
Probably better thing is to return integer 0. So something bad will be calculated... But you can still handle it.

Probably there is no nice solution for this because it differs from case to case.
What users do want to have?
camel
Donated!
Donated!
 
Posts: 363
Joined: Tue May 18, 2010 7:14 am
Location: Slovakia

Re: RANGEELAPSED for HR with no Data in Range

Postby GErnenputsch » Tue Jul 26, 2011 1:51 am

camel wrote:Ok I see it, I'm returning null as a result. But null or empty strings are just ignores as nothing was calculated for many reasons.
Now question for discuss, what is correct to return in this case.


Thx for your answer.

Let's think a second about this question ...

In my special case it should return the time spent in a particular heartbeat per minute range and I spent no time in this range. I would expect zero (System.Int32) as result if there is any data but not in the requested range, simply 'cause I spent no time in the requested range (aka zero seconds 8) ). The concept of conditions is all you need to catch cases where there is no hr data track. One option could be returning null if there is no hr datatrack as an additional indicator for these cases.

I think in other cases where you want calculate the time elapsed for a special datatrack this should be similar.

Maybe other range-functions / parameter combinations should be treated in other ways, but it should allways be possible to catch such cases in expressions with conditional statements to keep further calculations possible and the user can choose his solution in this way ... e.g.
Code: Select all
({RANGEELAPSED(HR,Low,High)} == null) ? 0 : {RANGEELAPSED(HR,Low,High)}


I don't know enough about the other range-type/parameters 'cause I just started using your plugin but I'm sure you know anything about them :wink:

Greets GErnenputsch
GErnenputsch
 
Posts: 4
Joined: Fri Jul 22, 2011 1:00 am

Re: RANGEELAPSED for HR with no Data in Range

Postby camel » Tue Jul 26, 2011 2:22 pm

For now I have modified only Range feature to return 0 if zero points were found.

You can download this new build on this link: (i have not yet updated sporttracks catalog, because it's too small change)
http://calculatedfields.googlecode.com/files/CalculatedFields_1_2_9_5.st3plugin

Nice day
Peter
camel
Donated!
Donated!
 
Posts: 363
Joined: Tue May 18, 2010 7:14 am
Location: Slovakia

Re: RANGEELAPSED for HR with no Data in Range

Postby GErnenputsch » Tue Jul 26, 2011 2:29 pm

I'll give it a try ... thx
GErnenputsch
 
Posts: 4
Joined: Fri Jul 22, 2011 1:00 am


Return to Calculated Fields

Who is online

Users browsing this forum: No registered users and 1 guest

cron