From 6b855d1835b5639430c1607797c257e01a14a95e Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Tue, 16 Jul 2024 16:32:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=BF=BD=E7=95=A5cpp=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 10 +- .../main/ets/common/service/indexService.ts | 100 +++++++++--------- 2 files changed, 57 insertions(+), 53 deletions(-) diff --git a/build-profile.json5 b/build-profile.json5 index cc014a42..13b64d74 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -4,13 +4,13 @@ { "name": "default", "material": { - "certpath": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.cer", - "storePassword": "0000001B0C5B52D8C8C6F415D4216EAD2848AA4A376B36FD72006E4072C15BA3D11E6E65C0D1FFA92A6D86", + "certpath": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.cer", + "storePassword": "0000001BBB63DD61213CF0DB2F4C752AEA1CA0C399A96F876B4CEEBE867F18A6C6A959203972B59A421CD8", "keyAlias": "debugKey", - "keyPassword": "0000001B8DCA3C8913C86858A0CDEAEB6BEE0DC29FCE9932930CA1FFE68FFF84341736AADF81F056CDD683", - "profile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p7b", + "keyPassword": "0000001BE0D5D3EB862C643A7206CFCE4664C22DA79C6D0D87FC8B187C2AD7F1DDFF70F49DE2BEA35B037B", + "profile": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p7b", "signAlg": "SHA256withECDSA", - "storeFile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p12" + "storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p12" } } ], diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index f6dd4a71..03814dc0 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -3,42 +3,43 @@ import promptAction from '@ohos.promptAction' import router from '@ohos.router' import { dateFormat } from '../utils/tools' import FileUtil from '../../common/utils/File' -import AccountTable from '../../common/database/tables/AccountTable'; -import MA_SYSSET from '../../common/constants/MA_SYSSET'; -import { takePhoto, deleteAllFileByPiC } from '../../common/service/videoService' +import AccountTable from '../../common/database/tables/AccountTable' +import MA_SYSSET from '../../common/constants/MA_SYSSET' +import { takePhoto } from '../../common/service/videoService' import { - getDataBaseTable, - upDateTable, - getMySystemSetTable, delSyncTable, - upDataZhongxinginitialization + getDataBaseTable, + getMySystemSetTable, + upDataZhongxinginitialization, + upDateTable } from '../../common/service/initable' import { GlobalConfig } from '../../config/index' import testNapi from '@ohos.hiserialsdk' -export async function getliushuiNum(){ +export async function getliushuiNum() { console.log('getLiushuihao') this.fileUtil = new FileUtil(this.context) - const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress+'/config/liushui.txt'); - if(data === '' || data === undefined){ - this.num=0 - let str=this.num.toString() - for(let i=0;str.length<=5;i++){ - str='0'+str + const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/liushui.txt'); + if (data === '' || data === undefined) { + this.num = 0 + let str = this.num.toString() + for (let i = 0; str.length <= 5; i++) { + str = '0' + str } - this.lsh=str + this.lsh = str // return str - }else{ - this.num=Number(JSON.parse(data).value)+1 - let str=this.num.toString() - for(let i=0;str.length<=5;i++){ - str='0'+str + } else { + this.num = Number(JSON.parse(data).value) + 1 + let str = this.num.toString() + for (let i = 0; str.length <= 5; i++) { + str = '0' + str } - this.lsh=str + this.lsh = str // return str } } + //配置流水号 export async function setliushuiNum(context) { const fileUtil = new FileUtil(context) @@ -130,6 +131,7 @@ export async function getDoubleCeneterTable() { }) } + //单中心存表 export async function getSingleCenterTable() { return new Promise((reslove, reject) => { @@ -207,11 +209,11 @@ export async function takePhotoFn(context) { spzd1: false, zdyz: '5', } - globalThis.spzd={ - spzd1:false, - spzd2:false, - spzd3:false, - spzd4:false, + globalThis.spzd = { + spzd1: false, + spzd2: false, + spzd3: false, + spzd4: false, } globalThis.takePhotoNum = 0 const map = {} @@ -228,11 +230,11 @@ export async function takePhotoFn(context) { map[key] = false // param[key] = false } - for(let i=0;i<=arr.length-1;i++){ - let key=arr[i] + for (let i = 0; i <= arr.length - 1; i++) { + let key = arr[i] if (param[key]) { param.pztd = param[`td${Number(i) + 1}`] - takePhoto(param, context, 'jt/',0,(data)=>{ + takePhoto(param, context, 'jt/', 0, (data) => { if (Number(data.fileSize) <= (Number(param.zdyz) * 1000)) { map[key] = true promptAction.showToast({ @@ -244,9 +246,9 @@ export async function takePhotoFn(context) { map[key] = false globalThis.spzd[key] = false } - setTimeout(()=>{ + setTimeout(() => { takePhotoFn() - },3000) + }, 3000) }) } } @@ -257,56 +259,58 @@ export async function takePhotoFn(context) { } }, 3000) } + let fd -const devPath="/dev/ttyUSB0" -async function openChuankouFn():Promise { +const devPath = "/dev/ttyS3" + +async function openChuankouFn(): Promise { console.log('fdfd1111 start') fd = await testNapi.SerialOpen(devPath); - globalThis.fd=fd - console.log('fdfd1111',globalThis.fd) + globalThis.fd = fd + console.log('fdfd1111', globalThis.fd) let parity = 0x4e; // 'N' let ret = await testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity); - console.log('setNum',ret) + console.log('setNum', ret) return ret - } + async function getChuankouFnMsg() { let timeout = 50000; // 2秒超时 let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE - console.log('fdfd',globalThis.fd) + console.log('fdfd', globalThis.fd) let uint8Arr = new Uint8Array(databuff); testNapi.SerialSend(globalThis.fd, uint8Arr).then((ret) => { - console.log('mmmm',ret) - testNapi?.SerialRecv(globalThis.fd, timeout,12).then((revTestInfo) => { - console.log('revTestInfo',revTestInfo.recevedBuf.length) + console.log('mmmm', ret) + testNapi?.SerialRecv(globalThis.fd, timeout, 12).then((revTestInfo) => { + console.log('revTestInfo', revTestInfo.recevedBuf.length) const message = revTestInfo?.recevedBuf?.toString() - console.log('chuankou',message) + console.log('chuankou', message) if (message == '') { return } const msg = message?.split(',') - if(!msg?.length){ + if (!msg?.length) { return } if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { return } - globalThis.chuankoMsg=msg[9] + globalThis.chuankoMsg = msg[9] }) }); } -export async function getChuankouFn(){ - if(globalThis.fd){ +export async function getChuankouFn() { + if (globalThis.fd) { return } openChuankouFn().then((fd) => { - setInterval(()=>{ + setInterval(() => { getChuankouFnMsg() - },1000) + }, 1000) }) } \ No newline at end of file