more G-Labs products

Author Topic: LastDifferentValue and LastDifferentUpdateTime  (Read 958 times)

June 02, 2014, 07:06:27 PM
Read 958 times

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
HG currently has the following values:

Value - current parameter value
LastValue - last different parameter value
UpdateTime - time the current parameter value was set
LastUpdateTime - time the last different parameter value was set

I have the need to know the last actual value and time it was set.  It seems to me that the best way to do this would be to add a new value that could be accessed directly from HG.  I have written some code to work around this and it works fine, but it would certainly be a lot cleaner if a new value could be added to HG that would provide the needed information.

If I look at the parameter names, It appears that intuitively LastValue should hold the last value sent (seen by HG) whether that value was the same or different.  If I was looking to find the last different value, I would think the call should be to something like LastDifferentValue or LastDiffValue.  LastValue should be used for the last time the parameter was set even if that value was the same.

This is my interpretation, so maybe I'm on an island here.  I know how to change the code in HG to do this, but every update to HG will revert any change I make.  The primary issue I see with this change is that any location where LastValue is used would potentially need to be changed to LastDifferentValue.

Alternately, perhaps there could be a new parameter to hold the last event (LastEventValue, LastEventUpdateTime).  In this way, no existing code would need altering.

June 02, 2014, 07:57:18 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi Ben,

there's an undocumented module member called "Statistics" that is a work in progress and currently only used to compute average values in a certain short range of time that are then stored into the db.
In the future the Statistics class will provide also an "History" and many other statistic related functionality like generic behavior informations that for example, in the case of "Status.Level", could be used to implement lifestyle feature.
This class will also play an important role for implementing some automation intelligence into HG. I've got a bunch of ideas about this, but ain't feeling like it's the right moment to work on this.
I agree that LastValue could be a bit confusing, but it's a bit complicated to change it now. =)

Cheers,
g.

June 02, 2014, 08:09:00 PM
Reply #2

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
What I have works right now, so this is not an imperative.  It seems like something to address at some point in some way.  Thanks.