This document provides context for Claude to assist with the DAQiFi Desktop application development.
Note: Please check the
.cursor/rulesfolder periodically for any updates to development standards and incorporate those changes into this document to maintain consistency across AI-assisted development tools.
DAQiFi Desktop is a Windows desktop application for communicating with DAQiFi hardware products. Our goal is to modernize data acquisition with user-friendly and intuitive products.
- .NET 9.0 and WPF for the desktop application
- SQLite for local data storage
- Google Protocol Buffers for device communication
- EntityFramework for database operations
- NLog for logging framework
- MSTest with Moq for testing
The application follows MVVM (Model-View-ViewModel) pattern with these projects:
- Daqifi.Desktop - Main project containing UI
- Daqifi.Desktop.Bootloader - Bootloader/firmware domain
- Daqifi.Desktop.Common - Shared components
- Daqifi.Desktop.DataModel - Data models
- Daqifi.Desktop.IO - Device messaging
- Daqifi.Desktop.Setup - Wix installer
- Interfaces: PascalCase with I prefix (e.g.,
IStreamingDevice) - Classes: PascalCase (e.g.,
FirewallConfiguration) - Methods: PascalCase (e.g.,
InitializeFirewallRules) - Properties: PascalCase (e.g.,
StreamingFrequency) - Private Fields: camelCase with _ prefix (e.g.,
_firewallHelper) - Constants: SCREAMING_SNAKE_CASE (e.g.,
RULE_NAME)
- Indentation: 4 spaces
- Max line length: 120 characters
- Braces: Allman style (opening brace on new line)
- Regions: Use #region for logical grouping
- File organization: One main class per file
public class FirewallConfiguration : IFirewallConfiguration
{
#region Constants
private const string RULE_NAME = "DAQiFi_TCP_Rule";
#endregion
#region Private Fields
private readonly IFirewallHelper _firewallHelper;
#endregion
#region Constructor
public FirewallConfiguration(IFirewallHelper firewallHelper)
{
_firewallHelper = firewallHelper;
}
#endregion
#region Public Methods
public void InitializeFirewallRules()
{
// Implementation
}
#endregion
}# Build the solution
dotnet build
# Run all tests
dotnet test
# Run with code coverage (80% minimum required)
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
# Run specific test project
dotnet test Daqifi.Desktop.Tests/Daqifi.Desktop.Tests.csproj# Format code
dotnet format
# Run code analysis
dotnet build /p:EnforceCodeStyleInBuild=true- Test projects must have
.Testsuffix - Test files named
*Tests.cs - 80% minimum code coverage
- Use MSTest framework with Moq for mocking
- Follow Arrange-Act-Assert pattern
- Mock external dependencies
[TestClass]
public class FirewallConfigurationTests
{
private Mock<IFirewallHelper> _mockFirewallHelper;
private FirewallConfiguration _configuration;
[TestInitialize]
public void Setup()
{
_mockFirewallHelper = new Mock<IFirewallHelper>();
_configuration = new FirewallConfiguration(_mockFirewallHelper.Object);
}
[TestMethod]
public void InitializeFirewallRules_Should_CreateRules()
{
// Arrange
_mockFirewallHelper.Setup(x => x.CreateRule(It.IsAny<string>())).Returns(true);
// Act
_configuration.InitializeFirewallRules();
// Assert
_mockFirewallHelper.Verify(x => x.CreateRule(RULE_NAME), Times.Once);
}
}- Admin privileges: Required for firewall changes
- Passwords: Use SecureString
- Input validation: Always validate user input
- Error handling: Secure error messages, no sensitive data in logs
- Connection strings: Store securely, never hardcode
- Use NLog framework
- Log levels: Error, Warning, Info, Debug
- Logs stored in:
%CommonApplicationData%\DAQifi\Logs - Include stack traces for errors
- No sensitive data in logs
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
try
{
// Operation
}
catch (Exception ex)
{
Logger.Error(ex, "Failed to initialize firewall rules");
throw;
}The application communicates with DAQiFi devices using:
- UDP for device discovery: Port 30303 (broadcast queries and responses)
- TCP for data streaming: Port varies by device (extracted from discovery response)
- Protocol Buffers: Message serialization for both UDP and TCP
- UDP Discovery Port: 30303 (used in
DaqifiDeviceFinderand firewall rules) - TCP Data Port: Device-specific (e.g., 9760) - discovered from
message.DevicePortin protobuf response - Manual IP connections: Must use the same TCP port as discovered devices
- Firewall Rule: UDP port 30303 must be allowed for device discovery
- Admin Privileges: Required for automatic firewall configuration
- Network Interface: Application and device must be on same subnet for UDP broadcast discovery
- Virtual Machines: Use bridged networking mode, not NAT/shared network
DaqifiDeviceFinder.cs- Handles UDP device discovery on port 30303DaqifiStreamingDevice.cs- Manages TCP connections to devicesFirewallManager.cs- Configures Windows Firewall for UDP port 30303- Protocol buffer messages defined in
.protofiles
SQLite database managed through Entity Framework:
- Connection string in app settings
- Migrations handled automatically
- Local data storage for device configurations and logged data
- Use async methods for database operations
- README.md: Keep updated with setup instructions
- XML comments: Required on all public APIs
- Conventional commits: Use feat:, fix:, docs:, chore:, deps:
- Keep documentation in sync with code changes
/// <summary>
/// Initializes firewall rules for DAQiFi device communication.
/// </summary>
/// <exception cref="UnauthorizedAccessException">Thrown when admin privileges are not available.</exception>
public void InitializeFirewallRules()
{
// Implementation
}- Main branch:
main - Feature branches:
feature/description - Fix branches:
fix/description - Chore branches:
chore/description - Use conventional commits
- Squash merge to main
- All PRs require code review
- Qodo (automated reviewer): When Qodo leaves review comments on a PR, always reply to each comment on GitHub explaining what action was taken (fixed, partially fixed, or disagreed with and why). Use
gh api repos/{owner}/{repo}/pulls/{pr}/comments/{id}/repliesto post threaded replies.
When working on:
- Device connectivity: Check
/Device/directory and ensure network configuration - UI changes: Update both View and ViewModel following MVVM
- Data persistence: Use Entity Framework patterns
- Protocol changes: Update
.protofiles and regenerate - Firewall/Network: Ensure admin privileges handled properly, verify ports match
- WiFi Discovery Issues: Check network interface detection and port configuration
- Manual IP Connections: Ensure TCP port matches what device discovery reports
- New features: Add unit tests with 80% coverage minimum
- Use async/await for I/O operations
- Implement IDisposable where appropriate
- Avoid blocking UI thread
- Use dependency injection for testability
- Cache expensive operations
- Use try-catch at appropriate levels
- Log all errors with context
- Provide user-friendly error messages
- Never expose sensitive information
- Handle device disconnection gracefully