First sector visualisation! Doesn't look bad.

This commit is contained in:
David Given
2022-02-25 01:31:10 +01:00
parent 5c063a9de3
commit a59b59fea4
3 changed files with 50 additions and 17 deletions

View File

@@ -31,11 +31,12 @@ std::string Logger::toString(const AnyLogMessage& message)
{
std::stringstream stream;
auto indent = [&]() {
if (!indented)
stream << " ";
indented = false;
};
auto indent = [&]()
{
if (!indented)
stream << " ";
indented = false;
};
std::visit(
overloaded{
@@ -58,7 +59,7 @@ std::string Logger::toString(const AnyLogMessage& message)
60e9 / m.rotationalPeriod);
},
/* Indicates that we're starting a write operation. */
/* Indicates that we're starting a write operation. */
[&](const BeginWriteOperationLogMessage& m)
{
stream << fmt::format("{:2}.{}: ", m.cylinder, m.head);
@@ -72,10 +73,11 @@ std::string Logger::toString(const AnyLogMessage& message)
indented = true;
},
/* We've just read a track (we might reread it if there are errors) */
/* We've just read a track (we might reread it if there are errors)
*/
[&](const TrackReadLogMessage& m)
{
const auto& track = *m.track;
const auto& track = *m.track;
const auto& trackdataflux = track.trackDatas.end()[-1];
indent();
@@ -98,13 +100,8 @@ std::string Logger::toString(const AnyLogMessage& message)
std::vector<std::shared_ptr<const Sector>> sectors(
track.sectors.begin(), track.sectors.end());
std::sort(sectors.begin(),
sectors.end(),
[](const std::shared_ptr<const Sector>& s1,
const std::shared_ptr<const Sector>& s2)
{
return s1->logicalSector < s2->logicalSector;
});
std::sort(
sectors.begin(), sectors.end(), sectorPointerSortPredicate);
for (const auto& sector : sectors)
stream << fmt::format(" {}{}",

View File

@@ -99,6 +99,8 @@ std::shared_ptr<const DiskFlux> readDiskCommand(FluxSource& fluxsource, Abstract
testForEmergencyStop();
auto track = std::make_shared<TrackFlux>();
track->physicalCylinder = cylinder;
track->physicalHead = head;
diskflux->tracks.push_back(track);
std::set<std::shared_ptr<const Sector>> track_sectors;

View File

@@ -2,6 +2,7 @@
#include "visualisation.h"
#include "fluxmap.h"
#include "flux.h"
#include "sector.h"
#include "fmt/format.h"
#include <wx/wx.h>
@@ -69,15 +70,43 @@ void VisualisationControl::OnPaint(wxPaintEvent&)
);
}
dc.SetBrush(DARK_GREY_BRUSH);
dc.SetPen(DARK_GREY_PEN);
for (int track = 0; track <= TRACKS; track++)
{
int y = scaletop + track*SECTORSIZE;
dc.SetBrush(DARK_GREY_BRUSH);
dc.SetPen(DARK_GREY_PEN);
dc.DrawRectangle(
{ w2-TICK/2, y },
{ TICK, SECTORSIZE-1 }
);
auto drawSectors =
[&](int head) {
key_t key = { track, head };
std::vector<std::shared_ptr<const Sector>> sectors;
for (auto it = _sectors.lower_bound(key); it != _sectors.upper_bound(key); it++)
sectors.push_back(it->second);
std::sort(sectors.begin(), sectors.end(), sectorPointerSortPredicate);
int x = 1;
for (const auto& sector : sectors)
{
if (head == 0)
dc.DrawRectangle(
{ w2 - x*SECTORSIZE - (SECTORSIZE-1), y },
{ SECTORSIZE-1, SECTORSIZE-1 }
);
else
dc.DrawRectangle(
{ w2 + x*SECTORSIZE, y },
{ SECTORSIZE-1, SECTORSIZE-1 }
);
x++;
}
};
drawSectors(0);
drawSectors(1);
}
}
@@ -97,6 +126,11 @@ void VisualisationControl::Clear()
void VisualisationControl::SetTrackData(std::shared_ptr<const TrackFlux> track)
{
key_t key = { track->physicalCylinder, track->physicalHead };
_sectors.erase(key);
for (auto& sector : track->sectors)
_sectors.insert({ key, sector });
Refresh();
}