private void handleStartSequencerEvent(StartSequencerEvent inEvent) { switch (inEvent._sequenceID) { case SequenceID.TestSequence: _startTestSequenceEvent.Set(); break; case SequenceID.twoOzSequence: _startTwoOzSequenceEvent.Set(); break; case SequenceID.fourOzSequence: _startFourOzSequenceEvent.Set(); break; case SequenceID.eightOzSequence: _startEightOzSequenceEvent.Set(); break; default: log.Error(string.Format("{1} is not a valid sequencer id", inEvent._sequenceID)); break; } }
private void handleSequencerClicked(SequenceID inSequencerID) { StartSequencerEvent newEvent = new StartSequencerEvent(inSequencerID); if (_uiDelegate != null) { log.Debug("Adding the startTestSequence event to the processing queue"); _uiDelegate.enqueueEvent(newEvent); } }
//*************************** 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; } } }