Skip to content

Adding a bunch of tests to see if Interface is complete #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 87 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
facc68b
Show up existing wires in tree
tomwendel Sep 22, 2020
661730e
Add more methods and events to the IRuntime interface
tomwendel Sep 22, 2020
f535f0b
Make connectors typed (not ready yet)
tomwendel Sep 22, 2020
94e4a5e
Start tests for InputConnector
tomwendel Sep 22, 2020
905c7a8
WPF Cleanup
tomwendel Sep 22, 2020
6b30277
Renamed RestGetNode file according to the class name
tomwendel Sep 22, 2020
459ad14
Make ContentType able to verify supported type
tomwendel Sep 24, 2020
73b1ae4
Allow ContentType to normalize input value
tomwendel Sep 24, 2020
eba6f8c
Make message equatable
tomwendel Sep 24, 2020
8050bfe
correction of access modificators in content types
tomwendel Sep 24, 2020
bd00ddf
Handle type split on a more common way
tomwendel Sep 24, 2020
5930633
Adding specific handler for string and binary in the input connector …
tomwendel Sep 24, 2020
227965d
Implement special send methods for sting and binary
tomwendel Sep 24, 2020
b1b9f9e
Special handling for string in connectors
tomwendel Sep 25, 2020
3207242
Added content type for binary content
tomwendel Sep 25, 2020
7a60885
Restructure handler management within input connector
tomwendel Sep 25, 2020
0776062
Implement content types of special implementations (string and binary)
tomwendel Sep 25, 2020
948a6fe
Fixed bug in internalSend (discovered by TheBlubb)
tomwendel Sep 25, 2020
a34e0fb
Handle internal exceptions and log them instead of breaking the messa…
tomwendel Sep 25, 2020
7f831d8
Added a bunch of test classes
tomwendel Sep 25, 2020
0a7cf2c
Add seralization attributes
tomwendel Sep 25, 2020
fe572ac
Test and fixed output connector
tomwendel Sep 25, 2020
c957636
Added a bunch of patch tests
tomwendel Sep 26, 2020
99e7847
Remove the AddNode method with configuration parameter
tomwendel Sep 26, 2020
d5e8eb8
Removed async on internalAddNode since this does not call any lifecyc…
tomwendel Sep 26, 2020
957d14d
Removed MidiFilter
tomwendel Sep 26, 2020
af6b2ce
Added Getter for known adapter descriptions
tomwendel Sep 26, 2020
6632a97
Fixed visibility of property boxes with converters
tomwendel Sep 26, 2020
5bd66c5
Replaced specific midi output by type specific input and output nodes
tomwendel Sep 26, 2020
1c16d1e
do typed registration
tomwendel Sep 26, 2020
65bca22
Make sure to push back new name of nodes into tree
tomwendel Sep 26, 2020
14cf237
Fixed bug of duplicate nodes (on attached, splitter, collector)
tomwendel Oct 6, 2020
444f56c
Added Config view and model for attached midi nodes
tomwendel Oct 6, 2020
918acac
Add settings for attached midi nodes to the template selector
tomwendel Oct 6, 2020
0fb764b
Involve midi attached node settings to the selector
tomwendel Oct 6, 2020
1e3e17b
involve attached midi nodes to VM
tomwendel Oct 6, 2020
f87f98e
Fully implement attached MIDI outputs
tomwendel Oct 6, 2020
a111de2
Final implementation of MIDI Attached notes
tomwendel Oct 6, 2020
f62174d
Corrected message types
tomwendel Oct 6, 2020
37debd2
Correction of node names since classes are renamed
tomwendel Oct 6, 2020
f27f9f8
Reorder message types
tomwendel Oct 6, 2020
bdc9f65
Finetune attached midi nodes
tomwendel Oct 6, 2020
933e103
Added supported type to the content type
tomwendel Oct 6, 2020
cc166c9
Removed unused create methods
tomwendel Oct 6, 2020
ad0f785
Fix nodes by using type for connectors
TheBlubb14 Oct 8, 2020
13d590d
Clean up GlobalKeyboardHook, Add keyboard char and string(unicode) ou…
TheBlubb14 Oct 8, 2020
5861ca3
Moved classes into own file
TheBlubb14 Oct 8, 2020
19c0a1a
Merged keyboard char node together with keyboard string node
TheBlubb14 Oct 9, 2020
24131b1
Prevent null ref
tomwendel Oct 9, 2020
9159d26
Fixed stuff which was marked as bug or code smell
tomwendel Oct 9, 2020
652cf9c
Start to define adapter settings in the ui
tomwendel Oct 9, 2020
949fe83
Manage wires
tomwendel Oct 9, 2020
416317b
Implement Load and Save to grid configurations
tomwendel Oct 10, 2020
18f74ca
Added ConfigurationMap to wire up key -> model -> view automatically
tomwendel Oct 12, 2020
ebe1e46
Decorate existing views with the new configuration map attribute
tomwendel Oct 12, 2020
991e130
Simplify configuration model
tomwendel Oct 12, 2020
c963ebe
Replaced hard wired NodeTemplateSelector with ConfigurationMap
tomwendel Oct 12, 2020
a5a4ea1
Added position information directly into AddNode call
tomwendel Oct 12, 2020
0c5a15f
Start declaration of a proper adapter
tomwendel Oct 12, 2020
de674d4
Create adapter infrastructure
tomwendel Oct 12, 2020
abc1509
more details of adapters
tomwendel Oct 12, 2020
9cdef01
Add a call to list up supported adapters
tomwendel Oct 12, 2020
d93f3d3
Created a sinus generator for testing purposes
tomwendel Oct 12, 2020
90a16be
proper disposing of wire and adapter
tomwendel Oct 12, 2020
fd0561b
Minor fixes
tomwendel Oct 13, 2020
1210093
Merge branch 'work/FinetuneIRuntime' into pr/45
tomwendel Oct 13, 2020
edec63d
Merge pull request #45 from TheBlubb14/feature/Keyboard
tomwendel Oct 13, 2020
63a8fab
Apply new configuration mapping concept on merged items
tomwendel Oct 13, 2020
f0f49a8
Store wire instead of connectors to the adapter to have clear relatio…
tomwendel Oct 13, 2020
cc5004a
Introduced PassAdapter as the default behavior for wires
tomwendel Oct 13, 2020
2aecaab
Turn around input/output naming in wire
tomwendel Oct 13, 2020
f2c710b
Added a whole bunch of new tests for Patch
tomwendel Oct 13, 2020
a7ecbc6
Added another test projekt for octoPatch.Server stuff
tomwendel Oct 13, 2020
9c89772
Fixed last occation of inverting input/output naming
tomwendel Oct 14, 2020
2aeeb3b
Handle also configuration = null
tomwendel Oct 14, 2020
8d9b098
Added float input to the console to have better type convertion scena…
tomwendel Oct 14, 2020
d737b54
Introduced importer and exporter in adapters to unify data handling
tomwendel Oct 14, 2020
626b8a9
Apply adapter changes and finish linear transformation adapter
tomwendel Oct 14, 2020
ea65497
Draft of a typed output registration
tomwendel Oct 14, 2020
5f4877d
Draft for typed input handler
tomwendel Oct 14, 2020
bd3c0e8
Replaced Register calls by new stuff
tomwendel Oct 14, 2020
3185cc6
Typed handlers for Input and output connectors
tomwendel Oct 22, 2020
c6f923d
Add a new runtime view (visual drag/drop editor)
tomwendel Oct 22, 2020
86dce95
GetConfiguration instead of Environment
TheBlubb14 Oct 24, 2020
d0b1ba3
Merge pull request #46 from TheBlubb14/fix/FinetuneIRuntime-/ApplyCon…
tomwendel Oct 27, 2020
86bfae8
Replace simple rectangle by a full node view control
tomwendel Oct 27, 2020
8e12275
Include a simple control for connectors
tomwendel Oct 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions OctoPatch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OctoPatch.Plugin.Keyboard",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OctoPatch.Plugin.Rest", "src\Plugins\OctoPatch.Plugin.Rest\OctoPatch.Plugin.Rest.csproj", "{35E27930-07AA-4AE2-999E-E6BBE4B71DFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OctoPatch.Server.Test", "test\OctoPatch.Server.Test\OctoPatch.Server.Test.csproj", "{91546803-665C-4CC1-B849-8498947F5186}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -81,6 +83,10 @@ Global
{35E27930-07AA-4AE2-999E-E6BBE4B71DFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35E27930-07AA-4AE2-999E-E6BBE4B71DFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35E27930-07AA-4AE2-999E-E6BBE4B71DFB}.Release|Any CPU.Build.0 = Release|Any CPU
{91546803-665C-4CC1-B849-8498947F5186}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91546803-665C-4CC1-B849-8498947F5186}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91546803-665C-4CC1-B849-8498947F5186}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91546803-665C-4CC1-B849-8498947F5186}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -93,6 +99,7 @@ Global
{DBA37B79-AF44-4C21-8BD6-B7704BD339F5} = {FA7B21A1-3ADA-4C35-BF59-100BFD2A689D}
{DD956A0D-1556-4CCA-B1F3-4010D0F0F8F3} = {826BC5FD-CEF2-466A-88E5-55489BDAD44B}
{35E27930-07AA-4AE2-999E-E6BBE4B71DFB} = {826BC5FD-CEF2-466A-88E5-55489BDAD44B}
{91546803-665C-4CC1-B849-8498947F5186} = {FA7B21A1-3ADA-4C35-BF59-100BFD2A689D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8F9B99B3-F5BE-4428-9751-1CC99FA5761B}
Expand Down
115 changes: 115 additions & 0 deletions src/Applications/OctoPatch.DesktopClient/ConfigurationMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OctoPatch.DesktopClient.Models;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;

