more G-Labs products

Author Topic: pressDuration  (Read 1008 times)

February 13, 2015, 04:56:04 PM
Read 1008 times

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
I use this Code for a pressDuration.
But after updating i get an Error

When.ModuleParameterChanged( (module, parameter) =>
{
if (module.Is("Entry switch") && parameter.Is("Status.Level"))
{
var endTime = parameter.UpdateTime; // this is the timestamp of button release
var startTime = parameter.LastUpdateTime; // this is the timestamp of button press
var pressDuration = endTime - startTime;

if (pressDuration.TotalSeconds > 2)

ERROR
HomeGenie.Data.ModuleParameter' does not contain a definition for `LastUpdateTime' and no extension method `LastUpdateTime' of type `HomeGenie.Data.ModuleParameter' could be found. Are you missing an assembly reference?

THX for Help
« Last Edit: February 13, 2015, 05:46:25 PM by funworld »

February 13, 2015, 05:55:59 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
In latest hg releases this has changed to:

Code: [Select]
parameter.Statistics.Last.Timestamp

more details about the Statistics field can be obtained from the source code:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Data/ValueStatistics.cs#L108

you can probably use:
Code: [Select]
var stats = parameter.Statistics;
var pressDuration = stats.LastOn.Timestamp - stats.LastOff.Timestamp;


g.
« Last Edit: February 13, 2015, 05:58:08 PM by Gene »

February 13, 2015, 08:48:06 PM
Reply #2

funworld

  • *
  • Information
  • Newbie
  • Posts: 20
I canged to

var endTime = parameter.UpdateTime; // this is the timestamp of button release
var startTime = parameter.Statistics.Last.Timestamp; // this is the timestamp of button press
var pressDuration = endTime - startTime;

Your code make a different effect,

THX for helping