import request from '@/utils/request';
//获取仪器状态
export function getInstrumentStatus() {
  return request({
    url: '/api/self_inspection',
    method: 'get'
  });
}

//发送下位机指令
export function sendInstrumentCommand(data) {
  return request({
    url: 'api/sendMsg',
    method: 'post',
    data
  });
}
// 获取老样品试验设置
export function getOldSampleSet(data) {
  return request({
    url: '/api/get_history',
    method: 'post',
    data
  });
}

// 新增校准试验
export function additionalJZTest(data) {
  return request({
    url: '/api/insertExperimentJZ',
    method: 'post',
    data
  });
}
// 新增正式试验
export function additionalTest(data) {
  return request({
    url: '/api/insertExperiment',
    method: 'post',
    data
  });
}

// //弹框
// export function expDialog(data) {
//   return request({
//     url: '/api/sendMsg',
//     method: 'post',
//     data
//   });
// }

// 保压实验
export function baoyaExper(data) {
  return request({
    url: '/api/insertExperimentBaoYa',
    method: 'post',
    data
  });
}

// 关闭保压实验
export function baoyaExperClose() {
  return request({
    url: '/api/stopExperimentBaoYa',
    method: 'post'
  });
}

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

//结束后端进程
export function stopExperThread() {
  return request({
    url: '/api/kill_thread',
    method: 'get'
  });
}

//问询是否结束上次实验

export function bdstopExper() {
  return request({
    url: '/api/get_experiment_status',
    method: 'get'
  });
}

//修改比热
export function updateLossRate(data) {
  return request({
    url: '/api/specific_heat',
    method: 'post',
    data
  });
}

//修改热损失
export function updateHeatLoss(data) {
  return request({
    url: '/api/loss_rate',
    method: 'post',
    data
  });
}

//获取校准试验的详情
export function getJZExperimentDetailApi({ experimentjz_id }) {
  return request({
    url: `/api/experimentjz_info?experimentjz_id=${experimentjz_id}`,
    method: 'get'
  });
}
//获取正式试验的详情
export function getExperimentDetailApi({ experiment_id }) {
  return request({
    url: `/api/experiment_info?experiment_id=${experiment_id}`,
    method: 'get'
  });
}

//获取试验列表数据
export function getExpData(data) {
  return request({
    url: '/api/get_experiment_list',
    method: 'post',
    data
  });
}

//查看试验曲线
export function getExperimentDataApi(data) {
  return request({
    url: '/api/get_data',
    method: 'post',
    data
  });
}

//导出
export function exportDataApi(data) {
  return request({
    url: 'api/export_table',
    method: 'post',
    data,
    responseType: 'blob'
  });
}

//浏览器导出
export function exportDataBrowserApi(data) {
  return request({
    url: 'api/export_table',
    method: 'post',
    data,
    responseType: 'blob'
  });
}

//设备自检
export function selfInspection() {
  return request({
    url: '/api/self_check',
    method: 'get'
  });
}

//获取试验次数
export function getExperimentTimes() {
  return request({
    url: '/api/experiment_count',
    method: 'get'
  });
}

// 删除实验报表项
export function delExperimentApi(data) {
  return request({
    url: '/api/del_experiment/',
    method: 'post',
    data
  });
}

// 新增试验
export function insertExperimentApi(data) {
  return request({
    url: '/api/insertExperiment',
    method: 'post',
    data
  });
}

// 获取试验详情
export function getExperimentInfoApi(data) {
  return request({
    url: '/api/experiment_info',
    method: 'get',
    params: data
  });
}
export function getExperimentInfoEchartApi(data) {
  return request({
    url: '/api/experiment_info',
    method: 'post',
     data
  });
}
// 发送下位机命令
export function sendMsgApi(data) {
  return request({
    url: '/api/sendMsg',
    method: 'post',
    data
  });
}

// 完成试验
export function stopExperimentApi(data) {
  return request({
    url: '/api/stopExperiment',
    method: 'post',
    data
  });
}

// 获取试验详情
export function selfCheckApi() {
  return request({
    url: '/api/self_check',
    method: 'get'
  });
}

// 下位机新增正式试验
export function machineInsertExperimentApi(data) {
  return request({
    url: '/api/machine_insertExperiment',
    method: 'post',
    data
  });
}

// 删除试验
export function deleteExperimentApi(experiment_id) {
  return request({
    url: `api/delete_experiment/${experiment_id}`,
    method: 'delete'
  });
}
// 删除单次试验
export function deleteRecodeApi(record_id) {
  return request({
    url: `api/delete_record/${record_id}`,
    method: 'delete'
  });
}


// 开始实验
export function openExe() {
  return request({
    url: '/api/open_exe',
    method: 'get'
  });
}