| 108 | |
| 109 | public: |
| 110 | std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl, |
| 111 | const std::vector<std::shared_ptr<const Sector>>& sectors, |
| 112 | const Image& image) override |
| 113 | { |
| 114 | int bitsPerRevolution = 200000.0 / _config.clock_rate_us(); |
| 115 | std::vector<bool> bits(bitsPerRevolution); |
| 116 | unsigned cursor = 0; |
| 117 | |
| 118 | int sectorCount = 0; |
| 119 | for (const auto& sectorData : sectors) |
| 120 | { |
| 121 | double headerMs = _config.post_index_gap_ms() + |
| 122 | sectorCount * _config.sector_spacing_ms(); |
| 123 | unsigned headerCursor = headerMs * 1e3 / _config.clock_rate_us(); |
| 124 | double dataMs = headerMs + _config.post_header_spacing_ms(); |
| 125 | unsigned dataCursor = dataMs * 1e3 / _config.clock_rate_us(); |
| 126 | |
| 127 | fillBitmapTo(bits, cursor, headerCursor, {true, false}); |
| 128 | write_sector_header(bits, |
| 129 | cursor, |
| 130 | sectorData->logicalCylinder, |
| 131 | sectorData->logicalSector); |
| 132 | fillBitmapTo(bits, cursor, dataCursor, {true, false}); |
| 133 | write_sector_data(bits, cursor, sectorData->data); |
| 134 | |
| 135 | sectorCount++; |
| 136 | } |
| 137 | |
| 138 | if (cursor >= bits.size()) |
| 139 | error("track data overrun"); |
| 140 | fillBitmapTo(bits, cursor, bits.size(), {true, false}); |
| 141 | |
| 142 | std::unique_ptr<Fluxmap> fluxmap(new Fluxmap); |
| 143 | fluxmap->appendBits(bits, _config.clock_rate_us() * 1e3); |
| 144 | return fluxmap; |
| 145 | } |
| 146 | |
| 147 | private: |
| 148 | const BrotherEncoderProto& _config; |
nothing calls this directly
no test coverage detected