using System;
using System.Threading;
using System.Threading.Tasks;
using NcProgramManager.Cnc.Models;

namespace NcProgramManager.Cnc
{
    public interface ICncMachine : IDisposable
    {
        string Name { get; }
        ConnectionState State { get; }

        event EventHandler<ConnectionState> StateChanged;

        Task<CncResult<bool>> ConnectAsync(CancellationToken ct = default);
        Task DisconnectAsync();

        Task<CncResult<MachineSnapshot>> ReadAsync(CancellationToken ct = default);

        Task<CncResult<string>> ReadActiveProgramAsync(CancellationToken ct = default);
        Task<CncResult<string>> ReadProgramAsync(string path, CancellationToken ct = default);
        Task<CncResult<bool>> WriteProgramAsync(string path, CncProgram program, CancellationToken ct = default);
        Task<CncResult<bool>> SelectMainProgramAsync(string path, CancellationToken ct = default);
        Task<CncResult<bool>> DeleteProgramAsync(string path, CancellationToken ct = default);
    }
}
