156 lines
3.7 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
import libJudgeSdk from 'libJudgeSdk.so'
2024-02-23 16:08:37 +08:00
// import libJudgeSdk from '@ohos.judgesdk'
2024-02-26 15:01:27 +08:00
2024-01-05 11:11:15 +08:00
/**
*
* @date 2023/04/10
* @desc c++
**/
/**
*
* @desc
**/
export async function examJudgeVersion(){
return await libJudgeSdk.examJudgeVersion();
}
/**
*
* @params level
* [0] [1] [2] [3] [4] [5] [6]
0 ,6 , 6线
* @params callBack
* @desc
*/
export async function examJudgeSetLogCallback(level:number,handleLog:Function):Promise<string>{
const temp = libJudgeSdk.examJudgeSetLogCallback(level,handleLog);
return await handle(temp,'examJudgeSetLogCallback')
}
/*
*
* @desc评判初始化
*/
export async function examJudgeInit(data){
const str = JSON.stringify(data);
const temp = libJudgeSdk.examJudgeInit(str,str.length);
return await handle(temp,'examJudgeInit')
}
/*
*
* @desc
*/
export async function examJudgeRealExam(data){
const str = JSON.stringify(data);
const temp = libJudgeSdk.examJudgeRealExam(str,str.length);
return await handle(temp,'examJudgeRealExam')
}
/*
*
* @desc
*/
//js_examJudgeSetRealExamCallback
export async function examJudgeSetRealExamCallback(fn){
const temp = libJudgeSdk.examJudgeSetRealExamCallback(fn);
return await handle(temp,'examJudgeSetRealExamCallback')
}
/*
*
* @desc
*/
export async function examJudgeMapImageSetCallback(fn){
const temp = libJudgeSdk.examJudgeMapImageSetCallback(fn);
return await handle(temp,'examJudgeMapImageSetCallback')
}
/*
*
* @desc
*/
export async function examJudgeMapSetDrawing(fn){
const temp = libJudgeSdk.examJudgeMapSetDrawing(fn);
return await handle(temp,'examJudgeMapSetDrawing')
}
/*
*
* @desc开始考试
*/
export async function examJudgeBeginExam(data){
const str = JSON.stringify(data);
const temp = libJudgeSdk.examJudgeBeginExam(str,str.length);
return await handle(temp,'examJudgeBeginExam')
}
/* @params levelinfoStrlen
* @desc处理日志文件
*/
export function handleLog(level,infoStr, len){
//TODO
}
/*
* @desc结束考试
*
*/
export async function examJudgeEndExam(){
const temp = libJudgeSdk.examJudgeEndExam();
return await handle(temp,'examJudgeEndExam')
}
/*
*@desc examJudgeDestroy
*
*/
export async function examJudgeDestroy(){
const temp = libJudgeSdk.examJudgeDestroy();
return await handle(temp,'examJudgeDestroy')
}
/*
*@desc设置地图轨迹图像参数
*
*/
export async function examJudgeMapSetParam(width:number,height:number){
const temp = libJudgeSdk.examJudgeMapSetParam(width,height );
return await handle(temp,'examJudgeMapSetParam')
}
/*
*@desc设置地图图像缩放系数
*
*/
export async function examJudgeMapSetScaling(scaling?:number){
const temp = libJudgeSdk.examJudgeMapSetScaling(scaling || 1);
return await handle(temp,'examJudgeMapSetScaling')
}
/*
*@desc设置考试过程数据回调
*
*/
export async function examJudgeSetPerformCallback(fn){
const temp = libJudgeSdk.examJudgeSetPerformCallback(fn);
return await handle(temp,'examJudgeSetPerformCallback')
}
/*
* @desc通用处理函数
*
*/
async function handle(temp,fnName):Promise<string>{
return new Promise((resolve,reject)=>{
if(temp == 0){
resolve(temp);
}else{
console.log('error:' + `调用c++函数 ${fnName} 异常:`+ libJudgeSdk.examJudgeErrorInfo(temp*1))
reject(temp)
}
})
}