Никита
6 years ago
10 changed files with 100 additions and 50 deletions
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Signal_Generator |
||||
|
{ |
||||
|
class AnalogSignalMethods |
||||
|
{ |
||||
|
internal string paramsToString(Collection<Parameter> paramsCollection) |
||||
|
{ |
||||
|
string result = ""; |
||||
|
foreach (Parameter p in paramsCollection) |
||||
|
result += " / " + p.name + " " + p.value; |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,45 +1,38 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Text; |
using System.Text; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
|
||||
namespace Signal_Generator |
namespace Signal_Generator |
||||
{ |
{ |
||||
class FmSignal : IAnalogSignal |
class FmSignal : AnalogSignalMethods, IAnalogSignal |
||||
{ |
{ |
||||
public Dictionary<string, double> paramsDict { get; set; } |
public Collection<Parameter> paramsCollection { get; set; } |
||||
|
|
||||
public string typeToString |
public string typeToString |
||||
{ |
{ |
||||
get |
get { return "FM сигнал"; } |
||||
{ |
|
||||
return "FM сигнал"; |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
public string paramsToString |
public new string paramsToString |
||||
{ |
{ |
||||
get |
get { return paramsToString(paramsCollection); } |
||||
{ |
|
||||
string result = ""; |
|
||||
foreach (KeyValuePair<string, double> pair in paramsDict) |
|
||||
result += " / " + pair.Key + " " + pair.Value; |
|
||||
return result; |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
public FmSignal(double ampl, double freq, double ampl2) |
public FmSignal(double ampl, double freq, double ampl2) |
||||
{ |
{ |
||||
paramsDict = new Dictionary<string, double>(); |
paramsCollection = new Collection<Parameter>(); |
||||
paramsDict.Add("Амплитуда несущей", ampl); |
paramsCollection.Add(new Parameter("Амплитуда несущей", ampl)); |
||||
paramsDict.Add("Частота несущей", freq); |
paramsCollection.Add(new Parameter("Частота несущей", freq)); |
||||
paramsDict.Add("Амплитуда", ampl); |
paramsCollection.Add(new Parameter("Амплитуда", ampl2)); |
||||
} |
} |
||||
|
|
||||
public double currentAmplitude(double t) |
public double currentAmplitude(double t) |
||||
{ |
{ |
||||
return paramsDict.ElementAt(0).Value * Math.Sin(2 * Math.PI * paramsDict.ElementAt(1).Value * t + paramsDict.ElementAt(1).Value * Math.Sin(t)); |
var c = paramsCollection.ToArray<Parameter>(); |
||||
|
return c[0].value * Math.Sin(2 * Math.PI * c[1].value* t + c[2].value * Math.Sin(t)); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Signal_Generator |
||||
|
{ |
||||
|
class Parameter |
||||
|
{ |
||||
|
public string name { get; set; } |
||||
|
public double value { get; set; } |
||||
|
|
||||
|
public Parameter (string name, double value) |
||||
|
{ |
||||
|
this.name = name; |
||||
|
this.value = value; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,50 +1,38 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Text; |
using System.Text; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
|
||||
namespace Signal_Generator |
namespace Signal_Generator |
||||
{ |
{ |
||||
class SinusoidalSignal : IAnalogSignal |
class SinusoidalSignal : AnalogSignalMethods, IAnalogSignal |
||||
{ |
{ |
||||
public string typeToString |
public string typeToString |
||||
{ |
{ |
||||
get |
get { return "SIN сигнал"; } |
||||
{ |
|
||||
return "SIN сигнал"; |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
public string paramsToString |
public new string paramsToString |
||||
{ |
{ |
||||
get |
get { return paramsToString(paramsCollection); } |
||||
{ |
|
||||
string result = ""; |
|
||||
foreach (KeyValuePair<string, double> pair in paramsDict) |
|
||||
result += " / " + pair.Key + " " + pair.Value; |
|
||||
return result; |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
public Dictionary<String, Double> paramsDict { get; set; } |
public Collection<Parameter> paramsCollection { get; set; } |
||||
|
|
||||
public override string ToString() |
|
||||
{ |
|
||||
return "SIN signal"; |
|
||||
} |
|
||||
|
|
||||
public SinusoidalSignal(double ampl, double freq, double phase = 0) |
public SinusoidalSignal(double ampl, double freq, double phase = 0) |
||||
{ |
{ |
||||
paramsDict = new Dictionary<string, double>(); |
paramsCollection = new Collection<Parameter>(); |
||||
paramsDict.Add("Амплитуда", ampl); |
paramsCollection.Add(new Parameter("Амплитуда", ampl)); |
||||
paramsDict.Add("Частота", freq); |
paramsCollection.Add(new Parameter("Частота", freq)); |
||||
paramsDict.Add("Фаза", phase); |
paramsCollection.Add(new Parameter("Фаза", phase)); |
||||
} |
} |
||||
|
|
||||
public double currentAmplitude(double t) |
public double currentAmplitude(double t) |
||||
{ |
{ |
||||
return paramsDict.ElementAt(0).Value * Math.Sin(2 * Math.PI * paramsDict.ElementAt(1).Value * t + paramsDict.ElementAt(2).Value); |
var c = paramsCollection.ToArray<Parameter>(); |
||||
|
return c[0].value * Math.Sin(2 * Math.PI * c[1].value * t + c[2].value); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue