Use List<T> instead of Array<T> in device report.

This commit is contained in:
2018-11-27 01:42:25 +00:00
parent 9c83c3d296
commit 7b45cf1b92
4 changed files with 76 additions and 64 deletions

View File

@@ -37,6 +37,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using DiscImageChef.CommonTypes.Enums; using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.Decoders.ATA; using DiscImageChef.Decoders.ATA;
@@ -96,10 +97,10 @@ namespace DiscImageChef.CommonTypes.Metadata
{ {
public Identify.IdentifyDevice? IdentifyDevice; public Identify.IdentifyDevice? IdentifyDevice;
[JsonIgnore] [JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public byte[] Identify { get; set; } public byte[] Identify { get; set; }
public TestedMedia ReadCapabilities { get; set; } public TestedMedia ReadCapabilities { get; set; }
public TestedMedia[] RemovableMedias { get; set; } public List<TestedMedia> RemovableMedias { get; set; }
} }
public class Chs public class Chs
@@ -115,33 +116,33 @@ namespace DiscImageChef.CommonTypes.Metadata
{ {
public Inquiry.SCSIInquiry? Inquiry; public Inquiry.SCSIInquiry? Inquiry;
[JsonIgnore] [JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public byte[] InquiryData { get; set; } public byte[] InquiryData { get; set; }
public ScsiPage[] EVPDPages { get; set; } public List<ScsiPage> EVPDPages { get; set; }
public bool SupportsModeSense6 { get; set; } public bool SupportsModeSense6 { get; set; }
public bool SupportsModeSense10 { get; set; } public bool SupportsModeSense10 { get; set; }
public bool SupportsModeSubpages { get; set; } public bool SupportsModeSubpages { get; set; }
public ScsiMode ModeSense { get; set; } public ScsiMode ModeSense { get; set; }
public Mmc MultiMediaDevice { get; set; } public Mmc MultiMediaDevice { get; set; }
public TestedMedia ReadCapabilities { get; set; } public TestedMedia ReadCapabilities { get; set; }
public TestedMedia[] RemovableMedias { get; set; } public List<TestedMedia> RemovableMedias { get; set; }
public Ssc SequentialDevice { get; set; } public Ssc SequentialDevice { get; set; }
public byte[] ModeSense6Data { get; set; } public byte[] ModeSense6Data { get; set; }
public byte[] ModeSense10Data { get; set; } public byte[] ModeSense10Data { get; set; }
} }
public class ScsiMode public class ScsiMode
{ {
[JsonIgnore] [JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public byte? MediumType { get; set; } public byte? MediumType { get; set; }
public bool WriteProtected { get; set; } public bool WriteProtected { get; set; }
public BlockDescriptor[] BlockDescriptors { get; set; } public List<BlockDescriptor> BlockDescriptors { get; set; }
public byte? Speed { get; set; } public byte? Speed { get; set; }
public byte? BufferedMode { get; set; } public byte? BufferedMode { get; set; }
public bool BlankCheckEnabled { get; set; } public bool BlankCheckEnabled { get; set; }
public bool DPOandFUA { get; set; } public bool DPOandFUA { get; set; }
public ScsiPage[] ModePages { get; set; } public List<ScsiPage> ModePages { get; set; }
} }
public class BlockDescriptor public class BlockDescriptor
@@ -168,7 +169,7 @@ namespace DiscImageChef.CommonTypes.Metadata
public int Id { get; set; } public int Id { get; set; }
public Modes.ModePage_2A ModeSense2A { get; set; } public Modes.ModePage_2A ModeSense2A { get; set; }
public MmcFeatures Features { get; set; } public MmcFeatures Features { get; set; }
public TestedMedia[] TestedMedia { get; set; } public List<TestedMedia> TestedMedia { get; set; }
} }
public class MmcFeatures public class MmcFeatures
@@ -407,24 +408,24 @@ namespace DiscImageChef.CommonTypes.Metadata
public uint? MaxBlockLength { get; set; } public uint? MaxBlockLength { get; set; }
public uint? MinBlockLength { get; set; } public uint? MinBlockLength { get; set; }
public SupportedDensity[] SupportedDensities { get; set; } public List<SupportedDensity> SupportedDensities { get; set; }
public SscSupportedMedia[] SupportedMediaTypes { get; set; } public List<SscSupportedMedia> SupportedMediaTypes { get; set; }
public TestedSequentialMedia[] TestedMedia { get; set; } public List<TestedSequentialMedia> TestedMedia { get; set; }
} }
public class TestedSequentialMedia public class TestedSequentialMedia
{ {
[JsonIgnore] [JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public bool? CanReadMediaSerial { get; set; } public bool? CanReadMediaSerial { get; set; }
public byte? Density { get; set; } public byte? Density { get; set; }
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
public bool MediaIsRecognized { get; set; } public bool MediaIsRecognized { get; set; }
public byte? MediumType { get; set; } public byte? MediumType { get; set; }
public string MediumTypeName { get; set; } public string MediumTypeName { get; set; }
public string Model { get; set; } public string Model { get; set; }
public SupportedDensity[] SupportedDensities { get; set; } public List<SupportedDensity> SupportedDensities { get; set; }
public SscSupportedMedia[] SupportedMediaTypes { get; set; } public List<SscSupportedMedia> SupportedMediaTypes { get; set; }
public byte[] ModeSense6Data { get; set; } public byte[] ModeSense6Data { get; set; }
public byte[] ModeSense10Data { get; set; } public byte[] ModeSense10Data { get; set; }
@@ -457,14 +458,14 @@ namespace DiscImageChef.CommonTypes.Metadata
public class SscSupportedMedia public class SscSupportedMedia
{ {
[JsonIgnore] [JsonIgnore]
public int Id { get; set; } public int Id { get; set; }
public byte MediumType { get; set; } public byte MediumType { get; set; }
public DensityCode[] DensityCodes { get; set; } public List<DensityCode> DensityCodes { get; set; }
public ushort Width { get; set; } public ushort Width { get; set; }
public ushort Length { get; set; } public ushort Length { get; set; }
public string Organization { get; set; } public string Organization { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
} }
public class DensityCode public class DensityCode

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2018 Natalia Portillo // Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System.Linq;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Console; using DiscImageChef.Console;
using DiscImageChef.Decoders.SCSI; using DiscImageChef.Decoders.SCSI;
@@ -65,7 +66,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer); DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue) if(dsh.HasValue)
{ {
report.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length]; SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++) for(int i = 0; i < dsh.Value.descriptors.Length; i++)
{ {
report.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm; report.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
@@ -81,6 +82,8 @@ namespace DiscImageChef.Core.Devices.Report
report.SupportedDensities[i].Width = dsh.Value.descriptors[i].width; report.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
report.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable; report.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
} }
report.SupportedDensities = array.ToList();
} }
} }
@@ -91,7 +94,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer); DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
if(!mtsh.HasValue) return report; if(!mtsh.HasValue) return report;
report.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length]; SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++) for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
{ {
report.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description; report.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
@@ -102,13 +105,15 @@ namespace DiscImageChef.Core.Devices.Report
report.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width; report.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes == null) continue; if(mtsh.Value.descriptors[i].densityCodes == null) continue;
report.SupportedMediaTypes[i].DensityCodes = DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++) for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
report.SupportedMediaTypes[i].DensityCodes[j] = report.SupportedMediaTypes[i].DensityCodes[j] =
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]}; new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
report.SupportedMediaTypes[i].DensityCodes = array3.ToList();
} }
report.SupportedMediaTypes = array2.ToList();
return report; return report;
} }
@@ -149,7 +154,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer); DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue) if(dsh.HasValue)
{ {
seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length]; SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++) for(int i = 0; i < dsh.Value.descriptors.Length; i++)
{ {
seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm; seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
@@ -165,6 +170,8 @@ namespace DiscImageChef.Core.Devices.Report
seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width; seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable; seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
} }
seqTest.SupportedDensities = array.ToList();
} }
} }
@@ -175,7 +182,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer); DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
if(mtsh.HasValue) if(mtsh.HasValue)
{ {
seqTest.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length]; SscSupportedMedia[] array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++) for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
{ {
seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description; seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
@@ -186,12 +193,14 @@ namespace DiscImageChef.Core.Devices.Report
seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width; seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes == null) continue; if(mtsh.Value.descriptors[i].densityCodes == null) continue;
seqTest.SupportedMediaTypes[i].DensityCodes = DensityCode[] array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++) for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
seqTest.SupportedMediaTypes[i].DensityCodes[j] = seqTest.SupportedMediaTypes[i].DensityCodes[j] =
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]}; new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
seqTest.SupportedMediaTypes[i].DensityCodes = array2.ToList();
} }
seqTest.SupportedMediaTypes = array.ToList();
} }
} }

