Skip to content

Add TapeLibNET calibration operation and TapeWinNET calibration workflow - #3

Open
avk1im with Copilot wants to merge 39 commits into
masterfrom
copilot/calibration-ui-part-4-phase-5
Open

Add TapeLibNET calibration operation and TapeWinNET calibration workflow#3
avk1im with Copilot wants to merge 39 commits into
masterfrom
copilot/calibration-ui-part-4-phase-5

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown

This PR implements Part 4 / Phase 5 for calibration: a service-layer calibration operation in TapeLibNET.Services and a GUI workflow in TapeWinNET to run, monitor, abort, review, save, and apply a calibration profile. It builds on the shipped Phases 0–4 without touching the validated low-level SCSI direct-write path.

  • Service operation: calibration

    • Adds CalibrateRequest / CalibrateResult to the existing ServiceOperationRequest -> operation -> ServiceOperationResult pattern.
    • Adds ExecuteCalibrateAsync() / ExecuteCalibrateCore() in TapeServiceBase.EW.cs.
    • Introduces ServiceCalibrateProgressHandler to bridge calibration’s chunk-oriented progress into the existing operation-progress model used by the WPF overlay.
    • Reuses the established cooperative abort flow by wiring service cancellation into TapeCalibrator.IsAbortRequested.
    • Exposes minimal calibration-facing service surface needed by the UI (DriveProfileKey, active calibration, AddCalibration()).
  • WPF workflow: confirm -> run -> review

    • Adds CalibrateWindow as the destructive-operation gate, patterned after the existing dialog conventions.
    • Adds CalibrationViewModel to own the run lifecycle, abort coordination, save/apply actions, and result state.
    • Adds CalibrationWindow to review the measured capacity, EW landmark, and EW→EOM distance, then save/apply the profile immediately.
  • MainWindow progress integration

    • Extends the shared operation overlay to handle calibration alongside backup/restore instead of introducing a new progress surface.
    • Adds WpfServiceHost.UpdateCalibrateProgress() and calibration-specific MainViewModel state/commands.
    • Reuses the existing IO sparkline, percent bar, phase text, and abort button plumbing.
  • Calibration curve visualization

    • Adds CalibrationCurveControl to plot ReportedRemaining -> ActualRemaining.
    • Marks EW and EOM explicitly.
    • Uses a split X-axis to magnify the EW→EOM tail region while keeping the full-capacity shape visible:
      • pre-EW span uses most of the width
      • EW→EOM tail gets a dedicated magnified segment
  • As-built notes

    • Calibration does not use TapeFileAgent or TOC state, so it does not literally reuse ServiceOperationProgressHandler; instead it follows the same operation triad with a dedicated calibration progress adapter.
    • IoRateSparklineControl is a rolling throughput sparkline, not a reusable 2D plot base, so the calibration graph is implemented as a dedicated control rather than forcing a shared inheritance layer.

Example of the new service-layer shape:

var result = await tapeService.ExecuteCalibrateAsync(
    new CalibrateRequest(
        EjectWhenDone: false,
        Options: new TapeCalibrationOptions())
    {
        Cancellation = cancellationToken,
        OperationLabel = "Calibration",
    });

if (result.Calibration is { } calibration)
{
    App.Settings.Calibrations.Save(calibration);
    tapeService.AddCalibration(calibration);
}

@avk1im
avk1im marked this pull request as ready for review July 30, 2026 17:52
Copilot AI changed the title [WIP] Implement calibration UI for Part 4 Phase 5 Add TapeLibNET calibration operation and TapeWinNET calibration workflow Jul 30, 2026
Copilot AI requested a review from avk1im July 30, 2026 18:04
@avk1im

avk1im commented Aug 1, 2026

Copy link
Copy Markdown
Owner

@copilot Great job overall! Please fix two issues:

1. UI — graph overflows its GroupBox.
The plot's bottom edge extends past the intended area and overlaps the "The orange tail…"
caption. It looks like the X-axis renders at the lower border of the enclosing GroupBox
"Reported -> Actual Remaining Curve" instead of inside its content area. Constrain the plot
to the GroupBox client bounds (reserve room for the axis labels and the caption) so nothing
bleeds past the frame.

2. Logic — overreport emulation does not affect the calibration result.
Repro: open a virtual drive, Options | Emulate EOM Behavior | Custom, set Capacity Overreport
to 10% on a 1000 MB cartridge, then run calibration. The run measures CapacityActual ≈ 1000 MB
— the overreport never manifests. I expect the two figures to diverge: the driver-reported
capacity should read inflated (~1100 MB, or remaining floored high at EOM) while CapacityActual
stays the true 1000 MB.

Please trace which side is wrong:

  • Does VirtualTapeMedia actually apply ReportedRemainingModel during the calibration writes, or
    does the calibrator sample the true figure? Confirm TrueRemaining drives hard-EOM while
    Remaining returns the overreported value.
  • Does the overreport knob reach the backend for THIS run, or does something reset it (the
    calibrator's RemoveAllCalibrations / EW-runtime reset must not clear the emulation profile)?
  • Clarify and document the intended semantics of "overreport %": phantom free space still
    claimed at hard EOM (reported > actual), NOT a reduction of true capacity. Make the calibration
    result show that gap (e.g. CapacityReported vs. CapacityActual) so the emulation is observably
    exercised.

Add or extend a test that sets a non-zero overreport and asserts CapacityReported > CapacityActual
after a run.

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Author

@copilot Great job overall! Please fix two issues:

1. UI — graph overflows its GroupBox.
...

Fixed in 428eaa2. The calibration chart now keeps its plot/axis labels inside the GroupBox content area, and calibration now preserves/report the overreported side of virtual-media runs so CapacityReported > CapacityActual when overreport emulation is enabled. I also added regression coverage for the non-zero overreport case.

@avk1im

avk1im commented Aug 1, 2026

Copy link
Copy Markdown
Owner

@copilot The graph doesn't bleed past its frame anymore, yet its lower part is truncated. Please scale the graph down vertically so that it fits in its frame, incl. the X-axis labels.

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Author

@copilot The graph doesn't bleed past its frame anymore, yet its lower part is truncated. Please scale the graph down vertically so that it fits in its frame, incl. the X-axis labels.

Adjusted the calibration chart to scale down vertically so the full plot and X-axis labels stay inside the frame. Fixed in 5944a29.

avk1im added 25 commits August 11, 2026 02:35
…he tail section (by default, 20% of calibration samples for the last 5% of media capacity or from EW on, whichever comes first). Implement SCSI log sense based remaning capacity inquiry to second-guess what tape driver reprts esp. near EW / EOM.
…dia section (around EW). Reduce the amount of tracing from Win32 LTO backend.
…ff by default. Trace exceptions in PresentationCore.dll.
…ssue with resuming writing to virtual media.
…esume calibration, and recalibrate (UI still to add). Extend SimpleBox with additional image icons: Complete and Failed; update its usages where applicable.
…. Add more unit tests for Resume Calibration. Update the design document.
…-partition media; allow upon confirmation. Update TapeWinNET UI to disable calibration of multi-partition media and restrict applying calibration profiles to single-partition media only.
…mechnism based on the actual test results. Introduce "ReportsExactRemaining" backend property for use with virtual drives. Update EW design doc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Part 4 Phase 5: Calibration UI (TapeWinNET) + calibration service layer (TapeLibNET)

2 participants