Remove the hardware source/sink flags.

This commit is contained in:
David Given
2021-05-15 13:06:53 +02:00
parent 93dcc7e242
commit 5a63172a86
18 changed files with 60 additions and 92 deletions

View File

@@ -13,4 +13,10 @@ extend google.protobuf.FieldOptions {
optional string help = 50000;
}
enum IndexMode {
INDEXMODE_DRIVE = 0;
INDEXMODE_300 = 1;
INDEXMODE_360 = 2;
}

View File

@@ -5,6 +5,7 @@ import "lib/encoders/encoders.proto";
import "lib/imagereader/imagereader.proto";
import "lib/imagewriter/imagewriter.proto";
import "lib/fluxsource/fluxsource.proto";
import "lib/fluxsink/fluxsink.proto";
import "lib/usb/usb.proto";
import "lib/common.proto";
@@ -16,13 +17,6 @@ message InputDiskProto {
}
}
message OutputDiskProto {
oneof dest {
string fluxfile = 1;
int32 drive = 2;
}
}
message InputProto {
oneof input {
InputFileProto file = 1;

View File

@@ -1,15 +0,0 @@
#include "globals.h"
#include "flags.h"
#include "flaggroups/fluxsourcesink.h"
FlagGroup fluxSourceSinkFlags;
SettableFlag fluxSourceSinkFortyTrack(
{ "--40-track", "-4" },
"indicates a 40 track drive");
SettableFlag fluxSourceSinkHighDensity(
{ "--high-density", "-H" },
"set the drive to high density mode");

View File

@@ -1,13 +0,0 @@
#ifndef FLUXSOURCESINK_H
#define FLUXSOURCESINK_H
#include "flags.h"
extern FlagGroup fluxSourceSinkFlags;
extern SettableFlag fluxSourceSinkFortyTrack;
extern SettableFlag fluxSourceSinkHighDensity;
#endif

View File

@@ -4,11 +4,11 @@
#include "flags.h"
#include <ostream>
extern FlagGroup hardwareFluxSinkFlags;
extern FlagGroup sqliteFluxSinkFlags;
class Fluxmap;
class OutputDiskProto;
class HardwareOutputProto;
class FluxSink
{
@@ -16,7 +16,7 @@ public:
virtual ~FluxSink() {}
static std::unique_ptr<FluxSink> createSqliteFluxSink(const std::string& filename);
static std::unique_ptr<FluxSink> createHardwareFluxSink(unsigned drive);
static std::unique_ptr<FluxSink> createHardwareFluxSink(const HardwareOutputProto& config);
static std::unique_ptr<FluxSink> create(const OutputDiskProto& config);

View File

@@ -0,0 +1,22 @@
syntax = "proto2";
import "lib/common.proto";
message HardwareOutputProto {
optional IndexMode index_mode = 1
[default = INDEXMODE_DRIVE, (help) = "index pulse source"];
optional int32 hard_sector_count = 2
[(help) = "number of hard sectors on the disk"];
optional bool high_density = 3
[default = true, (help) = "set if this is a high density disk"];
optional int32 drive = 4
[default = 0, (help) = "which drive to write to (0 or 1)"];
}
message OutputDiskProto {
oneof dest {
string fluxfile = 1;
HardwareOutputProto drive = 2;
}
}

View File

@@ -3,40 +3,21 @@
#include "fluxmap.h"
#include "usb/usb.h"
#include "fluxsink/fluxsink.h"
#include "flaggroups/fluxsourcesink.h"
#include "lib/fluxsink/fluxsink.pb.h"
#include "fmt/format.h"
FlagGroup hardwareFluxSinkFlags = {
&fluxSourceSinkFlags,
};
static IntFlag indexMode(
{ "--write-index-mode" },
"index pulse source (0=drive, 1=300 RPM fake source, 2=360 RPM fake source",
0);
static IntFlag hardSectorCount(
{ "--write-hard-sector-count" },
"number of hard sectors on the disk (0=soft sectors)",
0);
void setHardwareFluxSinkHardSectorCount(int sectorCount)
{
::hardSectorCount.setDefaultValue(sectorCount);
}
class HardwareFluxSink : public FluxSink
{
public:
HardwareFluxSink(unsigned drive):
_drive(drive)
HardwareFluxSink(const HardwareOutputProto& config):
_config(config)
{
if (hardSectorCount != 0)
if (config.has_hard_sector_count())
{
usbSetDrive(_drive, fluxSourceSinkHighDensity, indexMode);
usbSetDrive(_config.drive(), _config.high_density(), _config.index_mode());
std::cerr << "Measuring rotational speed... " << std::flush;
nanoseconds_t oneRevolution = usbGetRotationalPeriod(hardSectorCount);
_hardSectorThreshold = oneRevolution * 3 / (4 * hardSectorCount);
nanoseconds_t oneRevolution = usbGetRotationalPeriod(_config.hard_sector_count());
_hardSectorThreshold = oneRevolution * 3 / (4 * _config.hard_sector_count());
std::cerr << fmt::format("{}ms\n", oneRevolution / 1e6);
}
else
@@ -50,7 +31,8 @@ public:
public:
void writeFlux(int track, int side, Fluxmap& fluxmap)
{
usbSetDrive(_drive, fluxSourceSinkHighDensity, indexMode);
usbSetDrive(_config.drive(), _config.high_density(), _config.index_mode());
#if 0
if (fluxSourceSinkFortyTrack)
{
if (track & 1)
@@ -58,6 +40,7 @@ public:
usbSeek(track / 2);
}
else
#endif
usbSeek(track);
return usbWrite(side, fluxmap.rawBytes(), _hardSectorThreshold);
@@ -65,17 +48,17 @@ public:
operator std::string () const
{
return fmt::format("drive {}", _drive);
return fmt::format("drive {}", _config.drive());
}
private:
unsigned _drive;
const HardwareOutputProto& _config;
nanoseconds_t _hardSectorThreshold;
};
std::unique_ptr<FluxSink> FluxSink::createHardwareFluxSink(unsigned drive)
std::unique_ptr<FluxSink> FluxSink::createHardwareFluxSink(const HardwareOutputProto& config)
{
return std::unique_ptr<FluxSink>(new HardwareFluxSink(drive));
return std::unique_ptr<FluxSink>(new HardwareFluxSink(config));
}

View File

@@ -3,8 +3,6 @@
#include "flags.h"
extern FlagGroup hardwareFluxSourceFlags;
class Fluxmap;
class FluxSpec;
class InputDiskProto;

View File

@@ -1,10 +1,6 @@
syntax = "proto2";
enum IndexMode {
INDEXMODE_DRIVE = 0;
INDEXMODE_300 = 1;
INDEXMODE_360 = 2;
}
import "lib/common.proto";
message HardwareInputProto {
optional int32 drive = 1 [default = 0];
@@ -13,7 +9,8 @@ message HardwareInputProto {
optional bool sync_with_index = 3 [default = false];
optional IndexMode index_mode = 4 [default = INDEXMODE_DRIVE];
optional int32 hard_sector_count = 5 [default = 0];
optional bool high_density = 6 [default = true];
optional bool high_density = 6
[default = true, (help) = "set if this is a high density disk"];
}
message TestPatternInputProto {

View File

@@ -3,21 +3,16 @@
#include "fluxmap.h"
#include "usb/usb.h"
#include "fluxsource/fluxsource.h"
#include "flaggroups/fluxsourcesink.h"
#include "lib/fluxsource/fluxsource.pb.h"
#include "fmt/format.h"
FlagGroup hardwareFluxSourceFlags = {
&fluxSourceSinkFlags,
};
class HardwareFluxSource : public FluxSource
{
public:
HardwareFluxSource(const HardwareInputProto& config):
_config(config)
{
usbSetDrive(_config.drive(), fluxSourceSinkHighDensity, _config.index_mode());
usbSetDrive(_config.drive(), _config.high_density(), _config.index_mode());
std::cerr << "Measuring rotational speed... " << std::flush;
_oneRevolution = usbGetRotationalPeriod(_config.hard_sector_count());
if (_config.hard_sector_count() != 0)

View File

@@ -22,7 +22,6 @@
FlagGroup readerFlags
{
&hardwareFluxSourceFlags,
&sqliteFluxSinkFlags,
&fluxmapReaderFlags,
};

View File

@@ -17,7 +17,7 @@
#include "lib/config.pb.h"
#include "proto.h"
FlagGroup writerFlags { &hardwareFluxSourceFlags, &sqliteFluxSinkFlags, &hardwareFluxSinkFlags };
FlagGroup writerFlags { &sqliteFluxSinkFlags };
static sqlite3* outdb;

View File

@@ -270,6 +270,7 @@ buildproto libproto.a \
lib/decoders/decoders.proto \
lib/encoders/encoders.proto \
lib/fluxsource/fluxsource.proto \
lib/fluxsink/fluxsink.proto \
lib/imagereader/imagereader.proto \
lib/imagewriter/imagewriter.proto \
lib/usb/usb.proto \
@@ -314,7 +315,6 @@ buildlibrary libbackend.a \
lib/decoders/fluxmapreader.cc \
lib/decoders/fmmfm.cc \
lib/encoders/encoders.cc \
lib/flaggroups/fluxsourcesink.cc \
lib/flags.cc \
lib/fluxmap.cc \
lib/fluxsink/fluxsink.cc \

View File

@@ -7,13 +7,11 @@
#include "writer.h"
#include "protocol.h"
#include "fmt/format.h"
#include "flaggroups/fluxsourcesink.h"
#include "dep/agg/include/agg2d.h"
#include "dep/stb/stb_image_write.h"
#include <fstream>
static FlagGroup flags = {
&fluxSourceSinkFlags,
};
static DataSpecFlag dest(
@@ -181,6 +179,8 @@ static void draw_x_graticules(Agg2D& painter, double x1, double y1, double x2, d
int mainAnalyseDriveResponse(int argc, const char* argv[])
{
Error() << "TODO";
#if 0
flags.parseFlagsWithConfigFiles(argc, argv, {});
FluxSpec spec(dest);
@@ -346,6 +346,7 @@ int mainAnalyseDriveResponse(int argc, const char* argv[])
painter.rectangle(colourbarBounds.x1, drawableBounds.y1, drawableBounds.x2, drawableBounds.y2);
bitmapSpec.save();
}
#endif
return 0;
}

View File

@@ -10,7 +10,7 @@
#include "fmt/format.h"
#include <fstream>
static FlagGroup flags { &hardwareFluxSourceFlags };
static FlagGroup flags;
static DataSpecFlag source(
{ "--source", "-s" },

View File

@@ -10,7 +10,7 @@
#include "fmt/format.h"
#include <fstream>
static FlagGroup flags { &hardwareFluxSourceFlags };
static FlagGroup flags;
static DataSpecFlag source(
{ "--source", "-s" },

View File

@@ -1,11 +1,9 @@
#include "globals.h"
#include "flags.h"
#include "usb/usb.h"
#include "flaggroups/fluxsourcesink.h"
#include "protocol.h"
static FlagGroup flags = {
&fluxSourceSinkFlags,
};
static IntFlag drive(
@@ -21,7 +19,9 @@ static IntFlag track(
int mainSeek(int argc, const char* argv[])
{
flags.parseFlagsWithConfigFiles(argc, argv, {});
Error() << "TODO";
#if 0
usbSetDrive(drive, false, F_INDEX_REAL);
if (fluxSourceSinkFortyTrack)
{
@@ -31,5 +31,6 @@ int mainSeek(int argc, const char* argv[])
}
else
usbSeek(track);
#endif
return 0;
}

View File

@@ -51,7 +51,7 @@ static void test_config(void)
output {
disk {
drive: 0
drive { }
}
}
)M";