1. 新增623参数控制联网模式实施轨迹显示

2. 新增监管结束考试异常,错误提示弹窗显示
3. 优化文件系统:考试结束关闭文件读写
This commit is contained in:
surenjun 2025-01-09 20:56:36 +08:00
parent cd4affcb6f
commit 4f1a4f894c
7 changed files with 193 additions and 113 deletions

View File

@ -6,8 +6,7 @@ import common from '@ohos.app.ability.common'
import fs from '@ohos.file.fs' import fs from '@ohos.file.fs'
const LOGTAG = 'LOGTAG' const LOGTAG = 'LOGTAG'
export default class FileUtil{
export default class FileUtil {
private context: common.UIAbilityContext private context: common.UIAbilityContext
private wantInfos: Want[] private wantInfos: Want[]
private fileAccessHelper: fileAccess.FileAccessHelper private fileAccessHelper: fileAccess.FileAccessHelper
@ -15,7 +14,8 @@ export default class FileUtil {
//后续文件路径待替换 //后续文件路径待替换
private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files' private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files'
public destFile: string public destFile:string
public filePathFdObj:Object = {}
constructor(wantInfos) { constructor(wantInfos) {
const {requestPermission} = this; const {requestPermission} = this;
@ -27,88 +27,94 @@ export default class FileUtil {
* @desc * @desc
* *
*/ */
public initFolder = async (folderPath: string) => { public initFolder = async (folderPath:string) => {
const {absolutePath} = this; const {absolutePath} = this;
const folderList = folderPath.split('/').filter(folderName => folderName !== ''); const folderList = folderPath.split('/').filter(folderName => folderName !== '');
let path = absolutePath let path = absolutePath
folderList.forEach((folderName => { folderList.forEach((folderName=>{
path += `/${folderName}`; path += `/${folderName}`;
try { try {
const isExit = fs.accessSync(path); const isExit = fs.accessSync(path);
if (!isExit) { if(!isExit){
fs.mkdirSync(path) fs.mkdirSync(path)
} }
} catch (e) { } catch (e) {
console.info('初始化文件夹失败', path) console.info('初始化文件夹失败',path)
promptAction.showToast({ promptAction.showToast({
message: `初始化文件夹失败` + JSON.stringify(e), message:`初始化文件夹失败`+ folderPath + JSON.stringify(e),
duration: 4000, duration:4000,
}) })
} }
})); }));
return path; return path;
} }
/* /*
* @desc * @desc
* *
*/ */
public addFile = async (filePath: string, content: string, type?: string, fd?) => { public addFile = async (filePath:string,content:string,type?:string)=>{
const { READ_WRITE,CREATE,APPEND } = fs.OpenMode const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
const isExit = fs.accessSync(filePath); const isExit = fs.accessSync(filePath);
//文件存在先删除 //文件存在先删除
if (isExit) { if(isExit){
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
} }
try { try {
let file let file = fs.openSync(filePath, READ_WRITE | CREATE);
if (!fd) {
file = fs.openSync(filePath, READ_WRITE | CREATE);
}
//追加写入文件 //追加写入文件
fs.writeSync(file.fd, content) fs.writeSync(file.fd,content)
fs.closeSync(file) fs.closeSync(file)
return file.fd console.error(LOGTAG,'写入文件成功')
return true
} catch (e) { }catch (e){
console.error(LOGTAG, '写入失败', JSON.stringify(e)) promptAction.showToast({
message:`addFile文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.error(LOGTAG,'写入失败',JSON.stringify(e))
} }
} }
public openFileSync = async (filePath) => {
const { READ_WRITE,CREATE,APPEND } = fs.OpenMode
let file = fs.openSync(filePath, READ_WRITE | APPEND | CREATE);
return file
}
public editFileWidthOutOpen(file, content) {
const newStr = content + '\n'
fs.writeSync(file.fd, newStr)
fs.closeSync(file)
console.error(LOGTAG, '写入文件成功')
}
/* /*
* @desc * @desc
* *
*/ */
public editFile = async (filePath: string, content: string, fd?: number) => { public editFile = async (filePath:string,content:string,fd?:number)=>{
const { READ_WRITE,CREATE,APPEND } = fs.OpenMode const {filePathFdObj} = this;
const { READ_WRITE,CREATE,APPEND }= fs.OpenMode
const newStr = content + '\n'
const thisFile = filePathFdObj[filePath];
try { try {
const newStr = content + '\n' if(thisFile){
if (fd !== undefined) { fs.writeSync(fd,newStr)
fs.writeSync(fd, newStr) return fd;
return fd }else{
} else { let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE);
let file = fs.openSync(filePath, READ_WRITE | APPEND | CREATE); fs.writeSync(file.fd,newStr)
fs.writeSync(file.fd, newStr) this.filePathFdObj[filePath] = file
return file.fd return file.fd
} }
} catch (e) { } catch (e) {
console.error(LOGTAG, JSON.stringify(e)) promptAction.showToast({
message:`editFile文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.error(LOGTAG,JSON.stringify(e))
}
}
/*
* @desc
*
*/
public closeFile = async (filePath:string)=>{
const {filePathFdObj} = this;
const thisFile = filePathFdObj[filePath];
if(thisFile){
fs.closeSync(thisFile);
console.info(LOGTAG,filePath + '文件关闭成功')
} }
} }
@ -116,12 +122,17 @@ export default class FileUtil {
* @desc * @desc
* *
**/ **/
public readFile = async (filePath: string) => { public readFile = async (filePath:string) => {
try { try{
console.log('strrr', filePath) console.log('strrr',filePath)
const str = await fs.readText(filePath); const str = await fs.readText(filePath);
return str return str
} catch (err) { }catch (e){
promptAction.showToast({
message:`读取文件失败`+ filePath +JSON.stringify(e),
duration:4000,
})
console.log('readFile文件失败'+ filePath +JSON.stringify(e))
return '' return ''
} }
@ -130,9 +141,9 @@ export default class FileUtil {
/* /*
* @desc获取系统目录里的文件列表 * @desc获取系统目录里的文件列表
*/ */
public getDeviceList = async (folderPath?: string) => { public getDeviceList = async (folderPath?:string)=>{
const {absolutePath,getFilePathList} = this; const {absolutePath,getFilePathList} = this;
return getFilePathList(`${absolutePath}/${folderPath}`, false) return getFilePathList(`${absolutePath}/${folderPath}`,false)
}; };
// 删除文件夹或者文件 // 删除文件夹或者文件
@ -141,29 +152,29 @@ export default class FileUtil {
* @param{{type}} 1:文件夹 2 3 * @param{{type}} 1:文件夹 2 3
**/ **/
public deleteF = async (path: string, type: 1 | 2 | 3) => { public deleteF = async (path:string,type: 1 | 2 | 3) => {
const {getFilePathList,absolutePath} = this const {getFilePathList,absolutePath} = this
if (type === 1) { if(type === 1){
const fileList = await getFilePathList(`${absolutePath}/${path}`, false); const fileList = await getFilePathList(`${absolutePath}/${path}`,false);
fileList.forEach(filePath => { fileList.forEach(filePath =>{
fs.unlinkSync(`${absolutePath}/${path}/${filePath}`); fs.unlinkSync(`${absolutePath}/${path}/${filePath}`);
}) })
fs.rmdirSync(`${absolutePath}/${path}`); fs.rmdirSync(`${absolutePath}/${path}`);
return true return true
} }
if (type === 2) { if(type === 2){
fs.unlinkSync(`${absolutePath}/${path}`); fs.unlinkSync(`${absolutePath}/${path}`);
return true return true
} }
if (type === 3) { if(type === 3){
fs.unlinkSync(`${path}`); fs.unlinkSync(`${path}`);
return true return true
} }
} }
// 获取系统文件绝对路径 // 获取系统文件绝对路径
public getAbsolutePath = () => { public getAbsolutePath = () =>{
const {absolutePath} = this; const {absolutePath} = this;
return absolutePath return absolutePath
} }
@ -172,7 +183,7 @@ export default class FileUtil {
public getSdCardPathList = async () => { public getSdCardPathList = async () => {
this.wantInfos = await fileAccess.getFileAccessAbilityInfo(); this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
const {wantInfos,context} = this; const {wantInfos,context} = this;
const fileAccessHelper = fileAccess.createFileAccessHelper(this.context, this.wantInfos); const fileAccessHelper = fileAccess.createFileAccessHelper(this.context,this.wantInfos);
this.fileAccessHelper = fileAccessHelper; this.fileAccessHelper = fileAccessHelper;
let isDone = false; let isDone = false;
@ -188,48 +199,48 @@ export default class FileUtil {
if (!isDone) { if (!isDone) {
let deviceType = rootInfo.value.deviceType; let deviceType = rootInfo.value.deviceType;
let displayName = rootInfo.value.displayName; let displayName = rootInfo.value.displayName;
let uri: string = rootInfo.value.uri; let uri:string = rootInfo.value.uri;
let deviceFlags = rootInfo.value.deviceFlags; let deviceFlags = rootInfo.value.deviceFlags;
console.error(LOGTAG, `设备类型:${deviceType},设备名称:${displayName}设备根目录Uri${uri},设备支持的能力:${deviceFlags}`); console.error(LOGTAG,`设备类型:${deviceType},设备名称:${displayName}设备根目录Uri${uri},设备支持的能力:${deviceFlags}`);
if (uri.indexOf('/mnt/external/') > 0) { if(uri.indexOf('/mnt/external/')>0){
// if('vol-8-1' ==displayName){ // if('vol-8-1' ==displayName){
this.destFile = uri.split('ExternalFileManager')[1] + '/' this.destFile = uri.split('ExternalFileManager')[1]+'/'
console.error(LOGTAG, `外置存储路径:` + this.destFile); console.error(LOGTAG,`外置存储路径:`+this.destFile);
this.getFilePathList(this.destFile, true) this.getFilePathList(this.destFile,true)
} }
} }
} }
} catch (error) { } catch (error) {
console.error(LOGTAG, "getRoots failed, errCode:" + error.code + ", errMessage:" + error.message); console.error(LOGTAG,"getRoots failed, errCode:" + error.code + ", errMessage:" + error.message);
} }
} }
public getFileContent = (filePath: string) => { public getFileContent = (filePath:string) => {
const {absolutePath} = this; const {absolutePath} = this;
const { READ_WRITE } = fs.OpenMode const { READ_WRITE }= fs.OpenMode
const path = `${absolutePath}/${filePath}` const path = `${absolutePath}/${filePath}`
const str = fs.readTextSync(path); const str = fs.readTextSync(path);
return str return str
} }
private getFilePathList = async (filePath: string, isSdcard: boolean) => { private getFilePathList = async (filePath:string,isSdcard:boolean) => {
let fileName = [], sdCardFileName = []; let fileName = [],sdCardFileName = [];
try { try {
const filenames = await fs.listFile(filePath); const filenames = await fs.listFile(filePath);
for (let i = 0; i < filenames.length; i++) { for (let i = 0; i < filenames.length; i++) {
console.error(LOGTAG, `目录:${filePath}的子文件:${filenames[i]}`); console.error(LOGTAG,`目录:${filePath}的子文件:${filenames[i]}`);
if (isSdcard) { if(isSdcard){
sdCardFileName.push(filenames[i]) sdCardFileName.push(filenames[i])
} else { }else{
fileName.push(filenames[i]) fileName.push(filenames[i])
} }
} }
return isSdcard ? sdCardFileName : fileName return isSdcard ? sdCardFileName : fileName
} catch (e) { }catch (e){
console.error(LOGTAG, JSON.stringify(e)); console.error(LOGTAG,JSON.stringify(e));
} }
} }
@ -243,15 +254,17 @@ export default class FileUtil {
]; ];
this.wantInfos = await fileAccess.getFileAccessAbilityInfo(); this.wantInfos = await fileAccess.getFileAccessAbilityInfo();
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager()
atManager.requestPermissionsFromUser(context, permissions, async (code, result) => { atManager.requestPermissionsFromUser(context, permissions , async (code, result) => {
const permissionRequest = result.authResults[0] const permissionRequest = result.authResults[0]
if (permissionRequest == -1) { if(permissionRequest == -1){
promptAction.showToast({ promptAction.showToast({
message: "请先授权", message: "请先授权",
duration: 3000, duration:3000,
}) })
return return
} }
}) })
} }
} }

View File

@ -10,6 +10,7 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon';
import {uploadExamMileage} from '../api/judge' import {uploadExamMileage} from '../api/judge'
import DwztErrorPopup from './compontents/judge/DwztErrorPopup' import DwztErrorPopup from './compontents/judge/DwztErrorPopup'
import {debounce} from '../common/utils/tools' import {debounce} from '../common/utils/tools'
import MsgPopup from './compontents/judge/MsgPopup'
import { import {
CARINFO, CARINFO,
@ -186,6 +187,12 @@ struct Index {
name: decodeURI(sys.v_name) name: decodeURI(sys.v_name)
}) })
} }
//623 考试中是否可以查看轨迹画面(0-否+1-是)
if(sys.v_no == '623'){
this.syssetParam623 = value == '1'?true:false
}
//科目三应行驶距离参数 //科目三应行驶距离参数
if (sys.v_no == '303') { if (sys.v_no == '303') {
this.examMileage = this.examMileage == '0'?(sys.v_value + ''): this.examMileage; this.examMileage = this.examMileage == '0'?(sys.v_value + ''): this.examMileage;
@ -930,6 +937,7 @@ struct Index {
showBack: false, showBack: false,
scaleNum: 1.8, scaleNum: 1.8,
msgStr: this.judge.plcStr || '', msgStr: this.judge.plcStr || '',
showTrajectory:globalThis.singlePlay ? true : (this.syssetParam623),
}).margin({ top: 100 }) }).margin({ top: 100 })
Row() { Row() {
@ -977,6 +985,10 @@ struct Index {
this.endPopupVisible = false; this.endPopupVisible = false;
}, },
confirmFn: async () => { confirmFn: async () => {
if(this.isErrorMsgEnd){
router.back()
return
}
if (this.judgeConfigObj['344'] == 1) { if (this.judgeConfigObj['344'] == 1) {
Prompt.showToast({ Prompt.showToast({
message: '考试未结束,不允许手动退出!', message: '考试未结束,不允许手动退出!',
@ -991,6 +1003,7 @@ struct Index {
try { try {
this.judge.checkExamIsEnd(true); this.judge.checkExamIsEnd(true);
} catch (e) { } catch (e) {
this.judge.closeAllFiles()
router.back() router.back()
} }
@ -1005,6 +1018,16 @@ struct Index {
}) })
} }
if (this.errorMsg){
MsgPopup({
title: this.errorMsg,
confirmFn:()=>{
this.errorMsg = ''
this.isErrorMsgEnd = true;
},
})
}
if(this.dwztErrorVisible){ if(this.dwztErrorVisible){
DwztErrorPopup({ DwztErrorPopup({
title:'当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框', title:'当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框',
@ -1324,6 +1347,7 @@ struct Index {
@State xldm: string = '' @State xldm: string = ''
//监管接口序列号 //监管接口序列号
@State serialNumber: number = 0 @State serialNumber: number = 0
@State syssetParam623: boolean = false;
@State carType: string = '' @State carType: string = ''
@State carName: string = '' @State carName: string = ''
@State isDeductedPopShow: boolean = false @State isDeductedPopShow: boolean = false
@ -1369,4 +1393,6 @@ struct Index {
@State dwztErrorVisible: boolean = false; @State dwztErrorVisible: boolean = false;
@State popTimer:number =0; @State popTimer:number =0;
@State carlist:string= '' @State carlist:string= ''
@State errorMsg: string = ''
@State isErrorMsgEnd: boolean = false
} }

View File

@ -9,6 +9,7 @@ import { GlobalConfig } from '../../config/index'
@Component @Component
export default struct SignDisplayCom { export default struct SignDisplayCom {
@State showBack: boolean = false @State showBack: boolean = false
@Prop showTrajectory:boolean = false
@State scaleNum: number = 1 @State scaleNum: number = 1
@State msg: string = '' @State msg: string = ''
@State signArr: Array<any> = [] @State signArr: Array<any> = []
@ -50,7 +51,7 @@ export default struct SignDisplayCom {
}) })
if (!this.showBack) { if (this.showTrajectory) {
Row() { Row() {
Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio) Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
} }

View File

@ -0,0 +1,23 @@
@Component
export default struct MsgPopup{
constructor() {
super()
}
private title:string = ''
private confirmFn:(event?: ClickEvent) => void
build(){
Column(){
Column(){
Text(this.title).fontSize(36).margin({bottom:20}).lineHeight(50)
Row(){}.height(100)
Row(){
Text('确定').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(95).fontSize(28).fontColor('#FFF').textAlign(TextAlign.Center).onClick(this.confirmFn)
}.margin({top:20})
}.width('65%').height('70%').padding(30).backgroundColor('#E6E3DF').borderRadius(38).position({y:'12%',x:'17.5%'}).justifyContent(FlexAlign.Center)
}.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.7)')
}
}

View File

@ -95,6 +95,7 @@ export default class Judge {
: ( projectCenterObj.isEnd ? 3 : 1 ) : ( projectCenterObj.isEnd ? 3 : 1 )
} }
}) })
console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems)) console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems))
this.isExamEnd = false; this.isExamEnd = false;
} }
@ -170,7 +171,7 @@ export default class Judge {
await fileLog.setExamJudgeData(beginExamInfo) await fileLog.setExamJudgeData(beginExamInfo)
await examJudgeBeginExam(beginExamInfo); await examJudgeBeginExam(beginExamInfo);
console.info(judgeTag, '6.开始考试注册完成') console.info(judgeTag, '6.开始考试注册完成')
avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.WAV' : 'voice/监管成功.mp3']) avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
if(!globalThis.singlePlay){ if(!globalThis.singlePlay){
this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`) this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`)
@ -542,7 +543,8 @@ export default class Judge {
judgeUI, judgeUI,
checkExamIsEnd, checkExamIsEnd,
checkProjectIsStart, checkProjectIsStart,
lane lane,
closeAllFiles
} = this; } = this;
const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI; const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI;
@ -640,6 +642,7 @@ export default class Judge {
judgeTask.addTask(async () => { judgeTask.addTask(async () => {
console.info(judgeTag, '考试结束 start') console.info(judgeTag, '考试结束 start')
globalThis.isJudge = false; globalThis.isJudge = false;
closeAllFiles()
await handEndExam(ksjs) await handEndExam(ksjs)
}) })
clearInterval(globalThis.judgeTimer) clearInterval(globalThis.judgeTimer)
@ -1062,10 +1065,11 @@ export default class Judge {
if(code != 1){ if(code != 1){
avPlayer.playAudio(['voice/监管失败.mp3']) avPlayer.playAudio(['voice/监管失败.mp3'])
this.judgeUI.errorMsg = decodeURIComponent(message)
this.isUdpEnd = true this.isUdpEnd = true
router.back();
return return
} }
console.info(judgeTag, '考试结束 end') console.info(judgeTag, '考试结束 end')
const param302 = judgeConfigObj['302']; const param302 = judgeConfigObj['302'];
judgeUI.loadingPopupVisible = true; judgeUI.loadingPopupVisible = true;
@ -1566,7 +1570,7 @@ export default class Judge {
const msgStr = strArr[num]; const msgStr = strArr[num];
if(msgStr == ''){ if(msgStr == ''){
console.info(judgeTag, '模拟数据考试结束') console.info(judgeTag, '模拟数据考试结束')
// globalThis.windowClass.setWindowSystemBarEnable(['navigation']) globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
clearInterval(judgeTimer) clearInterval(judgeTimer)
this.checkExamIsEnd(true) this.checkExamIsEnd(true)
return return
@ -1664,6 +1668,11 @@ export default class Judge {
} }
} }
closeAllFiles = ()=>{
this.fileLog.closeAllFiles()
}
public plcStr: string public plcStr: string
private judgeUI private judgeUI
private fileLog private fileLog

View File

@ -5,17 +5,17 @@ import common from '@ohos.app.ability.common'
import Want from '@ohos.app.ability.Want' import Want from '@ohos.app.ability.Want'
import fs from '@ohos.file.fs' import fs from '@ohos.file.fs'
import FileUtil from '../../../common/utils/File' import FileUtil from '../../../common/utils/File'
import {getCurrentTime} from '../../../common/utils/tools' import { getCurrentTime } from '../../../common/utils/tools'
interface StuInfo{ interface StuInfo {
name:string name: string
lsh:string lsh: string
idCard:string idCard: string
} }
const LOGTAG = 'LOGTAG' const LOGTAG = 'LOGTAG'
export default class FileLog {
export default class FileLog {
//后续文件路径待替换 //后续文件路径待替换
private fileUtil: FileUtil private fileUtil: FileUtil
private stuInfo: StuInfo private stuInfo: StuInfo
@ -40,7 +40,7 @@ export default class FileLog {
} }
// 设置文件夹 // 设置文件夹
public initFileLogo = async (stuInfo:StuInfo) => { public initFileLogo = async (stuInfo: StuInfo) => {
const {fileUtil,setExamLineData} = this const {fileUtil,setExamLineData} = this
const {name,lsh,idCard} = stuInfo; const {name,lsh,idCard} = stuInfo;
this.stuInfo = stuInfo; this.stuInfo = stuInfo;
@ -53,56 +53,64 @@ export default class FileLog {
} }
// 过程文件数据 // 过程文件数据
public setExamProgressData = async (str:Object) => { public setExamProgressData = async (str: Object) => {
const {fileUtil,folderPath,progressDataFd} = this; const {fileUtil,folderPath,progressDataFd} = this;
this.progressDataFd = await fileUtil.editFile(`${folderPath}/exam_progress_data.txt`,JSON.stringify(str),progressDataFd); this.progressDataFd = await fileUtil.editFile(`${folderPath}/exam_progress_data.txt`, JSON.stringify(str), progressDataFd);
} }
// 无锡所接口数据 // 无锡所接口数据
public setExamJudgeWuxiData = async (str) => { public setExamJudgeWuxiData = async (str) => {
const {fileUtil,folderPath,examJudgeWuxiDataFd} = this; const {fileUtil,folderPath,examJudgeWuxiDataFd} = this;
this.examJudgeWuxiDataFd = await fileUtil.editFile(`${folderPath}/wuxi_exam_data.txt`,str,examJudgeWuxiDataFd); this.examJudgeWuxiDataFd = await fileUtil.editFile(`${folderPath}/wuxi_exam_data.txt`, str, examJudgeWuxiDataFd);
} }
// 无锡所过程数据 // 无锡所过程数据
public setExamJudgeWuxiProgressData = async (str)=>{ public setExamJudgeWuxiProgressData = async (str) => {
const {fileUtil,folderPath,examJudgeWuxiProgressDataFd} = this; const {fileUtil,folderPath,examJudgeWuxiProgressDataFd} = this;
this.examJudgeWuxiProgressDataFd = await fileUtil.editFile(`${folderPath}/wuxi_progress_data.txt`,str,examJudgeWuxiProgressDataFd); this.examJudgeWuxiProgressDataFd = await fileUtil.editFile(`${folderPath}/wuxi_progress_data.txt`, str, examJudgeWuxiProgressDataFd);
} }
// plc文件数据 // plc文件数据
public setPlcProgressData = async (str:Object) => { public setPlcProgressData = async (str: Object) => {
const {fileUtil,folderPath,plcDataFd} = this; const {fileUtil,folderPath,plcDataFd} = this;
this.plcDataFd = await fileUtil.editFile(`${folderPath}/plc_data.txt`,JSON.stringify(str),plcDataFd); this.plcDataFd = await fileUtil.editFile(`${folderPath}/plc_data.txt`, JSON.stringify(str), plcDataFd);
} }
// 过程评判json数据 // 过程评判json数据
public setExamJudgeData = async (str:Object) => { public setExamJudgeData = async (str: Object) => {
const {fileUtil,folderPath,examJudgeDataFd} = this; const {fileUtil,folderPath,examJudgeDataFd} = this;
this.examJudgeDataFd = await fileUtil.editFile(`${folderPath}/judge_exam_data.txt`,JSON.stringify(str),examJudgeDataFd); this.examJudgeDataFd = await fileUtil.editFile(`${folderPath}/judge_exam_data.txt`, JSON.stringify(str), examJudgeDataFd);
} }
// 过程评判回调数据 // 过程评判回调数据
public setExamJudgeCallbackData = async (str:string) => { public setExamJudgeCallbackData = async (str: string) => {
const {fileUtil,folderPath,examJudgeCallbackDataFd} = this; const {fileUtil,folderPath,examJudgeCallbackDataFd} = this;
this.examJudgeCallbackDataFd = await fileUtil.editFile(`${folderPath}/judge_progress_callback_data.txt`,str,examJudgeCallbackDataFd); this.examJudgeCallbackDataFd = await fileUtil.editFile(`${folderPath}/judge_progress_callback_data.txt`, str, examJudgeCallbackDataFd);
} }
// 过程评判日志调数据 // 过程评判日志调数据
public setExamJudgeLogData = async (str:string) => { public setExamJudgeLogData = async (str: string) => {
const {fileUtil,folderPath,examJudgeLogDataFd} = this; const {fileUtil,folderPath,examJudgeLogDataFd} = this;
this.examJudgeLogDataFd = await fileUtil.editFile(`${folderPath}/judge_log_data.txt`,str,examJudgeLogDataFd); this.examJudgeLogDataFd = await fileUtil.editFile(`${folderPath}/judge_log_data.txt`, str, examJudgeLogDataFd);
} }
// 设置四合一画面数据 // 设置四合一画面数据
public setFourAndOneLogData = async (str:string) => { public setFourAndOneLogData = async (str: string) => {
const {fileUtil,folderPath,fourAndOneLogDataFd} = this; const {fileUtil,folderPath,fourAndOneLogDataFd} = this;
this.fourAndOneLogDataFd = await fileUtil.editFile(`${folderPath}/four_one_log_data.txt`,str,fourAndOneLogDataFd); this.fourAndOneLogDataFd = await fileUtil.editFile(`${folderPath}/four_one_log_data.txt`, str, fourAndOneLogDataFd);
} }
public setFourAndOneLogDataBytes = async (str:string) => { public setFourAndOneLogDataBytes = async (str: string) => {
const {fileUtil,folderPath,fourAndOneLogDataBytesFd} = this; const {fileUtil,folderPath,fourAndOneLogDataBytesFd} = this;
this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`,str,fourAndOneLogDataBytesFd); this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd);
}
//关闭所有文件写入
public closeAllFiles = async () => {
const {fileUtil,folderPath,fourAndOneLogDataFd} = this;
['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data', 'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => {
fileUtil.closeFile(`${folderPath}/${path}.txt`);
})
} }
// 无锡所轨迹数据 // 无锡所轨迹数据
@ -111,7 +119,7 @@ export default class FileLog {
const plcData = plcStr.split(','); const plcData = plcStr.split(',');
const time = await getCurrentTime(); const time = await getCurrentTime();
const lineData = [ const lineData = [
/*帧头*/ time, /*帧头*/time,
/*卫星时间*/time, /*卫星时间*/time,
/*经度*/ plcData[95], /*经度*/ plcData[95],
/*纬度*/ plcData[95], /*纬度*/ plcData[95],
@ -130,11 +138,11 @@ export default class FileLog {
/*天向位置坐标*/'', /*天向位置坐标*/'',
/*东向速度*/'', /*东向速度*/'',
/*北向速度*/'', /*北向速度*/'',
/*评判信号1*/[plcData[14],plcData[19],plcData[5],'',plcData[2],plcData[3],plcData[7],plcData[8],plcData[13],plcData[12],plcData[17],'',plcData[4],plcData[11],plcData[20],plcData[9],0].join(','), /*评判信号1*/[plcData[14], plcData[19], plcData[5], '', plcData[2], plcData[3], plcData[7], plcData[8], plcData[13], plcData[12], plcData[17], '', plcData[4], plcData[11], plcData[20], plcData[9], 0].join(','),
/*评判信号2*/['',plcData[28],'','',plcData[10],'','','','','','','','','','','','',''].join(','), /*评判信号2*/['', plcData[28], '', '', plcData[10], '', '', '', '', '', '', '', '', '', '', '', '', ''].join(','),
/*发动机转速*/ plcData[25], /*发动机转速*/ plcData[25],
/*结束符*/ time, /*结束符*/ time,
]; ];
this.examLineDataFd = await fileUtil.editFile(`${folderPath}/exam_wuxi_data.txt`,JSON.stringify(lineData),examLineDataFd); this.examLineDataFd = await fileUtil.editFile(`${folderPath}/exam_wuxi_data.txt`, JSON.stringify(lineData), examLineDataFd);
}; };
} }

Binary file not shown.