12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T04:02:01.449211+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | f0aeebaaaf645cc5 |
Documentation: Download Parameters and Status Module
1. Purpose
This module provides the data structures and execution logic for managing and executing data downloads from DAS (Data Acquisition System) units within a state machine workflow. It consists of two core types: DownloadParameters, which holds configuration and runtime state for a download operation, and DownloadStatusInformation, which orchestrates the asynchronous download process, handles status reporting, cancellation, and directory management—including special handling for ROI (Region of Interest), Recovery, and folder copying scenarios. The module integrates with the broader state machine (via States.Instance.DownloadStart) and depends on DAS communication interfaces and logging utilities.
2. Public Interface
DownloadParameters
-
bool ProceedWhenDone { get; set; } = false;
Controls whether the state machine should proceed to the next state after the download completes. -
bool RequireAllDASFinish { get; set; } = false;
Indicates whether all DAS units inDASListmust successfully finish downloading for the operation to be considered complete. -
string DefaultDownloadFolder { get; set; } = string.Empty;
Holds the configured base download folder path from the application config file. -
bool DefaultUploadBinaries { get; set; } = false;
Config flag indicating whether binary data should be uploaded after download. -
bool DefaultUploadExports { get; set; } = false;
Config flag for uploading exports. -
bool DefaultUploadLogs { get; set; } = false;
Config flag for uploading logs. -
bool DefaultUploadReports { get; set; } = false;
Config flag for uploading reports. -
bool DefaultUploadSetups { get; set; } = false;
Config flag for uploading setup files (e.g.,SETUP,DASConfigs). -
IDASCommunication[] DASList { get; set; } = new IDASCommunication[0];
Array of DAS units to download data from. Must be non-null and populated before download. -
string CurrentTestTestId { get; set; } = string.Empty;
Test ID string for the current test session. -
string CurrentTestTestIdNode { get; set; } = string.Empty;
Test ID node (e.g., folder name) used in the file path hierarchy. -
string CurrentTestTestDirectory { get; set; } = string.Empty;
Full path to the current test directory. -
string CurrentTestOriginalTestDirectory { get; set; } = string.Empty;
Full path to the original test directory (used in recovery scenarios). -
bool ROI { get; set; } = false;
Indicates whether the current download is in ROI mode. -
bool Recovery { get; set; } = false;
Indicates whether the current download is a recovery operation. -
bool FoldersCopied { get; set; }
Flag to prevent redundant copying ofDASConfigs,SETUP,Logs,Reportsfolders during recovery or re-runs. -
ErrorCallback ErrorCallback { get; set; }
Callback delegate invoked for user prompts or error notifications (e.g., missing hardware, existing files). -
void Reset()
Resets all properties to their default values (e.g., emptyDASList,falsefor all flags,nullforErrorCallback).
Note: Does not resetROI,Recovery, orFoldersCopiedto defaults—only explicitly listed properties in the method body. -
string ToString()
Returns an empty string (no-op implementation).
DownloadStatusInformation
-
enum StatusValues
Defines all possible status messages that can be sent viaStatusAction:Preparing,Downloading,CaptureAttributes,Failed,ROIFailed,Completed,Cancelling,Cancelled,CancelledPartial,DownloadDirectory,MissingHardware,NoDataToDownload,NotAllChannelsDownloaded,ExistingFiles,CleaningUp,QueryEventData.
-
ManualResetEvent CancelEvent = new ManualResetEvent(false);
Signaled to request cancellation of the download. -
ManualResetEvent DoneEvent = new ManualResetEvent(false);
Signaled when the download task completes (successfully, cancelled, or failed). -
ActionCompleteDelegate CompleteAction { get; set; }
Callback invoked upon successful completion of the download task. -
SetProgressValueDelegate ProgressAction { get; set; }
Callback to report progress (currently unused inDownload()). -
StatusIntDelegate StatusAction { get; set; }
Callback to report status updates (takesintcast ofStatusValues). -
StatusExIntDelegate StatusExAction { get; set; }
Callback for extended status (e.g.,NoDataToDownloadpasses array of DAS with missing config). -
bool AllDASFinished { get; set; } = false;
Set totrueif all DAS inparam.DASListhave finished downloading (only checked ifRequireAllDASFinishis true). -
void Reset()
Clears all delegate references and resetsAllDASFinishedtofalse. -
void Download()
Starts the download process asynchronously on a background thread. Key behaviors:- Invokes
StatusAction(StatusValues.Preparing)at start. - Validates DAS availability against
DASFactory.GetDASList(), callsErrorCallback(StatusValues.MissingHardware)if missing. - Fails if
DASListis empty or any DAS lacksConfigData. - Retrieves event info via
GetOneEvent(); fails if no event found. - Constructs download directory:
<DownloadFolder>/<EventId>/<CurrentTestTestId>/Binary/<ROI|ALL>. - In Recovery mode, reuses the original
CurrentTestTestIdNodepath if test ID changed, and copies folders (DASConfigs,Logs,Reports,SETUP) from original test directory if needed (unlessFoldersCopiedis true). - Uses a
ManualResetEvent(mre) that waits indefinitely—no actual download logic is implemented; the task exits after settingCompleteActionandStatusAction(Completed). - Sets
DoneEventupon completion.
- Invokes
-
Task Cancel()
Asynchronously cancels the download:- Sets
CancelEvent. - Reports
StatusValues.Cancelling. - Waits 100ms (simulated delay).
- Waits for
DoneEvent. - Reports
StatusValues.Cancelled.
- Sets
-
bool DirectoryCopy(...)
Copies files fromsourceDirNametodestDirName, with filtering based on upload flags (DefaultUpload*).- Overwrites existing files (uses
File.Copy(..., true)). - Skips files if corresponding upload flag is
false(e.g., skipsBinaryifDefaultUploadBinariesisfalse). - Prompts user via
ErrorCallback(StatusValues.ExistingFiles)if destination files exist. - Logs success/failure via
APILogger. - Returns
trueonly if uploading data (uploadingData == true) and copy succeeds; otherwisefalse.
- Overwrites existing files (uses
-
private static string GetHash(DownloadReport.EventInfo)
Helper: returns"TestID_EventNumber"formatted as uppercase (e.g.,"T123_05"). -
private IEventInfoAggregate GetOneEvent(List<IDASCommunication>)
Helper: aggregates event info from DAS units.- Collects unique events by hash (
TestID_EventNumber). - Returns the first aggregated event (or
nullif none found).
Note: TheTODOcomment indicates incomplete event aggregation logic.
- Collects unique events by hash (
3. Invariants
-
DASListmust be non-null and populated before callingDownload()
The method checks for emptydasListand fails if!dasList.Any(). -
Each DAS in
DASListmust have non-nullConfigData
Checked viadas.ConfigData == null; triggersStatusExAction(StatusValues.NoDataToDownload). -
At least one DAS must have valid
EventInfowith events
GetOneEvent()must return non-null; otherwise,StatusAction(StatusValues.Failed)is invoked. -
Download directory must be creatable
IfDirectory.CreateDirectory(directory)throws,StatusAction(StatusValues.Failed)is invoked. -
StatusActionmust be assigned for status reporting
All status updates are conditional onStatusAction?.Invoke(...). -
ErrorCallbackmust handle user prompts synchronously
The code callserrorCallback?.Invoke(...)and expects aDialogResultreturn. -
Recovery mode path reuse
WhenRecovery == trueandCurrentTestTestId != CurrentTestTestIdNode, the download directory reusescurrentTestTestIdNode(original test ID node) to avoid duplicating folders. -
FoldersCopiedprevents redundant copying
Folder copying only occurs ifRecovery && (!foldersCopied).
4. Dependencies
Imports/References
DTS.Common.Interface.DASFactory
ProvidesIDASCommunication,IDASFactory, andIEventInfoAggregate.DTS.Common.Interface.StatusAndProgressBar
ProvidesIStatusParameters,IStatusInfo,ErrorCallback,ActionCompleteDelegate,SetProgressValueDelegate,StatusIntDelegate,StatusExIntDelegate.DTS.Common.Utilities.Logging
ProvidesAPILogger.System.Windows.Forms
Used forDialogResult(e.g.,DialogResult.OKinErrorCallbackusage).System.IO
ForDirectory,DirectoryInfo,File,Path,Uri.
Internal Dependencies
-
States.Instance.DownloadStart
Accessed to retrieve:Status.DownloadParams(DownloadParameters)Status.GlobalStatusParametersDASFactory(IDASFactory)
-
Common.Constants
Used for folder names:DAS_CONFIGS,REPORT_DIR_NAME(values not visible in source). -
Resources.UploadData_Files_Exist
String resource used inDirectoryCopyfor existing files prompt.
5. Gotchas
-
DirectoryCopydoes not actually upload data
Despite the name and upload-related flags, it only copies files within the local filesystem. TheuploadingDataparameter controls filtering but not network upload. -
No actual download logic in
Download()
The method sets up directories and runs validation, but the core download loop is missing—mre.WaitOne()blocks indefinitely, and the task exits without performing I/O. This suggests incomplete implementation or placeholder logic. -
DirectoryCopyhas confusing return semantics
Returnstrueonly ifuploadingData == trueand copy succeeds; otherwise returnsfalse. This makes it unsuitable for generic copying. -
DirectoryCopyusesUrifor relative path calculation
Builds URIs with"file:\\\\"prefix and usesMakeRelativeUri—non-standard and potentially fragile for Windows paths. -
GetOneEventis incomplete
TheTODOcomment and missingIEventInfoAggregateconstructor call (new IEventInfoAggregate(...)) indicate the event aggregation logic is not implemented. -
Reset()does not resetROI,Recovery, orFoldersCopied
Only resets explicitly listed properties—these flags retain their values unless manually cleared. -
ToString()is a no-op
Returns empty string; no debugging value. -
DirectoryCopymay throw ifsourceDirName/destDirNameare invalid
Uriconstruction andDirectoryInfoaccess lack explicit error handling beyond the outertry-catch. -
Hardcoded folder names
"Binary","ROI","ALL","Logs","SETUP","Reports","DASConfigs"are used directly—should be constants. -
Thread.Sleep(100)andThread.Sleep(10)in async path
Blocking calls in cancellation and upload paths may cause UI freezes or delays. -
Missing
NotAllChannelsDownloadedhandling
Status value exists but is never invoked inDownload(). -
ExistingFilesprompt may show multiple times
DirectoryCopyis called per folder (e.g.,DASConfigs,Logs, etc.), and each may prompt for existing files. -
No validation of
CurrentTest*path components
Invalid characters or null values could cause path construction errors.