View File

@@ -58,7 +58,7 @@ namespace DiscImageChef.Core.Devices.Report
return report; return report;
} }
public ScsiPage[] ReportEvpdPages() public List<ScsiPage> ReportEvpdPages()
{ {
DicConsole.WriteLine("Querying list of SCSI EVPDs..."); DicConsole.WriteLine("Querying list of SCSI EVPDs...");
bool sense = dev.ScsiInquiry(out byte[] buffer, out _, 0x00); bool sense = dev.ScsiInquiry(out byte[] buffer, out _, 0x00);
@@ -79,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Report
evpds.Add(evpd); evpds.Add(evpd);
} }
return evpds.Count > 0 ? evpds.ToArray() : null; return evpds.Count > 0 ? evpds : null;
} }
public void ReportScsiModes(ref DeviceReportV2 report, ref Modes.ModePage_2A cdromMode) public void ReportScsiModes(ref DeviceReportV2 report, ref Modes.ModePage_2A cdromMode)
@@ -160,7 +160,7 @@ namespace DiscImageChef.Core.Devices.Report
cdromMode = Modes.DecodeModePage_2A(page.PageResponse); cdromMode = Modes.DecodeModePage_2A(page.PageResponse);
} }
if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages.ToArray(); if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages;
} }
public TestedMedia ReportScsiMedia() public TestedMedia ReportScsiMedia()

