/// <summary> /// Delegate to be called whenever the Z-Wave controller's status changes - prepares the library. /// </summary> /// <param name="sender">The Z-Wave controller which sent the change.</param> /// <param name="args"></param> protected void OnControllerStatusChanged(object sender, ControllerStatusEventArgs args) { switch (args.Status) { case ControllerStatus.Connected: Controller.Initialize(); break; case ControllerStatus.Disconnected: if (_stoppingSemaphor != null) { _stoppingSemaphor.Release(); _stoppingSemaphor = null; } OnDisconnected?.Invoke(this); break; case ControllerStatus.Error: OnError?.Invoke(this); break; case ControllerStatus.Ready: Controller.Discovery(); break; case ControllerStatus.Initializing: default: break; } }