public void ValidationTest()
 {
     Assert.False(converter.Validate("", ""));
     Assert.True(converter.Validate("1", "1"));
     Assert.False(converter.Validate("1, 2", "3"));
     Assert.False(converter.Validate("1, a", "1, 5"));
     Assert.True(converter.Validate("1.0", "2.5"));
     Assert.False(converter.Validate("1", "2, 3"));
     Assert.False(converter.Validate("2, -1", "3, 4"));
 }
        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;
        }
Exemple #3
0
        private bool ParametersValidation()
        {
            double timeHorizon = 0d;

            if (!double.TryParse(tbTimeHorizon.Text, out timeHorizon) || timeHorizon <= 0d)
            {
                MessageBoxEx.Error("Invalid start time or end time value.");
                return(false);
            }

            double stepSize = 0d;

            if (!double.TryParse(tbTimeStep.Text, out stepSize) || stepSize <= 0d)
            {
                MessageBoxEx.Error("Invalid step size value");
                return(false);
            }

            int pointsPerSecond = 0;

            if (!int.TryParse(tbPointsPerSecond.Text, out pointsPerSecond) || pointsPerSecond < 1)
            {
                MessageBoxEx.Error("Invalid points per second value");
                return(false);
            }

            StepsParametersConverter stepsConverter = new StepsParametersConverter();

            if (!stepsConverter.Validate(tbStepTimes.Text, tbStepValues.Text))
            {
                MessageBoxEx.Error("Invalid step times or step values");
                return(false);
            }

            WavesParametersConverter wavesConverter = new WavesParametersConverter();

            if (!wavesConverter.Validate(tbAmplitude.Text, tbAmplitude.Text, tbOffset.Text))
            {
                MessageBoxEx.Error("Invalid waves parameters");
                return(false);
            }

            return(true);
        }