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