mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add a --write-csv=X option to the reader to dump the sector status map as a
machine-readable file.
This commit is contained in:
@@ -177,7 +177,8 @@ directory.
|
||||
These all take an optional `--write-flux` option which will cause the raw
|
||||
flux to be written to the specified file as well as the normal decode.
|
||||
There are various `--dump` options for showing raw data during the decode
|
||||
process.
|
||||
process, and `--write-csv` will write a copious CSV report of the state of
|
||||
every sector in the file in machine-readable format.
|
||||
|
||||
- `fluxengine write *`: writes various formats of disk. Again, see the
|
||||
per-format documentation [in the index page](../README.md).
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "track.h"
|
||||
#include "imagewriter/imagewriter.h"
|
||||
#include "fmt/format.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
FlagGroup readerFlags
|
||||
{
|
||||
@@ -47,6 +49,11 @@ static StringFlag visualise(
|
||||
"write a visualisation of the disk to this file",
|
||||
"");
|
||||
|
||||
static StringFlag csvFile(
|
||||
{ "--write-csv" },
|
||||
"write a CSV report of the disk state",
|
||||
"");
|
||||
|
||||
static SettableFlag justRead(
|
||||
{ "--just-read" },
|
||||
"just read the disk and do no further processing");
|
||||
@@ -133,6 +140,48 @@ std::vector<std::unique_ptr<Track>> readTracks()
|
||||
return tracks;
|
||||
}
|
||||
|
||||
static void writeCsv(const SectorSet& sectors, const std::string& filename)
|
||||
{
|
||||
std::ofstream f(filename, std::ios::out);
|
||||
if (!f.is_open())
|
||||
Error() << "cannot open CSV report file";
|
||||
|
||||
f << "\"Physical track\","
|
||||
"\"Physical side\","
|
||||
"\"Logical track\","
|
||||
"\"Logical side\","
|
||||
"\"Logical sector\","
|
||||
"\"Clock (ns)\","
|
||||
"\"Header start (ns)\","
|
||||
"\"Header end (ns)\","
|
||||
"\"Data start (ns)\","
|
||||
"\"Data end (ns)\","
|
||||
"\"Raw data address (bytes)\","
|
||||
"\"User payload length (bytes)\","
|
||||
"\"Status\""
|
||||
"\n";
|
||||
|
||||
for (const auto& e : sectors.get())
|
||||
{
|
||||
const auto& sector = e.second;
|
||||
f << fmt::format("{},{},{},{},{},{},{},{},{},{},{},{},{}\n",
|
||||
sector->physicalTrack,
|
||||
sector->physicalSide,
|
||||
sector->logicalTrack,
|
||||
sector->logicalSide,
|
||||
sector->logicalSector,
|
||||
sector->clock,
|
||||
sector->headerStartTime,
|
||||
sector->headerEndTime,
|
||||
sector->dataStartTime,
|
||||
sector->dataEndTime,
|
||||
sector->position.bytes,
|
||||
sector->data.size(),
|
||||
Sector::statusToString(sector->status)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static bool conflictable(Sector::Status status)
|
||||
{
|
||||
return (status == Sector::OK) || (status == Sector::CONFLICT);
|
||||
@@ -280,6 +329,9 @@ void readDiskCommand(AbstractDecoder& decoder)
|
||||
|
||||
if (!visualise.get().empty())
|
||||
visualiseSectorsToFile(allSectors, visualise.get());
|
||||
|
||||
if (!csvFile.get().empty())
|
||||
writeCsv(allSectors, csvFile.get());
|
||||
|
||||
writeSectorsToFile(allSectors, outputSpec);
|
||||
if (failures)
|
||||
|
||||
Reference in New Issue
Block a user