226 lines
5.0 KiB
TypeScript
Raw Normal View History

2024-01-05 11:11:15 +08:00
import libJudgeSdk from 'libJudgeSdk.so'
2024-05-15 16:22:48 +08:00
//@ts-ignore
2024-02-23 16:08:37 +08:00
// import libJudgeSdk from '@ohos.judgesdk'
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')
}
2024-05-15 16:22:48 +08:00
/*
*
* @desc
*/
export async function examJudgeArtificialMark(
//项目代码
itemno:number,
//扣分代码
2024-07-31 13:47:40 +08:00
serial:string,
//扣分类型number
type:number
2024-05-15 16:22:48 +08:00
){
2024-07-31 13:47:40 +08:00
const temp = libJudgeSdk.examJudgeArtificialMark(itemno,serial,type);
2024-05-15 16:22:48 +08:00
return await handle(temp,'examJudgeArtificialMark')
}
/*
*
* @desc
*/
export async function examJudgeArtificialItem(
//项目代码
itemno:number,
//操作类型
type:number = 0
){
const temp = libJudgeSdk.examJudgeArtificialItem(itemno,type);
return await handle(temp,'examJudgeArtificialMark')
}
2024-01-05 11:11:15 +08:00
/*
*
* @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')
}
2024-07-05 09:34:03 +08:00
/**
*
* @desc
* /
*/
export async function examJudgeSoundEnd(param:{
//项目代码
itemno:number,
//语音码
code:string,
//语音类型
type:number,
}){
const {itemno,code,type} = param;
const temp = libJudgeSdk.examJudgeSoundEnd(itemno,code,type);
return await handle(temp,'examJudgeSoundEnd')
}
2024-08-20 14:49:22 +08:00
/**
*
* @desc
*
* */
export async function examCalcGpsDistance(param:{
jd1:number,
wd1:number,
jd2:number,
wd2:number,
h:number
}){
const {jd1,wd1,jd2,wd2,h} = param
const temp = libJudgeSdk.examJudgeSoundEnd(jd1,wd1,jd2,wd2,h);
return await handle(temp,'examCalcGpsDistance')
}
2024-01-05 11:11:15 +08:00
/*
* @desc通用处理函数
*
*/
async function handle(temp,fnName):Promise<string>{
return new Promise((resolve,reject)=>{
if(temp == 0){
resolve(temp);
}else{
2024-05-15 16:22:48 +08:00
console.log('surenjun error:' + `调用c++函数 ${fnName} 异常:`+ libJudgeSdk.examJudgeErrorInfo(temp*1))
2024-01-05 11:11:15 +08:00
reject(temp)
}
})
}