namespace OctoPatch.DesktopClient
{
/// <summary>
/// Central place to map configuration setup (node/adapter key to configuration model and configuration view)
/// </summary>
public sealed class ConfigurationMap
{
/// <summary>
/// Holds the current map
/// </summary>
private static readonly List<MapEntry> Map = new List<MapEntry>();

/// <summary>
/// Constructor scans for existing configuration map attributes within the current app domain
/// </summary>
static ConfigurationMap()
{
// Scan all referenced assemblies
foreach (var assemblies in AppDomain.CurrentDomain.GetAssemblies())
{
try
{
// Scan all types
foreach (var type in assemblies.GetTypes())
{
// Scan all existing attributes
foreach (var attribute in type.GetCustomAttributes<ConfigurationMapAttribute>())
{
Map.Add(new MapEntry(attribute.Key, attribute.ModelType, type));
}
}
}
catch (Exception)
{
// Some assemblies are not allowed to be reflected...?
}
}
}

/// <summary>
/// Returns a new instance of the configuration model fitting to the given key or null, when no key is registered
/// </summary>
/// <param name="key">node key</param>
/// <returns>new model instance</returns>
public static ConfigurationModel GetConfigurationModel(string key)
{
var entry = Map.FirstOrDefault(e => string.Equals(e.Key, key, StringComparison.InvariantCultureIgnoreCase));
return entry == null ? null : (ConfigurationModel)Activator.CreateInstance(entry.ModelType);
}

public static UserControl GetConfigurationView(ConfigurationModel model)
{
if (model == null)
{
return null;
}

var entry = Map.FirstOrDefault(e => e.ModelType == model.GetType());
if (entry == null)
{
return null;
}

var control = (UserControl) Activator.CreateInstance(entry.ViewType);

// Set data context if possible
if (control != null)
{
control.DataContext = model;
}

return control;
}

#region nested types

/// <summary>
/// Local container to store a map entry
/// </summary>
private class MapEntry
{
/// <summary>
/// Gets the type of the data model
/// </summary>
public Type ModelType { get; }

/// <summary>
/// Gets the type of the view
/// </summary>
public Type ViewType { get; }

/// <summary>
/// Gets the key of the node or adapter
/// </summary>
public string Key { get; }

public MapEntry(string key, Type modelType, Type viewType)
{
Key = key;
ModelType = modelType;
ViewType = viewType;
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace OctoPatch.DesktopClient
{
/// <summary>
/// Attribute to decorate the configuration view with
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class ConfigurationMapAttribute : Attribute
{
/// <summary>
/// Gets the key string for the node or adapter
/// </summary>
public string Key { get; }

/// <summary>
/// Gets the model type which handles the node or adapter settings
/// </summary>
public Type ModelType { get; }

public ConfigurationMapAttribute(string key, Type modelType)
{
Key = key;
ModelType = modelType;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace OctoPatch.DesktopClient.Converters
{
/// <summary>
/// Checks if the given value is within the range
/// </summary>
[ValueConversion(typeof(int), typeof(Visibility))]
public sealed class InRangeToVisibilityConverter : IValueConverter
{
/// <summary>
/// Minimum value
/// </summary>
public int MinValue { get; set; }

/// <summary>
/// Maximum value
/// </summary>
public int MaxValue { get; set; }

public InRangeToVisibilityConverter()
{
MinValue = int.MinValue;
MaxValue = int.MaxValue;
}


public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is int input))
{
return Visibility.Collapsed;
}

return input >= MinValue && input <= MaxValue ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,87 @@

namespace OctoPatch.DesktopClient.Converters
{
/// <summary>
/// Converts selected tree node type into visibility
/// </summary>
[ValueConversion(typeof(NodeModel), typeof(Visibility))]
class NodeToVisibilityConverter : IValueConverter
{
/// <summary>
/// show up when common node is selected
/// </summary>
public bool CommonNode { get; set; }

/// <summary>
/// show up when attached node is selected
/// </summary>
public bool AttachedNode { get; set; }

/// <summary>
/// show up when splitter node is selected
/// </summary>
public bool SplitterNode { get; set; }

/// <summary>
/// show up when collector node is selected
/// </summary>
public bool CollectorNode { get; set; }

/// <summary>
/// show up when input connector is selected
/// </summary>
public bool InputConnector { get; set; }

/// <summary>
/// show up when output connector is selected
/// </summary>
public bool OutputConnector { get; set; }

/// <summary>
/// show up when wire is selected
/// </summary>
public bool Wire { get; set; }

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is CommonNodeModel || value is AttachedNodeModel || value is SplitterNodeModel || value is CollectorNodeModel ? Visibility.Visible : Visibility.Collapsed;
var visible = false;

if (CommonNode && value is CommonNodeModel)
{
visible = true;
}

if (AttachedNode && value is AttachedNodeModel)
{
visible = true;
}

if (SplitterNode && value is SplitterNodeModel)
{
visible = true;
}

if (CollectorNode && value is CollectorNodeModel)
{
visible = true;
}

if (InputConnector && value is InputNodeModel)
{
visible = true;
}

if (OutputConnector && value is OutputNodeModel)
{
visible = true;
}

if (Wire && value is WireNodeModel)
{
visible = true;
}

return visible ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
4 changes: 1 addition & 3 deletions src/Applications/OctoPatch.DesktopClient/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
xmlns:views="clr-namespace:OctoPatch.DesktopClient.Views"
mc:Ignorable="d"
Title="OctoPatch Desktop" Height="700" Width="800">
<Grid>
<views:RuntimeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
<views:RuntimeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Newtonsoft.Json;

namespace OctoPatch.DesktopClient.Models
{
/// <summary>
/// Basic configuration type for node configuration
/// </summary>
/// <typeparam name="TConfiguration">model type for configuration</typeparam>
/// <typeparam name="TEnvironment">model type for environment</typeparam>
public abstract class AdapterConfigurationModel<TConfiguration, TEnvironment> : ConfigurationModel
where TConfiguration : IConfiguration
where TEnvironment : IEnvironment
{
public override void Setup(string environment)
{
// Do nothing since adapter do not have any environment yet
}

public override void SetConfiguration(string configuration)
{
if (configuration == null)
{
return;
}

OnSetConfiguration(JsonConvert.DeserializeObject<TConfiguration>(configuration));
}

protected abstract void OnSetConfiguration(TConfiguration configuration);

public override string GetConfiguration()
{
return JsonConvert.SerializeObject(OnGetConfiguration());
}

protected abstract TConfiguration OnGetConfiguration();
}
}
Loading