diff --git a/Signal Generator/FmSignal.cs b/Signal Generator/FmSignal.cs index 5fc38ef..c32dd4c 100644 --- a/Signal Generator/FmSignal.cs +++ b/Signal Generator/FmSignal.cs @@ -8,35 +8,38 @@ namespace Signal_Generator { class FmSignal : IAnalogSignal { - private double ampl = 0; - private double freq = 0; - private IAnalogSignal modSignal; + public Dictionary paramsDict { get; set; } - public string ParamsToString + public string typeToString { get { - return this.ToString() + - " | А = " + ampl + - " | f = " + freq; + return "FM сигнал"; } } - public override string ToString() + public string paramsToString { - return "FM signal"; + get + { + string result = ""; + foreach (KeyValuePair pair in paramsDict) + result += " / " + pair.Key + " " + pair.Value; + return result; + } } - public FmSignal(double ampl, double freq, IAnalogSignal modSignal) + public FmSignal(double ampl, double freq, double ampl2) { - this.ampl = ampl; - this.freq = freq; - this.modSignal = modSignal; + paramsDict = new Dictionary(); + paramsDict.Add("Амплитуда несущей", ampl); + paramsDict.Add("Частота несущей", freq); + paramsDict.Add("Амплитуда", ampl); } public double currentAmplitude(double t) { - return ampl * Math.Sin(2 * Math.PI * freq * t + modSignal.currentAmplitude(t)); + return paramsDict.ElementAt(0).Value * Math.Sin(2 * Math.PI * paramsDict.ElementAt(1).Value * t + paramsDict.ElementAt(1).Value * Math.Sin(t)); } } } diff --git a/Signal Generator/IAnalogSignalModel.cs b/Signal Generator/IAnalogSignal.cs similarity index 63% rename from Signal Generator/IAnalogSignalModel.cs rename to Signal Generator/IAnalogSignal.cs index aec1757..ee276ea 100644 --- a/Signal Generator/IAnalogSignalModel.cs +++ b/Signal Generator/IAnalogSignal.cs @@ -8,7 +8,9 @@ namespace Signal_Generator { interface IAnalogSignal { - string ParamsToString { get; } + string typeToString { get; } + string paramsToString { get; } double currentAmplitude(double t); + Dictionary paramsDict { get; set; } } } diff --git a/Signal Generator/MainWindow.xaml b/Signal Generator/MainWindow.xaml index 2b137af..25f5040 100644 --- a/Signal Generator/MainWindow.xaml +++ b/Signal Generator/MainWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Signal_Generator" mc:Ignorable="d" - Title="MainWindow" Height="450" Width="489"> + Title="Signal Generator" Height="450" Width="489"> - + + + + + + + + - +