Browse Source

Первый коммит

master
Никита 6 years ago
parent
commit
f4c4584d2b
  1. 12
      Signal Generator/AddSignalWindow.xaml
  2. 27
      Signal Generator/AddSignalWindow.xaml.cs
  3. 2
      Signal Generator/App.config
  4. 1
      Signal Generator/App.xaml.cs
  5. 42
      Signal Generator/FmSignal.cs
  6. 14
      Signal Generator/IAnalogSignalModel.cs
  7. 24
      Signal Generator/MainWindow.xaml
  8. 13
      Signal Generator/MainWindow.xaml.cs
  9. 39
      Signal Generator/MultiSignal.cs
  10. 28
      Signal Generator/Settings.cs
  11. 19
      Signal Generator/Signal Generator.csproj
  12. 43
      Signal Generator/SinusoidalSignal.cs
  13. 28
      Signal Generator/TaskWindow.xaml
  14. 27
      Signal Generator/TaskWindow.xaml.cs

12
Signal Generator/AddSignalWindow.xaml

@ -0,0 +1,12 @@
<Window x:Class="Signal_Generator.AddSignalWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Signal_Generator"
mc:Ignorable="d"
Title="AddSignalWindow" Height="200" Width="400">
<Grid>
</Grid>
</Window>

27
Signal Generator/AddSignalWindow.xaml.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Signal_Generator
{
/// <summary>
/// Логика взаимодействия для AddSignalWindow.xaml
/// </summary>
public partial class AddSignalWindow : Window
{
public AddSignalWindow()
{
InitializeComponent();
}
}
}

2
Signal Generator/App.config

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>

1
Signal Generator/App.xaml.cs

@ -13,5 +13,6 @@ namespace Signal_Generator
/// </summary>
public partial class App : Application
{
}
}

42
Signal Generator/FmSignal.cs

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Signal_Generator
{
class FmSignal : IAnalogSignal
{
private double ampl = 0;
private double freq = 0;
private IAnalogSignal modSignal;
public string ParamsToString
{
get
{
return this.ToString() +
" | А = " + ampl +
" | f = " + freq;
}
}
public override string ToString()
{
return "FM signal";
}
public FmSignal(double ampl, double freq, IAnalogSignal modSignal)
{
this.ampl = ampl;
this.freq = freq;
this.modSignal = modSignal;
}
public double currentAmplitude(double t)
{
return ampl * Math.Sin(2 * Math.PI * freq * t + modSignal.currentAmplitude(t));
}
}
}

14
Signal Generator/IAnalogSignalModel.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Signal_Generator
{
interface IAnalogSignal
{
string ParamsToString { get; }
double currentAmplitude(double t);
}
}

24
Signal Generator/MainWindow.xaml

@ -5,8 +5,28 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Signal_Generator"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="MainWindow" Height="450" Width="489">
<Grid>
<DockPanel LastChildFill="True" Margin="10,10,10,10">
<ListBox x:Name="signals_ListBox" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
DockPanel.Dock="Top" ItemsSource="{Binding}" Margin="0,0,0,20">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=ParamsToString}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
<DockPanel x:Name="buttons_DockPanel" IsEnabled="False" Margin="10,0,10,10" VerticalAlignment="Bottom">
<DockPanel DockPanel.Dock="Left">
<Button x:Name="startProcedure_Button" Width="120" Content="Запустить процедуру" />
</DockPanel>
<DockPanel HorizontalAlignment="Right">
<Button x:Name="addSignal_Button" Width="20" Content="+"/>
<Button x:Name="removeSignal_Button" Width="20" Content="-" />
</DockPanel>
</DockPanel>
</Grid>
</Window>

13
Signal Generator/MainWindow.xaml.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -23,6 +24,18 @@ namespace Signal_Generator
public MainWindow()
{
InitializeComponent();
addSomeExtra();
}
private void addSomeExtra()
{
// test of signals_ListBox
SinusoidalSignal s1 = new SinusoidalSignal(1, 50);
SinusoidalSignal s2 = new SinusoidalSignal(3, 120);
ObservableCollection<IAnalogSignal> s = new ObservableCollection<IAnalogSignal>();
s.Add(s1);
signals_ListBox.Items.Clear();
signals_ListBox.ItemsSource = s;
}
}
}

