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); }
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; }
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); }