Reacting to sensor data events

Any incoming events related to our subscription can be accessed through event handlers on the subscription object that is returned from the subscription request. To follow these events, we define three event handlers:

         this.subscription.OnStateChanged += 
               Subscription_OnStateChanged; 
         this.subscription.OnFieldsReceived += 
               Subscription_OnFieldsReceived; 
         this.subscription.OnErrorsReceived += 
               Subscription_OnErrorsReceived; 
   } 
} 

For two of these events, we will simply output their state to the event log, so we can follow the process:

private void Subscription_OnStateChanged(object Sender, 
   SensorDataReadoutState NewState) 
{ 
   Log.Informational("Sensor subscription state changed.", 
         NewState.ToString()); 
} 
 
private void Subscription_OnErrorsReceived(object Sender, 
   IEnumerable<ThingError> NewErrors) 
{ 
   this.lastEventErrors = DateTime.Now; 
 
   foreach (ThingError Error in NewErrors) 
         Log.Error(Error.ErrorMessage); 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.210.17