diff --git a/App/.editorconfig b/App/.editorconfig new file mode 100644 index 0000000..4aaad81 --- /dev/null +++ b/App/.editorconfig @@ -0,0 +1,280 @@ +# editorconfig.org + +# top-most EditorConfig file +root = true + +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_namespace_match_folder = true:suggestion + +# C# files +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true +# trim_trailing_whitespace = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# prefer var +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true:suggestion + +# use language keywords instead of BCL types +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# private static fields should have s_ prefix +dotnet_naming_rule.private_static_fields_should_have_prefix.severity = suggestion +dotnet_naming_rule.private_static_fields_should_have_prefix.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_have_prefix.style = private_static_prefix_style + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.required_modifiers = static +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private + +dotnet_naming_style.private_static_prefix_style.required_prefix = s_ +dotnet_naming_style.private_static_prefix_style.capitalization = camel_case + +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style + +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal + +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case + +# use accessibility modifiers +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +# Code style defaults +dotnet_sort_system_directives_first = true +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false +space_within_single_line_array_initializer_braces = true + +#Net Analyzer +dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomment when all violations are fixed. + +# CS0649: Field 'field' is never assigned to, and will always have its default value 'value' +dotnet_diagnostic.CS0649.severity = error + +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = suggestion + +# CS0162: Remove unreachable code +dotnet_diagnostic.CS0162.severity = error +# CA1018: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.CA1018.severity = error +# CA1304: Specify CultureInfo +dotnet_diagnostic.CA1304.severity = warning +# CA1802: Use literals where appropriate +dotnet_diagnostic.CA1802.severity = warning +# CA1813: Avoid unsealed attributes +dotnet_diagnostic.CA1813.severity = error +# CA1815: Override equals and operator equals on value types +dotnet_diagnostic.CA1815.severity = warning +# CA1820: Test for empty strings using string length +dotnet_diagnostic.CA1820.severity = warning +# CA1821: Remove empty finalizers +dotnet_diagnostic.CA1821.severity = error +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = suggestion +dotnet_code_quality.CA1822.api_surface = private, internal +# CA1823: Avoid unused private fields +dotnet_diagnostic.CA1823.severity = error +# CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1825.severity = warning +# CA1826: Use property instead of Linq Enumerable method +dotnet_diagnostic.CA1826.severity = suggestion +# CA1827: Do not use Count/LongCount when Any can be used +dotnet_diagnostic.CA1827.severity = warning +# CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used +dotnet_diagnostic.CA1828.severity = warning +# CA1829: Use Length/Count property instead of Enumerable.Count method +dotnet_diagnostic.CA1829.severity = warning +#CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters +dotnet_diagnostic.CA1847.severity = warning +# CA1851: Possible multiple enumerations of IEnumerable collection +dotnet_diagnostic.CA1851.severity = warning +#CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method +dotnet_diagnostic.CA1854.severity = warning +#CA2211:Non-constant fields should not be visible +dotnet_diagnostic.CA2211.severity = error + +# Wrapping preferences +csharp_wrap_before_ternary_opsigns = false + +# Avalonia DevAnalyzer preferences +dotnet_diagnostic.AVADEV2001.severity = error + +# Avalonia PublicAnalyzer preferences +dotnet_diagnostic.AVP1000.severity = error +dotnet_diagnostic.AVP1001.severity = error +dotnet_diagnostic.AVP1002.severity = error +dotnet_diagnostic.AVP1010.severity = error +dotnet_diagnostic.AVP1011.severity = error +dotnet_diagnostic.AVP1012.severity = warning +dotnet_diagnostic.AVP1013.severity = error +dotnet_diagnostic.AVP1020.severity = error +dotnet_diagnostic.AVP1021.severity = error +dotnet_diagnostic.AVP1022.severity = error +dotnet_diagnostic.AVP1030.severity = error +dotnet_diagnostic.AVP1031.severity = error +dotnet_diagnostic.AVP1032.severity = error +dotnet_diagnostic.AVP1040.severity = error +dotnet_diagnostic.AVA2001.severity = error +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent + +# Xaml files +[*.{xaml,axaml}] +indent_size = 2 +# DuplicateSetterError +avalonia_xaml_diagnostic.AVLN2203.severity = error +# StyleInMergedDictionaries +avalonia_xaml_diagnostic.AVLN2204.severity = error +# RequiredTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2205.severity = error +# OptionalTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2206.severity = info +# TemplatePartWrongType +avalonia_xaml_diagnostic.AVLN2207.severity = error +# ItemContainerInsideTemplate +avalonia_xaml_diagnostic.AVLN2208.severity = error +# Obsolete +avalonia_xaml_diagnostic.AVLN5001.severity = error + +# Xml project files +[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size = 2 + +# Xml build files +[*.builds] +indent_size = 2 + +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size = 2 + +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 + +[*.json] +indent_size = 2 + +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf diff --git a/App/.gitignore b/App/.gitignore new file mode 100644 index 0000000..4dd3751 --- /dev/null +++ b/App/.gitignore @@ -0,0 +1,453 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json diff --git a/App/Directory.Build.props b/App/Directory.Build.props new file mode 100644 index 0000000..4d9a552 --- /dev/null +++ b/App/Directory.Build.props @@ -0,0 +1,7 @@ + + + enable + 11.2.6 + 1.0.0 + + diff --git a/App/Harp.Behavior.App.sln b/App/Harp.Behavior.App.sln new file mode 100644 index 0000000..174fcca --- /dev/null +++ b/App/Harp.Behavior.App.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{D6F1C6E5-7507-425D-A697-29DAB58ED458}") = "Harp.Behavior.App", "Harp.Behavior.App\Harp.Behavior.App.csproj", "{6281A17E-B18E-4F00-86B9-BC1665108D9D}" +EndProject +Project("{D6F1C6E5-7507-425D-A697-29DAB58ED458}") = "Harp.Behavior.Design", "Harp.Behavior.Design\Harp.Behavior.Design.csproj", "{FCB73743-9ECF-4D3E-A235-F0493BC10629}" +EndProject +Project("{D6F1C6E5-7507-425D-A697-29DAB58ED458}") = "Harp.Behavior", "..\Interface\Harp.Behavior\Harp.Behavior.csproj", "{5C1A2A65-9C57-419A-89A0-0B59BA4CF40C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{10D72C30-D95E-452C-910F-F39FC6BAF129}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + Harp.Behavior.nsi = Harp.Behavior.nsi + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6281A17E-B18E-4F00-86B9-BC1665108D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6281A17E-B18E-4F00-86B9-BC1665108D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6281A17E-B18E-4F00-86B9-BC1665108D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6281A17E-B18E-4F00-86B9-BC1665108D9D}.Release|Any CPU.Build.0 = Release|Any CPU + {FCB73743-9ECF-4D3E-A235-F0493BC10629}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCB73743-9ECF-4D3E-A235-F0493BC10629}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCB73743-9ECF-4D3E-A235-F0493BC10629}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCB73743-9ECF-4D3E-A235-F0493BC10629}.Release|Any CPU.Build.0 = Release|Any CPU + {5C1A2A65-9C57-419A-89A0-0B59BA4CF40C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C1A2A65-9C57-419A-89A0-0B59BA4CF40C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C1A2A65-9C57-419A-89A0-0B59BA4CF40C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C1A2A65-9C57-419A-89A0-0B59BA4CF40C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/App/Harp.Behavior.App/Harp.Behavior.App.csproj b/App/Harp.Behavior.App/Harp.Behavior.App.csproj new file mode 100644 index 0000000..80940c0 --- /dev/null +++ b/App/Harp.Behavior.App/Harp.Behavior.App.csproj @@ -0,0 +1,51 @@ + + + WinExe + + net8.0 + enable + true + app.manifest + ..\bin\$(Configuration) + $(AppVersion) + ..\Harp.Behavior.Design\Assets\cf-logo.ico + Harp.Behavior.App + + + + Harp.Behavior.App + Harp.Behavior.App + org.fchampalimaud + $(Version) + $(Version) + AAPL + . + Harp.Behavior.App + cf-logo.icns + NSApplication + true + Champalimaud Foundation + ..\Harp.Behavior.Design\Assets\cf-logo.ico + ..\README.md + git + ..\bin\$(Configuration) + + + + + + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.App/Program.cs b/App/Harp.Behavior.App/Program.cs new file mode 100644 index 0000000..bc33a2b --- /dev/null +++ b/App/Harp.Behavior.App/Program.cs @@ -0,0 +1,24 @@ +using System; + +using Avalonia; +using Avalonia.ReactiveUI; + +namespace Harp.Behavior.App; + +class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace() + .UseReactiveUI(); +} diff --git a/App/Harp.Behavior.App/Properties/launchSettings.json b/App/Harp.Behavior.App/Properties/launchSettings.json new file mode 100644 index 0000000..8455e9d --- /dev/null +++ b/App/Harp.Behavior.App/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "Harp.Behavior.App": { + "commandName": "Project" + }, + "WSL": { + "commandName": "WSL2", + "distributionName": "" + } + } +} \ No newline at end of file diff --git a/App/Harp.Behavior.App/app.manifest b/App/Harp.Behavior.App/app.manifest new file mode 100644 index 0000000..e0ce8d0 --- /dev/null +++ b/App/Harp.Behavior.App/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.Design/Adapters/RgbRegisterAdapter.cs b/App/Harp.Behavior.Design/Adapters/RgbRegisterAdapter.cs new file mode 100644 index 0000000..dd8d639 --- /dev/null +++ b/App/Harp.Behavior.Design/Adapters/RgbRegisterAdapter.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reactive.Linq; +using Avalonia.Media; +using ReactiveUI; + +namespace Harp.Behavior.Design.Adapters; + +public class RgbColorItem : ReactiveObject +{ + private Color _color; + public Color Color + { + get => _color; + set => this.RaiseAndSetIfChanged(ref _color, value); + } +} + +public enum RgbKind +{ + None, + Simple, + Array, + Structured, + Complex +} + +public class RgbRegisterAdapter : ReactiveObject +{ + public ObservableCollection Colors { get; } + public bool IsWritable { get; } + public string RegisterKey { get; } + public RgbKind Kind { get; } + + // For simple/structured: expose a single color property + public Color Color + { + get => Colors.Count > 0 ? Colors[0].Color : Avalonia.Media.Colors.Transparent; + set { if (Colors.Count > 0) Colors[0].Color = value; this.RaisePropertyChanged(nameof(Color)); } + } + + private RgbRegisterAdapter _linkedAdapter; + private int _linkedOffset; + + /// + /// Used for design-time data or default initialization. + /// + public RgbRegisterAdapter() + : this("DefaultKey", 1, true, RgbKind.Simple) + { + } + + public RgbRegisterAdapter(string registerKey, int colorCount, bool isWritable, RgbKind kind) + { + RegisterKey = registerKey; + IsWritable = isWritable; + Kind = kind; + Colors = new ObservableCollection( + Enumerable.Range(0, colorCount).Select(_ => new RgbColorItem())); + } + + /// + /// Updates the adapter from a register value (byte[] or struct). + /// + public void UpdateFromRegister(object registerValue) + { + if (registerValue is byte[] arr && arr.Length >= Colors.Count * 3) + { + for (int i = 0; i < Colors.Count; i++) + { + Colors[i].Color = Color.FromRgb(arr[i * 3], arr[i * 3 + 1], arr[i * 3 + 2]); + } + } + // Handle struct/complex types (e.g., with Red0, Green0, Blue0, Red1, ...) + else if (registerValue != null) + { + var type = registerValue.GetType(); + for (int i = 0; i < Colors.Count; i++) + { + string rName = Colors.Count == 1 ? "Red" : $"Red{i}"; + string gName = Colors.Count == 1 ? "Green" : $"Green{i}"; + string bName = Colors.Count == 1 ? "Blue" : $"Blue{i}"; + + // FIXME: exchanges here to compensate the error in the firmware + var r = GetByteField(type, registerValue, rName); + var g = GetByteField(type, registerValue, gName); + var b = GetByteField(type, registerValue, bName); + Colors[i].Color = Color.FromRgb(r, g, b); + } + } + } + + private static byte GetByteField(Type type, object obj, string name) + { + var prop = type.GetProperty(name); + if (prop != null && prop.PropertyType == typeof(byte)) + return (byte)prop.GetValue(obj); + var field = type.GetField(name); + if (field != null && field.FieldType == typeof(byte)) + return (byte)field.GetValue(obj); + return 0; + } + + /// + /// Converts the adapter's colors to a register value (byte[]). + /// + public byte[] ToRegisterValue() + { + var arr = new byte[Colors.Count * 3]; + for (int i = 0; i < Colors.Count; i++) + { + arr[i * 3] = Colors[i].Color.R; + arr[i * 3 + 1] = Colors[i].Color.G; + arr[i * 3 + 2] = Colors[i].Color.B; + } + return arr; + } + + /// + /// Link this adapter to a parent adapter's color collection (for subrange sync). + /// + public void LinkToParent(RgbRegisterAdapter parent, int offset) + { + _linkedAdapter = parent; + _linkedOffset = offset; + + // Sync initial values + for (int i = 0; i < Colors.Count; i++) + { + Colors[i].Color = parent.Colors[offset + i].Color; + } + + // Subscribe to changes in this adapter and propagate to parent + for (int i = 0; i < Colors.Count; i++) + { + int idx = i; + Colors[i].WhenAnyValue(x => x.Color) + .Skip(1) + .Subscribe(color => + { + parent.Colors[offset + idx].Color = color; + }); + + // Subscribe to changes in parent and propagate to this adapter + parent.Colors[offset + i].WhenAnyValue(x => x.Color) + .Skip(1) + .Subscribe(color => + { + Colors[idx].Color = color; + }); + } + } +} diff --git a/App/Harp.Behavior.Design/App.axaml b/App/Harp.Behavior.Design/App.axaml new file mode 100644 index 0000000..6183319 --- /dev/null +++ b/App/Harp.Behavior.Design/App.axaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.Design/App.axaml.cs b/App/Harp.Behavior.Design/App.axaml.cs new file mode 100644 index 0000000..073c400 --- /dev/null +++ b/App/Harp.Behavior.Design/App.axaml.cs @@ -0,0 +1,44 @@ +using System; +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +using Harp.Behavior.Design.ViewModels; +using Harp.Behavior.Design.Views; + +namespace Harp.Behavior.Design; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new BehaviorViewModel() + }; + } + else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform) + { + singleViewPlatform.MainView = new BehaviorView + { + DataContext = new BehaviorViewModel() + }; + } + + base.OnFrameworkInitializationCompleted(); + } + + private void NativeMenuItem_OnClick(object sender, EventArgs e) + { + var about = new About() { DataContext = new AboutViewModel() }; + about.ShowDialog((Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime) + .MainWindow); + } +} diff --git a/App/Harp.Behavior.Design/Assets/cf-logo-small.bmp b/App/Harp.Behavior.Design/Assets/cf-logo-small.bmp new file mode 100644 index 0000000..3d70185 Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf-logo-small.bmp differ diff --git a/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.png b/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.png new file mode 100644 index 0000000..ca64284 Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.png differ diff --git a/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.svg b/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.svg new file mode 100644 index 0000000..dc288cd --- /dev/null +++ b/App/Harp.Behavior.Design/Assets/cf-logo-white-lettering.svg @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.Design/Assets/cf-logo.icns b/App/Harp.Behavior.Design/Assets/cf-logo.icns new file mode 100644 index 0000000..d50056d Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf-logo.icns differ diff --git a/App/Harp.Behavior.Design/Assets/cf-logo.ico b/App/Harp.Behavior.Design/Assets/cf-logo.ico new file mode 100644 index 0000000..7f15636 Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf-logo.ico differ diff --git a/App/Harp.Behavior.Design/Assets/cf-logo.png b/App/Harp.Behavior.Design/Assets/cf-logo.png new file mode 100644 index 0000000..007e30e Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf-logo.png differ diff --git a/App/Harp.Behavior.Design/Assets/cf-logo.svg b/App/Harp.Behavior.Design/Assets/cf-logo.svg new file mode 100644 index 0000000..08e8841 --- /dev/null +++ b/App/Harp.Behavior.Design/Assets/cf-logo.svg @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.png b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.png new file mode 100644 index 0000000..f8afc50 Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.png differ diff --git a/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.svg b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.svg new file mode 100644 index 0000000..1896536 --- /dev/null +++ b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo.svg @@ -0,0 +1,94 @@ + + + + + + + CF_hardware_sofware_logo + + + + + CF_hardware_sofware_logo + + + + + + + + + Hardware and + + + Software + + Platform + + + + diff --git a/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.png b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.png new file mode 100644 index 0000000..e201b4b Binary files /dev/null and b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.png differ diff --git a/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.svg b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.svg new file mode 100644 index 0000000..c11b09a --- /dev/null +++ b/App/Harp.Behavior.Design/Assets/cf_hardware_software_logo_white_lettering.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + Hardware and + Software + Platform + diff --git a/App/Harp.Behavior.Design/Controls/ExtendedColorPicker.cs b/App/Harp.Behavior.Design/Controls/ExtendedColorPicker.cs new file mode 100644 index 0000000..f91dd70 --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/ExtendedColorPicker.cs @@ -0,0 +1,33 @@ +using System; +using System.Reflection; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Interactivity; + +namespace Harp.Behavior.Design.Controls; + +// NOTE: This is currently needed because there's an issue in the ColorPicker control where +// the SelectedIndex is not respected on load. +public class ExtendedColorPicker : ColorPicker +{ + protected override Type StyleKeyOverride => typeof(ColorPicker); + + private int _selectedTabIndex; + + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { + // There might be a property set in xaml that get's overridden here + _selectedTabIndex = SelectedIndex; + base.OnApplyTemplate(e); + } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + var type = typeof(ColorView); + if (type.GetField("_tabControl", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(this) is not TabControl tabControl) + return; + tabControl.SelectedIndex = _selectedTabIndex; + } +} diff --git a/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml b/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml new file mode 100644 index 0000000..871761f --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml.cs b/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml.cs new file mode 100644 index 0000000..829fd0f --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/RgbRegisterControl.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace Harp.Behavior.Design.Controls; + +public partial class RgbRegisterControl : UserControl +{ + public RgbRegisterControl() + { + InitializeComponent(); + } +} diff --git a/App/Harp.Behavior.Design/Controls/VisualStatus.axaml b/App/Harp.Behavior.Design/Controls/VisualStatus.axaml new file mode 100644 index 0000000..20d62e0 --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/VisualStatus.axaml @@ -0,0 +1,11 @@ + + + + + + diff --git a/App/Harp.Behavior.Design/Controls/VisualStatus.axaml.cs b/App/Harp.Behavior.Design/Controls/VisualStatus.axaml.cs new file mode 100644 index 0000000..73eb13f --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/VisualStatus.axaml.cs @@ -0,0 +1,21 @@ +using Avalonia; +using Avalonia.Controls; + +namespace Harp.Behavior.Design.Controls; + +public partial class VisualStatus : ContentControl +{ + public static readonly StyledProperty StatusProperty = + AvaloniaProperty.Register(nameof(Status), null); + + public bool? Status + { + get => GetValue(StatusProperty); + set => SetValue(StatusProperty, value); + } + + public VisualStatus() + { + InitializeComponent(); + } +} diff --git a/App/Harp.Behavior.Design/Controls/WriteMessagesControl.axaml b/App/Harp.Behavior.Design/Controls/WriteMessagesControl.axaml new file mode 100644 index 0000000..d94cfd5 --- /dev/null +++ b/App/Harp.Behavior.Design/Controls/WriteMessagesControl.axaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Start + + + Stop + + + + + + + + + + Digital Output 1 control and status + + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + Start + + + Stop + + + + + + + + + + Digital Output 2 control and status + + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + Start + + + Stop + + + + + + + + + + Digital Output 3 control and status + + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + Start + + + Stop + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Port 0 digital output control/ Poke 0 LED + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + Port 0 supply output control/ Poke 0 Valve + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + + + + + + DIO 0 state event status + + + + + + + + + + + Set + + + Clear + + + + + + + + + + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Port 1 digital output control/ Poke 1 LED + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + Port 1 supply output control/ Poke 1 Valve + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + + + + + + DIO 1 state event status + + + + + + + + + + + Set + + + Clear + + + + + + + + + + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Port 2 digital output control/ Poke 2 LED + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + Port 2 supply output control/ Poke 2 Valve + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + + + + + + DIO 2 state event status + + + + + + + + + + + Set + + + Clear + + + + + + + + + + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LED 0 current and pulse configuration + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + LED 1 current and pulse configuration + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RGB 0 color and pulse configuration + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + RGB 1 color and pulse configuration + + + + + + + + + + + Set + + + Clear + + + + + + + + + + Enable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Voltage reading from analog input 0 + + + + + + + + + + + + + + Voltage reading from analog input 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Camera 0 control and status + + + + + + + + + + + Start + + + Stop + + + + + + + + + + + + + + Camera 1 control and status + + + + + + + + + + + Start + + + Stop + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Servo Motor 2 (DO2) control + + + + + + + Enable + + + Disable + + + + + + + + + Period of the servo motor in DO2, in microseconds (2-65534) + + + + + + + + Pulse width of the servo motor in DO2, in microseconds (6-65530) + + + + + + + + + + + + + Servo Motor 3 (DO3) control + + + + + + + Enable + + + Disable + + + + + + + + + Period of the servo motor in DO3, in microseconds (2-65534) + + + + + + + + Pulse width of the servo motor in DO3, in microseconds (6-65530) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Current encoder counter value + + + + + + + + + + + Enable encoder on Port 2 + + + Port 2 + + + + + + + Encoder operation mode + + + + + + + + + + + Reset encoder counter to zero + + + Reset + +