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/.gitattributes b/App/.gitattributes
new file mode 100644
index 0000000..2c0234a
--- /dev/null
+++ b/App/.gitattributes
@@ -0,0 +1,35 @@
+* text=auto eol=lf
+
+# Text files (explicit for clarity; all normalized to LF)
+*.cs text eol=lf diff=csharp
+*.csproj text eol=lf
+*.sln text eol=lf
+*.props text eol=lf
+*.targets text eol=lf
+*.axaml text eol=lf
+*.json text eol=lf
+*.yml text eol=lf
+*.yaml text eol=lf
+*.md text eol=lf
+*.sh text eol=lf
+
+# SVG is XML text; keep it normalized and diffable.
+*.svg text eol=lf
+*.svgz binary
+
+# NSIS installer scripts -> keep as text and diffable.
+*.nsi text eol=lf diff=nsis
+*.nsh text eol=lf diff=nsis
+
+# Windows command scripts should remain CRLF.
+*.bat text eol=crlf
+*.cmd text eol=crlf
+
+# Binary assets (no EOL conversion, no text diffs)
+*.png binary
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.bmp binary
+*.ico binary
+*.icns binary
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..9c9329f
--- /dev/null
+++ b/App/Directory.Build.props
@@ -0,0 +1,7 @@
+
+
+ enable
+ 11.2.6
+ 1.0.0-alpha.1
+
+
diff --git a/App/Harp.LedArray.App.sln b/App/Harp.LedArray.App.sln
new file mode 100644
index 0000000..4465549
--- /dev/null
+++ b/App/Harp.LedArray.App.sln
@@ -0,0 +1,42 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35707.178
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{E25997E9-FD75-45C0-94EC-5EAC78BE0F73}") = "Harp.LedArray.App", "Harp.LedArray.App\Harp.LedArray.App.csproj", "{234DC1DC-09C3-417D-973A-3647252B26B5}"
+EndProject
+Project("{E25997E9-FD75-45C0-94EC-5EAC78BE0F73}") = "Harp.LedArray.Design", "Harp.LedArray.Design\Harp.LedArray.Design.csproj", "{3A36EE39-3540-417A-B979-3B36F9F21C3C}"
+EndProject
+Project("{E25997E9-FD75-45C0-94EC-5EAC78BE0F73}") = "Harp.LedArray", "..\Interface\Harp.LedArray\Harp.LedArray.csproj", "{5D43DE0B-202E-4F4F-9AEF-E63C5AA3530B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3662E764-C393-426E-905E-9F945506CC83}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ Harp.LedArray.nsi = Harp.LedArray.nsi
+ README.md = README.md
+ Directory.Build.props = Directory.Build.props
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {234DC1DC-09C3-417D-973A-3647252B26B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {234DC1DC-09C3-417D-973A-3647252B26B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {234DC1DC-09C3-417D-973A-3647252B26B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {234DC1DC-09C3-417D-973A-3647252B26B5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A36EE39-3540-417A-B979-3B36F9F21C3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A36EE39-3540-417A-B979-3B36F9F21C3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A36EE39-3540-417A-B979-3B36F9F21C3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A36EE39-3540-417A-B979-3B36F9F21C3C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D43DE0B-202E-4F4F-9AEF-E63C5AA3530B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D43DE0B-202E-4F4F-9AEF-E63C5AA3530B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D43DE0B-202E-4F4F-9AEF-E63C5AA3530B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D43DE0B-202E-4F4F-9AEF-E63C5AA3530B}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/App/Harp.LedArray.App/Harp.LedArray.App.csproj b/App/Harp.LedArray.App/Harp.LedArray.App.csproj
new file mode 100644
index 0000000..19d7acb
--- /dev/null
+++ b/App/Harp.LedArray.App/Harp.LedArray.App.csproj
@@ -0,0 +1,58 @@
+
+
+ WinExe
+
+ net8.0
+ enable
+ true
+ app.manifest
+ ..\bin\$(Configuration)
+ $(AppVersion)
+ ..\Harp.LedArray.Design\Assets\cf-logo.ico
+ Harp.LedArray.App
+
+
+
+ Champalimaud Foundation
+ ..\Harp.LedArray.Design\Assets\cf-logo.ico
+ ..\README.md
+ git
+ ..\bin\$(Configuration)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.App/Program.cs b/App/Harp.LedArray.App/Program.cs
new file mode 100644
index 0000000..562128d
--- /dev/null
+++ b/App/Harp.LedArray.App/Program.cs
@@ -0,0 +1,24 @@
+using System;
+
+using Avalonia;
+using Avalonia.ReactiveUI;
+
+namespace Harp.LedArray.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.LedArray.App/Properties/launchSettings.json b/App/Harp.LedArray.App/Properties/launchSettings.json
new file mode 100644
index 0000000..861eae1
--- /dev/null
+++ b/App/Harp.LedArray.App/Properties/launchSettings.json
@@ -0,0 +1,11 @@
+{
+ "profiles": {
+ "Harp.LedArray.App": {
+ "commandName": "Project"
+ },
+ "WSL": {
+ "commandName": "WSL2",
+ "distributionName": ""
+ }
+ }
+}
\ No newline at end of file
diff --git a/App/Harp.LedArray.App/app.manifest b/App/Harp.LedArray.App/app.manifest
new file mode 100644
index 0000000..e0ce8d0
--- /dev/null
+++ b/App/Harp.LedArray.App/app.manifest
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/App.axaml b/App/Harp.LedArray.Design/App.axaml
new file mode 100644
index 0000000..a0adf95
--- /dev/null
+++ b/App/Harp.LedArray.Design/App.axaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/App.axaml.cs b/App/Harp.LedArray.Design/App.axaml.cs
new file mode 100644
index 0000000..14cf97e
--- /dev/null
+++ b/App/Harp.LedArray.Design/App.axaml.cs
@@ -0,0 +1,48 @@
+using System;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+
+using Harp.LedArray.Design.ViewModels;
+using Harp.LedArray.Design.Views;
+
+namespace Harp.LedArray.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 LedArrayViewModel()
+ };
+ }
+ else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
+ {
+ singleViewPlatform.MainView = new LedArrayView
+ {
+ DataContext = new LedArrayViewModel()
+ };
+ }
+
+ base.OnFrameworkInitializationCompleted();
+ }
+
+ private void NativeMenuItem_OnClick(object sender, EventArgs e)
+ {
+ if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime owner &&
+ owner.MainWindow is Window ownerWindow)
+ {
+ var about = new About() { DataContext = new AboutViewModel() };
+ about.ShowDialog(ownerWindow);
+ }
+ }
+}
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo-small.bmp b/App/Harp.LedArray.Design/Assets/cf-logo-small.bmp
new file mode 100644
index 0000000..3d70185
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf-logo-small.bmp differ
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.png b/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.png
new file mode 100644
index 0000000..ca64284
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.png differ
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.svg b/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.svg
new file mode 100644
index 0000000..dc288cd
--- /dev/null
+++ b/App/Harp.LedArray.Design/Assets/cf-logo-white-lettering.svg
@@ -0,0 +1,224 @@
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo.icns b/App/Harp.LedArray.Design/Assets/cf-logo.icns
new file mode 100644
index 0000000..6dd5be3
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf-logo.icns differ
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo.ico b/App/Harp.LedArray.Design/Assets/cf-logo.ico
new file mode 100644
index 0000000..7f15636
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf-logo.ico differ
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo.png b/App/Harp.LedArray.Design/Assets/cf-logo.png
new file mode 100644
index 0000000..007e30e
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf-logo.png differ
diff --git a/App/Harp.LedArray.Design/Assets/cf-logo.svg b/App/Harp.LedArray.Design/Assets/cf-logo.svg
new file mode 100644
index 0000000..08e8841
--- /dev/null
+++ b/App/Harp.LedArray.Design/Assets/cf-logo.svg
@@ -0,0 +1,235 @@
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.png b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.png
new file mode 100644
index 0000000..f8afc50
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.png differ
diff --git a/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.svg b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.svg
new file mode 100644
index 0000000..1896536
--- /dev/null
+++ b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo.svg
@@ -0,0 +1,94 @@
+
+
diff --git a/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.png b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.png
new file mode 100644
index 0000000..e201b4b
Binary files /dev/null and b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.png differ
diff --git a/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.svg b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.svg
new file mode 100644
index 0000000..c11b09a
--- /dev/null
+++ b/App/Harp.LedArray.Design/Assets/cf_hardware_software_logo_white_lettering.svg
@@ -0,0 +1,81 @@
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Controls/GroupBox.cs b/App/Harp.LedArray.Design/Controls/GroupBox.cs
new file mode 100644
index 0000000..52bcfe0
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/GroupBox.cs
@@ -0,0 +1,29 @@
+using Avalonia;
+using Avalonia.Controls.Primitives;
+using Avalonia.Media;
+
+namespace Harp.LedArray.Design.Controls;
+
+public class GroupBox : HeaderedContentControl
+{
+ public static readonly StyledProperty HeaderBackgroundProperty =
+ AvaloniaProperty.Register(nameof(HeaderBackground));
+
+ public static readonly AttachedProperty SurfaceBackgroundProperty =
+ AvaloniaProperty.RegisterAttached(
+ "SurfaceBackground",
+ defaultValue: null,
+ inherits: true);
+
+ public IBrush? HeaderBackground
+ {
+ get => GetValue(HeaderBackgroundProperty);
+ set => SetValue(HeaderBackgroundProperty, value);
+ }
+
+ public static void SetSurfaceBackground(AvaloniaObject element, IBrush? value) =>
+ element.SetValue(SurfaceBackgroundProperty, value);
+
+ public static IBrush? GetSurfaceBackground(AvaloniaObject element) =>
+ element.GetValue(SurfaceBackgroundProperty);
+}
diff --git a/App/Harp.LedArray.Design/Controls/RegisterField.cs b/App/Harp.LedArray.Design/Controls/RegisterField.cs
new file mode 100644
index 0000000..e87c420
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/RegisterField.cs
@@ -0,0 +1,26 @@
+using Avalonia;
+using Avalonia.Controls.Primitives;
+using Avalonia.Media;
+
+namespace Harp.LedArray.Design.Controls;
+
+public class RegisterField : HeaderedContentControl
+{
+ public static readonly StyledProperty DescriptionProperty =
+ AvaloniaProperty.Register(nameof(Description));
+
+ public static readonly StyledProperty IconForegroundProperty =
+ AvaloniaProperty.Register(nameof(IconForeground));
+
+ public string? Description
+ {
+ get => GetValue(DescriptionProperty);
+ set => SetValue(DescriptionProperty, value);
+ }
+
+ public IBrush? IconForeground
+ {
+ get => GetValue(IconForegroundProperty);
+ set => SetValue(IconForegroundProperty, value);
+ }
+}
diff --git a/App/Harp.LedArray.Design/Controls/VisualStatus.axaml b/App/Harp.LedArray.Design/Controls/VisualStatus.axaml
new file mode 100644
index 0000000..9625b4b
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/VisualStatus.axaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Controls/VisualStatus.axaml.cs b/App/Harp.LedArray.Design/Controls/VisualStatus.axaml.cs
new file mode 100644
index 0000000..196f8a4
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/VisualStatus.axaml.cs
@@ -0,0 +1,21 @@
+using Avalonia;
+using Avalonia.Controls;
+
+namespace Harp.LedArray.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.LedArray.Design/Controls/WriteMessagesControl.axaml b/App/Harp.LedArray.Design/Controls/WriteMessagesControl.axaml
new file mode 100644
index 0000000..b082920
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/WriteMessagesControl.axaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/App/Harp.LedArray.Design/Controls/WriteMessagesControl.axaml.cs b/App/Harp.LedArray.Design/Controls/WriteMessagesControl.axaml.cs
new file mode 100644
index 0000000..ef9d10b
--- /dev/null
+++ b/App/Harp.LedArray.Design/Controls/WriteMessagesControl.axaml.cs
@@ -0,0 +1,11 @@
+using Avalonia.Controls;
+
+namespace Harp.LedArray.Design.Controls;
+
+public partial class WriteMessagesControl : UserControl
+{
+ public WriteMessagesControl()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/App/Harp.LedArray.Design/Converters/EnableFlagConverter.cs b/App/Harp.LedArray.Design/Converters/EnableFlagConverter.cs
new file mode 100644
index 0000000..1063041
--- /dev/null
+++ b/App/Harp.LedArray.Design/Converters/EnableFlagConverter.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Globalization;
+using Avalonia.Data.Converters;
+using Bonsai.Harp;
+
+namespace Harp.LedArray.Design.Converters;
+
+///
+/// Converts between EnableFlag enum values and boolean values for two-way binding
+///
+public class EnableFlagConverter : IValueConverter
+{
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ // Convert from enum to bool (for IsChecked)
+ if (value?.ToString() is string text)
+ return text.Contains("Enable");
+
+ return false;
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ // Convert from bool (IsChecked) to enum
+ if (value is not bool isChecked || parameter == null)
+ return null;
+
+ // Create the appropriate enum value based on the checkbox state
+ return isChecked ? EnableFlag.Enable : EnableFlag.Disable;
+ }
+}
diff --git a/App/Harp.LedArray.Design/Converters/EnumDisplayConverter.cs b/App/Harp.LedArray.Design/Converters/EnumDisplayConverter.cs
new file mode 100644
index 0000000..6ace0b7
--- /dev/null
+++ b/App/Harp.LedArray.Design/Converters/EnumDisplayConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using Avalonia.Data.Converters;
+
+namespace Harp.LedArray.Design.Converters;
+
+public class EnumDisplayConverter : IValueConverter
+{
+ public Dictionary Mappings { get; set; } = new Dictionary();
+
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+ var key = value.ToString();
+ return Mappings!.GetValueOrDefault(key, key);
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ return null;
+ }
+}
diff --git a/App/Harp.LedArray.Design/Converters/PayloadFieldConverter.cs b/App/Harp.LedArray.Design/Converters/PayloadFieldConverter.cs
new file mode 100644
index 0000000..e5ac545
--- /dev/null
+++ b/App/Harp.LedArray.Design/Converters/PayloadFieldConverter.cs
@@ -0,0 +1,152 @@
+using System;
+using System.Globalization;
+using System.Reflection;
+using Avalonia.Data.Converters;
+
+namespace Harp.LedArray.Design.Converters;
+
+public class PayloadFieldConverter : IValueConverter
+{
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value is null || parameter?.ToString() is not string fieldName)
+ return null;
+
+ var valueType = value.GetType();
+
+ // Handle struct types directly with field/property access
+ if (valueType.IsValueType && !valueType.IsPrimitive)
+ {
+ // Try direct field access first
+ var fieldInfo = valueType.GetField(fieldName);
+ if (fieldInfo != null)
+ {
+ return fieldInfo.GetValue(value);
+ }
+
+ // Try property access second
+ var propInfo = valueType.GetProperty(fieldName);
+ if (propInfo != null)
+ {
+ return propInfo.GetValue(value);
+ }
+ }
+
+ // For primitive types, use bit masking
+ // This handles any register with a maskType like DigitalOutputSyncPayload
+ // that is actually a simple number but needs masking
+ try
+ {
+ int mask = GetMaskForField(valueType, fieldName);
+ if (mask != 0)
+ {
+ int rawValue = System.Convert.ToInt32(value);
+ int shift = GetShiftForMask(mask);
+ int maskedValue = (rawValue & mask) >> shift;
+
+ // If targetType is an enum, convert to that enum type
+ if (targetType.IsEnum)
+ {
+ return Enum.ToObject(targetType, maskedValue);
+ }
+ return maskedValue;
+ }
+ }
+ catch
+ {
+ // Silently continue if mask extraction fails
+ }
+
+ return value;
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value is null || parameter?.ToString() is not string fieldName)
+ return null;
+
+ // Handle struct types - boxed copy approach
+ if (targetType.IsValueType && !targetType.IsPrimitive)
+ {
+ // Create a copy of the current target value if it exists
+ var currentValue = Activator.CreateInstance(targetType);
+
+ // Set the field/property on the copy
+ var fieldInfo = targetType.GetField(fieldName);
+ if (fieldInfo is not null && currentValue is not null)
+ {
+ object boxedCopy = currentValue;
+ fieldInfo.SetValue(boxedCopy, value);
+ return boxedCopy;
+ }
+
+ var propInfo = targetType.GetProperty(fieldName);
+ if (propInfo is not null && propInfo.CanWrite && currentValue is not null)
+ {
+ object boxedCopy = currentValue;
+ propInfo.SetValue(boxedCopy, value);
+ return boxedCopy;
+ }
+ }
+
+ // For primitive/enum types with bitmasks
+ try
+ {
+ int mask = GetMaskForField(targetType, fieldName);
+ if (mask != 0)
+ {
+ // Get the current value if available
+ int currentValue = 0;
+
+ // Extract the value from the selected enum
+ int newValue = System.Convert.ToInt32(value);
+ int shift = GetShiftForMask(mask);
+
+ // Apply the new value at the correct bit position
+ int result = (currentValue & ~mask) | ((newValue << shift) & mask);
+ return System.Convert.ChangeType(result, targetType);
+ }
+ }
+ catch
+ {
+ // Silently continue if mask extraction fails
+ }
+
+ // Default conversion
+ return value;
+ }
+
+ private static int GetMaskForField(Type type, string fieldName)
+ {
+ // Try to find mask by reflection from payload specification
+ // This assumes there's a static class or field with mask information
+ try
+ {
+ if(type.Namespace is string typeNamespace &&
+ Type.GetType($"{typeNamespace}.{type.Name}PayloadSpec") is Type payloadSpecType)
+ {
+ var maskField = payloadSpecType.GetField($"{fieldName}Mask", BindingFlags.Public | BindingFlags.Static);
+ if (maskField?.GetValue(null) is int value)
+ {
+ return value;
+ }
+ }
+ }
+ catch
+ {
+ // Ignore and use default
+ }
+ return 0;
+ }
+
+ private static int GetShiftForMask(int mask)
+ {
+ int shift = 0;
+ while ((mask & 1) == 0 && shift < 32)
+ {
+ mask >>= 1;
+ shift++;
+ }
+ return shift;
+ }
+}
diff --git a/App/Harp.LedArray.Design/Converters/VisualStatusColorConverter.cs b/App/Harp.LedArray.Design/Converters/VisualStatusColorConverter.cs
new file mode 100644
index 0000000..cf7d8d2
--- /dev/null
+++ b/App/Harp.LedArray.Design/Converters/VisualStatusColorConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Globalization;
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+
+namespace Harp.LedArray.Design.Converters;
+
+public class VisualStatusColorConverter : IValueConverter
+{
+ public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ var status = value as bool?;
+ return status switch
+ {
+ true => new SolidColorBrush(Colors.Green),
+ false => new SolidColorBrush(Colors.LightGray),
+ _ => new SolidColorBrush(Colors.LightGray)
+ };
+ }
+
+ public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
+ throw new NotImplementedException();
+}
diff --git a/App/Harp.LedArray.Design/FodyWeavers.xml b/App/Harp.LedArray.Design/FodyWeavers.xml
new file mode 100644
index 0000000..63fc148
--- /dev/null
+++ b/App/Harp.LedArray.Design/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/App/Harp.LedArray.Design/Harp.LedArray.Design.csproj b/App/Harp.LedArray.Design/Harp.LedArray.Design.csproj
new file mode 100644
index 0000000..816eec9
--- /dev/null
+++ b/App/Harp.LedArray.Design/Harp.LedArray.Design.csproj
@@ -0,0 +1,29 @@
+
+
+ net8.0
+ enable
+ latest
+ true
+ ..\bin\$(Configuration)
+ $(AppVersion)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Resources/GroupBox.axaml b/App/Harp.LedArray.Design/Resources/GroupBox.axaml
new file mode 100644
index 0000000..6a04852
--- /dev/null
+++ b/App/Harp.LedArray.Design/Resources/GroupBox.axaml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Resources/RegisterField.axaml b/App/Harp.LedArray.Design/Resources/RegisterField.axaml
new file mode 100644
index 0000000..6bc1e3f
--- /dev/null
+++ b/App/Harp.LedArray.Design/Resources/RegisterField.axaml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Styles/DefaultStyles.axaml b/App/Harp.LedArray.Design/Styles/DefaultStyles.axaml
new file mode 100644
index 0000000..a8d12c8
--- /dev/null
+++ b/App/Harp.LedArray.Design/Styles/DefaultStyles.axaml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/ViewModels/AboutViewModel.cs b/App/Harp.LedArray.Design/ViewModels/AboutViewModel.cs
new file mode 100644
index 0000000..6e17313
--- /dev/null
+++ b/App/Harp.LedArray.Design/ViewModels/AboutViewModel.cs
@@ -0,0 +1,5 @@
+namespace Harp.LedArray.Design.ViewModels;
+
+internal class AboutViewModel : ViewModelBase
+{
+}
diff --git a/App/Harp.LedArray.Design/ViewModels/MyDeviceViewModel.cs b/App/Harp.LedArray.Design/ViewModels/MyDeviceViewModel.cs
new file mode 100644
index 0000000..6d098e9
--- /dev/null
+++ b/App/Harp.LedArray.Design/ViewModels/MyDeviceViewModel.cs
@@ -0,0 +1,1095 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO.Ports;
+using System.Linq;
+using System.Reactive;
+using System.Reactive.Concurrency;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using Bonsai.Harp;
+using Harp.LedArray.Design.Views;
+using MsBox.Avalonia;
+using MsBox.Avalonia.Enums;
+using ReactiveUI;
+using ReactiveUI.Fody.Helpers;
+
+namespace Harp.LedArray.Design.ViewModels;
+
+
+public class LedArrayViewModel : ViewModelBase
+{
+ public string AppVersion { get; set; } = string.Empty;
+ public ReactiveCommand LoadDeviceInformation { get; }
+
+ #region Connection Information
+
+ [Reactive] public ObservableCollection Ports { get; set; }
+ [Reactive] public string? SelectedPort { get; set; }
+ [Reactive] public bool Connected { get; set; }
+ [Reactive] public string ConnectButtonText { get; set; } = "Connect";
+ public ReactiveCommand ConnectAndGetBaseInfoCommand { get; }
+
+ #endregion
+
+ #region Operations
+
+ public ReactiveCommand SaveConfigurationCommand { get; }
+ public ReactiveCommand ResetConfigurationCommand { get; }
+
+ #endregion
+
+ #region Device basic information
+
+ [Reactive] public int DeviceID { get; set; }
+ [Reactive] public string? DeviceName { get; set; }
+ [Reactive] public HarpVersion? HardwareVersion { get; set; }
+ [Reactive] public HarpVersion? FirmwareVersion { get; set; }
+ [Reactive] public int SerialNumber { get; set; }
+
+ #endregion
+
+ #region Registers
+
+ [Reactive] public LedState EnablePower { get; set; }
+ [Reactive] public LedState EnableLedMode { get; set; }
+ [Reactive] public LedState EnableLed { get; set; }
+ [Reactive] public LedState EnableLedWrite { get; set; }
+ [Reactive] public DigitalInputs DigitalInputState { get; set; }
+ [Reactive] public DigitalOutputSyncPayload DigitalOutputSync { get; set; }
+ [Reactive] public DigitalInputTriggerPayload DigitalInputTrigger { get; set; }
+ [Reactive] public PulseModePayload PulseMode { get; set; }
+ [Reactive] public byte Led0Power { get; set; }
+ [Reactive] public byte Led1Power { get; set; }
+ [Reactive] public float Led0PwmFrequency { get; set; }
+ [Reactive] public float Led0PwmDutyCycle { get; set; }
+ [Reactive] public ushort Led0PwmPulseCounter { get; set; }
+ [Reactive] public ushort Led0PulseTimeOn { get; set; }
+ [Reactive] public ushort Led0PulseTimeOff { get; set; }
+ [Reactive] public ushort Led0PulseTimePulseCounter { get; set; }
+ [Reactive] public ushort Led0PulseTimeTail { get; set; }
+ [Reactive] public ushort Led0PulseRepeatCounter { get; set; }
+ [Reactive] public float Led1PwmFrequency { get; set; }
+ [Reactive] public float Led1PwmDutyCycle { get; set; }
+ [Reactive] public ushort Led1PwmPulseCounter { get; set; }
+ [Reactive] public ushort Led1PulseTimeOn { get; set; }
+ [Reactive] public ushort Led1PulseTimeOff { get; set; }
+ [Reactive] public ushort Led1PulseTimePulseCounter { get; set; }
+ [Reactive] public ushort Led1PulseTimeTail { get; set; }
+ [Reactive] public ushort Led1PulseRepeatCounter { get; set; }
+ [Reactive] public float Led0PwmReal { get; set; }
+ [Reactive] public float Led0PwmDutyCycleReal { get; set; }
+ [Reactive] public float Led1PwmReal { get; set; }
+ [Reactive] public float Led1PwmDutyCycleReal { get; set; }
+ [Reactive] public AuxDigitalOutputs AuxDigitalOutputState { get; set; }
+ [Reactive] public byte AuxLedPower { get; set; }
+ [Reactive] public DigitalOutputs DigitalOutputState { get; set; }
+ [Reactive] public LedArrayEvents EnableEvents { get; set; }
+
+ #endregion
+
+ #region Array collections
+
+ #endregion
+
+ #region Events Flags
+
+ public bool IsEnableLedEnabled
+ {
+ get
+ {
+ return EnableEvents.HasFlag(LedArrayEvents.EnableLed);
+ }
+ set
+ {
+ if (value)
+ {
+ EnableEvents |= LedArrayEvents.EnableLed;
+ }
+ else
+ {
+ EnableEvents &= ~LedArrayEvents.EnableLed;
+ }
+
+ // Notify the UI about the change
+ this.RaisePropertyChanged(nameof(IsEnableLedEnabled));
+ this.RaisePropertyChanged(nameof(EnableEvents));
+ }
+ }
+
+ public bool IsDigitalInputStateEnabled
+ {
+ get
+ {
+ return EnableEvents.HasFlag(LedArrayEvents.DigitalInputState);
+ }
+ set
+ {
+ if (value)
+ {
+ EnableEvents |= LedArrayEvents.DigitalInputState;
+ }
+ else
+ {
+ EnableEvents &= ~LedArrayEvents.DigitalInputState;
+ }
+
+ // Notify the UI about the change
+ this.RaisePropertyChanged(nameof(IsDigitalInputStateEnabled));
+ this.RaisePropertyChanged(nameof(EnableEvents));
+ }
+ }
+
+ #endregion
+
+ #region LedState_EnablePower Flags
+
+ public bool IsLed0Enabled_EnablePower
+ {
+ get => EnablePower.HasFlag(LedState.Led0On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnablePower,
+ LedState.Led0On,
+ LedState.Led0Off,
+ value);
+
+ if (EnablePower == newValue)
+ return;
+
+ EnablePower = newValue;
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnablePower));
+ }
+ }
+
+ public bool IsLed1Enabled_EnablePower
+ {
+ get => EnablePower.HasFlag(LedState.Led1On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnablePower,
+ LedState.Led1On,
+ LedState.Led1Off,
+ value);
+
+ if (EnablePower == newValue)
+ return;
+
+ EnablePower = newValue;
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnablePower));
+ }
+ }
+
+ #endregion
+
+ #region LedState_EnableLedMode Flags
+
+ public bool IsLed0Enabled_EnableLedMode
+ {
+ get => EnableLedMode.HasFlag(LedState.Led0On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnableLedMode,
+ LedState.Led0On,
+ LedState.Led0Off,
+ value);
+
+ if (EnableLedMode == newValue)
+ return;
+
+ EnableLedMode = newValue;
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnableLedMode));
+ }
+ }
+
+ public bool IsLed1Enabled_EnableLedMode
+ {
+ get => EnableLedMode.HasFlag(LedState.Led1On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnableLedMode,
+ LedState.Led1On,
+ LedState.Led1Off,
+ value);
+
+ if (EnableLedMode == newValue)
+ return;
+
+ EnableLedMode = newValue;
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnableLedMode));
+ }
+ }
+
+ #endregion
+
+ #region LedState_EnableLed Flags (status/event only)
+
+ public bool IsLed0Enabled_EnableLed => EnableLed.HasFlag(LedState.Led0On);
+
+ public bool IsLed1Enabled_EnableLed => EnableLed.HasFlag(LedState.Led1On);
+
+ #endregion
+
+ #region LedState_EnableLedWrite Flags
+
+ public bool IsLed0Enabled_EnableLedWrite
+ {
+ get => EnableLedWrite.HasFlag(LedState.Led0On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnableLedWrite,
+ LedState.Led0On,
+ LedState.Led0Off,
+ value);
+
+ if (EnableLedWrite == newValue)
+ return;
+
+ EnableLedWrite = newValue;
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnableLedWrite));
+ }
+ }
+
+ public bool IsLed1Enabled_EnableLedWrite
+ {
+ get => EnableLedWrite.HasFlag(LedState.Led1On);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ EnableLedWrite,
+ LedState.Led1On,
+ LedState.Led1Off,
+ value);
+
+ if (EnableLedWrite == newValue)
+ return;
+
+ EnableLedWrite = newValue;
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnableLedWrite));
+ }
+ }
+
+ #endregion
+
+ #region DigitalInputs_DigitalInputState Flags
+
+ public bool IsDI0Enabled_DigitalInputState
+ {
+ get
+ {
+ return DigitalInputState.HasFlag(DigitalInputs.DI0);
+ }
+ set
+ {
+ if (value)
+ {
+ DigitalInputState |= DigitalInputs.DI0;
+ }
+ else
+ {
+ DigitalInputState &= ~DigitalInputs.DI0;
+ }
+
+ // Notify the UI about the change
+ this.RaisePropertyChanged(nameof(IsDI0Enabled_DigitalInputState));
+ this.RaisePropertyChanged(nameof(DigitalInputState));
+ }
+ }
+
+ public bool IsDI1Enabled_DigitalInputState
+ {
+ get
+ {
+ return DigitalInputState.HasFlag(DigitalInputs.DI1);
+ }
+ set
+ {
+ if (value)
+ {
+ DigitalInputState |= DigitalInputs.DI1;
+ }
+ else
+ {
+ DigitalInputState &= ~DigitalInputs.DI1;
+ }
+
+ // Notify the UI about the change
+ this.RaisePropertyChanged(nameof(IsDI1Enabled_DigitalInputState));
+ this.RaisePropertyChanged(nameof(DigitalInputState));
+ }
+ }
+
+ #endregion
+
+ #region AuxDigitalOutputs_AuxDigitalOutputState Flags
+
+ public bool IsAux0Enabled_AuxDigitalOutputState
+ {
+ get => AuxDigitalOutputState.HasFlag(AuxDigitalOutputs.Aux0Set);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ AuxDigitalOutputState,
+ AuxDigitalOutputs.Aux0Set,
+ AuxDigitalOutputs.Aux0Clear,
+ value);
+
+ if (AuxDigitalOutputState == newValue)
+ return;
+
+ AuxDigitalOutputState = newValue;
+ this.RaisePropertyChanged(nameof(IsAux0Enabled_AuxDigitalOutputState));
+ }
+ }
+
+ public bool IsAux1Enabled_AuxDigitalOutputState
+ {
+ get => AuxDigitalOutputState.HasFlag(AuxDigitalOutputs.Aux1Set);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ AuxDigitalOutputState,
+ AuxDigitalOutputs.Aux1Set,
+ AuxDigitalOutputs.Aux1Clear,
+ value);
+
+ if (AuxDigitalOutputState == newValue)
+ return;
+
+ AuxDigitalOutputState = newValue;
+ this.RaisePropertyChanged(nameof(IsAux1Enabled_AuxDigitalOutputState));
+ }
+ }
+
+ #endregion
+
+ #region DigitalOutputs_DigitalOutputState Flags
+
+ public bool IsDO0Enabled_DigitalOutputState
+ {
+ get => DigitalOutputState.HasFlag(DigitalOutputs.DO0Set);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ DigitalOutputState,
+ DigitalOutputs.DO0Set,
+ DigitalOutputs.DO0Clear,
+ value);
+
+ if (DigitalOutputState == newValue)
+ return;
+
+ DigitalOutputState = newValue;
+ this.RaisePropertyChanged(nameof(IsDO0Enabled_DigitalOutputState));
+ }
+ }
+
+ public bool IsDO1Enabled_DigitalOutputState
+ {
+ get => DigitalOutputState.HasFlag(DigitalOutputs.DO1Set);
+ set
+ {
+ var newValue = SetExclusiveFlagState(
+ DigitalOutputState,
+ DigitalOutputs.DO1Set,
+ DigitalOutputs.DO1Clear,
+ value);
+
+ if (DigitalOutputState == newValue)
+ return;
+
+ DigitalOutputState = newValue;
+ this.RaisePropertyChanged(nameof(IsDO1Enabled_DigitalOutputState));
+ }
+ }
+
+ #endregion
+
+ #region PulseMode
+
+ public PulseModeConfig Led0SelectedPulseMode
+ {
+ get => PulseMode.Led0Mode;
+ set
+ {
+ if (PulseMode.Led0Mode == value) return;
+
+ PulseMode = new PulseModePayload(value, PulseMode.Led1Mode);
+
+ this.RaisePropertyChanged(nameof(Led0SelectedPulseMode));
+ this.RaisePropertyChanged(nameof(IsLed0PwmMode));
+ this.RaisePropertyChanged(nameof(IsLed0IntervalMode));
+ }
+ }
+
+ public PulseModeConfig Led1SelectedPulseMode
+ {
+ get => PulseMode.Led1Mode;
+ set
+ {
+ if (PulseMode.Led1Mode == value) return;
+
+ PulseMode = new PulseModePayload(PulseMode.Led0Mode, value);
+
+ this.RaisePropertyChanged(nameof(Led1SelectedPulseMode));
+ this.RaisePropertyChanged(nameof(IsLed1PwmMode));
+ this.RaisePropertyChanged(nameof(IsLed1IntervalMode));
+ }
+ }
+
+ public bool IsLed0PwmMode => Led0SelectedPulseMode == PulseModeConfig.Pwm;
+ public bool IsLed0IntervalMode => Led0SelectedPulseMode == PulseModeConfig.PulseTime;
+ public bool IsLed1PwmMode => Led1SelectedPulseMode == PulseModeConfig.Pwm;
+ public bool IsLed1IntervalMode => Led1SelectedPulseMode == PulseModeConfig.PulseTime;
+
+ #endregion
+
+ #region Application State
+
+ [ObservableAsProperty] public bool IsLoadingPorts { get; }
+ [ObservableAsProperty] public bool IsConnecting { get; }
+ [ObservableAsProperty] public bool IsResetting { get; }
+ [ObservableAsProperty] public bool IsSaving { get; }
+
+ [Reactive] public bool ShowWriteMessages { get; set; }
+ [Reactive] public ObservableCollection HarpEvents { get; set; } = new ObservableCollection();
+ [Reactive] public ObservableCollection SentMessages { get; set; } = new ObservableCollection();
+
+ public ReactiveCommand ShowAboutCommand { get; private set; }
+ public ReactiveCommand ClearMessagesCommand { get; private set; }
+ public ReactiveCommand ShowMessagesCommand { get; private set; }
+ public ReactiveCommand WriteRegisterCommand { get; private set; }
+
+ #endregion
+
+ private Harp.LedArray.AsyncDevice? _device;
+ private IObservable? _deviceEventsObservable;
+ private IDisposable? _deviceEventsSubscription;
+
+ public LedArrayViewModel()
+ {
+ var assembly = typeof(LedArrayViewModel).Assembly;
+ var informationVersion = assembly.GetName().Version;
+ if (informationVersion != null)
+ AppVersion = $"v{informationVersion.Major}.{informationVersion.Minor}.{informationVersion.Build}";
+
+ Ports = new ObservableCollection();
+
+ ClearMessagesCommand = ReactiveCommand.Create(() => { SentMessages.Clear(); });
+ ShowMessagesCommand = ReactiveCommand.Create(() => { ShowWriteMessages = !ShowWriteMessages; });
+
+ LoadDeviceInformation = ReactiveCommand.CreateFromObservable(LoadUsbInformation);
+ LoadDeviceInformation.IsExecuting.ToPropertyEx(this, x => x.IsLoadingPorts);
+ LoadDeviceInformation.ThrownExceptions.Subscribe(ex =>
+ Console.WriteLine($"Error loading device information with exception: {ex.Message}"));
+ //Log.Error(ex, "Error loading device information with exception: {Exception}", ex));
+
+ // can connect if there is a selection and also if the new selection is different than the old one
+ var canConnect = this.WhenAnyValue(x => x.SelectedPort)
+ .Select(selectedPort => !string.IsNullOrEmpty(selectedPort));
+
+ ShowAboutCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime owner &&
+ owner.MainWindow is Window ownerWindow)
+ {
+ await new About() { DataContext = new AboutViewModel() }.ShowDialog(ownerWindow);
+ }
+ });
+
+ ConnectAndGetBaseInfoCommand = ReactiveCommand.CreateFromTask(ConnectAndGetBaseInfo, canConnect);
+ ConnectAndGetBaseInfoCommand.IsExecuting.ToPropertyEx(this, x => x.IsConnecting);
+ ConnectAndGetBaseInfoCommand.ThrownExceptions.Subscribe(ex =>
+ //Log.Error(ex, "Error connecting to device with error: {Exception}", ex));
+ Console.WriteLine($"Error connecting to device with error: {ex}"));
+
+ var canChangeConfig = this.WhenAnyValue(x => x.Connected).Select(connected => connected);
+ // Handle Save and Reset
+ SaveConfigurationCommand =
+ ReactiveCommand.CreateFromObservable(SaveConfiguration, canChangeConfig);
+ SaveConfigurationCommand.IsExecuting.ToPropertyEx(this, x => x.IsSaving);
+ SaveConfigurationCommand.ThrownExceptions.Subscribe(ex =>
+ //Log.Error(ex, "Error saving configuration with error: {Exception}", ex));
+ Console.WriteLine($"Error saving configuration with error: {ex}"));
+
+ ResetConfigurationCommand = ReactiveCommand.CreateFromObservable(ResetConfiguration, canChangeConfig);
+ ResetConfigurationCommand.IsExecuting.ToPropertyEx(this, x => x.IsResetting);
+ ResetConfigurationCommand.ThrownExceptions.Subscribe(ex =>
+ //Log.Error(ex, "Error resetting device configuration with error: {Exception}", ex));
+ Console.WriteLine($"Error resetting device configuration with error: {ex}"));
+
+ WriteRegisterCommand = ReactiveCommand.CreateFromTask(async registerName =>
+ {
+ if (_device == null) return;
+
+ var propertyName = registerName;
+ var writeMethodName = $"Write{registerName}Async";
+ var logRegisterName = registerName;
+
+ if (registerName == nameof(EnableLedWrite))
+ {
+ propertyName = nameof(EnableLedWrite);
+ writeMethodName = "WriteEnableLedAsync";
+ logRegisterName = nameof(EnableLed);
+ }
+
+ var property = GetType().GetProperty(propertyName);
+ if (property == null) return;
+
+ var value = property.GetValue(this);
+
+ // Find the write method for this register
+ var writeMethod = _device.GetType().GetMethod(writeMethodName);
+ if (writeMethod != null)
+ {
+ if (writeMethod.Invoke(_device, new[] { value, CancellationToken.None }) is Task task)
+ await task;
+ else
+ return;
+
+ RxApp.MainThreadScheduler.Schedule(() =>
+ {
+ SentMessages.Add($"{DateTime.Now:HH:mm:ss.fff} - Write {logRegisterName}: {value}");
+ });
+ }
+ });
+ WriteRegisterCommand.IsExecuting.ToPropertyEx(this, x => x.IsSaving);
+ WriteRegisterCommand.ThrownExceptions.Subscribe(ex =>
+ //Log.Error(ex, "Error writing register with error: {Exception}", ex));
+ Console.WriteLine($"Error writing register with error: {ex}"));
+
+ this.WhenAnyValue(x => x.Connected)
+ .Subscribe(x => { ConnectButtonText = x ? "Disconnect" : "Connect"; });
+
+ this.WhenAnyValue(x => x.EnableEvents)
+ .Subscribe(x =>
+ {
+ IsEnableLedEnabled = x.HasFlag(LedArrayEvents.EnableLed);
+ IsDigitalInputStateEnabled = x.HasFlag(LedArrayEvents.DigitalInputState);
+ });
+
+ // handle the events from the device
+ // When Connected changes subscribe/unsubscribe the device events.
+ this.WhenAnyValue(x => x.Connected)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(isConnected =>
+ {
+ if (isConnected && _deviceEventsObservable is not null)
+ {
+ // Subscribe on the UI thread so that the HarpEvents collection can be updated safely.
+ SubscribeToEvents(_deviceEventsObservable);
+ }
+ else
+ {
+ // Dispose subscription and clear messages.
+ _deviceEventsSubscription?.Dispose();
+ _deviceEventsSubscription = null;
+ }
+ });
+
+ this.WhenAnyValue(x => x.EnablePower)
+ .Subscribe(x =>
+ {
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnablePower));
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnablePower));
+ });
+
+ this.WhenAnyValue(x => x.EnableLedMode)
+ .Subscribe(x =>
+ {
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnableLedMode));
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnableLedMode));
+ });
+
+ this.WhenAnyValue(x => x.EnableLed)
+ .Subscribe(_ =>
+ {
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnableLed));
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnableLed));
+ });
+
+ this.WhenAnyValue(x => x.EnableLedWrite)
+ .Subscribe(_ =>
+ {
+ this.RaisePropertyChanged(nameof(IsLed0Enabled_EnableLedWrite));
+ this.RaisePropertyChanged(nameof(IsLed1Enabled_EnableLedWrite));
+ });
+
+ this.WhenAnyValue(x => x.DigitalInputState)
+ .Subscribe(x =>
+ {
+ IsDI0Enabled_DigitalInputState = x.HasFlag(DigitalInputs.DI0);
+ IsDI1Enabled_DigitalInputState = x.HasFlag(DigitalInputs.DI1);
+ });
+
+ this.WhenAnyValue(x => x.AuxDigitalOutputState)
+ .Subscribe(x =>
+ {
+ this.RaisePropertyChanged(nameof(IsAux0Enabled_AuxDigitalOutputState));
+ this.RaisePropertyChanged(nameof(IsAux1Enabled_AuxDigitalOutputState));
+ });
+
+ this.WhenAnyValue(x => x.DigitalOutputState)
+ .Subscribe(x =>
+ {
+ this.RaisePropertyChanged(nameof(IsDO0Enabled_DigitalOutputState));
+ this.RaisePropertyChanged(nameof(IsDO1Enabled_DigitalOutputState));
+ });
+
+ this.WhenAnyValue(x => x.PulseMode)
+ .Subscribe(x =>
+ {
+ this.RaisePropertyChanged(nameof(Led0SelectedPulseMode));
+ this.RaisePropertyChanged(nameof(Led1SelectedPulseMode));
+ this.RaisePropertyChanged(nameof(IsLed0PwmMode));
+ this.RaisePropertyChanged(nameof(IsLed1PwmMode));
+ this.RaisePropertyChanged(nameof(IsLed0IntervalMode));
+ this.RaisePropertyChanged(nameof(IsLed1IntervalMode));
+ });
+
+ // force initial population of currently connected ports
+ LoadUsbInformation();
+ }
+
+ private IObservable LoadUsbInformation()
+ {
+ return Observable.Start(() =>
+ {
+ var devices = SerialPort.GetPortNames();
+
+ if (OperatingSystem.IsMacOS())
+ // except with Bluetooth in the name
+ Ports = new ObservableCollection(devices.Where(d => d.Contains("cu.")).Except(devices.Where(d => d.Contains("Bluetooth"))));
+ else
+ Ports = new ObservableCollection(devices);
+
+ Console.WriteLine("Loaded USB information");
+ //Log.Information("Loaded USB information");
+ });
+ }
+
+ private async Task ConnectAndGetBaseInfo()
+ {
+ if (string.IsNullOrEmpty(SelectedPort))
+ throw new InvalidOperationException("invalid parameter");
+
+ if (Connected)
+ {
+ _device?.Dispose();
+ _device = null;
+ Connected = false;
+ SentMessages.Clear();
+ return;
+ }
+
+ try
+ {
+ using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(500));
+ _device = await Harp.LedArray.Device.CreateAsync(SelectedPort, cts.Token);
+ }
+ catch (OperationCanceledException ex)
+ {
+ Console.WriteLine($"Error connecting to device with error: {ex}");
+ //Log.Error(ex, "Error connecting to device with error: {Exception}", ex);
+ var messageBoxStandardWindow = MessageBoxManager
+ .GetMessageBoxStandard("Unexpected device found",
+ "Timeout when trying to connect to a device. Most likely not an Harp device.",
+ icon: Icon.Error);
+ await messageBoxStandardWindow.ShowAsync();
+ _device?.Dispose();
+ _device = null;
+ return;
+
+ }
+ catch (HarpException ex)
+ {
+ Console.WriteLine($"Error connecting to device with error: {ex}");
+ //Log.Error(ex, "Error connecting to device with error: {Exception}", ex);
+
+ var messageBoxStandardWindow = MessageBoxManager
+ .GetMessageBoxStandard("Unexpected device found",
+ ex.Message,
+ icon: Icon.Error);
+ await messageBoxStandardWindow.ShowAsync();
+
+ _device?.Dispose();
+ _device = null;
+ return;
+ }
+ catch (UnauthorizedAccessException ex)
+ {
+ Console.WriteLine($"COM port still in use and most likely not the expected Harp device");
+ var messageBoxStandardWindow = MessageBoxManager
+ .GetMessageBoxStandard("Unexpected device found",
+ $"COM port still in use and most likely not the expected Harp device.{Environment.NewLine}Specific error: {ex.Message}",
+ icon: Icon.Error);
+ await messageBoxStandardWindow.ShowAsync();
+
+ _device?.Dispose();
+ _device = null;
+ return;
+ }
+
+ // Clear the sent messages list
+ SentMessages.Clear();
+
+ //Log.Information("Attempting connection to port \'{SelectedPort}\'", SelectedPort);
+ Console.WriteLine($"Attempting connection to port \'{SelectedPort}\'");
+
+ DeviceID = await _device.ReadWhoAmIAsync();
+ DeviceName = await _device.ReadDeviceNameAsync();
+ HardwareVersion = await _device.ReadHardwareVersionAsync();
+ FirmwareVersion = await _device.ReadFirmwareVersionAsync();
+ try
+ {
+ // some devices may not have a serial number
+ SerialNumber = await _device.ReadSerialNumberAsync();
+ }
+ catch (HarpException)
+ {
+ // Device does not have a serial number, simply continue by ignoring the exception
+ }
+
+ EnablePower = await _device.ReadEnablePowerAsync();
+ EnableLedMode = await _device.ReadEnableLedModeAsync();
+ var enableLed = await _device.ReadEnableLedAsync();
+ EnableLed = enableLed;
+ EnableLedWrite = enableLed;
+ DigitalInputState = await _device.ReadDigitalInputStateAsync();
+ DigitalOutputSync = await _device.ReadDigitalOutputSyncAsync();
+ DigitalInputTrigger = await _device.ReadDigitalInputTriggerAsync();
+ PulseMode = await _device.ReadPulseModeAsync();
+ Led0Power = await _device.ReadLed0PowerAsync();
+ Led1Power = await _device.ReadLed1PowerAsync();
+ Led0PwmFrequency = await _device.ReadLed0PwmFrequencyAsync();
+ Led0PwmDutyCycle = await _device.ReadLed0PwmDutyCycleAsync();
+ Led0PwmPulseCounter = await _device.ReadLed0PwmPulseCounterAsync();
+ Led0PulseTimeOn = await _device.ReadLed0PulseTimeOnAsync();
+ Led0PulseTimeOff = await _device.ReadLed0PulseTimeOffAsync();
+ Led0PulseTimePulseCounter = await _device.ReadLed0PulseTimePulseCounterAsync();
+ Led0PulseTimeTail = await _device.ReadLed0PulseTimeTailAsync();
+ Led0PulseRepeatCounter = await _device.ReadLed0PulseRepeatCounterAsync();
+ Led1PwmFrequency = await _device.ReadLed1PwmFrequencyAsync();
+ Led1PwmDutyCycle = await _device.ReadLed1PwmDutyCycleAsync();
+ Led1PwmPulseCounter = await _device.ReadLed1PwmPulseCounterAsync();
+ Led1PulseTimeOn = await _device.ReadLed1PulseTimeOnAsync();
+ Led1PulseTimeOff = await _device.ReadLed1PulseTimeOffAsync();
+ Led1PulseTimePulseCounter = await _device.ReadLed1PulseTimePulseCounterAsync();
+ Led1PulseTimeTail = await _device.ReadLed1PulseTimeTailAsync();
+ Led1PulseRepeatCounter = await _device.ReadLed1PulseRepeatCounterAsync();
+ Led0PwmReal = await _device.ReadLed0PwmRealAsync();
+ Led0PwmDutyCycleReal = await _device.ReadLed0PwmDutyCycleRealAsync();
+ Led1PwmReal = await _device.ReadLed1PwmRealAsync();
+ Led1PwmDutyCycleReal = await _device.ReadLed1PwmDutyCycleRealAsync();
+ AuxDigitalOutputState = await _device.ReadAuxDigitalOutputStateAsync();
+ AuxLedPower = await _device.ReadAuxLedPowerAsync();
+ DigitalOutputState = await _device.ReadDigitalOutputStateAsync();
+ EnableEvents = await _device.ReadEnableEventsAsync();
+
+
+ // generate observable for the _deviceSync
+ _deviceEventsObservable = GenerateEventMessages();
+
+ Connected = true;
+
+ //Log.Information("Connected to device");
+ Console.WriteLine("Connected to device");
+ }
+
+ public IObservable GenerateEventMessages()
+ {
+ return Observable.Create(async (observer, cancellationToken) =>
+ {
+ // Loop until cancellation is requested or the device is no longer available.
+ while (!cancellationToken.IsCancellationRequested && _device != null)
+ {
+ // Capture local reference and check for null.
+ var device = _device;
+ if (device == null)
+ {
+ observer.OnCompleted();
+ break;
+ }
+
+ try
+ {
+ // Check if EnableLed event is enabled
+ if (IsEnableLedEnabled)
+ {
+ var result = await device.ReadEnableLedAsync(cancellationToken);
+ EnableLed = result;
+ observer.OnNext($"EnableLed: {result}");
+ }
+
+ // Check if DigitalInputState event is enabled
+ if (IsDigitalInputStateEnabled)
+ {
+ var result = await device.ReadDigitalInputStateAsync(cancellationToken);
+ // Update the corresponding property with the result
+ DigitalInputState = result;
+ observer.OnNext($"DigitalInputState: {result}");
+ }
+
+ // Wait a short while before polling again. Adjust delay as necessary.
+ await Task.Delay(TimeSpan.FromMilliseconds(10), cancellationToken);
+ }
+ catch (OperationCanceledException)
+ {
+ break;
+ }
+ catch (Exception ex)
+ {
+ observer.OnError(ex);
+ break;
+ }
+ }
+ observer.OnCompleted();
+ return Disposable.Empty;
+ });
+ }
+
+ private IObservable SaveConfiguration(bool savePermanently)
+ {
+ return Observable.StartAsync(async () =>
+ {
+ if (_device == null)
+ throw new Exception("You need to connect to the device first");
+
+ await WriteAndLogAsync(
+ value => _device.WriteEnablePowerAsync(value),
+ EnablePower,
+ "EnablePower");
+ await WriteAndLogAsync(
+ value => _device.WriteEnableLedAsync(value),
+ EnableLedWrite,
+ "EnableLed");
+ await WriteAndLogAsync(
+ value => _device.WriteEnableLedModeAsync(value),
+ EnableLedMode,
+ "EnableLedMode");
+ await WriteAndLogAsync(
+ value => _device.WriteDigitalOutputSyncAsync(value),
+ DigitalOutputSync,
+ "DigitalOutputSync");
+ await WriteAndLogAsync(
+ value => _device.WriteDigitalInputTriggerAsync(value),
+ DigitalInputTrigger,
+ "DigitalInputTrigger");
+ await WriteAndLogAsync(
+ value => _device.WritePulseModeAsync(value),
+ PulseMode,
+ "PulseMode");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PowerAsync(value),
+ Led0Power,
+ "Led0Power");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PowerAsync(value),
+ Led1Power,
+ "Led1Power");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PwmFrequencyAsync(value),
+ Led0PwmFrequency,
+ "Led0PwmFrequency");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PwmDutyCycleAsync(value),
+ Led0PwmDutyCycle,
+ "Led0PwmDutyCycle");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PwmPulseCounterAsync(value),
+ Led0PwmPulseCounter,
+ "Led0PwmPulseCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PulseTimeOnAsync(value),
+ Led0PulseTimeOn,
+ "Led0PulseTimeOn");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PulseTimeOffAsync(value),
+ Led0PulseTimeOff,
+ "Led0PulseTimeOff");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PulseTimePulseCounterAsync(value),
+ Led0PulseTimePulseCounter,
+ "Led0PulseTimePulseCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PulseTimeTailAsync(value),
+ Led0PulseTimeTail,
+ "Led0PulseTimeTail");
+ await WriteAndLogAsync(
+ value => _device.WriteLed0PulseRepeatCounterAsync(value),
+ Led0PulseRepeatCounter,
+ "Led0PulseRepeatCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PwmFrequencyAsync(value),
+ Led1PwmFrequency,
+ "Led1PwmFrequency");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PwmDutyCycleAsync(value),
+ Led1PwmDutyCycle,
+ "Led1PwmDutyCycle");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PwmPulseCounterAsync(value),
+ Led1PwmPulseCounter,
+ "Led1PwmPulseCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PulseTimeOnAsync(value),
+ Led1PulseTimeOn,
+ "Led1PulseTimeOn");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PulseTimeOffAsync(value),
+ Led1PulseTimeOff,
+ "Led1PulseTimeOff");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PulseTimePulseCounterAsync(value),
+ Led1PulseTimePulseCounter,
+ "Led1PulseTimePulseCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PulseTimeTailAsync(value),
+ Led1PulseTimeTail,
+ "Led1PulseTimeTail");
+ await WriteAndLogAsync(
+ value => _device.WriteLed1PulseRepeatCounterAsync(value),
+ Led1PulseRepeatCounter,
+ "Led1PulseRepeatCounter");
+ await WriteAndLogAsync(
+ value => _device.WriteAuxDigitalOutputStateAsync(value),
+ AuxDigitalOutputState,
+ "AuxDigitalOutputState");
+ await WriteAndLogAsync(
+ value => _device.WriteAuxLedPowerAsync(value),
+ AuxLedPower,
+ "AuxLedPower");
+ await WriteAndLogAsync(
+ value => _device.WriteDigitalOutputStateAsync(value),
+ DigitalOutputState,
+ "DigitalOutputState");
+ await WriteAndLogAsync(
+ value => _device.WriteEnableEventsAsync(value),
+ EnableEvents,
+ "EnableEvents");
+
+ // Save the configuration to the device permanently
+ if (savePermanently && _deviceEventsObservable is not null)
+ {
+ // To prevent multiple calls to the device while it is resetting
+ _deviceEventsSubscription?.Dispose();
+ _deviceEventsSubscription = null;
+
+ await WriteAndLogAsync(
+ value => _device.WriteResetDeviceAsync(value),
+ ResetFlags.Save,
+ "SavePermanently");
+
+ // Wait to ensure the device is ready after the reset
+ await Task.Delay(4000);
+
+ // Re-subscribe to the device events observable
+ SubscribeToEvents(_deviceEventsObservable);
+ }
+
+ // read the read-only values from the device again
+ await ReadRuntimeStatusRegistersAsync();
+ });
+ }
+
+ private IObservable ResetConfiguration()
+ {
+ return Observable.StartAsync(async () =>
+ {
+ if (_device != null)
+ {
+ await WriteAndLogAsync(
+ value => _device.WriteResetDeviceAsync(value),
+ ResetFlags.RestoreDefault,
+ "ResetDevice");
+ }
+ });
+ }
+
+ private async Task ReadRuntimeStatusRegistersAsync(CancellationToken ct = default)
+ {
+ if (_device == null)
+ throw new Exception("Device is not connected");
+
+ // On get read-only registers
+ Led0PwmReal = await _device.ReadLed0PwmRealAsync(ct);
+ Led0PwmDutyCycleReal = await _device.ReadLed0PwmDutyCycleRealAsync(ct);
+ Led1PwmReal = await _device.ReadLed1PwmRealAsync(ct);
+ Led1PwmDutyCycleReal = await _device.ReadLed1PwmDutyCycleRealAsync(ct);
+
+ // Runtime output states
+ AuxDigitalOutputState = await _device.ReadAuxDigitalOutputStateAsync(ct);
+ DigitalOutputState = await _device.ReadDigitalOutputStateAsync(ct);
+
+ // Other runtime-visible state you may want refreshed post-save
+ EnableEvents = await _device.ReadEnableEventsAsync(ct);
+ }
+
+ private async Task WriteAndLogAsync(Func writeFunc, T value, string registerName)
+ {
+ if (_device == null)
+ throw new Exception("Device is not connected");
+
+ await writeFunc(value);
+
+ // Log the message to the SentMessages collection on the UI thread
+ RxApp.MainThreadScheduler.Schedule(() =>
+ {
+ SentMessages.Add($"{DateTime.Now:HH:mm:ss.fff} - Write {registerName}: {value}");
+ });
+ }
+
+ private void SubscribeToEvents(IObservable deviceEvents)
+ {
+ _deviceEventsSubscription = deviceEvents
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(
+ msg => HarpEvents.Add(msg.ToString()),
+ ex => Debug.WriteLine($"Error in device events: {ex}")
+ );
+ }
+
+ private static LedState SetExclusiveFlagState(
+ LedState current,
+ LedState onFlag,
+ LedState offFlag,
+ bool isEnabled)
+ {
+ current &= ~(onFlag | offFlag);
+ current |= isEnabled ? onFlag : offFlag;
+ return current;
+ }
+
+private static AuxDigitalOutputs SetExclusiveFlagState(
+ AuxDigitalOutputs current,
+ AuxDigitalOutputs setFlag,
+ AuxDigitalOutputs clearFlag,
+ bool isSet)
+ {
+ current &= ~(setFlag | clearFlag);
+ current |= isSet ? setFlag : clearFlag;
+ return current;
+ }
+
+ private static DigitalOutputs SetExclusiveFlagState(
+ DigitalOutputs current,
+ DigitalOutputs setFlag,
+ DigitalOutputs clearFlag,
+ bool isSet)
+ {
+ current &= ~(setFlag | clearFlag);
+ current |= isSet ? setFlag : clearFlag;
+ return current;
+ }
+
+}
diff --git a/App/Harp.LedArray.Design/ViewModels/ViewModelBase.cs b/App/Harp.LedArray.Design/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..10cea79
--- /dev/null
+++ b/App/Harp.LedArray.Design/ViewModels/ViewModelBase.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Reactive.Linq;
+using Avalonia;
+using Avalonia.Media;
+using Avalonia.Platform;
+using Avalonia.Styling;
+using ReactiveUI;
+using ReactiveUI.Fody.Helpers;
+
+namespace Harp.LedArray.Design.ViewModels;
+
+public class ViewModelBase : ReactiveObject
+{
+ [Reactive] public bool IsDarkMode { get; set; }
+ [Reactive] public IBrush IconColor { get; set; }
+ [Reactive] public IBrush SurfaceBackground { get; set; }
+
+ private readonly IBrush _lightColor = Brushes.White;
+ private readonly IBrush _darkColor = Brushes.Black;
+
+
+ public ViewModelBase()
+ {
+ // Get the current theme on Application.Current!.RequestedTheme
+ var currentTheme = Application.Current!.RequestedThemeVariant;
+ IsDarkMode = currentTheme == ThemeVariant.Dark ||
+ (currentTheme == ThemeVariant.Default && IsSystemInDarkMode());
+
+ // set initial color
+ IconColor = IsDarkMode ? _lightColor : _darkColor;
+ // invert colors for backgrounds
+ SurfaceBackground = IsDarkMode ? _darkColor : _lightColor;
+
+ // update icon color when IsDarkMode changes
+ this.WhenAnyValue(x => x.IsDarkMode)
+ .Subscribe(isDarkMode =>
+ {
+ IconColor = isDarkMode ? _lightColor : _darkColor;
+ SurfaceBackground = isDarkMode ? _darkColor : _lightColor;
+ });
+
+ // Subscribe to changes in IsDarkMode
+ this.WhenAnyValue(x => x.IsDarkMode)
+ .Skip(1) // Skip the initial value to avoid unnecessary theme change on initialization
+ .Subscribe(isDarkMode => Application.Current.RequestedThemeVariant = isDarkMode ? ThemeVariant.Dark : ThemeVariant.Light);
+ }
+
+ private bool IsSystemInDarkMode()
+ {
+ // detect using avalonia if system is in dark mode
+ var colors = Application.Current!.PlatformSettings!.GetColorValues();
+ return colors.ThemeVariant == PlatformThemeVariant.Dark;
+ }
+}
diff --git a/App/Harp.LedArray.Design/Views/About.axaml b/App/Harp.LedArray.Design/Views/About.axaml
new file mode 100644
index 0000000..600b755
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/About.axaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ The LedArray GUI application allows to configure the LedArray device, developed by the Hardware and Software Platform at the Champalimaud Foundation.
+
+ The LedArray is a Harp device and has all the inherent Harp Devices functionalities.
+
+ The GUI was developed using [.NET](https://dotnet.microsoft.com/), [AvaloniaUI](https://avaloniaui.net/) with ReactiveUI and makes direct use of the [Bonsai.Harp](https://github.com/bonsai-rx/harp) library.
+
+ As with other Harp devices, the LedArray can also be used in [Bonsai](https://bonsai-rx.org/).
+
+
+
diff --git a/App/Harp.LedArray.Design/Views/About.axaml.cs b/App/Harp.LedArray.Design/Views/About.axaml.cs
new file mode 100644
index 0000000..d2ee185
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/About.axaml.cs
@@ -0,0 +1,11 @@
+using Avalonia.Controls;
+
+namespace Harp.LedArray.Design.Views;
+
+public partial class About : Window
+{
+ public About()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/App/Harp.LedArray.Design/Views/MainWindow.axaml b/App/Harp.LedArray.Design/Views/MainWindow.axaml
new file mode 100644
index 0000000..8d6c2a4
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/MainWindow.axaml
@@ -0,0 +1,14 @@
+
+
+
diff --git a/App/Harp.LedArray.Design/Views/MainWindow.axaml.cs b/App/Harp.LedArray.Design/Views/MainWindow.axaml.cs
new file mode 100644
index 0000000..2932b6c
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/MainWindow.axaml.cs
@@ -0,0 +1,11 @@
+using Avalonia.Controls;
+
+namespace Harp.LedArray.Design.Views;
+
+public partial class MainWindow : Window
+{
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/App/Harp.LedArray.Design/Views/MyDeviceView.axaml b/App/Harp.LedArray.Design/Views/MyDeviceView.axaml
new file mode 100644
index 0000000..45de3b1
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/MyDeviceView.axaml
@@ -0,0 +1,804 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Enable Led
+
+
+ Digital Input State
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PWM Mode
+ Interval mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PWM Mode
+ Interval mode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Enable power to LED0
+ Start and stop LED0 behavior
+ Turn LED0 on and off
+ Enable power to LED1
+ Start and stop LED1 behavior
+ Turn LED1 on and off
+ No trigger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Enable power to LED0
+ Start and stop LED0 behavior
+ Turn LED0 on and off
+ Enable power to LED1
+ Start and stop LED1 behavior
+ Turn LED1 on and off
+ No trigger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pure digital output (software controlled)
+ Mimics LED0 Enable Power
+ Mimics LED0 Enable Behavior
+ Mimics LED0 Enable LED
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pure digital output (software controlled)
+ Mimics LED1 Enable Power
+ Mimics LED1 Enable Behavior
+ Mimics LED1 Enable LED
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App/Harp.LedArray.Design/Views/MyDeviceView.axaml.cs b/App/Harp.LedArray.Design/Views/MyDeviceView.axaml.cs
new file mode 100644
index 0000000..53491f2
--- /dev/null
+++ b/App/Harp.LedArray.Design/Views/MyDeviceView.axaml.cs
@@ -0,0 +1,11 @@
+using Avalonia.Controls;
+
+namespace Harp.LedArray.Design.Views;
+
+public partial class LedArrayView : UserControl
+{
+ public LedArrayView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/App/Harp.LedArray.nsi b/App/Harp.LedArray.nsi
new file mode 100644
index 0000000..f2abb6a
Binary files /dev/null and b/App/Harp.LedArray.nsi differ
diff --git a/App/LICENSE b/App/LICENSE
new file mode 100644
index 0000000..47539f7
--- /dev/null
+++ b/App/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021-2023 Hardware & Software Platform, Champalimaud Foundation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/App/README.md b/App/README.md
new file mode 100644
index 0000000..55af1dd
--- /dev/null
+++ b/App/README.md
@@ -0,0 +1,2 @@
+# Harp.LedArray.App
+
diff --git a/Generators/Generators.csproj b/Generators/Generators.csproj
index 9e36287..9323234 100644
--- a/Generators/Generators.csproj
+++ b/Generators/Generators.csproj
@@ -15,7 +15,7 @@
..\Firmware\Harp.LedArray
-
+
diff --git a/Interface/Harp.LedArray/AsyncDevice.Generated.cs b/Interface/Harp.LedArray/AsyncDevice.Generated.cs
index 4df5654..cab6dce 100644
--- a/Interface/Harp.LedArray/AsyncDevice.Generated.cs
+++ b/Interface/Harp.LedArray/AsyncDevice.Generated.cs
@@ -14,15 +14,18 @@ public partial class Device
///
/// The name of the serial port used to communicate with the Harp device.
///
+ ///
+ /// A which can be used to cancel the operation.
+ ///
///
/// A task that represents the asynchronous initialization operation. The value of
/// the parameter contains a new instance of
/// the class.
///
- public static async Task CreateAsync(string portName)
+ public static async Task CreateAsync(string portName, CancellationToken cancellationToken = default)
{
var device = new AsyncDevice(portName);
- var whoAmI = await device.ReadWhoAmIAsync();
+ var whoAmI = await device.ReadWhoAmIAsync(cancellationToken);
if (whoAmI != Device.WhoAmI)
{
var errorMessage = string.Format(
@@ -1278,7 +1281,7 @@ public async Task> ReadTimestampedLed1PwmRealAsync(Cancellati
}
///
- /// Asynchronously reads the contents of the LedD1PwmDutyCycleReal register.
+ /// Asynchronously reads the contents of the Led1PwmDutyCycleReal register.
///
///
/// A which can be used to cancel the operation.
@@ -1287,14 +1290,14 @@ public async Task> ReadTimestampedLed1PwmRealAsync(Cancellati
/// A task that represents the asynchronous read operation. The
/// property contains the register payload.
///
- public async Task ReadLedD1PwmDutyCycleRealAsync(CancellationToken cancellationToken = default)
+ public async Task ReadLed1PwmDutyCycleRealAsync(CancellationToken cancellationToken = default)
{
- var reply = await CommandAsync(HarpCommand.ReadSingle(LedD1PwmDutyCycleReal.Address), cancellationToken);
- return LedD1PwmDutyCycleReal.GetPayload(reply);
+ var reply = await CommandAsync(HarpCommand.ReadSingle(Led1PwmDutyCycleReal.Address), cancellationToken);
+ return Led1PwmDutyCycleReal.GetPayload(reply);
}
///
- /// Asynchronously reads the timestamped contents of the LedD1PwmDutyCycleReal register.
+ /// Asynchronously reads the timestamped contents of the Led1PwmDutyCycleReal register.
///
///
/// A which can be used to cancel the operation.
@@ -1303,10 +1306,10 @@ public async Task ReadLedD1PwmDutyCycleRealAsync(CancellationToken cancel
/// A task that represents the asynchronous read operation. The
/// property contains the timestamped register payload.
///
- public async Task> ReadTimestampedLedD1PwmDutyCycleRealAsync(CancellationToken cancellationToken = default)
+ public async Task> ReadTimestampedLed1PwmDutyCycleRealAsync(CancellationToken cancellationToken = default)
{
- var reply = await CommandAsync(HarpCommand.ReadSingle(LedD1PwmDutyCycleReal.Address), cancellationToken);
- return LedD1PwmDutyCycleReal.GetTimestampedPayload(reply);
+ var reply = await CommandAsync(HarpCommand.ReadSingle(Led1PwmDutyCycleReal.Address), cancellationToken);
+ return Led1PwmDutyCycleReal.GetTimestampedPayload(reply);
}
///
diff --git a/Interface/Harp.LedArray/Device.Generated.cs b/Interface/Harp.LedArray/Device.Generated.cs
index a154781..0bde045 100644
--- a/Interface/Harp.LedArray/Device.Generated.cs
+++ b/Interface/Harp.LedArray/Device.Generated.cs
@@ -65,7 +65,7 @@ public Device() : base(WhoAmI) { }
{ 57, typeof(Led0PwmReal) },
{ 58, typeof(Led0PwmDutyCycleReal) },
{ 59, typeof(Led1PwmReal) },
- { 60, typeof(LedD1PwmDutyCycleReal) },
+ { 60, typeof(Led1PwmDutyCycleReal) },
{ 61, typeof(AuxDigitalOutputState) },
{ 62, typeof(AuxLedPower) },
{ 63, typeof(DigitalOutputState) },
@@ -93,7 +93,7 @@ static string GetDeviceMetadata()
/// describing the device registers.
///
[Description("Returns the contents of the metadata file describing the LedArray device registers.")]
- public partial class GetMetadata : Source
+ public partial class GetDeviceMetadata : Source
{
///
/// Returns an observable sequence with the contents of the metadata file
@@ -130,6 +130,156 @@ public override IObservable> Process(IObse
}
}
+ ///
+ /// Represents an operator that writes the sequence of " messages
+ /// to the standard Harp storage format.
+ ///
+ [Description("Writes the sequence of LedArray messages to the standard Harp storage format.")]
+ public partial class DeviceDataWriter : Sink, INamedElement
+ {
+ const string BinaryExtension = ".bin";
+ const string MetadataFileName = "device.yml";
+ readonly Bonsai.Harp.MessageWriter writer = new();
+
+ string INamedElement.Name => nameof(LedArray) + "DataWriter";
+
+ ///
+ /// Gets or sets the relative or absolute path on which to save the message data.
+ ///
+ [Description("The relative or absolute path of the directory on which to save the message data.")]
+ [Editor("Bonsai.Design.SaveFileNameEditor, Bonsai.Design", DesignTypes.UITypeEditor)]
+ public string Path
+ {
+ get => System.IO.Path.GetDirectoryName(writer.FileName);
+ set => writer.FileName = System.IO.Path.Combine(value, nameof(LedArray) + BinaryExtension);
+ }
+
+ ///
+ /// Gets or sets a value indicating whether element writing should be buffered. If ,
+ /// the write commands will be queued in memory as fast as possible and will be processed
+ /// by the writer in a different thread. Otherwise, writing will be done in the same
+ /// thread in which notifications arrive.
+ ///
+ [Description("Indicates whether writing should be buffered.")]
+ public bool Buffered
+ {
+ get => writer.Buffered;
+ set => writer.Buffered = value;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether to overwrite the output file if it already exists.
+ ///
+ [Description("Indicates whether to overwrite the output file if it already exists.")]
+ public bool Overwrite
+ {
+ get => writer.Overwrite;
+ set => writer.Overwrite = value;
+ }
+
+ ///
+ /// Gets or sets a value specifying how the message filter will use the matching criteria.
+ ///
+ [Description("Specifies how the message filter will use the matching criteria.")]
+ public FilterType FilterType
+ {
+ get => writer.FilterType;
+ set => writer.FilterType = value;
+ }
+
+ ///
+ /// Gets or sets a value specifying the expected message type. If no value is
+ /// specified, all messages will be accepted.
+ ///
+ [Description("Specifies the expected message type. If no value is specified, all messages will be accepted.")]
+ public MessageType? MessageType
+ {
+ get => writer.MessageType;
+ set => writer.MessageType = value;
+ }
+
+ private IObservable WriteDeviceMetadata(IObservable source)
+ {
+ var basePath = Path;
+ if (string.IsNullOrEmpty(basePath))
+ return source;
+
+ var metadataPath = System.IO.Path.Combine(basePath, MetadataFileName);
+ return Observable.Create(observer =>
+ {
+ Bonsai.IO.PathHelper.EnsureDirectory(metadataPath);
+ if (System.IO.File.Exists(metadataPath) && !Overwrite)
+ {
+ throw new System.IO.IOException(string.Format("The file '{0}' already exists.", metadataPath));
+ }
+
+ System.IO.File.WriteAllText(metadataPath, Device.Metadata);
+ return source.SubscribeSafe(observer);
+ });
+ }
+
+ ///
+ /// Writes each Harp message in the sequence to the specified binary file, and the
+ /// contents of the device metadata file to a separate text file.
+ ///
+ /// The sequence of messages to write to the file.
+ ///
+ /// An observable sequence that is identical to the
+ /// sequence but where there is an additional side effect of writing the
+ /// messages to a raw binary file, and the contents of the device metadata file
+ /// to a separate text file.
+ ///
+ public override IObservable Process(IObservable source)
+ {
+ return source.Publish(ps => ps.Merge(
+ WriteDeviceMetadata(writer.Process(ps.GroupBy(message => message.Address)))
+ .IgnoreElements()
+ .Cast()));
+ }
+
+ ///
+ /// Writes each Harp message in the sequence of observable groups to the
+ /// corresponding binary file, where the name of each file is generated from
+ /// the common group register address. The contents of the device metadata file are
+ /// written to a separate text file.
+ ///
+ ///
+ /// A sequence of observable groups, each of which corresponds to a unique register
+ /// address.
+ ///
+ ///
+ /// An observable sequence that is identical to the
+ /// sequence but where there is an additional side effect of writing the Harp
+ /// messages in each group to the corresponding file, and the contents of the device
+ /// metadata file to a separate text file.
+ ///
+ public IObservable> Process(IObservable> source)
+ {
+ return WriteDeviceMetadata(writer.Process(source));
+ }
+
+ ///
+ /// Writes each Harp message in the sequence of observable groups to the
+ /// corresponding binary file, where the name of each file is generated from
+ /// the common group register name. The contents of the device metadata file are
+ /// written to a separate text file.
+ ///
+ ///
+ /// A sequence of observable groups, each of which corresponds to a unique register
+ /// type.
+ ///
+ ///
+ /// An observable sequence that is identical to the
+ /// sequence but where there is an additional side effect of writing the Harp
+ /// messages in each group to the corresponding file, and the contents of the device
+ /// metadata file to a separate text file.
+ ///
+ public IObservable> Process(IObservable> source)
+ {
+ return WriteDeviceMetadata(writer.Process(source));
+ }
+ }
+
///
/// Represents an operator that filters register-specific messages
/// reported by the device.
@@ -162,7 +312,7 @@ public override IObservable> Process(IObse
///
///
///
- ///
+ ///
///
///
///
@@ -195,7 +345,7 @@ public override IObservable> Process(IObse
[XmlInclude(typeof(Led0PwmReal))]
[XmlInclude(typeof(Led0PwmDutyCycleReal))]
[XmlInclude(typeof(Led1PwmReal))]
- [XmlInclude(typeof(LedD1PwmDutyCycleReal))]
+ [XmlInclude(typeof(Led1PwmDutyCycleReal))]
[XmlInclude(typeof(AuxDigitalOutputState))]
[XmlInclude(typeof(AuxLedPower))]
[XmlInclude(typeof(DigitalOutputState))]
@@ -249,7 +399,7 @@ string INamedElement.Name
///
///
///
- ///
+ ///
///
///
///
@@ -282,7 +432,7 @@ string INamedElement.Name
[XmlInclude(typeof(Led0PwmReal))]
[XmlInclude(typeof(Led0PwmDutyCycleReal))]
[XmlInclude(typeof(Led1PwmReal))]
- [XmlInclude(typeof(LedD1PwmDutyCycleReal))]
+ [XmlInclude(typeof(Led1PwmDutyCycleReal))]
[XmlInclude(typeof(AuxDigitalOutputState))]
[XmlInclude(typeof(AuxLedPower))]
[XmlInclude(typeof(DigitalOutputState))]
@@ -315,7 +465,7 @@ string INamedElement.Name
[XmlInclude(typeof(TimestampedLed0PwmReal))]
[XmlInclude(typeof(TimestampedLed0PwmDutyCycleReal))]
[XmlInclude(typeof(TimestampedLed1PwmReal))]
- [XmlInclude(typeof(TimestampedLedD1PwmDutyCycleReal))]
+ [XmlInclude(typeof(TimestampedLed1PwmDutyCycleReal))]
[XmlInclude(typeof(TimestampedAuxDigitalOutputState))]
[XmlInclude(typeof(TimestampedAuxLedPower))]
[XmlInclude(typeof(TimestampedDigitalOutputState))]
@@ -366,7 +516,7 @@ public Parse()
///
///
///
- ///
+ ///
///
///
///
@@ -399,7 +549,7 @@ public Parse()
[XmlInclude(typeof(Led0PwmReal))]
[XmlInclude(typeof(Led0PwmDutyCycleReal))]
[XmlInclude(typeof(Led1PwmReal))]
- [XmlInclude(typeof(LedD1PwmDutyCycleReal))]
+ [XmlInclude(typeof(Led1PwmDutyCycleReal))]
[XmlInclude(typeof(AuxDigitalOutputState))]
[XmlInclude(typeof(AuxLedPower))]
[XmlInclude(typeof(DigitalOutputState))]
@@ -3165,25 +3315,25 @@ public static Timestamped GetPayload(HarpMessage message)
/// Represents a register that get the real duty cycle (%) of LED1 when in Pwm mode.
///
[Description("Get the real duty cycle (%) of LED1 when in Pwm mode.")]
- public partial class LedD1PwmDutyCycleReal
+ public partial class Led1PwmDutyCycleReal
{
///
- /// Represents the address of the register. This field is constant.
+ /// Represents the address of the register. This field is constant.
///
public const int Address = 60;
///
- /// Represents the payload type of the register. This field is constant.
+ /// Represents the payload type of the register. This field is constant.
///
public const PayloadType RegisterType = PayloadType.Float;
///
- /// Represents the length of the register. This field is constant.
+ /// Represents the length of the register. This field is constant.
///
public const int RegisterLength = 1;
///
- /// Returns the payload data for register messages.
+ /// Returns the payload data for register messages.
///
/// A object representing the register message.
/// A value representing the message payload.
@@ -3193,7 +3343,7 @@ public static float GetPayload(HarpMessage message)
}
///
- /// Returns the timestamped payload data for register messages.
+ /// Returns the timestamped payload data for register messages.
///
/// A object representing the register message.
/// A value representing the timestamped message payload.
@@ -3203,12 +3353,12 @@ public static Timestamped GetTimestampedPayload(HarpMessage message)
}
///
- /// Returns a Harp message for the register.
+ /// Returns a Harp message for the register.
///
/// The type of the Harp message.
/// The value to be stored in the message payload.
///
- /// A object for the register
+ /// A object for the register
/// with the specified message type and payload.
///
public static HarpMessage FromPayload(MessageType messageType, float value)
@@ -3217,14 +3367,14 @@ public static HarpMessage FromPayload(MessageType messageType, float value)
}
///
- /// Returns a timestamped Harp message for the
+ /// Returns a timestamped Harp message for the
/// register.
///
/// The timestamp of the message payload, in seconds.
/// The type of the Harp message.
/// The value to be stored in the message payload.
///
- /// A object for the register
+ /// A object for the register
/// with the specified message type, timestamp, and payload.
///
public static HarpMessage FromPayload(double timestamp, MessageType messageType, float value)
@@ -3235,25 +3385,25 @@ public static HarpMessage FromPayload(double timestamp, MessageType messageType,
///
/// Provides methods for manipulating timestamped messages from the
- /// LedD1PwmDutyCycleReal register.
+ /// Led1PwmDutyCycleReal register.
///
- ///
- [Description("Filters and selects timestamped messages from the LedD1PwmDutyCycleReal register.")]
- public partial class TimestampedLedD1PwmDutyCycleReal
+ ///
+ [Description("Filters and selects timestamped messages from the Led1PwmDutyCycleReal register.")]
+ public partial class TimestampedLed1PwmDutyCycleReal
{
///
- /// Represents the address of the register. This field is constant.
+ /// Represents the address of the register. This field is constant.
///
- public const int Address = LedD1PwmDutyCycleReal.Address;
+ public const int Address = Led1PwmDutyCycleReal.Address;
///
- /// Returns timestamped payload data for register messages.
+ /// Returns timestamped payload data for register messages.
///
/// A object representing the register message.
/// A value representing the timestamped message payload.
public static Timestamped GetPayload(HarpMessage message)
{
- return LedD1PwmDutyCycleReal.GetTimestampedPayload(message);
+ return Led1PwmDutyCycleReal.GetTimestampedPayload(message);
}
}
@@ -3698,7 +3848,7 @@ public static Timestamped GetPayload(HarpMessage message)
///
///
///
- ///
+ ///
///
///
///
@@ -3731,7 +3881,7 @@ public static Timestamped GetPayload(HarpMessage message)
[XmlInclude(typeof(CreateLed0PwmRealPayload))]
[XmlInclude(typeof(CreateLed0PwmDutyCycleRealPayload))]
[XmlInclude(typeof(CreateLed1PwmRealPayload))]
- [XmlInclude(typeof(CreateLedD1PwmDutyCycleRealPayload))]
+ [XmlInclude(typeof(CreateLed1PwmDutyCycleRealPayload))]
[XmlInclude(typeof(CreateAuxDigitalOutputStatePayload))]
[XmlInclude(typeof(CreateAuxLedPowerPayload))]
[XmlInclude(typeof(CreateDigitalOutputStatePayload))]
@@ -3764,7 +3914,7 @@ public static Timestamped GetPayload(HarpMessage message)
[XmlInclude(typeof(CreateTimestampedLed0PwmRealPayload))]
[XmlInclude(typeof(CreateTimestampedLed0PwmDutyCycleRealPayload))]
[XmlInclude(typeof(CreateTimestampedLed1PwmRealPayload))]
- [XmlInclude(typeof(CreateTimestampedLedD1PwmDutyCycleRealPayload))]
+ [XmlInclude(typeof(CreateTimestampedLed1PwmDutyCycleRealPayload))]
[XmlInclude(typeof(CreateTimestampedAuxDigitalOutputStatePayload))]
[XmlInclude(typeof(CreateTimestampedAuxLedPowerPayload))]
[XmlInclude(typeof(CreateTimestampedDigitalOutputStatePayload))]
@@ -5362,33 +5512,33 @@ public HarpMessage GetMessage(double timestamp, MessageType messageType)
/// Represents an operator that creates a message payload
/// that get the real duty cycle (%) of LED1 when in Pwm mode.
///
- [DisplayName("LedD1PwmDutyCycleRealPayload")]
+ [DisplayName("Led1PwmDutyCycleRealPayload")]
[Description("Creates a message payload that get the real duty cycle (%) of LED1 when in Pwm mode.")]
- public partial class CreateLedD1PwmDutyCycleRealPayload
+ public partial class CreateLed1PwmDutyCycleRealPayload
{
///
/// Gets or sets the value that get the real duty cycle (%) of LED1 when in Pwm mode.
///
[Description("The value that get the real duty cycle (%) of LED1 when in Pwm mode.")]
- public float LedD1PwmDutyCycleReal { get; set; }
+ public float Led1PwmDutyCycleReal { get; set; }
///
- /// Creates a message payload for the LedD1PwmDutyCycleReal register.
+ /// Creates a message payload for the Led1PwmDutyCycleReal register.
///
/// The created message payload value.
public float GetPayload()
{
- return LedD1PwmDutyCycleReal;
+ return Led1PwmDutyCycleReal;
}
///
/// Creates a message that get the real duty cycle (%) of LED1 when in Pwm mode.
///
/// Specifies the type of the created message.
- /// A new message for the LedD1PwmDutyCycleReal register.
+ /// A new message for the Led1PwmDutyCycleReal register.
public HarpMessage GetMessage(MessageType messageType)
{
- return Harp.LedArray.LedD1PwmDutyCycleReal.FromPayload(messageType, GetPayload());
+ return Harp.LedArray.Led1PwmDutyCycleReal.FromPayload(messageType, GetPayload());
}
}
@@ -5396,19 +5546,19 @@ public HarpMessage GetMessage(MessageType messageType)
/// Represents an operator that creates a timestamped message payload
/// that get the real duty cycle (%) of LED1 when in Pwm mode.
///
- [DisplayName("TimestampedLedD1PwmDutyCycleRealPayload")]
+ [DisplayName("TimestampedLed1PwmDutyCycleRealPayload")]
[Description("Creates a timestamped message payload that get the real duty cycle (%) of LED1 when in Pwm mode.")]
- public partial class CreateTimestampedLedD1PwmDutyCycleRealPayload : CreateLedD1PwmDutyCycleRealPayload
+ public partial class CreateTimestampedLed1PwmDutyCycleRealPayload : CreateLed1PwmDutyCycleRealPayload
{
///
/// Creates a timestamped message that get the real duty cycle (%) of LED1 when in Pwm mode.
///
/// The timestamp of the message payload, in seconds.
/// Specifies the type of the created message.
- /// A new timestamped message for the LedD1PwmDutyCycleReal register.
+ /// A new timestamped message for the Led1PwmDutyCycleReal register.
public HarpMessage GetMessage(double timestamp, MessageType messageType)
{
- return Harp.LedArray.LedD1PwmDutyCycleReal.FromPayload(timestamp, messageType, GetPayload());
+ return Harp.LedArray.Led1PwmDutyCycleReal.FromPayload(timestamp, messageType, GetPayload());
}
}
diff --git a/Interface/Harp.LedArray/Harp.LedArray.csproj b/Interface/Harp.LedArray/Harp.LedArray.csproj
index 1adb6c6..4ac1407 100644
--- a/Interface/Harp.LedArray/Harp.LedArray.csproj
+++ b/Interface/Harp.LedArray/Harp.LedArray.csproj
@@ -17,8 +17,8 @@
icon.png
LICENSE
..\bin\$(Configuration)
- net462;netstandard2.0
- 0.2.0
+ net462;netstandard2.0;net8.0
+ 0.3.0
9.0
diff --git a/device.yml b/device.yml
index cc9006d..f50db56 100644
--- a/device.yml
+++ b/device.yml
@@ -207,7 +207,7 @@ registers:
access: Read
type: Float
description: Get the real frequency (Hz) of LED1 when in Pwm mode.
- LedD1PwmDutyCycleReal:
+ Led1PwmDutyCycleReal:
address: 60
access: Read
type: Float