Exemple #1
0
        private BackgroundSimulationInput GetSimulationInput()
        {
            var input = new BackgroundSimulationInput();

            input.timeHorizon = double.Parse(tbTimeHorizon.Text);
            input.timeStep    = double.Parse(tbTimeStep.Text);

            pointsPerSecond = int.Parse(tbPointsPerSecond.Text);
            iterativeSimulator.initialMode = (ControlSystemMode)cbMode.SelectedValue;

            iterativeSimulator.waveType = (SignalType)cbInputType.SelectedValue;
            StepsParametersConverter stepsConverter = new StepsParametersConverter();

            double[] stepTimes, stepValues;
            stepsConverter.Convert(tbStepTimes.Text, tbStepValues.Text, out stepTimes, out stepValues);
            iterativeSimulator.SignalGenerator.SetStepsParameters(stepTimes, stepValues);

            double frequency, amplitude, offset;
            WavesParametersConverter wavesConverter = new WavesParametersConverter();

            wavesConverter.Convert(tbFrequency.Text, tbAmplitude.Text, tbOffset.Text, out frequency, out amplitude, out offset);
            iterativeSimulator.SignalGenerator.SetWavesParameters(frequency, amplitude, offset);

            input.iterativeSimulator = iterativeSimulator;
            return(input);
        }
        public void ConvertTest()
        {
            double[] times  = null;
            double[] values = null;

            converter.Convert("1, 2", "3,4", out times, out values);
            CollectionAssert.AreEqual(new double[] { 1d, 2d }, times);
            CollectionAssert.AreEqual(new double[] { 3d, 4d }, values);
        }
        private void SetStepsParameters()
        {
            StepsParametersConverter converter = new StepsParametersConverter();

            if (!converter.Validate(tbStepTimes.Text, tbStepValues.Text))
            {
                MessageBoxEx.Error("Invalid step parameters");
                return;
            }

            double[] times, values;
            converter.Convert(tbStepTimes.Text, tbStepValues.Text, out times, out values);
            simulator.SignalsGenerator.SetStepsParameters(times, values);

            tbSetStepTimes.Text  = tbStepTimes.Text;
            tbSetStepValues.Text = tbStepValues.Text;
        }