import request from '@/utils/request'

// ==================== ASM功能操作 ====================

/**
 * 开始录制
 */
export function startRecord(deviceId, mapName) {
  return request({
    url: '/robot/control/asm/record/start',
    method: 'post',
    params: { deviceId, mapName }
  })
}

/**
 * 停止录制
 */
export function stopRecord(mapName) {
  return request({
    url: '/robot/control/asm/record/stop',
    method: 'post',
    params: {mapName}
  })
}

/**
 * 开始构建地图
 * @param {string} deviceId 设备ID
 * @param {string} mapName 地图名称
 * @param {string} buildSteps 构建步骤（逗号分隔，如:recon,kfmix,octomap,tilemap,potree）
 */
export function startBuild(mapName, buildSteps) {
  return request({
    url: '/robot/control/asm/build/start',
    method: 'post',
    params: { mapName, buildSteps }
  })
}

/**
 * 停止构建地图
 */
export function stopBuild() {
  return request({
    url: '/robot/control/asm/build/stop',
    method: 'post',
    // params: {  }
  })
}

/**
 * 完成构建地图
 */
export function completedBuild(mapName, funcName) {
  return request({
    url: '/robot/control/asm/build/completed',
    method: 'post',
    params: { mapName, funcName }
  })
} 
/**
 * 开始实时SLAM
 */
export function startSlam(mapName) {
  return request({
    url: '/robot/control/asm/slam/start',
    method: 'post',
    params: {mapName }
  })
}

/**
 * 停止实时SLAM
 */
export function stopSlam() {
  return request({
    url: '/robot/control/asm/slam/stop',
    method: 'post',
    // params: {  }
  })
}

// ==================== 标定操作 ====================

/**
 * 执行坐标系标定
 */
export function executeCalibration(mapName, calibrationPoints) {
  return request({
    url: '/robot/control/calibration/execute',
    method: 'post',
    params: {mapName },
    data: calibrationPoints,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// ==================== VSLAM操作 ====================

/**
 * 设置导航探索模式
 */
export function setNavExplore(autoMode) {
  return request({
    url: '/robot/control/vslam/navExplore',
    method: 'post',
    params: { autoMode }
  })
}

// ==================== 状态查询 ====================

/**
 * 获取ASM操作状态
 */
export function getAsmStatus(functionName) {
  return request({
    url: '/robot/control/asm/status',
    method: 'get',
    params: {functionName }
  })
}
