mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Reformat code.
This commit is contained in:
@@ -74,6 +74,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
DicConsole.ErrorWriteLine(ataReader.ErrorMessage);
|
||||
return results;
|
||||
}
|
||||
|
||||
uint blockSize = ataReader.LogicalBlockSize;
|
||||
// Check how many blocks to read, if error show and return
|
||||
if(ataReader.GetBlocksToRead(64))
|
||||
@@ -81,6 +82,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
DicConsole.ErrorWriteLine(ataReader.ErrorMessage);
|
||||
return results;
|
||||
}
|
||||
|
||||
uint blocksToRead = ataReader.BlocksToRead;
|
||||
ushort cylinders = ataReader.Cylinders;
|
||||
byte heads = ataReader.Heads;
|
||||
@@ -115,10 +117,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
byte seekSc = (byte)rnd.Next(sectors);
|
||||
|
||||
aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = aborted = true;
|
||||
};
|
||||
System.Console.CancelKeyPress += (sender, e) => { e.Cancel = aborted = true; };
|
||||
|
||||
if(ataReader.IsLBA)
|
||||
{
|
||||
@@ -130,49 +129,28 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
start = DateTime.UtcNow;
|
||||
for(ulong i = 0; i < results.blocks; i += blocksToRead)
|
||||
{
|
||||
if(aborted)
|
||||
break;
|
||||
if(aborted) break;
|
||||
|
||||
if((results.blocks - i) < blocksToRead)
|
||||
blocksToRead = (byte)(results.blocks - i);
|
||||
if((results.blocks - i) < blocksToRead) blocksToRead = (byte)(results.blocks - i);
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(currentSpeed > results.maxSpeed && currentSpeed != 0)
|
||||
results.maxSpeed = currentSpeed;
|
||||
if(currentSpeed < results.minSpeed && currentSpeed != 0)
|
||||
results.minSpeed = currentSpeed;
|
||||
if(currentSpeed > results.maxSpeed && currentSpeed != 0) results.maxSpeed = currentSpeed;
|
||||
if(currentSpeed < results.minSpeed && currentSpeed != 0) results.minSpeed = currentSpeed;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks, currentSpeed);
|
||||
DicConsole.Write("\rReading sector {0} of {1} ({2:F3} MiB/sec.)", i, results.blocks,
|
||||
currentSpeed);
|
||||
|
||||
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration);
|
||||
|
||||
if(!error)
|
||||
{
|
||||
if(duration >= 500)
|
||||
{
|
||||
results.F += blocksToRead;
|
||||
}
|
||||
else if(duration >= 150)
|
||||
{
|
||||
results.E += blocksToRead;
|
||||
}
|
||||
else if(duration >= 50)
|
||||
{
|
||||
results.D += blocksToRead;
|
||||
}
|
||||
else if(duration >= 10)
|
||||
{
|
||||
results.C += blocksToRead;
|
||||
}
|
||||
else if(duration >= 3)
|
||||
{
|
||||
results.B += blocksToRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
results.A += blocksToRead;
|
||||
}
|
||||
if(duration >= 500) { results.F += blocksToRead; }
|
||||
else if(duration >= 150) { results.E += blocksToRead; }
|
||||
else if(duration >= 50) { results.D += blocksToRead; }
|
||||
else if(duration >= 10) { results.C += blocksToRead; }
|
||||
else if(duration >= 3) { results.B += blocksToRead; }
|
||||
else { results.A += blocksToRead; }
|
||||
|
||||
mhddLog.Write(i, duration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
@@ -180,12 +158,10 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
else
|
||||
{
|
||||
results.errored += blocksToRead;
|
||||
for(ulong b = i; b < i + blocksToRead; b++)
|
||||
results.unreadableSectors.Add(b);
|
||||
if(duration < 500)
|
||||
mhddLog.Write(i, 65535);
|
||||
else
|
||||
mhddLog.Write(i, duration);
|
||||
for(ulong b = i; b < i + blocksToRead; b++) results.unreadableSectors.Add(b);
|
||||
|
||||
if(duration < 500) mhddLog.Write(i, 65535);
|
||||
else mhddLog.Write(i, duration);
|
||||
|
||||
ibgLog.Write(i, 0);
|
||||
}
|
||||
@@ -195,19 +171,21 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
end = DateTime.UtcNow;
|
||||
DicConsole.WriteLine();
|
||||
mhddLog.Close();
|
||||
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
|
||||
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(results.blocks + 1)) / 1024) / (results.processingTime / 1000), devicePath);
|
||||
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
|
||||
(results.processingTime / 1000), devicePath);
|
||||
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
|
||||
|
||||
if(ataReader.CanSeekLBA)
|
||||
{
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(aborted)
|
||||
break;
|
||||
if(aborted) break;
|
||||
|
||||
seekPos = (uint)rnd.Next((int)results.blocks);
|
||||
|
||||
@@ -216,10 +194,8 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
ataReader.Seek(seekPos, out seekCur);
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(seekCur > results.seekMax && seekCur != 0)
|
||||
results.seekMax = seekCur;
|
||||
if(seekCur < results.seekMin && seekCur != 0)
|
||||
results.seekMin = seekCur;
|
||||
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
|
||||
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
results.seekTotal += seekCur;
|
||||
@@ -241,8 +217,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
for(byte Sc = 1; Sc < sectors; Sc++)
|
||||
{
|
||||
if(aborted)
|
||||
break;
|
||||
if(aborted) break;
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(currentSpeed > results.maxSpeed && currentSpeed != 0)
|
||||
@@ -251,36 +226,19 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
results.minSpeed = currentSpeed;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", Cy, Hd, Sc, currentSpeed);
|
||||
DicConsole.Write("\rReading cylinder {0} head {1} sector {2} ({3:F3} MiB/sec.)", Cy, Hd,
|
||||
Sc, currentSpeed);
|
||||
|
||||
bool error = ataReader.ReadCHS(out cmdBuf, Cy, Hd, Sc, out duration);
|
||||
|
||||
if(!error)
|
||||
{
|
||||
if(duration >= 500)
|
||||
{
|
||||
results.F += blocksToRead;
|
||||
}
|
||||
else if(duration >= 150)
|
||||
{
|
||||
results.E += blocksToRead;
|
||||
}
|
||||
else if(duration >= 50)
|
||||
{
|
||||
results.D += blocksToRead;
|
||||
}
|
||||
else if(duration >= 10)
|
||||
{
|
||||
results.C += blocksToRead;
|
||||
}
|
||||
else if(duration >= 3)
|
||||
{
|
||||
results.B += blocksToRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
results.A += blocksToRead;
|
||||
}
|
||||
if(duration >= 500) { results.F += blocksToRead; }
|
||||
else if(duration >= 150) { results.E += blocksToRead; }
|
||||
else if(duration >= 50) { results.D += blocksToRead; }
|
||||
else if(duration >= 10) { results.C += blocksToRead; }
|
||||
else if(duration >= 3) { results.B += blocksToRead; }
|
||||
else { results.A += blocksToRead; }
|
||||
|
||||
mhddLog.Write(currentBlock, duration);
|
||||
ibgLog.Write(currentBlock, currentSpeed * 1024);
|
||||
@@ -289,10 +247,8 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
results.errored += blocksToRead;
|
||||
results.unreadableSectors.Add(currentBlock);
|
||||
if(duration < 500)
|
||||
mhddLog.Write(currentBlock, 65535);
|
||||
else
|
||||
mhddLog.Write(currentBlock, duration);
|
||||
if(duration < 500) mhddLog.Write(currentBlock, 65535);
|
||||
else mhddLog.Write(currentBlock, duration);
|
||||
|
||||
ibgLog.Write(currentBlock, 0);
|
||||
}
|
||||
@@ -306,33 +262,34 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end = DateTime.UtcNow;
|
||||
DicConsole.WriteLine();
|
||||
mhddLog.Close();
|
||||
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
|
||||
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, (((double)blockSize * (double)(results.blocks + 1)) / 1024) / (results.processingTime / 1000), devicePath);
|
||||
ibgLog.Close(dev, results.blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
|
||||
(((double)blockSize * (double)(results.blocks + 1)) / 1024) /
|
||||
(results.processingTime / 1000), devicePath);
|
||||
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
|
||||
|
||||
if(ataReader.CanSeek)
|
||||
{
|
||||
for(int i = 0; i < seekTimes; i++)
|
||||
{
|
||||
if(aborted)
|
||||
break;
|
||||
if(aborted) break;
|
||||
|
||||
seekCy = (ushort)rnd.Next(cylinders);
|
||||
seekHd = (byte)rnd.Next(heads);
|
||||
seekSc = (byte)rnd.Next(sectors);
|
||||
|
||||
DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd, seekSc);
|
||||
DicConsole.Write("\rSeeking to cylinder {0}, head {1}, sector {2}...\t\t", seekCy, seekHd,
|
||||
seekSc);
|
||||
|
||||
ataReader.SeekCHS(seekCy, seekHd, seekSc, out seekCur);
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(seekCur > results.seekMax && seekCur != 0)
|
||||
results.seekMax = seekCur;
|
||||
if(seekCur < results.seekMin && seekCur != 0)
|
||||
results.seekMin = seekCur;
|
||||
if(seekCur > results.seekMax && seekCur != 0) results.seekMax = seekCur;
|
||||
if(seekCur < results.seekMin && seekCur != 0) results.seekMin = seekCur;
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
|
||||
results.seekTotal += seekCur;
|
||||
@@ -346,7 +303,8 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
results.processingTime /= 1000;
|
||||
results.totalTime = (end - start).TotalSeconds;
|
||||
#pragma warning disable IDE0004 // Without this specific cast, it gives incorrect values
|
||||
results.avgSpeed = (((double)blockSize * (double)(results.blocks + 1)) / 1048576) / results.processingTime;
|
||||
results.avgSpeed = (((double)blockSize * (double)(results.blocks + 1)) / 1048576) /
|
||||
results.processingTime;
|
||||
#pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values
|
||||
results.seekTimes = seekTimes;
|
||||
|
||||
@@ -357,4 +315,4 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user