feat: Import SD card logging sessions into application#375
feat: Import SD card logging sessions into application#375
Conversation
Add the ability to import SD card .bin log files into the desktop app's SQLite database for viewing, analysis, and CSV export. This implements the desktop side of #126, wiring up the core library's SdCardFileParser and ISdCardOperations to the desktop data model. New SdCardSessionImporter service with three entry points: - ImportFromFileAsync: import a local .bin file (no device needed) - ImportFromStreamAsync: import from a stream - ImportFromDeviceAsync: download from USB device then import Maps core SdCardLogEntry to desktop DataSample entities (one per analog/ digital channel per sample), creates LoggingSession in SQLite, and uses batch bulk inserts for performance. UI additions: - "Import .bin File" button in APPLICATION LOGS tab for local file import - Per-file "Import" button in DEVICE LOGS file list for USB device import - "Import All" button in DEVICE LOGS header to batch import all files - Progress overlay during download and import operations Also adds DownloadSdCardFileAsync and DeleteSdCardFileAsync to the desktop IStreamingDevice interface, and conditional local core project reference support via DaqifiCoreProjectPath MSBuild property. Closes #374 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||||||||
- Update Daqifi.Core NuGet from 0.14.0 to 0.15.0 across all projects to include SD card parsing/download types needed for import feature - Add null safety check for downloadResult.FilePath before use - Validate downloaded file is in expected temp directory - Log cleanup errors instead of silently swallowing them - Sanitize user-facing error messages to avoid leaking internal details - Add audit logging for import, download, and delete operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix StartSdCardLogging sending individual channel enable commands instead of a combined bitmask. Each EnableAdcChannels SCPI command replaces the previous setting, so sending one-channel-at-a-time resulted in only the last channel being logged. Now builds a single bitmask for all active analog channels before sending. - Suppress streaming data from appearing on the Live Graph when in Log to Device mode by checking Mode in OnStreamMessageReceived. - Add diagnostic logging to SdCardSessionImporter for device config, first sample details, and channel discovery to aid debugging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…stics - Changed ImportFromDeviceAsync to use ParseAsync with the original device filename instead of ParseFileAsync with the temp path. This fixes: 1. Session names showing temp GUIDs instead of the original log filename 2. Date extraction from log filenames (e.g., log_20260206_101851.bin) - Added download result diagnostics (reported size, disk size, temp path) - Added empty file detection with descriptive error message - Added warning log when 0 samples are imported for debugging Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Log first two samples (instead of just first) to verify timestamps are properly spaced after the core parser fix - Add warning when TimestampFrequency is 0, indicating firmware may not include TimestampFreq in logged messages - Include sample index in diagnostic log for easier debugging Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Device firmware does not include TimestampFreq in SD card log data, causing all imported samples to have identical timestamps. Changes: - Store TimestampFrequency on AbstractStreamingDevice from status messages - Expose TimestampFrequency on IStreamingDevice interface - Pass device's TimestampFrequency as FallbackTimestampFrequency when parsing SD card files via ImportFromDeviceAsync - Add diagnostic logging for first two samples to verify timestamp spacing - Add warning when no TimestampFrequency is available Requires daqifi-core PR #117 (FallbackTimestampFrequency support) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📊 Code Coverage ReportSummarySummary
CoverageDAQiFi - 9.6%
Daqifi.Desktop.Bootloader - 19.6%
Daqifi.Desktop.Common - 45.9%
Daqifi.Desktop.DataModel - 100%
Daqifi.Desktop.IO - 0%
Coverage report generated by ReportGenerator • View full report in build artifacts |
User description
Summary
SdCardSessionImporterservice that parses SD card.binlog files (via core library'sSdCardFileParser) and bulk-inserts them into the desktop app's SQLite database asLoggingSession+DataSampleentitiesDownloadSdCardFileAsyncandDeleteSdCardFileAsyncto the desktopIStreamingDeviceinterfaceDaqifiCoreProjectPathMSBuild property (needed until core fix: updated menu name with correct capitalizaiton #110/chore: Update build workflow to build MSI installer #111 are published to NuGet)Test plan
.binfile via "Import .bin File" button → session appears in session list → viewable in plot → exportable to CSVdotnet build -p:DaqifiCoreProjectPath="path/to/Daqifi.Core.csproj"Prerequisites
Closes #374
🤖 Generated with Claude Code
PR Type
Enhancement
Description
Add
SdCardSessionImporterservice to parse and bulk-import SD card.binlog files into SQLite databaseImplement three import paths: local file, stream, and USB device download with progress tracking
Add "Import .bin File" button in Application Logs tab for local file imports
Add per-file "Import" and "Import All" buttons in Device Logs tab for USB device imports
Extend
IStreamingDeviceinterface withDownloadSdCardFileAsyncandDeleteSdCardFileAsyncmethodsSupport conditional local core project reference via
DaqifiCoreProjectPathMSBuild propertyDiagram Walkthrough
File Walkthrough
SdCardSessionImporter.cs
Core SD card import service with batch processingDaqifi.Desktop/Loggers/SdCardSessionImporter.cs
ImportFromFileAsync,ImportFromStreamAsync, andImportFromDeviceAsyncSdCardLogEntryobjects to desktopDataSampleentities withper-channel color assignment
samples) for performance
ImportOptionsfor session name override, overwrite behavior,and post-import device file deletion
ImportProgressclass for progress reporting during importoperations
IStreamingDevice.cs
Extend interface with SD card operationsDaqifi.Desktop/Device/IStreamingDevice.cs
DownloadSdCardFileAsyncmethod to download files from device SDcard over USB with progress tracking
DeleteSdCardFileAsyncmethod to delete files from device SD cardAbstractStreamingDevice.cs
Implement SD card operations in device classDaqifi.Desktop/Device/AbstractStreamingDevice.cs
Daqifi.Core.Device.SdCardnamespaceDownloadSdCardFileAsyncmethod delegating to core deviceDeleteSdCardFileAsyncmethod delegating to core deviceGetCoreDeviceForSd()helper for validationDaqifiViewModel.cs
Add local file import command to main view modelDaqifi.Desktop/ViewModels/DaqifiViewModel.cs
ImportSdCardLogFilerelay command for importing local.binfilesvia file dialog
LoggingManagerandshowing success dialog
cancellation support
DeviceLogsViewModel.cs
Add device file import commands with batch supportDaqifi.Desktop/ViewModels/DeviceLogsViewModel.cs
ImportFilerelay command for importing individual files fromconnected USB device
ImportAllFilesrelay command for batch importing all device fileswith per-file error handling
LoggingManagerMainWindow.xaml
Add import button to application logs UIDaqifi.Desktop/MainWindow.xaml
import icon and label
export/delete buttons
ImportSdCardLogFileCommandfrom view modelDeviceLogsView.xaml
Add import buttons to device logs UIDaqifi.Desktop/View/DeviceLogsView.xaml
positioned right of refresh button
Daqifi.Desktop.csproj
Support conditional local core project referenceDaqifi.Desktop/Daqifi.Desktop.csproj
Daqifi.CoreNuGet package reference conditional onDaqifiCoreProjectPathbeing emptyProjectReferenceto local core project whenDaqifiCoreProjectPathMSBuild property is setproject file