private async Task RunWiggleTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.SmallWiggle; await SendCommand(c); }
private async Task RunEyeTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.Wink; await SendCommand(c); }
private async void RunWingFlapTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.Flap; _owl.RunCommand(c); }
private async Task RunHeadRightTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.HeadRight; await SendCommand(c); }
private async void RunWiggleTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.SmallWiggle; _owl.RunCommand(c); }
private async void RunHeadRightTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.HeadRight; _owl.RunCommand(c); }
private async Task RunWingFlapTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.Flap; await SendCommand(c); }
private async void RunEyeTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.Wink; _owl.RunCommand(c); }
private void RunHeadLeftTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.HeadLeft; _owl.RunCommand(c); }
private async Task RunCalibrationTest() { OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.Recalibrate; await SendCommand(c); }
public async Task SendOwlCommandAsync(OwlCommand command) { var message = new ValueSet(); // Serialized classes are OK string value = Serialize <OwlCommand>(command); await SendMessageAsync(new KeyValuePair <string, object>("command", value)); }
private void ApplyOwlStateFromCommand(OwlCommand c) { if (c.State != null) { ApplyControllerState(_head, c.State.Head, c.StayAfterComplete); ApplyControllerState(_leftEye, c.State.LeftEye, c.StayAfterComplete); ApplyControllerState(_rightEye, c.State.RightEye, c.StayAfterComplete); ApplyControllerState(_wings, c.State.Wings, c.StayAfterComplete); } }
private async Task SendCommand(OwlCommand c) { if (!relayClient.IsConnected) { //deferral.Complete(); TestButton.Content = "Bad: Relay Client connection is not open -- " + DateTime.Now.ToString(); return; } await relayClient.SendOwlCommandAsync(c); }
private void CommandQueue_CommandAdded(object sender, OwlCommand command) { bool needToStart = false; //Only allow one task to be running lock (_taskLockObj) { if (_commandQueueTask == null || _commandQueueTask.Status == TaskStatus.RanToCompletion || _commandQueueTask.Status == TaskStatus.Canceled || _commandQueueTask.Status == TaskStatus.Faulted) { needToStart = true; } if (needToStart) { _commandQueueTask = Task.Factory.StartNew(() => ProcessCommandQueue()); } } }
private async void DoStuffOwlClient() { if (relayClient == null) { relayClient = new StatusRelay.RelayClient(); } OwlCommand c = new OwlCommand(); c.Command = OwlCommand.Commands.RandomFull; if (!relayClient.IsConnected) { ExceptionDispatchInfo capturedException = null; try { await relayClient.Open(); } catch (Exception ex) { capturedException = ExceptionDispatchInfo.Capture(ex); } string exMessage = String.Empty; if (capturedException != null) { //await ExceptionHandler(); //capturedException.Throw(); exMessage += capturedException.SourceException.ToString(); } if (!relayClient.IsConnected) { //deferral.Complete(); TestButton.Content = "Bad: Relay Client connection is not open -- " + DateTime.Now.ToString() + " -- Error: " + exMessage; return; } } //if we made it here, do the message await relayClient.SendOwlCommandAsync(c); }
/// <summary> /// Creates new instance of DialogViewModel /// </summary> internal DialogViewModel() { OkCommand = new OwlCommand { CanExecuteDelegate = x => OkCommandCanExecute(x), ExecuteDelegate = x => { OkCommandExecute(x); RaiseCloseRequest(); } }; CancelCommand = new OwlCommand { CanExecuteDelegate = x => CancelCommandCanExecute(x), ExecuteDelegate = x => { CancelCommandExecute(x); RaiseCloseRequest(true); } }; }
private void DoIntervalAction(int minutes, bool setLastAutoExecutedTime = true) { if (((DateTime.Now - _lastAutoActionInitiated).Minutes > 2) || !setLastAutoExecutedTime) { if (ActionSchedule.ContainsKey(minutes)) { //don't let the automated trigger stack up events if (setLastAutoExecutedTime) { _lastAutoActionInitiated = DateTime.Now; } Task.Factory.StartNew(() => { OwlCommand c = new OwlCommand(); c.Command = ActionSchedule[minutes]; _owl.RunCommand(c); }); } } }
private void RelayClient_OnMessageReceived(ValueSet message) { Write("DEBUG", "RelayClient_OnMessageReceived"); if (message.ContainsKey("command")) { string payload = (string)message["command"]; OwlCommand c = BigOwl.StatusRelay.RelayClient.DeSerializeOwlCommand(payload); //OwlCommand c = (OwlCommand)message["command"]; if (c != null) { CommandQueue().Add(c); string msg = "Command: " + c.Command.ToString(); Write("DEBUG", msg); System.Diagnostics.Debug.WriteLine("Command: " + msg); relayClient.SendAck(c.Id.ToString()); } else { Write("DEBUG", "command was null"); System.Diagnostics.Debug.WriteLine("Command was null."); relayClient.SendNack(c.Id.ToString()); } } else if (message.ContainsKey("ack")) { Write("DEBUG", "message was ack"); } else if (message.ContainsKey("nack")) { Write("DEBUG", "message was nack"); } else { //was something else. } }
// Should only be performed by _commandQueueTask. Should probably move this into // a job manager object. protected void ProcessCommandQueue() { Status = OwlDeviceStateBase.StatusTypes.Busy; StatusReason = OwlDeviceStateBase.StatusReasonTypes.ExecutingMove; while (CommandQueue.PeekNext() != null) { OwlCommand c = CommandQueue.GetNext(); if (c != null) { switch (c.Command) { case OwlCommand.Commands.Recalibrate: DoRecalibrate(); break; case OwlCommand.Commands.CancelAllAndReset: CancelAllAndReset(); break; case OwlCommand.Commands.Flap: DoFlap(); break; case OwlCommand.Commands.HeadLeft: DoHeadLeft(); break; case OwlCommand.Commands.HeadRight: DoHeadRight(); break; case OwlCommand.Commands.RandomFull: DoRandomFull(); break; case OwlCommand.Commands.RandomLong: DoRandomLong(); break; case OwlCommand.Commands.RandomShort: DoRandomShort(); break; case OwlCommand.Commands.Rest: GoHomePosition(); break; case OwlCommand.Commands.SmallWiggle: DoSmallWiggle(); break; case OwlCommand.Commands.Wink: DoWink(); break; case OwlCommand.Commands.Surprise: DoSurprise(); break; case OwlCommand.Commands.ApplyState: ApplyOwlStateFromCommand(c); break; } } } Status = OwlDeviceStateBase.StatusTypes.Ready; }
public void RunCommand(OwlCommand c) { CommandQueue.Add(c); //Need to set up a queue event to fire this automatically. //ProcessCommandQueue(); }
private async void _commandQueue_CommandAdded(object sender, OwlCommand command) { await Write("DEBUG", "_commandQueue_CommandAdded"); }