private void turnOffLEDButton_Click(object sender, RoutedEventArgs e) { log.Info("Clicked the turnOffLED button"); ChangeLEDStateEvent clickTarget = new ChangeLEDStateEvent(false); if (_uiDelegate != null) { log.Debug("Adding the turnOffLED event to processing queue"); _uiDelegate.enqueueEvent(clickTarget); } }
//*************************** EventInterface End **************************************************// /// <summary> /// Method which the processing thread will execute in order to /// process the ui event queue. /// /// Will stop when the _shouldStop flag is set /// </summary> private void processQueue() { while (!_shouldStop) { //Get out the newest event log.Debug("Waiting for new event in UIHandle_LLSL processing queue"); _enqueueEvent.WaitOne(100); if (_eventQueue.Count() < 1) { continue; } log.Debug("UIHandle_LLSL processing thread received item enqueued event"); Event newEvent; bool dequeueSuccessful = _eventQueue.TryDequeue(out newEvent); if (!dequeueSuccessful) { continue; } log.Info(string.Format("UIHandle_LLSL processing queue dequeued event {0}", newEvent.getEventIdentifier())); //Decide what to do with the event switch (newEvent.getEventIdentifier()) { case EventIdentifier.GenericEvent: break; case EventIdentifier.ConnectRequest: log.Debug("Handling ConnectRequest ui event"); handleConnectEvent(); break; case EventIdentifier.ToggleLEDRequest: log.Debug("Handling toggleLED ui event"); handleToggleLEDEvent(); break; case EventIdentifier.FlashLEDRequest: log.Debug("Handling flashLED ui event"); handleFlashLEDEvent(); break; case EventIdentifier.ChangeLEDStateRequest: ChangeLEDStateEvent changeLEDEvent = (ChangeLEDStateEvent)newEvent; bool ledIsHigh = changeLEDEvent._isHigh; log.Debug(string.Format("Handling changeLED (setting high: {0}) ui event", changeLEDEvent._isHigh)); handleChangeLEDStateEvent(ledIsHigh); break; case EventIdentifier.ToggleOutputRequest: ToggleOutputEvent toggleOutputEvent = (ToggleOutputEvent)newEvent; DIOPins pinToToggle = toggleOutputEvent._pinToToggle; log.Debug(string.Format("Handling toggleOutput (toggle pin: {0}) ui event", toggleOutputEvent._pinToToggle)); handleToggleOutputEvent(pinToToggle); break; case EventIdentifier.StartSequencerRequest: log.Debug("Handling startTestSequence ui event"); StartSequencerEvent sequencerEvent = (StartSequencerEvent)newEvent; handleStartSequencerEvent(sequencerEvent); break; case EventIdentifier.UpdateOutputRequest: log.Debug("Handling updateOutput UI Event"); UpdateOutputEvent updateOutput = (UpdateOutputEvent)newEvent; DIOPins pinToChange = updateOutput._pinToUpdate; bool shouldSetHigh = updateOutput._shouldBeHigh; handleUpdateOutputEvent(pinToChange, shouldSetHigh); break; default: break; } } }