public void AddSchedule(CommandPacket command)
 {
     commandSchedule.Add(command);
 }
 public void ModifySchedule(int index, CommandPacket command)
 {
     commandSchedule[index] = command;
 }
Beispiel #3
0
        public CommandModifyForm(MainForm mainForm, DataGridViewRow dataRow)
        {
            InitializeComponent();
            this.mainForm = mainForm;

            this.rollPitchGraphic   = this.rollPitchBox.CreateGraphics();
            this.gazYawGraphic      = this.gazYawBox.CreateGraphics();
            this.redPen             = new Pen(Color.Red, 2f);
            this.bluePen            = new Pen(Color.Blue, 2f);
            this.rollPitchMouseDown = false;
            this.rollPitchPoint     = Point.Empty;
            this.gazYawMouseDown    = false;
            this.gazYawPoint        = Point.Empty;
            this.isOK = false;

            this.rollPitchBox.Paint += rollPitchBox_Paint;
            this.gazYawBox.Paint    += gazYawBox_Paint;

            if (dataRow.Cells[GridViewConsts.COMMAND_TYPE].Value.Equals(CommandComboBoxConsts.TAKE_OFF))
            {
                this.packet = CommandPacketManager.CommandPack(DroneCommandType.DRONE_FLYING, DroneFlyingMode.TAKE_OFF);
                this.commandComboBox.SelectedIndex = 0;
            }
            else if (dataRow.Cells[GridViewConsts.COMMAND_TYPE].Value.Equals(CommandComboBoxConsts.LAND))
            {
                this.packet = CommandPacketManager.CommandPack(DroneCommandType.DRONE_FLYING, DroneFlyingMode.TAKE_OFF);
                this.commandComboBox.SelectedIndex = 1;
            }
            else if (dataRow.Cells[GridViewConsts.COMMAND_TYPE].Value.Equals(CommandComboBoxConsts.PILOTING))
            {
                sbyte roll = 0, pitch = 0, yaw = 0, gaz = 0;
                short sustainTime = 0;
                bool  parseResult =
                    sbyte.TryParse((string)dataRow.Cells[GridViewConsts.ROLL].Value, out roll) &&
                    sbyte.TryParse((string)dataRow.Cells[GridViewConsts.PITCH].Value, out pitch) &&
                    sbyte.TryParse((string)dataRow.Cells[GridViewConsts.YAW].Value, out yaw) &&
                    sbyte.TryParse((string)dataRow.Cells[GridViewConsts.GAZ].Value, out gaz) &&
                    short.TryParse((string)dataRow.Cells[GridViewConsts.TIME].Value, out sustainTime);
                if (!parseResult)
                {
                    mainForm.ShowMessageBox("선택한 행의 데이터가 잘못되었습니다.");
                    this.Close();
                    return;
                }

                this.packet = CommandPacketManager.CommandPack(DroneCommandType.DRONE_PILOTING,
                                                               DroneFlyingMode.NONE,
                                                               roll,
                                                               pitch,
                                                               yaw,
                                                               gaz,
                                                               sustainTime);

                this.rollPitchPoint = new Point((int)((((float)roll + 100) / 200) * this.rollPitchBox.Size.Width),
                                                (int)(((-(float)pitch + 100) / 200) * this.rollPitchBox.Size.Height));
                this.gazYawPoint = new Point((int)((((float)yaw + 100) / 200) * this.gazYawBox.Size.Width),
                                             (int)(((-(float)gaz + 100) / 200) * this.gazYawBox.Size.Height));

                this.rollPitchBox.Invalidate();
                this.gazYawBox.Invalidate();

                this.rollTextBox.Text  = roll.ToString();
                this.pitchTextBox.Text = pitch.ToString();
                this.yawTextBox.Text   = yaw.ToString();
                this.gazTextBox.Text   = gaz.ToString();
                this.timeTextBox.Text  = sustainTime.ToString();
            }
        }