39
Signal Generator/MultiSignal.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Signal_Generator
{
class MultiSignal : IAnalogSignal
{
private List<IAnalogSignal> signals { get; set; }
public string ParamsToString { get; set; }
public MultiSignal()
{
signals = new List<IAnalogSignal>();
}
public void add(IAnalogSignal signal)
{
signals.Add(signal);
}
public void remove(IAnalogSignal signal)
{
signals.Remove(signal);
}
public double currentAmplitude(double t)
{
double summaryAmplitude = 0;
foreach (IAnalogSignal item in signals)
{
summaryAmplitude += item.currentAmplitude(t);
}
return summaryAmplitude;
}
}
}

28
Signal Generator/Settings.cs

@ -0,0 +1,28 @@
namespace Signal_Generator.Properties {
// Этот класс позволяет обрабатывать определенные события в классе параметров:
// Событие SettingChanging возникает перед изменением значения параметра.
// Событие PropertyChanged возникает после изменения значения параметра.
// Событие SettingsLoaded возникает после загрузки значений параметров.
// Событие SettingsSaving возникает перед сохранением значений параметров.
internal sealed partial class Settings {
public Settings() {
// // Для добавления обработчиков событий для сохранения и изменения параметров раскомментируйте приведенные ниже строки:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Добавьте здесь код для обработки события SettingChangingEvent.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Добавьте здесь код для обработки события SettingsSaving.
}
}
}

19
Signal Generator/Signal Generator.csproj

@ -55,6 +55,19 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddSignalWindow.xaml.cs">
<DependentUpon>AddSignalWindow.xaml</DependentUpon>
</Compile>
<Compile Include="FmSignal.cs" />
<Compile Include="Settings.cs" />
<Compile Include="SinusoidalSignal.cs" />
<Compile Include="TaskWindow.xaml.cs">
<DependentUpon>TaskWindow.xaml</DependentUpon>
</Compile>
<Page Include="AddSignalWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -63,12 +76,18 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="IAnalogSignalModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TaskWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MultiSignal.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>

43
Signal Generator/SinusoidalSignal.cs

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Signal_Generator
{
class SinusoidalSignal : IAnalogSignal
{
private double ampl = 0;
private double freq = 0;
private double phase = 0;
public string ParamsToString
{
get
{
return this.ToString() +
" | A = " + ampl +
" | f = " + freq +
" | phi = " + phase;
}
}
public override string ToString()
{
return "SIN signal";
}
public SinusoidalSignal(double ampl, double freq, double phase = 0)
{
this.ampl = ampl;
this.freq = freq;
this.phase = phase;
}
public double currentAmplitude(double t)
{
return ampl * Math.Sin(2 * Math.PI * freq * t + phase);
}
}
}

28
Signal Generator/TaskWindow.xaml

@ -0,0 +1,28 @@
<Window x:Class="Signal_Generator.TaskWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Signal_Generator"
mc:Ignorable="d"
Title="TaskWindow" Height="127" Width="284"
ResizeMode="NoResize">
<Grid>
<DockPanel VerticalAlignment="Top" Margin="10,10,10,0">
<DockPanel>
<TextBlock x:Name="currentTime_TextBlock" TextWrapping="Wrap" DockPanel.Dock="Top" Height="18">
Время выполения:
</TextBlock>
<TextBlock x:Name="currentAmplitude_TextBlock" TextWrapping="Wrap">
Текущий сигнал:
</TextBlock>
</DockPanel>
<TextBox x:Name="currentTime_TextBox" TextWrapping="Wrap" DockPanel.Dock="Top"/>
<TextBox x:Name="currentAmplitude_TextBox" TextWrapping="Wrap" DockPanel.Dock="Top"/>
<DockPanel HorizontalAlignment="Center">
<Button x:Name="start_Button" Width="60" Content="Старт" Margin="5,0"/>
<Button x:Name="pause_Button" Width="60" Content="Пауза" Margin="5,0"/>
</DockPanel>
</DockPanel>
</Grid>
</Window>

27
Signal Generator/TaskWindow.xaml.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Signal_Generator
{
/// <summary>
/// Логика взаимодействия для TaskWindow.xaml
/// </summary>
public partial class TaskWindow : Window
{
public TaskWindow()
{
InitializeComponent();
}
}
}
Loading…
Cancel
Save