Author: Not specified Language: cpp
Description: Not specified Timestamp: 2017-01-29 23:14:58 +0000
View raw paste Reply
  1. void CNetExample::RpmUpdate()
  2. {
  3.     printf("Motor RPM has been updated. RPM = [%f]", motorRpm->GetValue());
  4. }
  5.  
  6. bool CNetExample::Initialize()
  7. {
  8.     // Define Net Types
  9.     motorRpm = CreateFloat("motorRpm");
  10.     motorRpm->InitializeNet("machine.motor.rpm");
  11.  
  12.     // Use EVENT_HANDLER macro with RegisterEvent(delegate) to define an async
  13.     // event handler for motor rpm updates.
  14.     motorRpm->RegisterEvent(EVENT_HANDLER(RpmUpdate));
  15.  
  16.     motorTarget = CreateFloat("targetRpm");
  17.     motorTarget->InitializeNet("machine.motor.vfd.target");
  18.  
  19.     // Write update without needing to know how to connect to the target device.
  20.     motorTarget->SetValue(58.3);
  21.    
  22.     return true;
  23. }
View raw paste Reply