/// <summary> /// Compares the peeked state and the previous state and fires events if the state has changed. /// This method calls method <see cref="PeekState"/> automatically if the state is not peeked. /// </summary> public void FetchState() { lock (_syncRoot) { if (_peekedState == null) { PeekState(); } byte[] newState = _peekedState; _peekedState = null; if (newState.SequenceEqual(_committedState)) { return; } byte[] oldState = GetState(); Array.Copy(newState, _state, _state.Length); Array.Copy(newState, _committedState, _committedState.Length); Log.Verbose("'" + Id + "' fetched different state (" + ByteExtensions.ToString(oldState) + "->" + ByteExtensions.ToString(newState) + ")."); StateChanged?.Invoke(this, new IOBoardStateChangedEventArgs(oldState, newState)); } }