mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use a block map in media scan in the GUI.
This commit is contained in:
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -1677,6 +1677,7 @@
|
||||
</e>
|
||||
<e p="ConsoleHandler.cs" t="Include" />
|
||||
<e p="Controls" t="Include">
|
||||
<e p="BlockMap.cs" t="Include" />
|
||||
<e p="ColoredGrid.cs" t="Include" />
|
||||
<e p="SvgImageView.cs" t="Include" />
|
||||
</e>
|
||||
|
||||
@@ -103,16 +103,16 @@ namespace DiscImageChef.Core
|
||||
/// </summary>
|
||||
public delegate void ErrorMessageHandler(string text);
|
||||
|
||||
public delegate void InitBlockMapHandler(ulong blocks, ulong blockSize, ulong blocksToRead);
|
||||
|
||||
/// <summary>
|
||||
/// Updates lists of time taken on scanning the specified number of blocks
|
||||
/// Updates lists of time taken on scanning from the specified sector
|
||||
/// </summary>
|
||||
/// <param name="time">Time in milliseconds</param>
|
||||
/// <param name="blocks">Number of blocks scanned</param>
|
||||
public delegate void ScanTimeHandler(double time, uint blocks);
|
||||
/// <param name="duration">Time in milliseconds</param>
|
||||
public delegate void ScanTimeHandler(ulong sector, double duration);
|
||||
|
||||
/// <summary>
|
||||
/// Specified a number of blocks could not be read on scan
|
||||
/// </summary>
|
||||
/// <param name="blocks">Number of blocks scanned</param>
|
||||
public delegate void ScanUnreadableHandler(uint blocks);
|
||||
public delegate void ScanUnreadableHandler(ulong sector);
|
||||
}
|
||||
@@ -117,6 +117,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead);
|
||||
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
ibgLog = new IbgLog(ibgLogPath, ATA_PROFILE);
|
||||
|
||||
@@ -149,13 +150,13 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else if(duration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(duration, blocksToRead);
|
||||
ScanTime?.Invoke(i, duration);
|
||||
mhddLog.Write(i, duration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanUnreadable?.Invoke(blocksToRead);
|
||||
ScanUnreadable?.Invoke(i);
|
||||
results.Errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
|
||||
|
||||
@@ -207,6 +208,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
}
|
||||
else
|
||||
{
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead);
|
||||
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
ibgLog = new IbgLog(ibgLogPath, ATA_PROFILE);
|
||||
|
||||
@@ -245,13 +247,13 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else if(duration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(duration, blocksToRead);
|
||||
ScanTime?.Invoke(currentBlock, duration);
|
||||
mhddLog.Write(currentBlock, duration);
|
||||
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanUnreadable?.Invoke(blocksToRead);
|
||||
ScanUnreadable?.Invoke(currentBlock);
|
||||
results.Errored += blocksToRead;
|
||||
results.UnreadableSectors.Add(currentBlock);
|
||||
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
|
||||
|
||||
@@ -70,5 +70,6 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
public event PulseProgressHandler PulseProgress;
|
||||
public event ScanTimeHandler ScanTime;
|
||||
public event ScanUnreadableHandler ScanUnreadable;
|
||||
public event InitBlockMapHandler InitBlockMap;
|
||||
}
|
||||
}
|
||||
@@ -278,6 +278,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead);
|
||||
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
ibgLog = new IbgLog(ibgLogPath, currentProfile);
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
@@ -317,7 +318,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else if(cmdDuration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(cmdDuration, blocksToRead);
|
||||
ScanTime?.Invoke(i, cmdDuration);
|
||||
mhddLog.Write(i, cmdDuration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
}
|
||||
@@ -345,7 +346,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanUnreadable?.Invoke(blocksToRead);
|
||||
ScanUnreadable?.Invoke(i);
|
||||
results.Errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
|
||||
|
||||
@@ -379,6 +380,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead);
|
||||
mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
ibgLog = new IbgLog(ibgLogPath, currentProfile);
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
@@ -411,14 +413,14 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else if(cmdDuration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(cmdDuration, blocksToRead);
|
||||
ScanTime?.Invoke(i, cmdDuration);
|
||||
mhddLog.Write(i, cmdDuration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
}
|
||||
// TODO: Separate errors on kind of errors.
|
||||
else
|
||||
{
|
||||
ScanUnreadable?.Invoke(blocksToRead);
|
||||
ScanUnreadable?.Invoke(i);
|
||||
results.Errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
|
||||
UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");
|
||||
|
||||
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead);
|
||||
MhddLog mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead);
|
||||
IbgLog ibgLog = new IbgLog(ibgLogPath, SD_PROFILE);
|
||||
|
||||
@@ -180,13 +181,13 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else if(duration >= 3) results.B += blocksToRead;
|
||||
else results.A += blocksToRead;
|
||||
|
||||
ScanTime?.Invoke(duration, blocksToRead);
|
||||
ScanTime?.Invoke(i, duration);
|
||||
mhddLog.Write(i, duration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScanUnreadable?.Invoke(blocksToRead);
|
||||
ScanUnreadable?.Invoke(i);
|
||||
results.Errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
-->
|
||||
<Form xmlns="http://schema.picoe.ca/eto.forms" Title="Media scan" ClientSize="600, 450" Padding="10">
|
||||
<Form xmlns="http://schema.picoe.ca/eto.forms" xmlns:local="clr-namespace:DiscImageChef.Gui.Controls;assembly=DiscImageChef.Gui" Title="Media scan" ClientSize="600, 450" Padding="10">
|
||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
||||
<TabControl Visible="False" ID="tabResults">
|
||||
<TabControl Visible="True" ID="tabResults">
|
||||
<TabPage Text="Log">
|
||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch">
|
||||
@@ -51,6 +51,9 @@
|
||||
<Label ID="lblMinSpeed" Text="Slowest speed burst: 0 MiB/sec." Visible="False"/>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
<TabPage Text="Graph">
|
||||
<local:BlockMap ID="blockMap"/>
|
||||
</TabPage>
|
||||
</TabControl>
|
||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||
ID="stkProgress" Visible="False">
|
||||
|
||||
@@ -37,6 +37,8 @@ using DiscImageChef.Core;
|
||||
using DiscImageChef.Core.Devices.Scanning;
|
||||
using DiscImageChef.Core.Media.Info;
|
||||
using DiscImageChef.Devices;
|
||||
using DiscImageChef.Gui.Controls;
|
||||
using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using DeviceInfo = DiscImageChef.Core.Devices.Info.DeviceInfo;
|
||||
@@ -45,10 +47,16 @@ namespace DiscImageChef.Gui.Forms
|
||||
{
|
||||
public class frmMediaScan : Form
|
||||
{
|
||||
static readonly Color LightGreen = Color.FromRgb(0x00FF00);
|
||||
static readonly Color Green = Color.FromRgb(0x006400);
|
||||
static readonly Color DarkGreen = Color.FromRgb(0x003200);
|
||||
static readonly Color Yellow = Color.FromRgb(0xFFA500);
|
||||
static readonly Color Orange = Color.FromRgb(0xFF4500);
|
||||
static readonly Color Red = Color.FromRgb(0x800000);
|
||||
static Color LightRed = Color.FromRgb(0xFF0000);
|
||||
ulong blocksToRead;
|
||||
string devicePath;
|
||||
|
||||
ScanResults localResults;
|
||||
|
||||
MediaScan scanner;
|
||||
|
||||
public frmMediaScan(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
|
||||
@@ -111,6 +119,7 @@ namespace DiscImageChef.Gui.Forms
|
||||
scanner.InitProgress += InitProgress;
|
||||
scanner.UpdateProgress += UpdateProgress;
|
||||
scanner.EndProgress += EndProgress;
|
||||
scanner.InitBlockMap += InitBlockMap;
|
||||
|
||||
ScanResults results = scanner.Scan();
|
||||
|
||||
@@ -152,6 +161,16 @@ namespace DiscImageChef.Gui.Forms
|
||||
WorkFinished();
|
||||
}
|
||||
|
||||
void InitBlockMap(ulong blocks, ulong blocksize, ulong blockstoread)
|
||||
{
|
||||
Application.Instance.Invoke(() =>
|
||||
{
|
||||
blockMap.Sectors = blocks;
|
||||
blockMap.SectorsToRead = (uint)blockstoread;
|
||||
blocksToRead = blockstoread;
|
||||
});
|
||||
}
|
||||
|
||||
void WorkFinished()
|
||||
{
|
||||
Application.Instance.Invoke(() =>
|
||||
@@ -221,25 +240,51 @@ namespace DiscImageChef.Gui.Forms
|
||||
Application.Instance.Invoke(() => { lblProgress.Text = text; });
|
||||
}
|
||||
|
||||
void OnScanUnreadable(uint blocks)
|
||||
void OnScanUnreadable(ulong sector)
|
||||
{
|
||||
Application.Instance.Invoke(() =>
|
||||
{
|
||||
localResults.Errored += blocks;
|
||||
localResults.Errored += blocksToRead;
|
||||
lblUnreadableSectors.Text = $"{localResults.Errored} sectors could not be read.";
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, LightGreen));
|
||||
});
|
||||
}
|
||||
|
||||
void OnScanTime(double time, uint blocks)
|
||||
void OnScanTime(ulong sector, double duration)
|
||||
{
|
||||
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;
|
||||
if(duration < 3)
|
||||
{
|
||||
localResults.A += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, LightGreen));
|
||||
}
|
||||
else if(duration >= 3 && duration < 10)
|
||||
{
|
||||
localResults.B += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, Green));
|
||||
}
|
||||
else if(duration >= 10 && duration < 50)
|
||||
{
|
||||
localResults.C += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, DarkGreen));
|
||||
}
|
||||
else if(duration >= 50 && duration < 150)
|
||||
{
|
||||
localResults.D += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, Yellow));
|
||||
}
|
||||
else if(duration >= 150 && duration < 500)
|
||||
{
|
||||
localResults.E += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, Orange));
|
||||
}
|
||||
else if(duration >= 500)
|
||||
{
|
||||
localResults.F += blocksToRead;
|
||||
blockMap.ColoredSectors.Add(new ColoredBlock(sector, Red));
|
||||
}
|
||||
|
||||
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.";
|
||||
@@ -272,6 +317,7 @@ namespace DiscImageChef.Gui.Forms
|
||||
Label lblProgress2;
|
||||
ProgressBar prgProgress2;
|
||||
TabControl tabResults;
|
||||
BlockMap blockMap;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user