Skip to content

Commit

Permalink
Submit all code
Browse files Browse the repository at this point in the history
  • Loading branch information
TanukiSharp committed Sep 17, 2017
1 parent 1d5efdd commit 07f45bd
Show file tree
Hide file tree
Showing 102 changed files with 7,474 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vs/
**/bin/Debug/
**/bin/Release/
**/obj/Debug/
**/obj/Release/
*.csproj.user
Binary file added Builds/SignalVisualizer_1.0.0.zip
Binary file not shown.
42 changes: 42 additions & 0 deletions CpuDataSourceExtension/CpuDataSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using SignalVisualizer.Contracts;

namespace CpuDataSourceExtension
{
[Export(typeof(IDataSource))]
public class CpuDataSource : DataSourceBase
{
public override string Name { get; } = "CPU meter";
public override uint Version { get; } = 1;
public override Guid UniqueIdentifier { get; } = new Guid("3c77228a-f646-4ce2-836b-d68e707f68a8");
public override string[] ComponentNames { get; } = new string[] { "Processor time (%)", "Idle time (%)" };

public override async Task Start(CancellationToken cancellationToken)
{
// allocates the storage for the values of the two components of the data source
var values = new double[2];

// create performance counters
var totalCpu = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
var currentProcessCpu = new PerformanceCounter("Processor", "% Idle Time", "_Total", true);

// iterate while not cancelled
while (cancellationToken.IsCancellationRequested == false)
{
// sample the performance counters values
values[0] = totalCpu.NextValue();
values[1] = currentProcessCpu.NextValue();

// notify SignalVisualizer that a new value has been produced
NotifyNext(values);

// awaits to avoid burn out, then loop and restart
await Task.Delay(250);
}
}
}
}
57 changes: 57 additions & 0 deletions CpuDataSourceExtension/CpuDataSourceExtension.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0C589A68-BA92-4334-A711-E2F9E1025817}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CpuDataSourceExtension</RootNamespace>
<AssemblyName>CpuDataSourceExtension</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CpuDataSource.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SignalVisualizer.Contracts\SignalVisualizer.Contracts.csproj">
<Project>{5c3c2e64-5e96-45d2-b58c-e46692699aaf}</Project>
<Name>SignalVisualizer.Contracts</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions" &amp; copy "$(TargetPath)" "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions\$(TargetFileName)"
</PostBuildEvent>
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions CpuDataSourceExtension/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Reflection;

[assembly: AssemblyTitle("CpuDataSourceExtension")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyProduct("CpuDataSourceExtension")]
[assembly: AssemblyCopyright("Copyright © Sebastien ROBERT")]

[assembly: AssemblyVersion("1.0.0.0")]
Binary file added Documentation/images/add_signal_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/app_with_three_signals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/change_wpf_project_type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/data_sources.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/filtered_signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/filters_pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_sawtooth_signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_signals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_square_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_square_signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_triangle_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/fourier_triangle_signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/low_pass_filter_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/mef_assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/new_wpf_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/signal_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/signal_view_actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/signals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/images/wpf_as_library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions FourierDataSourceExtension/BaseTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Windows.Input;

namespace FourierDataSourceExtension
{
public abstract class ConfigurationViewModelBase
{
private Action configChanged;

protected ConfigurationViewModelBase(Action configChanged)
{
this.configChanged = configChanged;
}

protected bool SetValue<T>(ref T field, T value)
{
if (EqualityComparer<T>.Default.Equals(field, value) == false)
{
field = value;
configChanged();
return true;
}

return false;
}
}

public class AnonymousCommand : ICommand
{
private Action<object> action;

public event EventHandler CanExecuteChanged = delegate { };

public AnonymousCommand(Action<object> action)
{
if (action == null)
throw new ArgumentNullException(nameof(action));

this.action = action;
}

public bool CanExecute(object parameter)
{
return true;
}

public void Execute(object parameter)
{
action(parameter);
}
}
}
111 changes: 111 additions & 0 deletions FourierDataSourceExtension/FourierDataSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Xml;
using SignalVisualizer.Contracts;

namespace FourierDataSourceExtension
{
public struct SineWaveParameters
{
public static readonly SineWaveParameters Identity = new SineWaveParameters(1.0, 0.0, 1.0);

public readonly double Amplitude;
public readonly double Phase;
public readonly double Frequency;

public SineWaveParameters(double amplitude, double phase, double frequency)
{
Amplitude = amplitude;
Phase = phase;
Frequency = frequency;
}

public double ProduceValue(double theta)
{
return Amplitude * Math.Sin((theta + Phase) * Frequency);
}
}

[Export(typeof(IDataSource))]
public class FourierDataSource : DataSourceBase
{
public override string Name { get; } = "Fourrier";
public override uint Version { get; } = 1;
public override Guid UniqueIdentifier { get; } = new Guid("b925976e-934f-4c73-b666-4480d514b9ca");
public override string[] ComponentNames { get; } = new string[] { "Signal" };

private MainWindow window;

public FourierDataSource()
{
Application.Current.Dispatcher.BeginInvoke((Action)delegate
{
window = new MainWindow(this, OnConfigurationChanged)
{
Owner = Application.Current.MainWindow,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};

window.Closing += (ss, ee) =>
{
ee.Cancel = true;
window.Visibility = Visibility.Collapsed;
};
});
}

public override async Task Start(CancellationToken cancellationToken)
{
double value;
var array = new double[1];
var stopwatch = Stopwatch.StartNew();

while (cancellationToken.IsCancellationRequested == false)
{
double theta = stopwatch.ElapsedMilliseconds / 1000.0;

value = 0.0;
foreach (SineWaveParametersViewModel vm in window.SineWaveParameters)
{
if (vm.IsActive)
value += vm.Model.ProduceValue(theta);
}

array[0] = value;

NotifyNext(array);

await Task.Delay(20);
}
}

private void OnConfigurationChanged()
{
OnConfigurationChanged(EventArgs.Empty);
}

public override void Configure()
{
base.Configure();
window.Visibility = Visibility.Visible;
}

public override void Load(XmlElement element)
{
window.SetSineWaves(element.ChildNodes.OfType<XmlElement>());
}

public override void Save(XmlWriter writer)
{
writer.WriteStartElement("parameters");
foreach (SineWaveParametersViewModel vm in window.SineWaveParameters)
vm.Save(writer);
writer.WriteEndElement();
}
}
}
100 changes: 100 additions & 0 deletions FourierDataSourceExtension/FourierDataSourceExtension.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{21EDA73C-354D-450F-99EB-F28EB5986DF2}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>FourierDataSourceExtension</RootNamespace>
<AssemblyName>FourierDataSourceExtension</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseTypes.cs" />
<Compile Include="SineWaveParametersViewModel.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="FourierDataSource.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SignalVisualizer.Contracts\SignalVisualizer.Contracts.csproj">
<Project>{5c3c2e64-5e96-45d2-b58c-e46692699aaf}</Project>
<Name>SignalVisualizer.Contracts</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions" &amp; copy "$(TargetPath)" "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions\$(TargetFileName)"
</PostBuildEvent>
</PropertyGroup>
</Project>
Loading

0 comments on commit 07f45bd

Please sign in to comment.