public Command(Command old) { commandType = old.commandType; target = old.target; destination = old.destination; targetType = old.targetType; }
public Command(Command.commandTypes t, Vehicle target = null, Vector3 destination = default(Vector3)) { commandType = t; this.target = target; this.destination = destination; if (target == null && destination != default(Vector3)) { targetType = targetTypes.Point; } else if (target != null) { targetType = targetTypes.Unit; this.destination = target.vehicleObject.transform.position; } else { Debug.LogError("Command created with invalid parameters"); throw new UnityException(); } }
private void parseCommand(string message) { commandTypes type = (commandTypes)Int16.Parse(message.Substring(0, 1)); int command = Int16.Parse(message.Substring(1, 2)); switch (type) { case commandTypes.Focus: if (command <= System.Enum.GetValues(typeof(focusCommands)).Length) { newFocusCommand = true; this.focusCommand = (focusCommands)command; } break; case commandTypes.Hsm: newHsmCommand = true; hsmCommand = (hsmCommands)command; break; case commandTypes.Palet: if (command <= System.Enum.GetValues(typeof(paletCommands)).Length) { newPaletCommand = true; paletCommand = (paletCommands)command; } break; case commandTypes.Rec: newRecCommand = true; recCommand = (recCommands)command; break; default: break; } }
public OokTokenTag(commandTypes type) { this.type = type; }
private async void ParseExecuteCommand(string message) { commandTypes type = (commandTypes)Int16.Parse(message.Substring(0, 1)); int command = Int16.Parse(message.Substring(1, 2)); switch (type) { case commandTypes.Range: if (command <= System.Enum.GetValues(typeof(rangeCommands)).Length) { rangeCommands rangeCommand = (rangeCommands)command; string rangeText = comboBoxRange.Items[(int)rangeCommand - 1].ToString(); BeginInvoke((Action)(() => textBoxArduino.AppendText("Range : " + rangeText + Environment.NewLine))); cam.ThermalImage.EnterLock(); switch (rangeCommand) { case rangeCommands.Auto: cam.ThermalImage.Scale.IsAutoAdjustEnabled = true; break; case rangeCommands.Range1: cam.ThermalImage.Scale.Range = new Range <double>(-4.0, 50.0); break; case rangeCommands.Range2: cam.ThermalImage.Scale.Range = new Range <double>(14.0, 77.0); break; case rangeCommands.Range3: cam.ThermalImage.Scale.Range = new Range <double>(50.0, 122.0); break; case rangeCommands.Range4: cam.ThermalImage.Scale.Range = new Range <double>(104.0, 185.0); break; case rangeCommands.Range5: cam.ThermalImage.Scale.Range = new Range <double>(158.0, 248.0); break; case rangeCommands.Range6: cam.ThermalImage.Scale.Range = new Range <double>(212.0, 320.0); break; default: break; } cam.ThermalImage.ExitLock(); BeginInvoke((Action)(() => rangeStatus.Text = rangeText)); } break; //function to enable/disable HSM from the arduino signal case commandTypes.Hsm: if (command == (int)hsmCommands.Disable || command == (int)hsmCommands.Enable) { hsmCommands hsmCommand = (hsmCommands)command; BeginInvoke((Action)(() => textBoxArduino.AppendText("Hsm : " + hsmCommand.ToString() + Environment.NewLine))); if (hsmCommand == hsmCommands.Disable) { Command(() => cam.RemoteControl.CameraSettings.SetHighSensitivityModeEnabled(false), false); // just added 3 lines below but havent tested it yet 01/02/19 cam.ThermalImage.EnterLock(); cam.ThermalImage.ThermalPipeline.Add(hsmFilter); cam.ThermalImage.ExitLock(); } else if (hsmCommand == hsmCommands.Enable) { Command(() => cam.RemoteControl.CameraSettings.SetHighSensitivityModeEnabled(true), false); // just added 3 lines below but havent tested it yet 01/02/19 cam.ThermalImage.EnterLock(); cam.ThermalImage.ThermalPipeline.Clear(); cam.ThermalImage.ExitLock(); } await camLock.WaitAsync(); bool hsm = cam.RemoteControl.CameraSettings.IsHighSensitivityModeEnabled(); if (camLock.CurrentCount == 0) { camLock.Release(); } if (hsm) { BeginInvoke((Action)(() => hsmStatus.Text = "Enabled")); } else { BeginInvoke((Action)(() => hsmStatus.Text = "Disabled")); } } break; case commandTypes.Palet: if (command <= System.Enum.GetValues(typeof(paletCommands)).Length) { paletCommands paletCommand = (paletCommands)command; BeginInvoke((Action)(() => textBoxArduino.AppendText("Palet : " + paletCommand.ToString() + Environment.NewLine))); cam.ThermalImage.EnterLock(); cam.ThermalImage.Palette = palletes[command - 1]; string palet = cam.ThermalImage.Palette.Name; cam.ThermalImage.ExitLock(); BeginInvoke((Action)(() => paletStatus.Text = palet)); } break; case commandTypes.Rec: if (command == (int)recCommands.Stop || command == (int)recCommands.Record || command == (int)recCommands.Pause) { recCommands recCommand = (recCommands)command; BeginInvoke((Action)(() => textBoxArduino.AppendText("Record : " + recCommand.ToString() + Environment.NewLine))); await camLock.WaitAsync(); RecorderState status = cam.Recorder.Status; if (camLock.CurrentCount == 0) { camLock.Release(); } if (recCommand == recCommands.Stop) { if (status == RecorderState.Paused || status == RecorderState.Recording) { Command(() => cam.Recorder.Stop(), true); BeginInvoke((Action)(() => buttonRec.Text = "RECORD")); } } else if (recCommand == recCommands.Record) { if (status == RecorderState.Stopped || status == RecorderState.PreRecording) { // start recording Command(() => cam.Recorder.Start(GetNextFileName()), true); BeginInvoke((Action)(() => buttonRec.Text = "STOP")); } else if (status == RecorderState.Paused) { Command(() => cam.Recorder.Continue(), true); BeginInvoke((Action)(() => buttonPause.Text = "PAUSE")); } } else if (recCommand == recCommands.Pause) { if (status == RecorderState.Recording) { Command(() => cam.Recorder.Pause(), true); BeginInvoke((Action)(() => buttonPause.Text = "CONTINUE")); } } } break; case commandTypes.Focus: if (command == (int)focusCommands.Auto || command == (int)focusCommands.Off) { focusCommands focusCommand = (focusCommands)command; BeginInvoke((Action)(() => textBoxArduino.AppendText("Focus : " + focusCommand.ToString() + Environment.NewLine))); if (command == (int)focusCommands.Auto) { Command(() => cam.RemoteControl.Focus.Mode(FocusMode.Auto), false); } else if (command == (int)focusCommands.Off) { Command(() => cam.RemoteControl.Focus.Mode(FocusMode.Stop), false); } await camLock.WaitAsync(); if (camLock.CurrentCount == 0) { camLock.Release(); } BeginInvoke((Action)(() => focusStatus.Text = focusCommand.ToString())); } break; default: break; } }