import request, { apiGet } from '@/utils/request';
//移动火源
export function runFireApi() {
  return apiGet('/runfire?typef=1');
}

//点火
export function openFireApi() {
  return apiGet('/dianhuo');
}

//开灯
export function openLightApi() {
  return apiGet('/openLight');
}

//关灯
export function closeLightApi() {
  return apiGet('/closeLight');
}

//电磁阀 0 1
export function openElectricApi(params) {
  return apiGet('/diancifa', params);
}

//试验下一步
export function addExperiment(data) {
  return request({
    url: '/api/insertExperiment',
    method: 'post',
    data
  });
}

// 向下位机发送命令
export function sendMsgApi(data) {
  return request({
    url: '/api/sendMsg',
    method: 'post',
    data
  });
}

// 获取试验报表
export function getAllExperimentApi(data) {
  return request({
    url: '/api/get_all_experiment',
    method: 'post',
    data
  });
}

// 获取所有试验,按样品名称分组
export function getExperimentListApi(data) {
  return request({
    url: '/api/get_experiment_groupby_specimen',
    method: 'post',
    data
  });
}

//开始试验
export function startExperimentApi(data) {
  return request({
    url: `/api/insertExperiment`,
    method: 'post',
    data
  });
}

// 结束试验
export function stopExperimentApi(data) {
  return request({
    url: '/api/stopExperiment',
    method: 'post',
    data
  });
}
//获取正式试验的详情
export function getExperimentDetailApi(experiment_id) {
  return request({
    url: `/api/experiment_info?experiment_id=${experiment_id}`,
    method: 'get'
  });
}

// 获取一个样品的所有试验
export function getExperimentBySpecimenApi(data) {
  return request({
    url: '/api/get_experiment_by_specimen',
    method: 'post',
    data
  });
}

// 保存试验结果
export function updateExperimentApi(data) {
  return request({
    url: '/api/updateExperiment',
    method: 'post',
    data
  });
}

// 计算燃烧爆炸上限及下限
export function computeCombustionLimitApi(data) {
  return request({
    url: 'api/compute_combustion_limit',
    method: 'post',
    data
  });
}

// // 获取所有保压试验
// export function getPressListApi (data) {
//   return request ({
//     url: 'api/get_press_reten_experiment_list',
//     method: 'post',
//     data
//   })
// }

// // 新增保压试验
// export function insertPressApi (data) {
//   return request ({
//     url: 'api/insert_press_reten_experiment',
//     method: 'post',
//     data
//   })
// }

// // 删除保压试验
// export function delPressApi (data) {
//   return request ({
//     url: 'api/del_press_reten_experiment',
//     method: 'post',
//     data
//   })
// }

// 查看视频
export function viewVideoApi(data) {
  return request({
    url: 'api/view_video',
    method: 'post',
    data
  });
}

// 导出视频
export function exportVideoApi(data) {
  return request({
    url: 'api/export_video',
    method: 'post',
    data
  });
}

// 导出报表
export function exportTableApi(data) {
  return request({
    url: 'api/export_table',
    method: 'post',
    data
  });
}
export function readyShiYan(params) {
  return apiGet('/ready_shiyan', params);
}

export function start_experiment2() {
  return apiGet('/start_experiment2');
}

export function getHistoryListApi() {
  return request({
    url: 'api/get_experiment_history',
    method: 'get'
  });
}
export function getReportDeatail(data) {
  return request({
    url: '/api/get_specimen_list',
    method: 'post',
    data
  });
}

/**
 * 更新实验结果
 */
export function updateRecord(data) {
  return request({
    url: '/api/updateRecord',
    method: 'post',
    data
  });
}

/**
 * 停止实验结果
 */
export function experimentOver(data) {
  return request({
    url: '/api/stopExperiment',
    method: 'post',
    data
  });
}

/**
 * 获取设备设置
 */
export function getTerminalSetting() {
  return apiGet('/api/getConfig');
}

/**
 * 修改设备配置
 */
export function updateConfig(data) {
  return request({
    url: '/api/updateConfig',
    method: 'post',
    data
  });
}

/**
 * 修改设备配置
 */
export function getAllSpecimen() {
  return request({
    url: '/api/get_sample_history',
    method: 'get'
  });
}

/**
 * 获取通道列表
 */
export function getChannelList(data) {
  return request({
    url: '/api/getChannelList',
    method: 'get',
    params: data
  });
}

/**
 * 修改门状态
 */
export function updateDoorApi(data) {
  return request({
    url: '/api/updateDoor',
    method: 'get',
    params: data
  });
}

/**
 * 获取通道详情
 */
export function getChannelInfoApi(data) {
  return request({
    url: '/api/getChannelInfo',
    method: 'get',
    params: data
  });
}

/**
 * 获取试验详情
 */
export function getExperimentInfoApi(data) {
  return request({
    url: '/api/getExperimentInfo',
    method: 'get',
    params: data
  });
}


export function getSettingApi() {
  return request({
    url: 'api/terminal_setting',
    method: 'get'
  });
}
/**
 * 校准
 */
export function setCoefficientCalculationApi(data) {
  return request({
    url: '/api/coefficient_calculation',
    method: 'post',
    data
  });
}