mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Cleanup.
This commit is contained in:
2
Makefile
2
Makefile
@@ -39,7 +39,7 @@ endif
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTCXX = g++ -std=c++17
|
||||
HOSTCFLAGS = -g -O3
|
||||
HOSTCFLAGS = -g
|
||||
HOSTLDFLAGS =
|
||||
|
||||
QTBINS = $(shell $(PKG_CONFIG) Qt5Core --variable=host_bins)
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/data/image.h"
|
||||
#include "lib/data/flux.h"
|
||||
#include "lib/data/layout.h"
|
||||
#include "globals.h"
|
||||
#include "datastore.h"
|
||||
|
||||
class DatastoreImpl : public Datastore
|
||||
{
|
||||
W_OBJECT(DatastoreImpl);
|
||||
|
||||
public:
|
||||
DatastoreImpl(
|
||||
std::shared_ptr<Encoder>& encoder, std::shared_ptr<Decoder>& decoder):
|
||||
_encoder(encoder),
|
||||
_decoder(decoder)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
void setDiskData(std::shared_ptr<const DiskFlux> diskData) override {}
|
||||
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> trackData) override
|
||||
{
|
||||
key_t key = {trackData->trackInfo->physicalTrack,
|
||||
trackData->trackInfo->physicalSide};
|
||||
_tracks[key] = trackData;
|
||||
}
|
||||
|
||||
void setImageData(std::shared_ptr<const Image> imageData) override
|
||||
{
|
||||
clear();
|
||||
_loadedSectors = *imageData;
|
||||
}
|
||||
|
||||
void clear() override
|
||||
{
|
||||
_loadedSectors.clear();
|
||||
_changedSectors.clear();
|
||||
_tracks.clear();
|
||||
}
|
||||
|
||||
public:
|
||||
std::shared_ptr<const Sector> get(
|
||||
unsigned track, unsigned side, unsigned sectorId) override
|
||||
{
|
||||
auto it = _changedSectors.get(track, side, sectorId);
|
||||
if (it)
|
||||
return it;
|
||||
|
||||
return _loadedSectors.get(track, side, sectorId);
|
||||
}
|
||||
|
||||
std::shared_ptr<Sector> put(
|
||||
unsigned track, unsigned side, unsigned sectorId) override
|
||||
{
|
||||
return _changedSectors.put(track, side, sectorId);
|
||||
}
|
||||
|
||||
virtual bool isReadOnly() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needsFlushing() override
|
||||
{
|
||||
return !_changedSectors.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<Encoder> _encoder;
|
||||
std::shared_ptr<Decoder> _decoder;
|
||||
Image _loadedSectors;
|
||||
Image _changedSectors;
|
||||
|
||||
typedef std::pair<unsigned, unsigned> key_t;
|
||||
std::map<key_t, std::shared_ptr<const TrackFlux>> _tracks;
|
||||
};
|
||||
|
||||
W_OBJECT_IMPL(Datastore);
|
||||
W_OBJECT_IMPL(DatastoreImpl);
|
||||
|
||||
Datastore* Datastore::create(
|
||||
std::shared_ptr<Encoder>& encoder, std::shared_ptr<Decoder>& decoder)
|
||||
{
|
||||
return new DatastoreImpl(encoder, decoder);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/vfs/sectorinterface.h"
|
||||
|
||||
class Datastore : public SectorInterface, public QObject
|
||||
{
|
||||
W_OBJECT(Datastore);
|
||||
|
||||
public:
|
||||
virtual void setDiskData(std::shared_ptr<const DiskFlux> diskData) = 0;
|
||||
W_SLOT(setDiskData)
|
||||
|
||||
virtual void setTrackData(std::shared_ptr<const TrackFlux> trackData) = 0;
|
||||
W_SLOT(setTrackData)
|
||||
|
||||
virtual void setImageData(std::shared_ptr<const Image> imageData) = 0;
|
||||
W_SLOT(setImageData)
|
||||
|
||||
virtual void clear() = 0;
|
||||
W_SLOT(clear)
|
||||
|
||||
public:
|
||||
static Datastore* create(
|
||||
std::shared_ptr<Encoder>& encoder, std::shared_ptr<Decoder>& decoder);
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/usb/usbfinder.h"
|
||||
#include "globals.h"
|
||||
#include "fluxcomponent.h"
|
||||
#include "mainwindow.h"
|
||||
#include "fluxvisualiserwidget.h"
|
||||
|
||||
class FluxComponentImpl : public FluxComponent, public QObject
|
||||
{
|
||||
W_OBJECT(FluxComponentImpl)
|
||||
|
||||
public:
|
||||
FluxComponentImpl(MainWindow* mainWindow): _mainWindow(mainWindow)
|
||||
{
|
||||
setParent(mainWindow);
|
||||
|
||||
_fluxVisualiserWidget = FluxVisualiserWidget::create();
|
||||
_mainWindow->fluxViewContainer->layout()->addWidget(
|
||||
_fluxVisualiserWidget);
|
||||
|
||||
connect(_mainWindow->fluxSideComboBox,
|
||||
QOverload<int>::of(&QComboBox::activated),
|
||||
_fluxVisualiserWidget,
|
||||
&FluxVisualiserWidget::setVisibleSide);
|
||||
connect(_mainWindow->fluxContrastSlider,
|
||||
&QAbstractSlider::valueChanged,
|
||||
[this](int value)
|
||||
{
|
||||
_fluxVisualiserWidget->setGamma(value / 100.0);
|
||||
});
|
||||
|
||||
_mainWindow->fluxContrastSlider->setValue(500);
|
||||
}
|
||||
|
||||
public:
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> track)
|
||||
{
|
||||
_fluxVisualiserWidget->setTrackData(track);
|
||||
}
|
||||
|
||||
private:
|
||||
MainWindow* _mainWindow;
|
||||
FluxVisualiserWidget* _fluxVisualiserWidget;
|
||||
};
|
||||
W_OBJECT_IMPL(FluxComponentImpl)
|
||||
|
||||
FluxComponent* FluxComponent::create(MainWindow* mainWindow)
|
||||
{
|
||||
return new FluxComponentImpl(mainWindow);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class FluxComponent
|
||||
{
|
||||
public:
|
||||
virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0;
|
||||
|
||||
public:
|
||||
static FluxComponent* create(MainWindow* mainWindow);
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/usb/usbfinder.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "globals.h"
|
||||
#include "imagecomponent.h"
|
||||
#include "mainwindow.h"
|
||||
#include "imagevisualiserwidget.h"
|
||||
|
||||
class ImageComponentImpl : public ImageComponent, public QObject
|
||||
{
|
||||
W_OBJECT(ImageComponentImpl)
|
||||
|
||||
public:
|
||||
ImageComponentImpl(MainWindow* mainWindow): _mainWindow(mainWindow)
|
||||
{
|
||||
setParent(mainWindow);
|
||||
|
||||
_imageVisualiserWidget = ImageVisualiserWidget::create();
|
||||
_mainWindow->imageViewContainer->layout()->addWidget(
|
||||
_imageVisualiserWidget);
|
||||
}
|
||||
|
||||
public:
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> track)
|
||||
{
|
||||
_imageVisualiserWidget->setTrackData(track);
|
||||
}
|
||||
|
||||
void setDiskData(std::shared_ptr<const DiskFlux> disk)
|
||||
{
|
||||
//_fluxVisualiserWidget->setDiskData(disk);
|
||||
}
|
||||
|
||||
private:
|
||||
MainWindow* _mainWindow;
|
||||
ImageVisualiserWidget* _imageVisualiserWidget;
|
||||
};
|
||||
W_OBJECT_IMPL(ImageComponentImpl)
|
||||
|
||||
ImageComponent* ImageComponent::create(MainWindow* mainWindow)
|
||||
{
|
||||
return new ImageComponentImpl(mainWindow);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class ImageComponent
|
||||
{
|
||||
public:
|
||||
virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0;
|
||||
virtual void setDiskData(std::shared_ptr<const DiskFlux> disk) = 0;
|
||||
|
||||
public:
|
||||
static ImageComponent* create(MainWindow* mainWindow);
|
||||
};
|
||||
@@ -1,195 +0,0 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/algorithms/readerwriter.h"
|
||||
#include "lib/core/utils.h"
|
||||
#include "lib/fluxsource/fluxsource.h"
|
||||
#include "lib/decoders/decoders.h"
|
||||
#include "arch/arch.h"
|
||||
#include "globals.h"
|
||||
#include "mainwindow.h"
|
||||
#include "drivecomponent.h"
|
||||
#include "formatcomponent.h"
|
||||
#include "fluxcomponent.h"
|
||||
#include "imagecomponent.h"
|
||||
|
||||
class CallbackOstream : public std::streambuf
|
||||
{
|
||||
public:
|
||||
CallbackOstream(std::function<void(const std::string&)> cb): _cb(cb) {}
|
||||
|
||||
public:
|
||||
std::streamsize xsputn(const char* p, std::streamsize n) override
|
||||
{
|
||||
_cb(std::string(p, n));
|
||||
return n;
|
||||
}
|
||||
|
||||
int_type overflow(int_type v) override
|
||||
{
|
||||
char c = v;
|
||||
_cb(std::string(&c, 1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(const std::string&)> _cb;
|
||||
};
|
||||
|
||||
class MainWindowImpl : public MainWindow
|
||||
{
|
||||
W_OBJECT(MainWindowImpl)
|
||||
|
||||
private:
|
||||
enum State
|
||||
{
|
||||
STATE_IDLE,
|
||||
STATE_READING,
|
||||
STATE_WRITING
|
||||
};
|
||||
|
||||
public:
|
||||
MainWindowImpl():
|
||||
_logStreamBuf(
|
||||
[this](const std::string& s)
|
||||
{
|
||||
logViewerEdit->appendPlainText(QString::fromStdString(s));
|
||||
logViewerEdit->ensureCursorVisible();
|
||||
}),
|
||||
_logStream(&_logStreamBuf),
|
||||
_logRenderer(LogRenderer::create(_logStream))
|
||||
{
|
||||
_driveComponent = DriveComponent::create(this);
|
||||
_formatComponent = FormatComponent::create(this);
|
||||
_fluxComponent = FluxComponent::create(this);
|
||||
_imageComponent = ImageComponent::create(this);
|
||||
|
||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||
|
||||
connect(readDiskButton,
|
||||
&QAbstractButton::clicked,
|
||||
this,
|
||||
&MainWindowImpl::readDisk);
|
||||
|
||||
setState(STATE_IDLE);
|
||||
}
|
||||
|
||||
public:
|
||||
void logMessage(const AnyLogMessage& message) override
|
||||
{
|
||||
#if 0
|
||||
std::visit(overloaded{/* Fallback --- do nothing */
|
||||
[this](const auto& m)
|
||||
{
|
||||
},
|
||||
|
||||
/* A track has been read. */
|
||||
[&](const TrackReadLogMessage& m)
|
||||
{
|
||||
_fluxComponent->setTrackData(m.track);
|
||||
_imageComponent->setTrackData(m.track);
|
||||
},
|
||||
|
||||
/* A complete disk has been read. */
|
||||
[&](const DiskReadLogMessage& m)
|
||||
{
|
||||
_imageComponent->setDiskData(m.disk);
|
||||
_currentDisk = m.disk;
|
||||
},
|
||||
|
||||
/* Large-scale operation start. */
|
||||
[this](const BeginOperationLogMessage& m)
|
||||
{
|
||||
_progressWidget->setValue(0);
|
||||
},
|
||||
|
||||
/* Large-scale operation end. */
|
||||
[this](const EndOperationLogMessage& m)
|
||||
{
|
||||
},
|
||||
|
||||
/* Large-scale operation progress. */
|
||||
[this](const OperationProgressLogMessage& m)
|
||||
{
|
||||
_progressWidget->setValue(m.progress);
|
||||
}},
|
||||
*message);
|
||||
#endif
|
||||
|
||||
_logRenderer->add(message);
|
||||
_logStream.flush();
|
||||
}
|
||||
|
||||
void collectConfig() override
|
||||
{
|
||||
try
|
||||
{
|
||||
globalConfig().clear();
|
||||
_formatComponent->collectConfig();
|
||||
_driveComponent->collectConfig();
|
||||
}
|
||||
catch (const ErrorException& e)
|
||||
{
|
||||
log("Fatal error: {}", e.message);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
log("Mysterious uncaught exception!");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void readDisk()
|
||||
{
|
||||
if (isWorkerThreadRunning())
|
||||
return;
|
||||
|
||||
collectConfig();
|
||||
::emergencyStop = false;
|
||||
setState(STATE_READING);
|
||||
|
||||
runThen(
|
||||
[this]()
|
||||
{
|
||||
auto fluxSource = FluxSource::create(globalConfig());
|
||||
auto decoder = Arch::createDecoder(globalConfig());
|
||||
auto diskflux = readDiskCommand(*fluxSource, *decoder);
|
||||
},
|
||||
[this]()
|
||||
{
|
||||
setState(STATE_IDLE);
|
||||
});
|
||||
}
|
||||
W_SLOT(readDisk)
|
||||
|
||||
private:
|
||||
void setState(int state)
|
||||
{
|
||||
_stopWidget->setEnabled(state != STATE_IDLE);
|
||||
_progressWidget->setEnabled(state != STATE_IDLE);
|
||||
diskOperationsGroup->setEnabled(state == STATE_IDLE);
|
||||
memoryOperationsGroup->setEnabled(state == STATE_IDLE);
|
||||
driveWindow->setEnabled(state == STATE_IDLE);
|
||||
formatWindow->setEnabled(state == STATE_IDLE);
|
||||
|
||||
_state = state;
|
||||
}
|
||||
W_SLOT(setState)
|
||||
|
||||
private:
|
||||
std::ostream _logStream;
|
||||
CallbackOstream _logStreamBuf;
|
||||
std::unique_ptr<LogRenderer> _logRenderer;
|
||||
DriveComponent* _driveComponent;
|
||||
FormatComponent* _formatComponent;
|
||||
FluxComponent* _fluxComponent;
|
||||
ImageComponent* _imageComponent;
|
||||
std::shared_ptr<const DiskFlux> _currentDisk;
|
||||
int _state;
|
||||
};
|
||||
W_OBJECT_IMPL(MainWindowImpl)
|
||||
|
||||
std::unique_ptr<MainWindow> MainWindow::create()
|
||||
{
|
||||
return std::make_unique<MainWindowImpl>();
|
||||
}
|
||||
Reference in New Issue
Block a user