| 699 | } |
| 700 | |
| 701 | void readDiskCommand(const DiskLayout& diskLayout, |
| 702 | FluxSource& fluxSource, |
| 703 | Decoder& decoder, |
| 704 | Disk& disk) |
| 705 | { |
| 706 | std::unique_ptr<FluxSinkFactory> outputFluxSinkFactory; |
| 707 | if (globalConfig()->decoder().has_copy_flux_to()) |
| 708 | outputFluxSinkFactory = |
| 709 | FluxSinkFactory::create(globalConfig()->decoder().copy_flux_to()); |
| 710 | |
| 711 | std::map<CylinderHead, std::vector<std::shared_ptr<const Track>>> |
| 712 | tracksByLogicalLocation; |
| 713 | for (auto& [ch, track] : disk.tracksByPhysicalLocation) |
| 714 | tracksByLogicalLocation[CylinderHead(track->ltl->logicalCylinder, |
| 715 | track->ltl->logicalHead)] |
| 716 | .push_back(track); |
| 717 | |
| 718 | log(BeginOperationLogMessage{"Reading and decoding disk"}); |
| 719 | |
| 720 | if (fluxSource.isHardware()) |
| 721 | disk.rotationalPeriod = measureDiskRotation(); |
| 722 | else |
| 723 | disk.rotationalPeriod = getRotationalPeriodFromConfig(); |
| 724 | |
| 725 | { |
| 726 | std::unique_ptr<FluxSink> outputFluxSink; |
| 727 | if (outputFluxSinkFactory) |
| 728 | outputFluxSink = outputFluxSinkFactory->create(); |
| 729 | unsigned index = 0; |
| 730 | for (auto& [logicalLocation, ltl] : diskLayout.layoutByLogicalLocation) |
| 731 | { |
| 732 | log(OperationProgressLogMessage{ |
| 733 | index * 100 / |
| 734 | (unsigned)diskLayout.layoutByLogicalLocation.size()}); |
| 735 | index++; |
| 736 | |
| 737 | testForEmergencyStop(); |
| 738 | |
| 739 | auto& trackFluxes = tracksByLogicalLocation[logicalLocation]; |
| 740 | std::vector<std::shared_ptr<const Sector>> trackSectors; |
| 741 | readAndDecodeTrack(diskLayout, |
| 742 | fluxSource, |
| 743 | decoder, |
| 744 | ltl, |
| 745 | trackFluxes, |
| 746 | trackSectors); |
| 747 | |
| 748 | /* Replace all tracks on the disk by the new combined set. */ |
| 749 | |
| 750 | for (const auto& flux : trackFluxes) |
| 751 | disk.tracksByPhysicalLocation.erase(CylinderHead{ |
| 752 | flux->ptl->physicalCylinder, flux->ptl->physicalHead}); |
| 753 | for (const auto& flux : trackFluxes) |
| 754 | disk.tracksByPhysicalLocation.emplace( |
| 755 | CylinderHead{ |
| 756 | flux->ptl->physicalCylinder, flux->ptl->physicalHead}, |
| 757 | flux); |
| 758 |
no test coverage detected