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

Method encode

arch/victor9k/encoder.cc:167–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166public:
167 std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl,
168 const std::vector<std::shared_ptr<const Sector>>& sectors,
169 const Image& image) override
170 {
171 Victor9kEncoderProto::TrackdataProto trackdata;
172 getTrackFormat(trackdata, ltl.logicalCylinder, ltl.logicalHead);
173
174 unsigned bitsPerRevolution = (trackdata.rotational_period_ms() * 1e3) /
175 trackdata.clock_period_us();
176 std::vector<bool> bits(bitsPerRevolution);
177 nanoseconds_t clockPeriod =
178 calculatePhysicalClockPeriod(trackdata.clock_period_us() * 1e3,
179 trackdata.rotational_period_ms() * 1e6);
180 unsigned cursor = 0;
181
182 fillBitmapTo(bits,
183 cursor,
184 trackdata.post_index_gap_us() * 1e3 / clockPeriod,
185 {true, false});
186 lastBit = false;
187
188 for (const auto& sector : sectors)
189 write_sector(bits, cursor, trackdata, *sector);
190
191 if (cursor >= bits.size())
192 error("track data overrun by {} bits", cursor - bits.size());
193 fillBitmapTo(bits, cursor, bits.size(), {true, false});
194
195 std::unique_ptr<Fluxmap> fluxmap(new Fluxmap);
196 fluxmap->appendBits(bits, clockPeriod);
197 return fluxmap;
198 }
199
200private:
201 const Victor9kEncoderProto& _config;

Callers

nothing calls this directly

Calls 4

fillBitmapToFunction · 0.85
errorFunction · 0.85
write_sectorFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected