mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Update media scan GUI block times via events.
This commit is contained in:
@@ -104,9 +104,9 @@ namespace DiscImageChef.Core
|
|||||||
public delegate void ErrorMessageHandler(string text);
|
public delegate void ErrorMessageHandler(string text);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates lists of time taken on scanning the specified number of blocks
|
/// Updates lists of time taken on scanning the specified number of blocks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">Time in milliseconds</param>
|
/// <param name="time">Time in milliseconds</param>
|
||||||
/// <param name="blocks">Number of blocks scanned</param>
|
/// <param name="blocks">Number of blocks scanned</param>
|
||||||
public delegate void ScanTime(double time, uint blocks);
|
public delegate void ScanTimeHandler(double time, uint blocks);
|
||||||
}
|
}
|
||||||
@@ -149,6 +149,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
else if(duration >= 3) results.B += blocksToRead;
|
else if(duration >= 3) results.B += blocksToRead;
|
||||||
else results.A += blocksToRead;
|
else results.A += blocksToRead;
|
||||||
|
|
||||||
|
ScanTime?.Invoke(duration, blocksToRead);
|
||||||
mhddLog.Write(i, duration);
|
mhddLog.Write(i, duration);
|
||||||
ibgLog.Write(i, currentSpeed * 1024);
|
ibgLog.Write(i, currentSpeed * 1024);
|
||||||
}
|
}
|
||||||
@@ -243,6 +244,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
else if(duration >= 3) results.B += blocksToRead;
|
else if(duration >= 3) results.B += blocksToRead;
|
||||||
else results.A += blocksToRead;
|
else results.A += blocksToRead;
|
||||||
|
|
||||||
|
ScanTime?.Invoke(duration, blocksToRead);
|
||||||
mhddLog.Write(currentBlock, duration);
|
mhddLog.Write(currentBlock, duration);
|
||||||
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,6 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event UpdateStatusHandler UpdateStatus;
|
public event UpdateStatusHandler UpdateStatus;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event raised to report a non-fatal error
|
|
||||||
/// </summary>
|
|
||||||
public event ErrorMessageHandler ErrorMessage;
|
|
||||||
/// <summary>
|
|
||||||
/// Event raised to report a fatal error that stops the dumping operation and should call user's attention
|
/// Event raised to report a fatal error that stops the dumping operation and should call user's attention
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event ErrorMessageHandler StoppingErrorMessage;
|
public event ErrorMessageHandler StoppingErrorMessage;
|
||||||
@@ -72,5 +68,6 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
/// Event raised to update the status of an undeterminate progress bar
|
/// Event raised to update the status of an undeterminate progress bar
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event PulseProgressHandler PulseProgress;
|
public event PulseProgressHandler PulseProgress;
|
||||||
|
public event ScanTimeHandler ScanTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,6 +317,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
else if(cmdDuration >= 3) results.B += blocksToRead;
|
else if(cmdDuration >= 3) results.B += blocksToRead;
|
||||||
else results.A += blocksToRead;
|
else results.A += blocksToRead;
|
||||||
|
|
||||||
|
ScanTime?.Invoke(cmdDuration, blocksToRead);
|
||||||
mhddLog.Write(i, cmdDuration);
|
mhddLog.Write(i, cmdDuration);
|
||||||
ibgLog.Write(i, currentSpeed * 1024);
|
ibgLog.Write(i, currentSpeed * 1024);
|
||||||
}
|
}
|
||||||
@@ -409,6 +410,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
else if(cmdDuration >= 3) results.B += blocksToRead;
|
else if(cmdDuration >= 3) results.B += blocksToRead;
|
||||||
else results.A += blocksToRead;
|
else results.A += blocksToRead;
|
||||||
|
|
||||||
|
ScanTime?.Invoke(cmdDuration, blocksToRead);
|
||||||
mhddLog.Write(i, cmdDuration);
|
mhddLog.Write(i, cmdDuration);
|
||||||
ibgLog.Write(i, currentSpeed * 1024);
|
ibgLog.Write(i, currentSpeed * 1024);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
else if(duration >= 3) results.B += blocksToRead;
|
else if(duration >= 3) results.B += blocksToRead;
|
||||||
else results.A += blocksToRead;
|
else results.A += blocksToRead;
|
||||||
|
|
||||||
|
ScanTime?.Invoke(duration, blocksToRead);
|
||||||
mhddLog.Write(i, duration);
|
mhddLog.Write(i, duration);
|
||||||
ibgLog.Write(i, currentSpeed * 1024);
|
ibgLog.Write(i, currentSpeed * 1024);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
{
|
{
|
||||||
string devicePath;
|
string devicePath;
|
||||||
|
|
||||||
|
ScanResults localResults;
|
||||||
|
|
||||||
MediaScan scanner;
|
MediaScan scanner;
|
||||||
|
|
||||||
public frmMediaScan(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
|
public frmMediaScan(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
|
||||||
@@ -96,7 +98,9 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
|
|
||||||
Statistics.AddDevice(dev);
|
Statistics.AddDevice(dev);
|
||||||
|
|
||||||
scanner = new MediaScan(null, null, devicePath, dev);
|
localResults = new ScanResults();
|
||||||
|
scanner = new MediaScan(null, null, devicePath, dev);
|
||||||
|
scanner.ScanTime += OnScanTime;
|
||||||
ScanResults results = scanner.Scan();
|
ScanResults results = scanner.Scan();
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
Application.Instance.Invoke(() =>
|
||||||
@@ -143,6 +147,25 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnScanTime(double time, uint blocks)
|
||||||
|
{
|
||||||
|
Application.Instance.Invoke(() =>
|
||||||
|
{
|
||||||
|
if(time < 3) localResults.A += blocks;
|
||||||
|
else if(time >= 3 && time < 10) localResults.B += blocks;
|
||||||
|
else if(time >= 10 && time < 50) localResults.C += blocks;
|
||||||
|
else if(time >= 50 && time < 150) localResults.D += blocks;
|
||||||
|
else if(time >= 150 && time < 500) localResults.E += blocks;
|
||||||
|
else if(time >= 500) localResults.F += blocks;
|
||||||
|
lblA.Text = $"{localResults.A} sectors took less than 3 ms.";
|
||||||
|
lblB.Text = $"{localResults.B} sectors took less than 10 ms but more than 3 ms.";
|
||||||
|
lblC.Text = $"{localResults.C} sectors took less than 50 ms but more than 10 ms.";
|
||||||
|
lblD.Text = $"{localResults.D} sectors took less than 150 ms but more than 50 ms.";
|
||||||
|
lblE.Text = $"{localResults.E} sectors took less than 500 ms but more than 150 ms.";
|
||||||
|
lblF.Text = $"{localResults.F} sectors took more than 500 ms.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#region XAML IDs
|
#region XAML IDs
|
||||||
Label lblTotalTime;
|
Label lblTotalTime;
|
||||||
Label lblAvgSpeed;
|
Label lblAvgSpeed;
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
MediaScan scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
MediaScan scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||||
scanner.UpdateStatus += Progress.UpdateStatus;
|
scanner.UpdateStatus += Progress.UpdateStatus;
|
||||||
scanner.ErrorMessage += Progress.ErrorMessage;
|
|
||||||
scanner.StoppingErrorMessage += Progress.ErrorMessage;
|
scanner.StoppingErrorMessage += Progress.ErrorMessage;
|
||||||
scanner.UpdateProgress += Progress.UpdateProgress;
|
scanner.UpdateProgress += Progress.UpdateProgress;
|
||||||
scanner.PulseProgress += Progress.PulseProgress;
|
scanner.PulseProgress += Progress.PulseProgress;
|
||||||
|
|||||||
Reference in New Issue
Block a user