Skip to content

Commit 07f45bd

Browse files
committed
Submit all code
1 parent 1d5efdd commit 07f45bd

File tree

102 files changed

+7474
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+7474
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vs/
2+
**/bin/Debug/
3+
**/bin/Release/
4+
**/obj/Debug/
5+
**/obj/Release/
6+
*.csproj.user

Builds/SignalVisualizer_1.0.0.zip

77.4 KB
Binary file not shown.
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using System.Diagnostics;
4+
using System.Threading;
5+
using System.Threading.Tasks;
6+
using SignalVisualizer.Contracts;
7+
8+
namespace CpuDataSourceExtension
9+
{
10+
[Export(typeof(IDataSource))]
11+
public class CpuDataSource : DataSourceBase
12+
{
13+
public override string Name { get; } = "CPU meter";
14+
public override uint Version { get; } = 1;
15+
public override Guid UniqueIdentifier { get; } = new Guid("3c77228a-f646-4ce2-836b-d68e707f68a8");
16+
public override string[] ComponentNames { get; } = new string[] { "Processor time (%)", "Idle time (%)" };
17+
18+
public override async Task Start(CancellationToken cancellationToken)
19+
{
20+
// allocates the storage for the values of the two components of the data source
21+
var values = new double[2];
22+
23+
// create performance counters
24+
var totalCpu = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
25+
var currentProcessCpu = new PerformanceCounter("Processor", "% Idle Time", "_Total", true);
26+
27+
// iterate while not cancelled
28+
while (cancellationToken.IsCancellationRequested == false)
29+
{
30+
// sample the performance counters values
31+
values[0] = totalCpu.NextValue();
32+
values[1] = currentProcessCpu.NextValue();
33+
34+
// notify SignalVisualizer that a new value has been produced
35+
NotifyNext(values);
36+
37+
// awaits to avoid burn out, then loop and restart
38+
await Task.Delay(250);
39+
}
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{0C589A68-BA92-4334-A711-E2F9E1025817}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>CpuDataSourceExtension</RootNamespace>
11+
<AssemblyName>CpuDataSourceExtension</AssemblyName>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.ComponentModel.Composition" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="CpuDataSource.cs" />
44+
<Compile Include="Properties\AssemblyInfo.cs" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<ProjectReference Include="..\SignalVisualizer.Contracts\SignalVisualizer.Contracts.csproj">
48+
<Project>{5c3c2e64-5e96-45d2-b58c-e46692699aaf}</Project>
49+
<Name>SignalVisualizer.Contracts</Name>
50+
</ProjectReference>
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<PropertyGroup>
54+
<PostBuildEvent>mkdir "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions" &amp; copy "$(TargetPath)" "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions\$(TargetFileName)"
55+
</PostBuildEvent>
56+
</PropertyGroup>
57+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyTitle("CpuDataSourceExtension")]
4+
[assembly: AssemblyDescription("")]
5+
[assembly: AssemblyProduct("CpuDataSourceExtension")]
6+
[assembly: AssemblyCopyright("Copyright © Sebastien ROBERT")]
7+
8+
[assembly: AssemblyVersion("1.0.0.0")]
28.7 KB
Loading
68.5 KB
Loading
2.94 KB
Loading

Documentation/images/data_sources.png

14.1 KB
Loading
38.2 KB
Loading
14.4 KB
Loading
Loading
Loading
14.7 KB
Loading
49 KB
Loading
9.5 KB
Loading
13.4 KB
Loading
13.7 KB
Loading
11.9 KB
Loading

Documentation/images/groups.png

14.4 KB
Loading
Loading
2.44 KB
Loading

Documentation/images/mef_assembly.png

4.84 KB
Loading

Documentation/images/new_wpf_app.png

7.35 KB
Loading

Documentation/images/signal_view.png

11 KB
Loading
8.39 KB
Loading

Documentation/images/signals.png

35.5 KB
Loading
1.86 KB
Loading
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Windows.Input;
4+
5+
namespace FourierDataSourceExtension
6+
{
7+
public abstract class ConfigurationViewModelBase
8+
{
9+
private Action configChanged;
10+
11+
protected ConfigurationViewModelBase(Action configChanged)
12+
{
13+
this.configChanged = configChanged;
14+
}
15+
16+
protected bool SetValue<T>(ref T field, T value)
17+
{
18+
if (EqualityComparer<T>.Default.Equals(field, value) == false)
19+
{
20+
field = value;
21+
configChanged();
22+
return true;
23+
}
24+
25+
return false;
26+
}
27+
}
28+
29+
public class AnonymousCommand : ICommand
30+
{
31+
private Action<object> action;
32+
33+
public event EventHandler CanExecuteChanged = delegate { };
34+
35+
public AnonymousCommand(Action<object> action)
36+
{
37+
if (action == null)
38+
throw new ArgumentNullException(nameof(action));
39+
40+
this.action = action;
41+
}
42+
43+
public bool CanExecute(object parameter)
44+
{
45+
return true;
46+
}
47+
48+
public void Execute(object parameter)
49+
{
50+
action(parameter);
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Xml;
9+
using SignalVisualizer.Contracts;
10+
11+
namespace FourierDataSourceExtension
12+
{
13+
public struct SineWaveParameters
14+
{
15+
public static readonly SineWaveParameters Identity = new SineWaveParameters(1.0, 0.0, 1.0);
16+
17+
public readonly double Amplitude;
18+
public readonly double Phase;
19+
public readonly double Frequency;
20+
21+
public SineWaveParameters(double amplitude, double phase, double frequency)
22+
{
23+
Amplitude = amplitude;
24+
Phase = phase;
25+
Frequency = frequency;
26+
}
27+
28+
public double ProduceValue(double theta)
29+
{
30+
return Amplitude * Math.Sin((theta + Phase) * Frequency);
31+
}
32+
}
33+
34+
[Export(typeof(IDataSource))]
35+
public class FourierDataSource : DataSourceBase
36+
{
37+
public override string Name { get; } = "Fourrier";
38+
public override uint Version { get; } = 1;
39+
public override Guid UniqueIdentifier { get; } = new Guid("b925976e-934f-4c73-b666-4480d514b9ca");
40+
public override string[] ComponentNames { get; } = new string[] { "Signal" };
41+
42+
private MainWindow window;
43+
44+
public FourierDataSource()
45+
{
46+
Application.Current.Dispatcher.BeginInvoke((Action)delegate
47+
{
48+
window = new MainWindow(this, OnConfigurationChanged)
49+
{
50+
Owner = Application.Current.MainWindow,
51+
WindowStartupLocation = WindowStartupLocation.CenterOwner,
52+
};
53+
54+
window.Closing += (ss, ee) =>
55+
{
56+
ee.Cancel = true;
57+
window.Visibility = Visibility.Collapsed;
58+
};
59+
});
60+
}
61+
62+
public override async Task Start(CancellationToken cancellationToken)
63+
{
64+
double value;
65+
var array = new double[1];
66+
var stopwatch = Stopwatch.StartNew();
67+
68+
while (cancellationToken.IsCancellationRequested == false)
69+
{
70+
double theta = stopwatch.ElapsedMilliseconds / 1000.0;
71+
72+
value = 0.0;
73+
foreach (SineWaveParametersViewModel vm in window.SineWaveParameters)
74+
{
75+
if (vm.IsActive)
76+
value += vm.Model.ProduceValue(theta);
77+
}
78+
79+
array[0] = value;
80+
81+
NotifyNext(array);
82+
83+
await Task.Delay(20);
84+
}
85+
}
86+
87+
private void OnConfigurationChanged()
88+
{
89+
OnConfigurationChanged(EventArgs.Empty);
90+
}
91+
92+
public override void Configure()
93+
{
94+
base.Configure();
95+
window.Visibility = Visibility.Visible;
96+
}
97+
98+
public override void Load(XmlElement element)
99+
{
100+
window.SetSineWaves(element.ChildNodes.OfType<XmlElement>());
101+
}
102+
103+
public override void Save(XmlWriter writer)
104+
{
105+
writer.WriteStartElement("parameters");
106+
foreach (SineWaveParametersViewModel vm in window.SineWaveParameters)
107+
vm.Save(writer);
108+
writer.WriteEndElement();
109+
}
110+
}
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{21EDA73C-354D-450F-99EB-F28EB5986DF2}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>FourierDataSourceExtension</RootNamespace>
10+
<AssemblyName>FourierDataSourceExtension</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<PropertyGroup>
37+
<StartupObject />
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Reference Include="System" />
41+
<Reference Include="System.ComponentModel.Composition" />
42+
<Reference Include="System.Xml" />
43+
<Reference Include="Microsoft.CSharp" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="System.Xaml">
47+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
48+
</Reference>
49+
<Reference Include="WindowsBase" />
50+
<Reference Include="PresentationCore" />
51+
<Reference Include="PresentationFramework" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="BaseTypes.cs" />
55+
<Compile Include="SineWaveParametersViewModel.cs" />
56+
<Page Include="MainWindow.xaml">
57+
<Generator>MSBuild:Compile</Generator>
58+
<SubType>Designer</SubType>
59+
</Page>
60+
<Compile Include="FourierDataSource.cs" />
61+
<Compile Include="MainWindow.xaml.cs">
62+
<DependentUpon>MainWindow.xaml</DependentUpon>
63+
<SubType>Code</SubType>
64+
</Compile>
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Include="Properties\AssemblyInfo.cs">
68+
<SubType>Code</SubType>
69+
</Compile>
70+
<Compile Include="Properties\Resources.Designer.cs">
71+
<AutoGen>True</AutoGen>
72+
<DesignTime>True</DesignTime>
73+
<DependentUpon>Resources.resx</DependentUpon>
74+
</Compile>
75+
<Compile Include="Properties\Settings.Designer.cs">
76+
<AutoGen>True</AutoGen>
77+
<DependentUpon>Settings.settings</DependentUpon>
78+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
79+
</Compile>
80+
<EmbeddedResource Include="Properties\Resources.resx">
81+
<Generator>ResXFileCodeGenerator</Generator>
82+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
83+
</EmbeddedResource>
84+
<None Include="Properties\Settings.settings">
85+
<Generator>SettingsSingleFileGenerator</Generator>
86+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
87+
</None>
88+
</ItemGroup>
89+
<ItemGroup>
90+
<ProjectReference Include="..\SignalVisualizer.Contracts\SignalVisualizer.Contracts.csproj">
91+
<Project>{5c3c2e64-5e96-45d2-b58c-e46692699aaf}</Project>
92+
<Name>SignalVisualizer.Contracts</Name>
93+
</ProjectReference>
94+
</ItemGroup>
95+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
96+
<PropertyGroup>
97+
<PostBuildEvent>mkdir "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions" &amp; copy "$(TargetPath)" "$(SolutionDir)$(SolutionName)\$(OutDir)Extensions\$(TargetFileName)"
98+
</PostBuildEvent>
99+
</PropertyGroup>
100+
</Project>

0 commit comments

Comments
 (0)