MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / encode

Method encode

arch/agat/encoder.cc:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60public:
61 std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl,
62 const std::vector<std::shared_ptr<const Sector>>& sectors,
63 const Image& image) override
64 {
65 double clockRateUs = _config.target_clock_period_us() / 2.0;
66 int bitsPerRevolution =
67 (_config.target_rotational_period_ms() * 1000.0) / clockRateUs;
68 _bits.resize(bitsPerRevolution);
69 _cursor = 0;
70
71 writeFillerRawBytes(_config.post_index_gap_bytes(), 0xaaaa);
72
73 for (const auto& sector : sectors)
74 {
75 /* Header */
76
77 writeFillerRawBytes(_config.pre_sector_gap_bytes(), 0xaaaa);
78 writeRawBits(SECTOR_ID, 64);
79 writeByte(0x5a);
80 writeByte((sector->logicalCylinder << 1) | sector->logicalHead);
81 writeByte(sector->logicalSector);
82 writeByte(0x5a);
83
84 /* Data */
85
86 writeFillerRawBytes(_config.pre_data_gap_bytes(), 0xaaaa);
87 auto data = sector->data.slice(0, AGAT_SECTOR_SIZE);
88 writeRawBits(DATA_ID, 64);
89 writeBytes(data);
90 writeByte(agatChecksum(data));
91 writeByte(0x5a);
92 }
93
94 if (_cursor >= _bits.size())
95 error("track data overrun");
96 fillBitmapTo(_bits, _cursor, _bits.size(), {true, false});
97
98 auto fluxmap = std::make_unique<Fluxmap>();
99 fluxmap->appendBits(_bits,
100 calculatePhysicalClockPeriod(_config.target_clock_period_us() * 1e3,
101 _config.target_rotational_period_ms() * 1e6));
102 return fluxmap;
103 }
104
105private:
106 const AgatEncoderProto& _config;

Callers

nothing calls this directly

Calls 6

agatChecksumFunction · 0.85
errorFunction · 0.85
fillBitmapToFunction · 0.85
sliceMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected