import '../../programs/models/program.dart';
import '../../programs/models/step.dart';

/// 运行器状态
enum RunnerStatus {
  idle,
  running,
  paused,
  completed,
  error,
}

/// 运行器回调
class RunnerCallbacks {
  /// 步骤进度回调: (stepIndex, remainingSeconds, progress, currentWell)
  final void Function(int stepIndex, int remainingSeconds, double progress, String well)? onProgress;

  /// 运行完成回调
  final void Function()? onComplete;

  /// 错误回调
  final void Function(String error)? onError;

  const RunnerCallbacks({
    this.onProgress,
    this.onComplete,
    this.onError,
  });
}

/// 运行器抽象接口
/// 定义硬件运行控制的标准接口
abstract class Runner {
  /// 当前状态
  RunnerStatus status = RunnerStatus.idle;

  /// 启动程序运行
  void start(Program program, List<Step> steps, RunnerCallbacks callbacks);

  /// 暂停运行
  void pause();

  /// 继续运行
  void resume();

  /// 停止运行
  void stop();

  /// 获取当前状态
  RunnerStatus getStatus();

  /// 释放资源
  void dispose();
}