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

Method encode

arch/micropolis/encoder.cc:90–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl,
91 const std::vector<std::shared_ptr<const Sector>>& sectors,
92 const Image& image) override
93 {
94 int bitsPerRevolution =
95 (_config.rotational_period_ms() * 1e3) / _config.clock_period_us();
96
97 std::vector<bool> bits(bitsPerRevolution);
98 std::vector<unsigned> indexes;
99 unsigned prev_cursor = 0;
100 unsigned cursor = 0;
101
102 for (const auto& sectorData : sectors)
103 {
104 indexes.push_back(cursor);
105 prev_cursor = cursor;
106 write_sector(bits, cursor, sectorData, _config.ecc_type());
107 }
108 indexes.push_back(prev_cursor + (cursor - prev_cursor) / 2);
109 indexes.push_back(cursor);
110
111 if (cursor != bits.size())
112 error("track data mismatched length");
113
114 std::unique_ptr<Fluxmap> fluxmap(new Fluxmap);
115 nanoseconds_t clockPeriod =
116 calculatePhysicalClockPeriod(_config.clock_period_us() * 1e3,
117 _config.rotational_period_ms() * 1e6);
118 auto pos = bits.begin();
119 for (int i = 1; i < indexes.size(); i++)
120 {
121 auto end = bits.begin() + indexes[i];
122 fluxmap->appendBits(std::vector<bool>(pos, end), clockPeriod);
123 fluxmap->appendIndex();
124 pos = end;
125 }
126 return fluxmap;
127 }
128
129private:
130 const MicropolisEncoderProto& _config;

Callers

nothing calls this directly

Calls 5

errorFunction · 0.85
write_sectorFunction · 0.70
push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected