more G-Labs products

Author Topic: C# documentation  (Read 4541 times)

May 30, 2014, 03:26:54 PM
Reply #15

Gene

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

Value/UpdateTime fields are always updated with current received data.
Indeed LastValue/LastUpdateTime is only updated when a new value is received and it's not updated if received data keep being the same.

This is because the meaning of LastValue is "last value different from current one".

If you need to access all values history you can implement an automation program that uses the WhenModuleParameterChange event to store all received values into a List<ModuleParameter> .

Cheers,
g.

May 30, 2014, 04:15:16 PM
Reply #16

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Sounds like that's the approach I'll take.  Do you have an example of defining and accessing a list in C# for HG?  Is it possible to generate a list in a parameter such that it could be accessed by something like:
Code: [Select]
Modules.WithName("My Module").Parameter("ActivityList(0)").Value"Maybe this would be better implemented directly in the code.  I know I can just make parameters "LastValue", "LastLastValue", etc., I was just thinking about a cleaner implementation.

June 18, 2014, 08:15:19 PM
Reply #17

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I know that when a module changes, the UpdateTime field is updated.  But, if I create my own parameter (a timer for example), do I need to set the UpdateTime field manually or does this get updated by HG?  For example,

Code: [Select]
Modules.WithFeature(SMART_LIGHT_ENABLE).Each((light_mod)=>
{
  light_mod.Parameter(TIMER_ON).Value="TRUE";
  light_mod.Parameter(TIMER_ON).UpdateTime=DateTime.UtcNow;
});

Do I really need to have the second line to set the TIMER_ON UpdateTime?  It doesn't seem to update on its own.