This commit is contained in:
wangzhongjie 2025-07-01 10:42:14 +08:00
commit 0c2715821d
7 changed files with 78 additions and 38 deletions

View File

@ -433,19 +433,21 @@ let fd
const devPath = "/dev/ttyS3"
function openChuankouFn(callback) {
console.log('SerialOpen in indexservice, path=' + devPath)
//自动挡车不读取串口
if(globalThis.carInfo && globalThis.carInfo.kscx == 'C1'){
testNapi.SerialOpenAsync(devPath, (fd) => {
globalThis.fd = fd;
globalThis.num = 0
let parity = 0x4e; // 'N'
let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => {
callback()
getSyncData('ES_CARINFO').then(result => {
const carInfo = result[0] || {};
globalThis.carInfo.kscx = carInfo.kscx
console.info('srj ES_CARINFO=>',JSON.stringify(carInfo))
if(carInfo.kscx == 'C1'){
testNapi.SerialOpenAsync(devPath, (fd) => {
globalThis.fd = fd;
globalThis.num = 0
let parity = 0x4e; // 'N'
let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => {
callback()
});
});
});
}
}
})
}
function getChuankouFnMsg() {

View File

@ -3,7 +3,7 @@ import { getSyncData } from '../service/initable';
import hilog from '@ohos.hilog';
import FileUtil from '../../common/utils/File'
import { GlobalConfig } from '../../config/index'
const TAG = 'socketTag[TcpDemo.TcpClient]'
export async function getTCP(flag=false) {
globalThis.getCloseTcp=true
const fileUtil = new FileUtil(globalThis.context)
@ -35,10 +35,16 @@ export async function getTCP(flag=false) {
console.log('ttttttt00')
clearInterval(globalThis.intervalSendmsg)
globalThis.intervalSendmsg=setInterval(()=>{
globalThis.intervalSendmsg=setInterval(async()=>{
console.log('getCloseTcp',globalThis.carInfo.carNo)
if(!globalThis.getCloseTcp){
globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
globalThis.tcpStep+=1
if(globalThis.tcpStep>30){
console.log(TAG,'tcp重连开始')
globalThis.tcpStep=0
getTCP()
}
}
},1000/3)
globalThis.TcpClient.onError((val) => {
@ -68,10 +74,16 @@ export async function getTCP(flag=false) {
console.log('ttttttt12')
clearInterval(globalThis.intervalSendmsg)
globalThis.intervalSendmsg=setInterval(()=>{
globalThis.intervalSendmsg=setInterval(async()=>{
// console.log('getCloseTcp',globalThis.getCloseTcp)
if(!globalThis.getCloseTcp){
globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
globalThis.tcpStep+=1
if(globalThis.tcpStep>30){
console.log(TAG,'tcp重连开始')
globalThis.tcpStep=0
getTCP()
}
}
},1000/3)
globalThis.TcpClient.onError((val) => {

View File

@ -148,13 +148,12 @@ export default class TcpClient {
this.tcpSendNum=0
return
}
globalThis.getCloseTcp=true
console.log(`${TAG} TCPsend error ${JSON.stringify(err)}`)
// this.writeLog({
// time:dateFormat(new Date()),
// message: `${TAG} TCPsend error ${JSON.stringify(err)}`,
// })
reslove(false)
reject(false)
});
})
}
@ -165,6 +164,7 @@ export default class TcpClient {
// time:dateFormat(new Date()),
// PLC:`${TAG} Tcponmessage`,
// })
globalThis.tcpStep=0
globalThis.tcpUdpError = false
if (value) {
callback && callback(value.message)

View File

@ -37,6 +37,8 @@ export default class EntryAbility extends UIAbility {
// this.context
// Main window is created, set main page for this ability
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
await tcpUtil.init()
globalThis.tcpStep=0
globalThis.carInfo = {}
globalThis.examinerInfo = {}
@ -64,11 +66,15 @@ export default class EntryAbility extends UIAbility {
globalThis.pathDir = this.context.filesDir;
globalThis.context = this.context;
globalThis.isJudgeInitBool = false
console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir);
// this.requestPermission(this.context)
// this.featureAbilityAuth()
const windowClass = await windowStage.getMainWindow();
globalThis.windowClass = windowClass
await windowClass.setWindowLayoutFullScreen(true)
await windowClass.setWindowSystemBarEnable([])
// await windowClass.setWindowLayoutFullScreen(true)
// await windowClass.setWindowSystemBarEnable([]) //全屏
await windowClass.setWindowSystemBarEnable(['navigation'])
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {

View File

@ -91,6 +91,7 @@ struct UserInfo {
'Param398': '0', //考前上车准备
'Param835': '0', //考前上车准备
'Param850': '0', //考前上车准备
'Param853': '0', //未熄火不能开始考试
}
@State startExam: boolean = false
// 过程照片拍照
@ -537,6 +538,9 @@ struct UserInfo {
if (sys.v_no === '770') {
that.systemParam.Param770Str = sys.v_value;
}
if(sys.v_no === '853'){
that.systemParam.Param853 = sys.v_value;
}
if (sys.v_no === '835') {
that.systemParam.Param835 = sys.v_value;
}
@ -946,8 +950,10 @@ struct UserInfo {
const {isCheckFireOpen} = judgeConfig
const {systemParam,isBoardPrePareSetPopupOpen} = this;
const Param803Str = systemParam.Param803Str
if (Param803Str === '') {
const Param853Str = systemParam.Param853
if (Param803Str === '' && Param853Str != '1') {
return true
}
return new Promise((resolve, reject) => {
if (isCheckFireOpen) {
@ -963,6 +969,14 @@ struct UserInfo {
const ygd = msgArr[8];
const ssc = msgArr[13];
const dw = msgArr[28];
if(Param853Str == '1'){
this.avPlayer.playAudio(['voice/熄火.mp3'])
promptAction.showToast({
message: '请熄火',
duration: 4000
})
reject(false)
}
// 开始考试信号检测
if (Param803Str !== '') {
//安全带
@ -1482,4 +1496,5 @@ type systemParam = {
'Param398': string, //考前上车准备
'Param835': string, //考前上车准备
'Param850': string, //考前上车准备
'Param853': string, //未熄火不能开始考试
}

View File

@ -538,14 +538,14 @@ export default class Judge {
// 调代理接口是否断网了
private isJudgeDisConnect: boolean;
// 项目开始接口同步
beginProject = async (ksxm) => {
beginProject = async (ksxm,xmxh?:string) => {
const carInfo = globalThis.carInfo;
const { examSubject,plateNo } = carInfo;
const {judgeUI,fileLog,getSbbm,xmxh,filePath} = this;
const {judgeUI,fileLog,getSbbm,filePath} = this;
const {lsh,idCard,serialNumber,projectsObj,ksdd,kslx,xldm} = judgeUI
const time = await getCurrentTime();
const project = projectsObj[ksxm]
const sbxh = getSbbm(ksxm, xmxh)
const sbxh = getSbbm(ksxm, xmxh || this.xmxh)
const data = {
//系统类别 接口序列号 接口标识
xtlb: '17', jkxlh: serialNumber, jkid: '17C52',
@ -572,15 +572,15 @@ export default class Judge {
promptWxCode('17C52', code)
}
// 项目结束接口同步
endProject = async (ksxm) => {
endProject = async (ksxm,xmxh?:string) => {
const carInfo = globalThis.carInfo;
const deviceNo = globalThis.deviceNo;
const { examSubject,plateNo,carNo } = carInfo;
const {judgeUI,fileLog,getSbxh,xmxh,getSbbm,filePath} = this;
const {judgeUI,fileLog,getSbxh,getSbbm,filePath} = this;
const {lsh,idCard,serialNumber,projectsObj,cdsbInfoObj,ksdd,kslx,xldm,} = judgeUI
const time = await getCurrentTime();
const project = projectsObj[ksxm]
const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh)
const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh || this.xmxh)
const data = {
xtlb: '17', jkxlh: serialNumber, jkid: '17C55',
@ -1066,7 +1066,7 @@ export default class Judge {
if (!isEnd) {
judgeTask.addTask(async () => {
console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`)
await beginProject(xmdm)
await beginProject(xmdm,xmxh)
}, {
isDelay: true
})
@ -1095,7 +1095,7 @@ export default class Judge {
if (!projectIsEnd) {
judgeTask.addTask(async () => {
console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`)
await endProject(xmdm);
await endProject(xmdm,xmxh)
this.xmmcSingleCode = 0;
this.xmmcEndCode = undefined;
}, {
@ -1714,7 +1714,7 @@ export default class Judge {
// 检测差分状态
checkDwzt = async (type) => {
const {avPlayer} = this;
const judgeConfig = this.judgeUI.judgeConfig;
const config499 = this.judgeUI.judgeConfigObj['499'];
switch (type) {
case 0:
this.judgeUI.isDwztRight = true;
@ -1722,10 +1722,17 @@ export default class Judge {
case 1:
this.judgeUI.dwztErrorVisible = true;
clearInterval(this.judgeUI.timer);
clearInterval(globalThis.judgeTimer)
avPlayer.playAudio([`voice/差分状态异常.mp3`], true)
setTimeout(() => {
router.back()
}, 3000)
try {
this.checkExamIsEnd(true);
} catch (e) {
this.closeAllFiles()
router.back()
}
}, config499 * 1000)
break;
case 2:

View File

@ -1,15 +1,13 @@
{
"lockfileVersion": 2,
"lockfileVersion": 1,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6"
},
"packages": {
"@ohos/hypium@1.0.6": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==",
"registryType": "ohpm",
"shasum": "3f5fed65372633233264b3447705b0831dfe7ea1"
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz",
"integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ=="
}
}
}