View File

@@ -38,10 +38,12 @@ using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Console; using DiscImageChef.Console;
using DiscImageChef.Core; using DiscImageChef.Core;
using DiscImageChef.Database;
using DiscImageChef.Database.Models;
using DiscImageChef.Decoders.ATA; using DiscImageChef.Decoders.ATA;
using DiscImageChef.Decoders.SCSI; using DiscImageChef.Decoders.SCSI;
using DiscImageChef.Devices;
using Newtonsoft.Json; using Newtonsoft.Json;
using Device = DiscImageChef.Devices.Device;
namespace DiscImageChef.Commands namespace DiscImageChef.Commands
{ {
@@ -220,7 +222,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest); mediaTests.Add(mediaTest);
} }
report.ATA.RemovableMedias = mediaTests.ToArray(); report.ATA.RemovableMedias = mediaTests;
} }
else report.ATA.ReadCapabilities = reporter.ReportAta(report.ATA.IdentifyDevice.Value); else report.ATA.ReadCapabilities = reporter.ReportAta(report.ATA.IdentifyDevice.Value);
@@ -607,7 +609,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest); mediaTests.Add(mediaTest);
} }
report.SCSI.MultiMediaDevice.TestedMedia = mediaTests.ToArray(); report.SCSI.MultiMediaDevice.TestedMedia = mediaTests;
} }
break; break;
case PeripheralDeviceTypes.SequentialAccess: case PeripheralDeviceTypes.SequentialAccess:
@@ -694,7 +696,7 @@ namespace DiscImageChef.Commands
seqTests.Add(seqTest); seqTests.Add(seqTest);
} }
report.SCSI.SequentialDevice.TestedMedia = seqTests.ToArray(); report.SCSI.SequentialDevice.TestedMedia = seqTests;
} }
break; break;
@@ -828,7 +830,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest); mediaTests.Add(mediaTest);
} }
report.SCSI.RemovableMedias = mediaTests.ToArray(); report.SCSI.RemovableMedias = mediaTests;
} }
else else
{ {