public MainViewModel() { TransactionButtonCommand = new ButtonCommands(ChangeTransactionVisibility); //Changes ChangeTransactionVisibility to true TargetButtonCommand = new ButtonCommands(ChangeTargetVisibility); //changes ChangeTargetVisibility to true so this page is displayed //EditButtonCommand = new ButtonCommands(EditTarget); DeleteButtonCommand = new ButtonCommands(DeleteTarget); }
public BasicCamLoopState UpdateState(BasicCamLoopState state, ButtonCommands button) { int i = (int)state; int j = (int)button; return(nextState[i, j]); }
private void AddComplexTaskButton() { const int followWallBeaconId = 3; var lineState = new UntilBeaconDecorator( new FollowingLineState(), followWallBeaconId, null); var wallState = new UntilLineAppearsDecorator( new FollowingWallOnLeftState(turnSpeed: 5), lineState); lineState.Follower = wallState; ButtonCommands.Add(new CommandButton("Task2", Brain, lineState)); }
private void InitButtonCommands() { ButtonCommands.Add(new CommandButton("Follow line", Brain, new FollowingLineState(5.0))); ButtonCommands.Add(new CommandButton("Follow left wall", Brain, new FollowingWallOnLeftState())); ButtonCommands.Add(new CommandButton("Follow right wall", Brain, new FollowingWallOnRightState())); ButtonCommands.Add(new CommandButton("Cruise", Brain, new CruiseState())); ButtonCommands.Add(new CommandButton("Turn left", Brain, new RotateState(-5.0))); ButtonCommands.Add(new CommandButton("Turn right", Brain, new RotateState(5.0))); ButtonCommands.Add(new CommandButton("Stop", Brain, new StopState())); AddBeaconAccelerationTaskButton(); AddComplexTaskButton(); }
private void AddBeaconAccelerationTaskButton() { const int accelerationBeaconId = 3; const int decelerationBeaconId = 1; var followSlowly = new FollowingLineState(4); var followFaster = new FollowingLineState(6); var slowState = new UntilBeaconDecorator( followSlowly, accelerationBeaconId, null); var fastState = new UntilBeaconDecorator( followFaster, decelerationBeaconId, slowState); slowState.Follower = fastState; ButtonCommands.Add(new CommandButton("Task1", Brain, slowState)); }
public ButtonMessage(Buttons button, ButtonCommands command) { this.Command = command; this.Button = button; }
public void Update() { xBoxController.controller.GetState(state: out state); currButtonStates.CopyTo(array: prevButtonStates, index: 0); for (int i = 0; i < nControllableButtons; i++) { currButtonStates[i] = state.Gamepad.Buttons.HasFlag(gamepadButtonFlags[i]); } for (int i = 0; i < nControllableButtons; i++) { if (prevButtonStates[i] == false && currButtonStates[i] == true) { ButtonCommands buttonCommand = (ButtonCommands)Enum.Parse(typeof(ButtonCommands), controllableButtonCommands[i]); if (camButtons.Contains(buttonCommand)) { for (int j = 0; j < xBoxController.nCameras; j++) { ButtonCommands message = buttonCommand; xBoxController.camControlMessageQueues[j].Enqueue(message); } } if (soundButtons.Contains(buttonCommand)) { string message; if (buttonCommand == ButtonCommands.PlayInitiateTrialTone) { message = "initiate_trial"; xBoxController.serialPort.Write(text: message); } else if (buttonCommand == ButtonCommands.PlayRewardTone) { message = "reward"; xBoxController.serialPort.Write(text: message); } else if (buttonCommand == ButtonCommands.Exit) { message = "exit"; xBoxController.serialPort.Write(text: message); xBoxController.serialPort.Close(); } } if (displayButtons.Contains(buttonCommand)) { if (buttonCommand == ButtonCommands.BeginStreaming) { xBoxController.mainForm.isStreaming = true; } else if (buttonCommand == ButtonCommands.EndStreaming) { xBoxController.mainForm.isStreaming = false; } } if (streamProcessingButtons.Contains(buttonCommand)) { ButtonCommands message = buttonCommand; xBoxController.mainForm.processingThreadMessageQueue.Enqueue(message); } if (buttonCommand == ButtonCommands.Exit) { xBoxController.mainForm.ExitButtonPressed(); } } } }