O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Notifying subscribers manually

We also need to be able to manually trigger our observable notifications. For digital input objects, this is easy. We do this every time the digital input changes state:

  public void Set(bool Value) 
  { 
    if (!this.state.BooleanValue.HasValue || 
      this.state.BooleanValue.Value != Value) 
    { 
      this.state.BooleanValue = Value; 
      this.state.TriggerAll(); 
 
      if (Value) 
      { 
        this.counter.IntegerValue++; 
        this.counter.TriggerAll(); 
      } 
 
      this.TriggerAll(); 
    } 
  } 
} 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required