From 10f384088094f0a40703b9bbfff62845f2283578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Thu, 8 Nov 2018 01:12:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=207=20=D0=B4=D0=BD=D0=B5=D0=B9.=20=D0=9C=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Signal Generator/FmSignal.cs | 31 ++++++++++--------- ...IAnalogSignalModel.cs => IAnalogSignal.cs} | 4 ++- Signal Generator/MainWindow.xaml | 17 +++++++--- Signal Generator/MainWindow.xaml.cs | 18 ++++++----- Signal Generator/MultiSignal.cs | 9 +++++- Signal Generator/Signal Generator.csproj | 2 +- Signal Generator/SinusoidalSignal.cs | 31 ++++++++++++------- 7 files changed, 71 insertions(+), 41 deletions(-) rename Signal Generator/{IAnalogSignalModel.cs => IAnalogSignal.cs} (63%) 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"> - + + + + + + + + - +