From 157a3e86f9af3cd26be413247f015ecd72c34594 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Thu, 29 Aug 2024 08:10:20 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=9A=E6=9C=9F=E6=B8=85=E7=90=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/common/service/indexService.ts | 27 ++- .../main/ets/common/service/videoService.ts | 214 +++++++++++++----- .../main/ets/common/service/voiceService.ts | 3 +- entry/src/main/ets/common/utils/tools.ts | 11 + 4 files changed, 191 insertions(+), 64 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index bec0cf8a..a8e8c4a1 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -5,7 +5,7 @@ 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 } from '../../common/service/videoService' +import { takePhoto,deleteAllFileByPiC } from '../../common/service/videoService' import { delSyncTable, @@ -46,6 +46,7 @@ export async function deleteAllFIleLog(path){ "recursion": false, "listNum": 0, }; + let filenames = fs.listFileSync(path, options); console.info("listFile succeed",JSON.stringify(filenames)); for (let i = 0; i < filenames.length; i++) { @@ -64,6 +65,30 @@ export async function deleteAllFIleLog(path){ } } +export async function delHilgo(){ + const fileUtil = new FileUtil(globalThis.context) + const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/hilogTime.txt'); + if(data === '' || data === undefined){ + const folderPath = await fileUtil.initFolder(`/config`); + fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1)) + }else{ + if(Number(data)<7){ + let num=Number(data)+1 + fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num)) + }else{ + let num=Number(data)+1 + fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1)) + fs.rmdir('/data/log/hilog', (err) => { + if (err) { + console.error("rmdir failed with error message: " + err.message + ", error code: " + err.code); + } else { + console.info("rmdir succeed"); + } + }); + deleteAllFileByPiC('jt',1) + } + } +} function isSevenDaysAgo(date) { const today = new Date(); // 当前日期 const target = new Date(date); // 需要判断的日期 diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index 3b5c1322..be4b22f7 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -5,45 +5,55 @@ import fs from '@ohos.file.fs' // @ts-ignore import photoAccessHelper from '@ohos.file.photoAccessHelper' import dataSharePredicates from '@ohos.data.dataSharePredicates' -import { getCurrentTime } from '../utils/tools' +import { dateFormat, getCurrentTime, isSevenDaysAgo } from '../utils/tools' // import rtsp_server from '@ohos.rtsprecord'; import record from '@ohos.rtsprecord'; import { FileHelper } from './FileHelper'; +import FileUtil from '../utils/File'; +import { GlobalConfig } from '../../config'; const rtsp_server = record.createServer(); //开始录屏 const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, -photoAccessHelper.PhotoKeys.PHOTO_TYPE, -photoAccessHelper.PhotoKeys.DISPLAY_NAME, -photoAccessHelper.PhotoKeys.SIZE, -photoAccessHelper.PhotoKeys.DATE_ADDED, -photoAccessHelper.PhotoKeys.DATE_MODIFIED, -photoAccessHelper.PhotoKeys.DURATION, -photoAccessHelper.PhotoKeys.WIDTH, -photoAccessHelper.PhotoKeys.HEIGHT, -photoAccessHelper.PhotoKeys.DATE_TAKEN, -photoAccessHelper.PhotoKeys.ORIENTATION, -photoAccessHelper.PhotoKeys.FAVORITE, -photoAccessHelper.PhotoKeys.TITLE, -photoAccessHelper.PhotoKeys.POSITION, -photoAccessHelper.PhotoKeys.DATE_TRASHED, -photoAccessHelper.PhotoKeys.HIDDEN]; + photoAccessHelper.PhotoKeys.PHOTO_TYPE, + photoAccessHelper.PhotoKeys.DISPLAY_NAME, + photoAccessHelper.PhotoKeys.SIZE, + photoAccessHelper.PhotoKeys.DATE_ADDED, + photoAccessHelper.PhotoKeys.DATE_MODIFIED, + photoAccessHelper.PhotoKeys.DURATION, + photoAccessHelper.PhotoKeys.WIDTH, + photoAccessHelper.PhotoKeys.HEIGHT, + photoAccessHelper.PhotoKeys.DATE_TAKEN, + photoAccessHelper.PhotoKeys.ORIENTATION, + photoAccessHelper.PhotoKeys.FAVORITE, + photoAccessHelper.PhotoKeys.TITLE, + photoAccessHelper.PhotoKeys.POSITION, + photoAccessHelper.PhotoKeys.DATE_TRASHED, + photoAccessHelper.PhotoKeys.HIDDEN]; + // const rtsp_server = record.createServer(); -export async function startRecordVideo(param, td, context, dir) { - return new Promise((reslove, reject) => { +export async function startRecordVideo(param, td, context, dir, path?) { + return new Promise(async (reslove, reject) => { + // const fileUtil = new FileUtil(globalThis.context) + // const date=dateFormat(new Date).split(' ')[0] + + // const folderPath = await fileUtil.initFolder(`/PLC/${date}/${dir}`); var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`; if (rtsp_server != null) { console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri); const num = Math.floor(Math.random() * 10000) - const fileName = `movie_record${num}.mp4` + let fileName + if (!path) { + fileName = `movie_record${num}.mp4` + } else { + fileName = `${path}.mp4` + } + // @ts-ignore var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, dir); const handleId = recordResult.dataInt; - console.log(`Rtsprecord startRecordVideo begin,handleId`, handleId); - reslove(handleId) - console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt); } else { console.log(`Rtsprecord startRecordVideo rtsp_server isnull`); @@ -55,33 +65,106 @@ export async function startRecordVideo(param, td, context, dir) { } //结束录屏 -export async function endRecordVideo(record_handle) { - if (rtsp_server != null && record_handle > 0) { - console.log(`Rtsprecord endRecordVideo begin`); - // @ts-ignore - var recordResult = rtsp_server.endRecordVideo(record_handle); - console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt + ` filename:` + recordResult.fileName); +export async function endRecordVideo(record_handleObj) { + for (let key in record_handleObj) { + if (rtsp_server != null && record_handleObj[key] > 0) { + console.log(`Rtsprecord endRecordVideo begin`); + // @ts-ignore + var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]); + console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + record_handleObj[key].fileName); + + } + else { + console.log(`Rtsprecord endRecordVideo handleId isnull`); + } } - else { - console.log(`Rtsprecord endRecordVideo handleId isnull`); - } - // var result = onvifclient.endRecordVideo(record_handle); - // fs.closeSync(record_handle); - // file_asset.close(record_handle); } + + +export async function saveStartRecordVideo(path) { + return new Promise(async (reslove, reject) => { + const fileUtil = new FileUtil(globalThis.context) + const fileHelper = new FileHelper(); + const date = dateFormat(new Date).split(' ')[0] + fileHelper.createAlbum(date); + // const folderPath = await fileUtil.initFolder(`/${path}/${date}`); + const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt'); + const param = JSON.parse(data) + const record_handle = { + 1: 0, + 2: 1, + 3: 2, + 4: 3 + } + for (let i = 1; i <= 4; i++) { + if (param['videoRecord'+i]) { + console.log('pathpath0',path) + + record_handle[i] = await getfilehandleCode(i, param, date, path) + } + } + reslove(record_handle) + }) +} + +async function getfilehandleCode(td, param, dir, path) { + return new Promise(async (reslove, reject) => { + console.log('pathpath1',path) + + const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path) + // this.rocordHandleObj['rocord_handle'+td] = record_handle + reslove(record_handle) + }) + +} + + +export async function getUserAlbumItemByDisplayName(displayName: string): Promise { + let fetchResult = null + let album: photoAccessHelper.Album = null + try { + console.log('getUserAlbumItemByDisplayName'); + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, displayName) + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context); + + fetchResult = await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); + console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); + if (fetchResult.getCount() > 0) { + const albums = await fetchResult.getLastObject(); + if(isSevenDaysAgo(albums.albumName)){ + deleteAllFileByPiC(albums.albumName,2) + } + console.log('get getUserAlbumItemByDisplayName album',) + } + } catch (err) { + console.log('get Album getUserAlbumItemByDisplayName fetchResult failed with err: ' + err); + } finally { + if (fetchResult != null) { + fetchResult.close(); + } + } + return album; +} + /** *拍照 * @param param * @param context * @param type=0不获取base64 */ -interface takePhotoParam { - name?:string, - base64?:string, - fileSize?:number, - errorCode?:number +interface takePhotoParam { + name?: string, + base64?: string, + fileSize?: number, + errorCode?: number } + /** * * @param param @@ -92,32 +175,38 @@ interface takePhotoParam { * @returns */ const fileHelper = new FileHelper(); -export async function takePhoto(param, context,dir,flag=1,callback?) { - var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; - // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`; +export async function takePhoto(param, context, dir, flag = 1, callback?) { - const num = Math.floor(Math.random() * 10000) - const fileName = `picture_record${num}.jpg` -console.log('baoyihubaoyihu',video_uri,flag) + var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; + // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`; - console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName:` + fileName); - // @ts-ignore - // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir); - if(flag==0){ - rtsp_server.detectVideoSnapshotSize(video_uri,fileName,(err,snapResult)=>{ - console.log("baohaowen_detectLoop round end size1:"+snapResult.fileSize); - callback({fileSize:snapResult.fileSize,errorCode:snapResult.errorCode }) + const num = Math.floor(Math.random() * 10000) + const fileName = `picture_record${num}.jpg` + console.log('baoyihubaoyihu', video_uri, flag) + + console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName:` + fileName); + // @ts-ignore + // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir); + if (flag == 0) { + rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err, snapResult) => { + console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize); + callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode }) }); } - else{ - console.log('baoyihubaoyihu1',video_uri,flag) - return new Promise((resolve,reject)=>{ - rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,true,(err,snapResult)=>{ - console.log('baoyihubaoyihu',video_uri,flag,JSON.stringify(snapResult)) - console.log('getPhtot',JSON.stringify(snapResult)) - resolve({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize,errorCode:snapResult.errorCode }) + else { + console.log('baoyihubaoyihu1', video_uri, flag) + return new Promise((resolve, reject) => { + rtsp_server.getVideoSnapshot(context, video_uri, fileName, dir, true, (err, snapResult) => { + console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult)) + console.log('getPhtot', JSON.stringify(snapResult)) + resolve({ + base64: snapResult.dataString, + name: snapResult.fileName, + fileSize: snapResult.fileSize, + errorCode: snapResult.errorCode + }) }); }) console.log('getmyLog02') @@ -127,13 +216,14 @@ console.log('baoyihubaoyihu',video_uri,flag) } + //type:1 是图片 2是视频 -export async function deleteAllFileByPiC(dirName,type=1) { +export async function deleteAllFileByPiC(dirName, type = 1) { // const fileHelper = new FileHelper(); - fileHelper.deleteFileOfAlbum(dirName,type); + fileHelper.deleteFileOfAlbum(dirName, type); } -export async function deleteAllVideos(context,type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise { +export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise { let fetchResult: photoAccessHelper.FetchResult = null; try { const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); diff --git a/entry/src/main/ets/common/service/voiceService.ts b/entry/src/main/ets/common/service/voiceService.ts index 19c4082e..dde6fdcf 100644 --- a/entry/src/main/ets/common/service/voiceService.ts +++ b/entry/src/main/ets/common/service/voiceService.ts @@ -93,12 +93,13 @@ export class voiceService { // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例 avPlayerFdSrc(name) { - globalThis.context.resourceManager.getRawFd(name, (error, value) => { + globalThis.context.resourceManager.getRawFd(name,async (error, value) => { if (error != null) { console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`); } else { console.log('jiangsongjiangsong',this.avPlayer) if (this.avPlayer) { + await this.avPlayer.reset() this.avPlayer.fdSrc = value; } diff --git a/entry/src/main/ets/common/utils/tools.ts b/entry/src/main/ets/common/utils/tools.ts index a7a0b831..962fcc5d 100644 --- a/entry/src/main/ets/common/utils/tools.ts +++ b/entry/src/main/ets/common/utils/tools.ts @@ -2,7 +2,18 @@ import systemTime from '@ohos.systemDateTime'; import { expect } from '@ohos/hypium'; import FileUtil from './File'; +export function isSevenDaysAgo(date) { + const today = new Date(); // 当前日期 + const target = new Date(date); // 需要判断的日期 + console.info("listFile succeed1",JSON.stringify(target)); + const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异 + const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数 + console.info("listFile succeed2",JSON.stringify(diffDays)); + // 如果差异天数正好是7,则原日期是当前日期的前七天 + console.log('diffDays',diffDays) + return diffDays > 7; +} export async function writeLog(path,param){ return const fileUtil = new FileUtil(globalThis.context) From 8e276824e86eab32da82d4f59c7df7d457b65c64 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Thu, 29 Aug 2024 11:04:10 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=9C=96=E7=89=87=E5=88=AA=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/common/service/indexService.ts | 33 +++++++++---------- entry/src/main/ets/pages/Index.ets | 25 +++++++------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index a8e8c4a1..1c9ec1e9 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -65,27 +65,25 @@ export async function deleteAllFIleLog(path){ } } -export async function delHilgo(){ +export async function delHilog(){ + console.log('kkkkmmm1') + const fileUtil = new FileUtil(globalThis.context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/hilogTime.txt'); + const folderPath = await fileUtil.initFolder(`/config`); + console.log('kkkkmmm2',data) if(data === '' || data === undefined){ - const folderPath = await fileUtil.initFolder(`/config`); - fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1)) + const date=dateFormat(new Date()).split(' ')[0] + console.log('mm'.date) + fileUtil.addFile(`${folderPath}/hilogTime.txt`, date) }else{ - if(Number(data)<7){ - let num=Number(data)+1 - fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num)) - }else{ - let num=Number(data)+1 - fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1)) - fs.rmdir('/data/log/hilog', (err) => { - if (err) { - console.error("rmdir failed with error message: " + err.message + ", error code: " + err.code); - } else { - console.info("rmdir succeed"); - } - }); + console.log('kkkkmmm2',data) + console.log('datadata',data,isSevenDaysAgo(data)) + if(isSevenDaysAgo(data)){ + const date=dateFormat(new Date()).split(' ')[0] + fileUtil.addFile(`${folderPath}/hilogTime.txt`, date) deleteAllFileByPiC('jt',1) + // fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num)) } } } @@ -93,10 +91,9 @@ function isSevenDaysAgo(date) { const today = new Date(); // 当前日期 const target = new Date(date); // 需要判断的日期 console.info("listFile succeed1",JSON.stringify(target)); - const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异 const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数 - console.info("listFile succeed2",JSON.stringify(diffDays)); + console.info("listFile succeed2",(diffDays)); // 如果差异天数正好是7,则原日期是当前日期的前七天 return diffDays > 7; } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6f7a6443..ad9df068 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -11,7 +11,7 @@ import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; -import { getliushuiNum, setliushuiNum, takePhotoFn, deleteAllFIleLog } from '../common/service/indexService'; +import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -19,6 +19,7 @@ import { voiceService } from '../common/service/voiceService'; import errorMsgDialog from './compontents/errorMsgDialog' import { getSyncData } from '../common/service/initable'; import GetDistance from '../common/utils/GetDistance' +import UIAbility from '@ohos.app.ability.UIAbility'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -369,19 +370,23 @@ struct Index { async onPageShow() { console.log('ttttt', 1111) this.userAuth(); + let resourceManager = this.context.resourceManager; this.vocObj = new voiceService(async (status, val, next) => { }); console.log('globalThis.singlePlay', globalThis.singlePlay) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { - console.log('tttttttt') - setTimeout(()=>{ + this.context.resourceManager.getRawFileContent("welcome.wav").then(value => { this.vocObj.playAudio({ type: 1, name: 'welcome.wav' }) - },500) + // let rawFile = value; + }).catch(error => { + console.log("getRawFileContent promise error is " + error); + }); + globalThis.singlePlay = false } this.isSingle = globalThis.singlePlay @@ -425,6 +430,8 @@ struct Index { } async initParams() { + console.log('kkkkmmm') + delHilog() // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') //设置plc udp 同步requesthost await getUDP(this.context, false) @@ -451,16 +458,6 @@ struct Index { if (this.num >= 3) { this.heartMsg() } - // const data=AppStorage.Get('errorMsg'); - // console.log('1123',data,globalThis.type,globalThis.dialogOpen) - // if(data==1){ - // if(globalThis.type=='3'&&!globalThis.dialogOpen){ - // globalThis.dialogOpen=true - // this.errorDialog.open() - // }else if(globalThis.type=='1'){ - // this.errorDialog.open() - // } - // } }, 1000) //下载模型 // await this.getModel() From 747f88e65acab4d53ec249d2bdbcea6342b6b878 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Thu, 29 Aug 2024 12:28:19 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=9C=96=E7=89=87=E5=88=AA=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/service/indexService.ts | 2 +- entry/src/main/ets/pages/judgeSDK/judge.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index 1c9ec1e9..966cbdf4 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -82,7 +82,7 @@ export async function delHilog(){ if(isSevenDaysAgo(data)){ const date=dateFormat(new Date()).split(' ')[0] fileUtil.addFile(`${folderPath}/hilogTime.txt`, date) - deleteAllFileByPiC('jt',1) + deleteAllFileByPiC('pz',1) // fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num)) } } diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 0e267d68..484d7597 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -1444,7 +1444,7 @@ export default class Judge { const msgStr = strArr[num]; if(msgStr == ''){ console.info(judgeTag, '模拟数据考试结束') - globalThis.windowClass.setWindowSystemBarEnable(['navigation']) + // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) clearInterval(judgeTimer) this.checkExamIsEnd(true) return From ca8a535eabc211e78fc2c23bc2e1b4d00e8263d9 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 09:04:23 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=88=AA=E9=99=A4=E5=9C=96=E7=89=87?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index ad9df068..e1a31134 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -431,7 +431,6 @@ struct Index { async initParams() { console.log('kkkkmmm') - delHilog() // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') //设置plc udp 同步requesthost await getUDP(this.context, false) @@ -459,6 +458,7 @@ struct Index { this.heartMsg() } }, 1000) + delHilog() //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] From a4065dde4cf77472ca92e72321699bbc3f81e5b8 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 10:16:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?tcp=E9=A9=97=E8=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/TcpClient.ts | 4 ++-- entry/src/main/ets/pages/Index.ets | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 110c9c08..f3380498 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -195,7 +195,7 @@ export default class TcpClient { } clearInterval(globalThis.intervaltcp) globalThis.intervaltcp=setInterval(()=>{ - setTimeout(async () => { + // setTimeout(async () => { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') @@ -206,7 +206,7 @@ export default class TcpClient { }); } globalThis.tcpUdpError = true; - }, 2000) + // }, 2000) },3000) // callback(value.message) }); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e1a31134..14704146 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -12,6 +12,7 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; +import { getUserAlbumItemByDisplayName } from '../common/service/videoService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -459,6 +460,7 @@ struct Index { } }, 1000) delHilog() + // getUserAlbumItemByDisplayName() //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] From 77ddbc9c1f4f9456b8defdb38bbf7b89662272e2 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 12:30:17 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=8B=8D=E7=85=A7=E9=8C=84=E5=83=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/common/service/videoService.ts | 12 +++++++----- entry/src/main/ets/common/utils/TcpClient.ts | 2 -- .../main/ets/common/utils/UdpClientByCenter.ts | 16 ++++++++-------- entry/src/main/ets/entryability/EntryAbility.ts | 4 ++-- entry/src/main/ets/pages/Index.ets | 9 ++++----- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index be4b22f7..eb3b2542 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -33,7 +33,7 @@ const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, // const rtsp_server = record.createServer(); -export async function startRecordVideo(param, td, context, dir, path?) { +export async function startRecordVideo(param, td, context, dir, path?,index?) { return new Promise(async (reslove, reject) => { // const fileUtil = new FileUtil(globalThis.context) // const date=dateFormat(new Date).split(' ')[0] @@ -47,7 +47,7 @@ export async function startRecordVideo(param, td, context, dir, path?) { if (!path) { fileName = `movie_record${num}.mp4` } else { - fileName = `${path}.mp4` + fileName = `${path}_${index||num}.mp4` } // @ts-ignore @@ -101,18 +101,18 @@ export async function saveStartRecordVideo(path) { if (param['videoRecord'+i]) { console.log('pathpath0',path) - record_handle[i] = await getfilehandleCode(i, param, date, path) + record_handle[i] = await getfilehandleCode(i, param, date, path,i) } } reslove(record_handle) }) } -async function getfilehandleCode(td, param, dir, path) { +async function getfilehandleCode(td, param, dir, path,index) { return new Promise(async (reslove, reject) => { console.log('pathpath1',path) - const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path) + const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path,index) // this.rocordHandleObj['rocord_handle'+td] = record_handle reslove(record_handle) }) @@ -137,6 +137,8 @@ export async function getUserAlbumItemByDisplayName(displayName: string): Promis console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); if (fetchResult.getCount() > 0) { const albums = await fetchResult.getLastObject(); + console.log('get getUserAlbumItemByDisplayName album111',albums.albumName) + if(isSevenDaysAgo(albums.albumName)){ deleteAllFileByPiC(albums.albumName,2) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index f3380498..eea1e52d 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -195,7 +195,6 @@ export default class TcpClient { } clearInterval(globalThis.intervaltcp) globalThis.intervaltcp=setInterval(()=>{ - // setTimeout(async () => { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') @@ -206,7 +205,6 @@ export default class TcpClient { }); } globalThis.tcpUdpError = true; - // }, 2000) },3000) // callback(value.message) }); diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index bef8ac0d..87156197 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -343,10 +343,10 @@ export default class UdpClientByCenter { // this.stashFn(str) const newArr = JSON.parse(JSON.stringify(strachArr)) - // this.writeLog({ - // time:dateFormat(new Date()), - // PLC: JSON.stringify(newArr.toString()), - // }) + this.writeLog({ + time:dateFormat(new Date()), + PLC: JSON.stringify(newArr.toString()), + }) if(strachArr[83]!='4'){ this.chafenFlag++ if(this.chafenFlag>=15&&!globalThis.dialogOpen){ @@ -393,10 +393,10 @@ export default class UdpClientByCenter { this.testIfUdpConnetced(callback) } async writeLog(param){ - // const fileUtil = new FileUtil(globalThis.context) - // const date=dateFormat(new Date).split(' ')[0] - // const folderPath = await fileUtil.initFolder(`/PLC/${date}`); - // fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) + const fileUtil = new FileUtil(globalThis.context) + const date=dateFormat(new Date).split(' ')[0] + const folderPath = await fileUtil.initFolder(`/PLC/${date}`); + fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) } //获取当前UDP信号 diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 643a1add..b587e5d0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -59,8 +59,8 @@ export default class EntryAbility extends UIAbility { 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) => { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 14704146..43beacc4 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,4 +1,3 @@ -// @ts-nocheck import common from '@ohos.app.ability.common'; import router from '@ohos.router'; import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; @@ -12,7 +11,6 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; -import { getUserAlbumItemByDisplayName } from '../common/service/videoService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -21,6 +19,7 @@ import errorMsgDialog from './compontents/errorMsgDialog' import { getSyncData } from '../common/service/initable'; import GetDistance from '../common/utils/GetDistance' import UIAbility from '@ohos.app.ability.UIAbility'; +import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -46,8 +45,6 @@ struct Index { private vocObj = null; private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; - private title = '' - private type = '2' errorDialog: CustomDialogController = new CustomDialogController({ builder: errorMsgDialog({ title: globalThis.title, @@ -331,6 +328,7 @@ struct Index { workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { console.log("baoyihu after postMessage :", JSON.stringify(e.data)); + // @ts-ignore let workData: WorkData = e.data; if (workData.isComplete) { router.pushUrl({ @@ -379,6 +377,7 @@ struct Index { console.log('globalThis.singlePlay', globalThis.singlePlay) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { this.context.resourceManager.getRawFileContent("welcome.wav").then(value => { + console.log('tttttttt') this.vocObj.playAudio({ type: 1, name: 'welcome.wav' @@ -460,7 +459,7 @@ struct Index { } }, 1000) delHilog() - // getUserAlbumItemByDisplayName() + getUserAlbumItemByDisplayName('') //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]