Exemple #1
0
        /// <summary>
        /// Loads a forcing function file.
        /// </summary>
        /// <param name="sender">Not used</param>
        /// <param name="e">Not used</param>
        private void loadButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog;

            logger.Debug("Enter: loadButton_Click(object, EventArgs)");

            dialog                  = new OpenFileDialog();
            dialog.DefaultExt       = "csv";
            dialog.Filter           = "Forcing function files (*.csv)|*.csv";
            dialog.Multiselect      = false;
            dialog.InitialDirectory = Environment.CurrentDirectory;

            ForcingFunctions.Clear();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try {
                    forcingFunctionsFilename = dialog.FileName;
                    ForcingFunctions.Read(Path.GetFileName(dialog.FileName));
                } catch (Exception) {
                    MessageBox.Show("Error: Could not open file.");
                }
            }

            goButton.Enabled = true;
        }
        /// <summary>
        /// Called from the main control loop whenever the task is running.
        /// DO NOT call this method directly from DelayMeasurementTask or DelayMeasurementPanel.
        /// </summary>
        public override void ContinueTask()
        {
            ControlInput      controlInput;
            FunctionTimepoint function;
            MotionCommand     command;
            double            elapsedTime;

            elapsedTime = runningStopwatch.ElapsedMilliseconds * 1.0 / 1000;

            function = ForcingFunctions.GetForcingFunction(elapsedTime);

            controlInput = (Hulk.InnerAxis == Hulk.Axis.Roll) ?
                           new ControlInput(function.Input.roll, function.Input.pitch, false, false) :
                           new ControlInput(function.Input.yaw, function.Input.pitch, false, false);

            command = new MotionCommand();
            command.innerVelocity     = controlInput.x * amplitude;
            command.outerVelocity     = controlInput.y * amplitude;
            command.innerAcceleration = 300;
            command.outerAcceleration = 300;

            Hulk.SetCommand(command);
            Hulk.ContinueTask();

            LogData(elapsedTime, Hulk.CurrentMotion, command, controlInput);

            if (elapsedTime >= ForcingFunctions.GetForcingFunctionMaxTime())
            {
                Hulk.StopTask();

                return;
            }
        }