コード例 #1
0
 /// <summary>
 /// Checks if the switch has been pressed since the last UpdateState, and fires off relevant events if so.
 /// Call this frequently enough to catch all presses, as only one event is registered per cycle.
 /// I.e. if a switch is pressed 3 times between UpdateState() calls, only one event is sent.
 /// </summary>
 public void UpdateState()
 {
     if (this.HadEvent)
     {
         LimitSwitchToggle Event = new LimitSwitchToggle()
         {
             CurrentState = this.Invert ? !this.NewState : this.NewState
         };
         OnSwitchToggle(Event);
         this.HadEvent = false;
     }
 }
コード例 #2
0
 protected virtual void OnSwitchToggle(LimitSwitchToggle Event)
 {
     SwitchToggle?.Invoke(this, Event);
 }