55 lines
2.6 KiB
C#
55 lines
2.6 KiB
C#
using System.Threading.Tasks;
|
|
using TuneBoss.Core.Models;
|
|
|
|
namespace TuneBoss.Core.IO;
|
|
|
|
/// <summary>
|
|
/// Serializes / parses the <c>data</c> section of a map file — the space- and
|
|
/// <c>__</c>-delimited table dump. Kept behind an interface because its exact
|
|
/// table ordering is interop-critical and is filled once the format (legacy-exact
|
|
/// vs. new) and the included save-types are confirmed.
|
|
///
|
|
/// Implementations live in the app layer, where they can read and write the
|
|
/// table view-models that hold the current ECU state.
|
|
/// </summary>
|
|
public interface IMapTableCodec
|
|
{
|
|
/// <summary>
|
|
/// Ensures any device-backed state required to serialize the given type is loaded,
|
|
/// re-reading tables whose models are not cached. Called before <see cref="Serialize"/>
|
|
/// so a save works even if the user reached this page before a full table load
|
|
/// finished (or a table read was missed). Default: nothing to do.
|
|
/// </summary>
|
|
Task PrepareAsync(MapSaveType saveType, int cylinderCount) => Task.CompletedTask;
|
|
|
|
/// <summary>Runs an on-hardware diagnostic of the user-table read path and returns a report.</summary>
|
|
Task<string> DiagnoseAsync() => Task.FromResult(string.Empty);
|
|
|
|
/// <summary>Serializes the current in-app table state into a map <c>data</c> section.</summary>
|
|
string Serialize(MapSaveType saveType, int cylinderCount);
|
|
|
|
/// <summary>
|
|
/// Writes the currently-applied content for the given save type to the ECU,
|
|
/// optionally flashing at the end. Returns a human-readable summary.
|
|
/// </summary>
|
|
Task<string> WriteLoadedAsync(MapSaveType saveType, int cylinderCount, bool flash,
|
|
IProgress<string>? progress = null)
|
|
=> throw new NotImplementedException("Write-to-ECU on load is not wired for this codec.");
|
|
|
|
/// <summary>Parses a map <c>data</c> section and applies it to the in-app table state.</summary>
|
|
void Deserialize(string data, MapSaveType saveType, int cylinderCount);
|
|
|
|
/// <summary>Rebuilds the editor nav trees from the current session layout
|
|
/// (used after an offline file establishes a layout, so entries exist to populate).</summary>
|
|
void RebuildNavTrees() { }
|
|
|
|
/// <summary>
|
|
/// Builds an FSR document from the currently-loaded editors. Walks loaded entries
|
|
/// directly and skips anything not loaded (never throws "not loaded").
|
|
/// </summary>
|
|
FsrFile.FsrDocument BuildFsrFromEditors(Models.EcuInfo? info, MapTag? tag, int cylinderCount);
|
|
|
|
/// <summary>Applies a parsed FSR document into the editors.</summary>
|
|
void ApplyFsr(FsrFile.FsrDocument doc);
|
|
}
|