main #2

Merged
wangzhongjie merged 4 commits from harmony_car/subject-two:main into main 2024-03-05 15:52:04 +08:00
21 changed files with 836 additions and 1385 deletions

View File

@ -162,11 +162,11 @@ export default class Rdb {
callback(ret); callback(ret);
}); });
} }
sqlOperate(str,name,callback) { async sqlOperate(str,name,callback) {
this.rdbStore.executeSql(str,(err)=>{ this.rdbStore.executeSql(str,(err)=>{
if (err) { if (err) {
callback(false)
console.info("ExecuteSql failed, err: "+name + JSON.stringify(err)) console.info("ExecuteSql failed, err: "+name + JSON.stringify(err))
callback(false)
return return
} }
console.log('ExecuteSqlsuccess') console.log('ExecuteSqlsuccess')

View File

@ -101,20 +101,16 @@ export async function getDoubleCeneterTable() {
//单中心存表 //单中心存表
export async function getSingleCenterTable() { export async function getSingleCenterTable() {
return new Promise((reslove,reject)=>{ return new Promise((reslove,reject)=>{
upDataZhongxinginitialization().then((flag)=>{ upDataZhongxinginitialization().then((result)=>{
if(flag){ if(result){
router.pushUrl({ router.pushUrl({
url: 'pages/ExaminerLogin', url: 'pages/ExaminerLogin',
}, router.RouterMode.Single) }, router.RouterMode.Single)
reslove(true) reslove(true)
}else{ }else{
// router.pushUrl({
// url: 'pages/ExaminerLogin',
// }, router.RouterMode.Single)
// reslove(true)
promptAction.showToast({ promptAction.showToast({
message: '联网更新失败,请检查网络后重新更新', message: `联网更新失败,请检查网络后重新更新`,
duration: 1000 duration: 500
}); });
reslove(false) reslove(false)
} }

View File

@ -73,6 +73,7 @@ const centerToMap={
't_carparmset':MA_T_CARPARMSET, 't_carparmset':MA_T_CARPARMSET,
// 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER
} }
function sqlInsertCommonFn(tableName,resultArr){ function sqlInsertCommonFn(tableName,resultArr){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
const accountTable = new AccountTable(() => { const accountTable = new AccountTable(() => {
@ -138,6 +139,7 @@ function sqlInsertCommonFn(tableName,resultArr){
}); });
}) })
} }
export async function getDataBaseTable(params) { export async function getDataBaseTable(params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const accountTable = new AccountTable(() => { const accountTable = new AccountTable(() => {
@ -199,7 +201,11 @@ export async function getDataBaseTable(params) {
}); });
}) })
} }
//依据数组和表名更新sql表
export async function upDateTableByArray(tableName,arr) {
sqlInsertCommonFn(tableName,arr)
}
//更新双中心表
export async function upDateTable(params) { export async function upDateTable(params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const date = new Date() const date = new Date()
@ -237,11 +243,6 @@ export async function upDateTable(params) {
}); });
} }
//
export async function upDateTableConfig(tableName,arr) {
sqlInsertCommonFn(tableName,arr)
}
//考试平台 //考试平台
export async function getMySystemSetTable(params) { export async function getMySystemSetTable(params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -276,6 +277,7 @@ export async function getMySystemSetTable(params) {
} }
//依据表名同步获取数据
export async function getSyncData(tableName) { export async function getSyncData(tableName) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const accountTable = new AccountTable(() => { const accountTable = new AccountTable(() => {
@ -288,6 +290,7 @@ export async function getSyncData(tableName) {
}) })
} }
export async function delSyncTable(tableName){ export async function delSyncTable(tableName){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
const accountTable = new AccountTable(() => { const accountTable = new AccountTable(() => {

View File

@ -4,7 +4,7 @@ import { dateFormat} from '../utils/tools'
//获取设备信息 //获取设备信息
export async function getDeviceInfo() { export async function getDeviceInfo() {
globalThis.deviceNo = 'J43405J003101'; //设备mac // globalThis.deviceNo = 'J43405J003101'; //设备mac
globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac
globalThis.diskId = '1231231231'; //硬盘号 globalThis.diskId = '1231231231'; //硬盘号
globalThis.hasAuth = true; globalThis.hasAuth = true;

View File

@ -4,54 +4,42 @@ import fs from '@ohos.file.fs'
import util from '@ohos.util'; import util from '@ohos.util';
import configAddress from '../../common/utils/FileConfig' import configAddress from '../../common/utils/FileConfig'
import { getCurrentTime } from '../utils/tools' import { getCurrentTime } from '../utils/tools'
import record from '@ohos.rtsprecord';
const rtsp_server = record.createServer();
//开始录屏 //开始录屏
export async function startRecordVideo(param,td,context) { export async function startRecordVideo(param, td, context, dir) {
return new Promise<videoPlayRes>(async (reslove,reject)=>{ return new Promise<videoPlayRes>((reslove, reject) => {
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`; var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`;
// var result3 = onvifclient.startRecordVideo(video_uri, "video/" ); if (rtsp_server != null) {
// const record_handle = result3.dataInt; console.log(`Rtsprecord startRecordVideo begin`);
// console.info( `baoyihu startRecordVideo result:`+result3.result+ ` VideoFile:`+result3.dataString ); var recordResult = rtsp_server.startRecordVideo(context, video_uri, dir);
// reslove(record_handle) const handleId = recordResult.dataInt;
// return reslove(handleId)
var mediaTest = mediaLibrary.getMediaLibrary(context); console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt);
let mediaType = mediaLibrary.MediaType.VIDEO;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO;
const num = Math.floor(Math.random() * 10000)
const name = `movie_record${getCurrentTime(1)}.mp4`
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
mediaTest.createAsset(mediaType, name, path, (error, asset) => {
const file_asset = asset; // 记录 ,关闭时用到
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = configAddress.videoSavePath + name;
var result = onvifclient.startRecordVideo(video_uri, file_path, fd);
var rocord_handle = result.dataInt; // 记录 ,关闭时用到
reslove({fd,rocord_handle,file_asset})
} else {
reslove({fd:0,rocord_handle:0,file_asset:0})
console.error('baoyihu startRecordVideo File Open failed with error: ' + error);
} }
}); else {
}); console.log(`Rtsprecord startRecordVideo rtsp_server isnull`);
reslove(0)
}
console.log(`Rtsprecord startRecordVideo end`);
}) })
} }
//结束录屏 //结束录屏
export async function endRecordVideo(record_handle) { export async function endRecordVideo(record_handle) {
if(this.record_handle >0) if (rtsp_server != null && record_handle > 0) {
{ console.log(`Rtsprecord endRecordVideo begin`);
var result = onvifclient.endRecordVideo(record_handle); var recordResult = rtsp_server.endRecordVideo(record_handle);
// this.record_handle = -1; console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt + ` filename:` + recordResult.fileName);
console.info( `baoyihu endRecordVideo result:`+result.result+ ` VideoFile:`+result.dataString );
} }
else else {
{ console.log(`Rtsprecord endRecordVideo handleId isnull`);
console.info( `baoyihu endRecordVideo no task error`);
} }
// var result = onvifclient.endRecordVideo(filehandle); // var result = onvifclient.endRecordVideo(record_handle);
// fs.closeSync(filehandle); // fs.closeSync(record_handle);
// file_asset.close(filehandle); // file_asset.close(record_handle);
} }
/** /**
@ -60,62 +48,46 @@ export async function endRecordVideo(record_handle) {
* @param context * @param context
* @param type=0base64 * @param type=0base64
*/ */
export async function takePhoto(param,context,type=0) { export async function takePhoto(param, context, type = 0, dir) {
return new Promise(async (reslove,reject)=>{ return new Promise((reslove, reject) => {
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, dir);
var mediaTest = mediaLibrary.getMediaLibrary(context); console.log(`baoyihu Rtsprecord getVideoSnapshot file` + snapResult.dataString);
let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
const name="picture_record" + getCurrentTime(1) + ".jpg"
// if(type==1){
// var result = onvifclient.getVideoSnapshot(video_uri,"")
// reslove(result.dataString)
// }else{
// var result = onvifclient.getVideoSnapshot(video_uri,"")
// reslove('')
// }
// return
mediaTest.createAsset(mediaType, name, path, (error, asset) => {
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path =configAddress.picSavePath + name
// var result3 = onvifclient.getVideoSnapshot(video_uri,"");
var result3 = onvifclient.getVideoSnapshot(video_uri, file_path, fd);
fs.closeSync(fd);
asset.close(fd);
if (type == 1) { if (type == 1) {
fs.lstat(file_path).then((stat) => { reslove(snapResult.dataString)
let file = fs.openSync(file_path, fs.OpenMode.READ_WRITE);
const size = Number(stat.size) + 100
let buf = new ArrayBuffer(size);
let num = fs.readSync(file.fd, buf);
var that = new util.Base64();
var array = new Uint8Array(buf);
var result = that.encodeToStringSync(array); //base64圖片
mediaTest.deleteAsset(file_path).then(() => {
console.log('delSuccess')
}).catch(() => {
console.log('delError')
})
this.fileUtil.deleteF(file_path, 3)
reslove(result)
}).catch((err) => {
console.info("get link status failed with error message: " + err.message + ", error code: " + err.code);
});
} else { } else {
reslove('') reslove('')
} }
} else {
console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error);
}
});
});
}) })
} }
export async function deleteAllFile(dir,context) {
const mediaType = mediaLibrary.MediaType.IMAGE
var mymediaLib = await mediaLibrary.getMediaLibrary(context);
let fetchOp = { selections: `media_type =? `, selectionArgs: [`${mediaType}`] }
console.info(`baoyihu deleteRecordFile fetchOp:` + fetchOp);
var asset = await mymediaLib.getFileAssets(fetchOp);
if (mediaType == mediaLibrary.MediaType.IMAGE) {
var base_Dir = "/storage/media/100/local/files/Pictures/";
}
else {
var base_Dir = "/storage/media/100/local/files/Videos/";
}
var my_dir = dir;
asset.getAllObject((eer, fileArray) => {
for (let onfile of fileArray) {
var delet_dir = base_Dir + my_dir + onfile.uri
console.info(`baoyihu deleteRecordFile uri:` + delet_dir);
mymediaLib.deleteAsset(delet_dir, (error, asset) => {
console.info(`baoyihu deleteRecordFile 3 error:` + error);
});
}
});
console.log(`Rtsprecord getVideoSnapshot end`);
}
export interface videoPlayRes { export interface videoPlayRes {
rocord_handle?: number; rocord_handle?: number;
fd?: number; fd?: number;

View File

@ -14,12 +14,9 @@ export async function getUDP() {
if(result.length){ if(result.length){
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){ if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
globalThis.udpClient.closeUdp(()=>{ globalThis.udpClient.closeUdp(()=>{
// const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','192.168.36.9','11111')//杭州
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort) globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
globalThis.udpClient.sendMsg('111') globalThis.udpClient.sendMsg('111')
// globalThis.udpClient = udpClient
}) })
}else{ }else{
@ -42,48 +39,31 @@ export async function getUDP2() {
if(result.length){ if(result.length){
if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){ if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){
globalThis.udpClient2.closeUdp(async ()=>{ globalThis.udpClient2.closeUdp(async ()=>{
// globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800','112.80.35.83','11056') // const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','192.168.36.9','11111')//杭州
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort) globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
// globalThis.udpClient2.rebindUdp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
// globalThis.udpClient2.rebindUdp(result[0].udplocalIp, result[0].udpLocalIpByGPS,result[0].udpOppositeIp,result[0].udpOppositeIpPortByGPS)
globalThis.udpClient2.onMessage((val)=>{ globalThis.udpClient2.onMessage((val)=>{
// globalThis.udpClnt2.sendMsg(heartMsg(context)) // globalThis.udpClnt2.sendMsg(heartMsg(context))
}) })
}) })
}else{ }else{
// const udpClient: UdpClient =new UdpClient(result[0].udplocalIp, result[0].udpLocalIpByGPS,result[0].udpOppositeIp,result[0].udpOppositeIpPortByGPS)
const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort) const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
// const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','112.80.35.83','11056')
// const udpClient: UdpClient =new UdpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
globalThis.udpClient2 = udpClient globalThis.udpClient2 = udpClient
globalThis.udpClient2.bindUdp() globalThis.udpClient2.bindUdp()
// globalThis.udpClient2.sendMsg(heartMsg(context))
globalThis.udpClient2.onMessage((val)=>{ globalThis.udpClient2.onMessage((val)=>{
if(val.id=='32'){ if(val.id=='32'){
globalThis.signNum=val.body[1] globalThis.signNum=val.body[1]
}else if(val.id=='46'){ }else if(val.id=='46'){
let tmpList = [] let tmpList = []
console.log('lsh',globalThis.lsh) console.log('lsh',globalThis.lsh)
const str = globalThis.lsh const str = globalThis.lsh
for (let i = 0;i < str.length; i++) { for (let i = 0;i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
} }
const param = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } const param = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId }
globalThis.udpClient2.send(param) globalThis.udpClient2.send(param)
} }
// setTimeout(async ()=>{
//
// globalThis.udpClient2.sendMsg(heartMsg(context))
//
// },1000)
}) })
} }
}else{ }else{
@ -98,7 +78,6 @@ export async function setTopLineUdp(){
if(config && config[0] && config[0].udplocalIp){ if(config && config[0] && config[0].udplocalIp){
const {udplocalIp,udpOppositeIp,udpOppositeIpPort} = config[0]; const {udplocalIp,udpOppositeIp,udpOppositeIpPort} = config[0];
const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '55509',udpOppositeIp,udpOppositeIpPort) const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '55509',udpOppositeIp,udpOppositeIpPort)
// const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8800','192.168.36.4','33333')
udpClient.bindUdp() udpClient.bindUdp()
return { return {
@ -114,7 +93,7 @@ export async function setJudgeUdp(){
const config = await getSyncData('IpConfigTable'); const config = await getSyncData('IpConfigTable');
if(config && config[0] && config[0].udplocalIp){ if(config && config[0] && config[0].udplocalIp){
const {udplocalIp} = config[0]; const {udplocalIp} = config[0];
// const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080','192.168.32.167','33333') // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080','192.168.36.9','33333')
const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080',globalThis.carInfo?.gpsAddress,globalThis.carInfo?.hintPort) const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080',globalThis.carInfo?.gpsAddress,globalThis.carInfo?.hintPort)
// const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8800','192.168.36.4','33333') // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8800','192.168.36.4','33333')
udpClient.bindUdp() udpClient.bindUdp()

View File

@ -27,6 +27,7 @@ export default class UdpClient {
private oppositeIpPort: string = '' private oppositeIpPort: string = ''
private udp: any = null private udp: any = null
private stashFn
constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
this.localIp = udplocalIp this.localIp = udplocalIp
@ -72,7 +73,9 @@ export default class UdpClient {
console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`);
}); });
} }
setMsgCallBack(callback){
this.stashFn=callback
}
sendMsg(msg: string) { sendMsg(msg: string) {
let promise = this.udp.send({ let promise = this.udp.send({
data: msg, data: msg,
@ -114,6 +117,8 @@ export default class UdpClient {
if (strachArr[0] != '#DN_GD') { if (strachArr[0] != '#DN_GD') {
return return
} }
this.stashFn(str)
this.stashFn=()=>{}
callback(str) callback(str)
} else { } else {
callback('') callback('')

View File

@ -161,7 +161,9 @@ export default class UdpClientByCenter {
console.log(`${TAG} udpLine send fail:${JSON.stringify(err)}`); console.log(`${TAG} udpLine send fail:${JSON.stringify(err)}`);
}); });
} }
setMsgCallBack(callback){
this.stashFn=callback
}
sendMsg(param,context?) { sendMsg(param,context?) {
if(context){ if(context){
this.context=context this.context=context
@ -177,11 +179,13 @@ export default class UdpClientByCenter {
port: parseInt(this.oppositeIpPort), port: parseInt(this.oppositeIpPort),
} }
}); });
this.stashFn=param.callback?param.callback:()=>{}
promise.then(() => { promise.then(() => {
if(this.sendId=='46'&&param.callback){ if(param.sendCallback){
param.callback() param.sendCallback()
} }
// if(this.sendId=='46'&&param.callback){
// param.callback()
// }
console.log(`${TAG} udp send success:`); console.log(`${TAG} udp send success:`);
}).catch(err => { }).catch(err => {
console.log(`${TAG} udp send fail:${JSON.stringify(err)}`); console.log(`${TAG} udp send fail:${JSON.stringify(err)}`);

View File

@ -2,8 +2,7 @@ import router from '@ohos.router'
import TopLogo from './compontents/topLogo' import TopLogo from './compontents/topLogo'
import { examinerLoginService } from '../common/service/ExaminerService' import { examinerLoginService } from '../common/service/ExaminerService'
import Md5 from '../common/utils/md5'; import Md5 from '../common/utils/md5';
import prompt from '@ohos.prompt' import promptAction from '@ohos.promptAction'
import { voiceService } from '../common/service/voiceService'
@Entry @Entry
@Component @Component
@ -57,7 +56,7 @@ struct Index {
Image(item).width('38%').height('24%').onClick(() => { Image(item).width('38%').height('24%').onClick(() => {
if(this.inputTextArr[0].trim()==''||this.inputTextArr[1].trim()==''){ if(this.inputTextArr[0].trim()==''||this.inputTextArr[1].trim()==''){
prompt.showToast({ promptAction.showToast({
message: '请输入用户名和密码', message: '请输入用户名和密码',
duration: 3000 duration: 3000
}); });
@ -129,15 +128,6 @@ struct Index {
} }
aboutToAppear() { aboutToAppear() {
this.url='' this.url=''
// this.vocObj = new voiceService(async (status,val) => {
// if (status == 'idle') {
// if(this.url=='pages/userInfo'){
// router.pushUrl({
// url: this.url,
// });
// }
// }
// });
console.info('ExmainerLogin aboutToAppear'); console.info('ExmainerLogin aboutToAppear');
} }
onPageShow() { onPageShow() {

View File

@ -12,7 +12,7 @@ import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'
import {initJudgeUdp} from '../common/utils/UdpJudge' import {initJudgeUdp} from '../common/utils/UdpJudge'
import { getTCP } from '../common/utils/GlobleTcp' import { getTCP } from '../common/utils/GlobleTcp'
import TcpClient from '../common/utils/TcpClient'; import TcpClient from '../common/utils/TcpClient';
import testNapi from '@ohos.hiserialsdk'
import {setliushuiNum,getSingleCenterTable,getDoubleCeneterTable} from '../common/service/indexService' import {setliushuiNum,getSingleCenterTable,getDoubleCeneterTable} from '../common/service/indexService'
@Entry @Entry
@Component @Component
@ -175,7 +175,7 @@ struct Index {
this.loading = false this.loading = false
} }
async heartMsg(context) { async heartMsg() {
const arr = [globalThis.signNum||0, globalThis.statue||1] const arr = [globalThis.signNum||0, globalThis.statue||1]
let tmpList = []; let tmpList = [];
tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
@ -184,11 +184,9 @@ struct Index {
for (let i = 0;i < str.length; i++) { for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
} }
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId} const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId}
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
globalThis.udpClient2.sendMsg(param, this.context) globalThis.udpClient2.sendMsg(param, this.context)
} }
onPageShow() { onPageShow() {
@ -197,11 +195,10 @@ struct Index {
getUDP() getUDP()
getUDP2() getUDP2()
setInterval(() => { setInterval(() => {
setliushuiNum(this.context) setliushuiNum()
this.heartMsg(this.context) this.heartMsg()
}, 1000) }, 1000)
// getTCP() // getTCP()
// const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) {
@ -226,6 +223,7 @@ struct Index {
// await this.getModel() // await this.getModel()
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer) // globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
console.info(testNapi)
} }
async getModel() { async getModel() {
const context = this.context; const context = this.context;

View File

@ -18,13 +18,13 @@ struct Index {
Column() { Column() {
Row() { Row() {
Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(()=>{ Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(()=>{
this.url='pages/register' this.url='pages/Register'
router.pushUrl({ router.pushUrl({
url: this.url, url: this.url,
},router.RouterMode.Single); },router.RouterMode.Single);
}) })
Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(()=>{ Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(()=>{
this.url='pages/videoConfig' this.url='pages/VideoConfig'
router.pushUrl({ router.pushUrl({
url: this.url, url: this.url,
},router.RouterMode.Single); },router.RouterMode.Single);

View File

@ -0,0 +1,191 @@
import router from '@ohos.router'
import TopLogo from './compontents/topLogo'
import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt'
import { upDateTableByArray} from '../common/service/initable'
import { getSyncData} from '../common/service/initable'
import { voiceService } from '../common/service/voiceService'
@Entry
@Component
struct Index {
@State textList1: string[] = ['ftp服务器IP','响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:',]
@State textList2: string[] = ['后置机IP','响应端口:', '本地端口:']
@State ratio: number = 850 / 960
@State inputFontSize:number=12 //12
//
@State inputTextList1: string[] = ['192.168.36.2','8083','192.168.36.92','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.203','8000',]
@State inputTextList2: string[] = ['192.168.36.91','20022']
// 112.80.35.83 11052
// @State inputTextList1: string[] = ['192.168.7.254','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11052']
// @State inputTextList2: string[] = ['192.168.7.124','20022']
@State @Watch('outClick') outFlag: boolean = false;
private vocObj = null;
scroller: Scroller = new Scroller()
build() {
Column() {
TopLogo({outFlag:$outFlag})
Column() {
Column() {
Scroll(this.scroller){
Flex({'wrap':FlexWrap.Wrap}) {
ForEach(this.textList1, (item:string, index:number) => {
Row() {
Text(item)
.width('40%')
.height('100%')
.fontColor('#E5CBA1')
.padding({'left': '35px'})
.fontSize(this.inputFontSize*this.ratio)
TextInput({'text':this.inputTextList1[index]?this.inputTextList1[index]: ''})
.width('50%')
.height('60%')
.fontColor('#fff')
.borderColor('#E6E0D8')
.borderRadius('10px')
.borderWidth('2px')
.fontSize(this.inputFontSize*this.ratio)
.padding({top:0,bottom:0})
.linearGradient({
angle: 0,
colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]]
}).onChange((value: string) => {
this.inputTextList1[index]=value
})
}
.width('50%')
.height('16.7%')
})
ForEach(this.textList2, (item:string, index:number) => {
Row() {
Text(item)
.width('40%')
.height('100%')
.fontColor('#E5CBA1')
.fontSize(this.inputFontSize*this.ratio)
.padding({'left': '35px'})
TextInput({'text':this.inputTextList2[index]?this.inputTextList2[index]: ''})
.width('60%')
.height('60%')
.fontColor('#fff')
.borderColor('#E6E0D8')
.borderRadius('10px')
.borderWidth('2px')
.padding({top:0,bottom:0})
.fontSize(this.inputFontSize*this.ratio)
.linearGradient({
angle: 0,
colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]]
})
.onChange((value: string) => {
this.inputTextList2[index]=value
})
}
.width('32.5%')
.height('16.7%')
})
}
}
.width('95%')
.height('90%')
.margin({'top': '2%'})
.backgroundColor('#282828')
.borderRadius('15px')
}
.width('100%')
.height('80%')
.borderRadius('25px')
Column() {
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{
upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[2],udplocalIpPort:this.inputTextList1[3],udpOppositeIp:this.inputTextList2[0],udpOppositeIpPort:this.inputTextList2[1],tcplocalIp:this.inputTextList1[0],tcplocalIpPort:this.inputTextList1[1],tcpOppositeIp:this.inputTextList1[9],tcpOppositePort:this.inputTextList1[10],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[8]}])
ethernet.setIfaceConfig("eth0", {
mode: 0,
ipAddr:this.inputTextList1[2],
route: "0.0.0.0",
gateway: this.inputTextList1[5],//value.gateway网关
netMask: this.inputTextList1[4],//value.netMask网络掩码
dnsServers: this.inputTextList1[8],
// domain: ""
}, (error) => {
if (error) {
prompt.showToast({
message: '设置失败'+JSON.stringify(error),
duration: 3000
});
} else {
prompt.showToast({
message: '设置成功',
duration: 3000
});
}
});
})
}
.backgroundColor('#CCC4B8')
.width('100%')
.height('20%')
.borderRadius({'bottomLeft':'25px','bottomRight':'25px'})
.justifyContent(FlexAlign.SpaceAround)
}
.width('75%')
.height('69.4%')
.backgroundColor('#E6E3DF')
.borderRadius('25px')
.margin({'top':'7%'})
.justifyContent(FlexAlign.SpaceAround)
}
.width('100%')
.height('100%')
.backgroundImagePosition({x: 0, y: 0})
.backgroundImage($r('app.media.index_bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToAppear() {
getSyncData('IpConfigTable').then((result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){
console.log('tagtag',JSON.stringify(result))
this.inputTextList1[2]=result[0].udplocalIp
this.inputTextList1[3]=result[0].udplocalIpPort
this.inputTextList2[0]=result[0].udpOppositeIp
this.inputTextList2[1]=result[0].udpOppositeIpPort
this.inputTextList1[0]=result[0].tcplocalIp
this.inputTextList1[1]=result[0].tcplocalIpPort
this.inputTextList1[9]=result[0].tcpOppositeIp
this.inputTextList1[10]=result[0].tcpOppositePort
this.inputTextList1[5]=result[0].gateway
this.inputTextList1[4]=result[0].netMask
this.inputTextList1[8]=result[0].dnsServers
this.inputTextList1[11]=result[0].centerIp
this.inputTextList1[12]=result[0].heartPort
this.inputTextList1[13]=result[0].gpsPort
}
})
ethernet.getIfaceConfig("eth0", (error, value) => {
if (error) {
// that.errorMsg='error'
console.log("boot_up getIp_new callback error = " + JSON.stringify(error));
} else {
console.log("boot_up getIp_new callback ipAddr = " + JSON.stringify(value.ipAddr)); //
console.log(" boot_up getIp_new callback mode = " + JSON.stringify(value.mode));
console.log("boot_up getIp_new callback route = " + JSON.stringify(value.route));
console.log("boot_up getIp_new callback gateway = " + JSON.stringify(value.gateway));
console.log("boot_up getIp_new callback netMask = " + JSON.stringify(value.netMask));
console.log("boot_up getIp_new callback dnsServers = " + JSON.stringify(value.dnsServers));
}
})
}
onPageShow() {
console.info('Index onPageShow');
}
outClick(){
}
}

View File

@ -16,6 +16,7 @@ import WebRTCVoice from './webRTC/'
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction'
import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData" import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData"
import {string2Bytes} from '../common/utils/tools' import {string2Bytes} from '../common/utils/tools'
import { getSyncData } from '../common/service/initable'
@Entry @Entry
@Component @Component
struct UserInfo { struct UserInfo {
@ -69,43 +70,30 @@ struct UserInfo {
@State grantDept: string = ''; @State grantDept: string = '';
@State effectDate: string = ''; @State effectDate: string = '';
@State interval: any = null; @State interval: any = null;
@State interval2: any = null;
@State interval3: any = null;
@State studentRefreshStatue: string = '0'; @State studentRefreshStatue: string = '0';
@State photo: string = 'data:image/bmp;base64,'; @State photo: string = 'data:image/bmp;base64,';
@State numCount: number = 0; @State numCount: number = 0;
@State signNum: number = 0; @State signNum: number = 0;
@State isCanClick: boolean = true; @State isCanClick: boolean = true;
@State FaceOpenStatue: string = '0';//是否开启人脸识别
subscriber; subscriber;
@State faceCatchImg: string = '' @State faceCatchImg: string = ''
onPageShow() { async onPageShow() {
//语音功能 //语音功能
const systemParms:any = await getSyncData('MA_SYSTEMPARM')
console.log('systemParms',systemParms.length)
new WebRTCVoice(this.context); new WebRTCVoice(this.context);
//初始化数据 //初始化数据
this.initData() this.initData()
//身份证读卡器初始化 //身份证读卡器初始化
this.openDeviceByIDCard() // this.openDeviceByIDCard()
// 如果是单机模式则模拟假数据 // 如果是单机模式则模拟假数据
if (globalThis.singlePlay) {
// TODO 模拟假数据
this.list = CandidateData
this.pageIndex = 0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
this.currentUser = this.dataList[0]
this.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
globalThis.lsh = this.lsh
return
} else {
// this.getExaminationStudentInfoFn()
}
this.initSysset() this.initSysset()
initJudgeUdp() initJudgeUdp()
this.interval=setInterval(()=>{
this.heartMsg() this.heartMsg()
},1000)
} }
//身份证读卡器初始化 //身份证读卡器初始化
openDeviceByIDCard(){ openDeviceByIDCard(){
@ -118,6 +106,9 @@ struct UserInfo {
console.error("zzctest Failed to Open Device"); console.error("zzctest Failed to Open Device");
} }
} }
stopDeviceById(){
testNapi&&testNapi.StopReadCard()
}
// 通过身份证获取当前学员 // 通过身份证获取当前学员
getCurrentStudent(id) { getCurrentStudent(id) {
let flag = false let flag = false
@ -133,7 +124,7 @@ struct UserInfo {
// this.currentUser.kszp=this.photo+res.kszp // this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
if (globalThis.singlePlay) { if (globalThis.singlePlay) {
testNapi.StopReadCard(); this.stopDeviceById()
// globalThis.statue=4 // globalThis.statue=4
router.pushUrl({ router.pushUrl({
url: 'pages/Judge', url: 'pages/Judge',
@ -219,18 +210,23 @@ struct UserInfo {
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
globalThis.statue = 2 globalThis.statue = 2
this.numCount = 0 this.numCount = 0
if (globalThis.singlePlay) {
// TODO 模拟假数据
this.list = CandidateData
this.pageIndex = 0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
this.currentUser = this.dataList[0]
this.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
globalThis.lsh = this.lsh
return
} else {
// this.getExaminationStudentInfoFn()
}
} }
async heartMsg() { async heartMsg() {
const arr = [globalThis.signNum||0, globalThis.statue||1] globalThis.udpClient2.setMsgCallBack((val)=>{
let tmpList = [];
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
const str =globalThis.lsh|| '0000000000000'
for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId,callback:(val)=>{
if(val.id=='32'){ if(val.id=='32'){
globalThis.signNum=val.body[1] globalThis.signNum=val.body[1]
if(val.body[0]=='7'){ if(val.body[0]=='7'){
@ -241,8 +237,7 @@ struct UserInfo {
console.log('qkfnqkfn',val.body[0]) console.log('qkfnqkfn',val.body[0])
this.qkFn() this.qkFn()
} }
}} })
globalThis.udpClient2.sendMsg(param, this.context)
} }
getqkFn() { getqkFn() {
let tmpList = []; let tmpList = [];
@ -275,18 +270,28 @@ struct UserInfo {
that.ksxtbh = ksxtbhArr?.[0]?.v_value || '222' that.ksxtbh = ksxtbhArr?.[0]?.v_value || '222'
const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452') const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452')
that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0'
const faceParam = syssetParams.filter(sys => sys.v_no === '2313')
that.FaceOpenStatue =faceParam?.[0]?.v_value=='3'? '1':'0'
that.FaceOpenStatue = '0'
console.log('that.FaceOpenStatue',that.FaceOpenStatue)
// faceParam?.[0]?.v_value ||
// 1身份证读卡器 2指纹 3人脸
if(faceParam?.[0]?.v_value=='1'){
that.openDeviceByIDCard()
}
console.log('mmmmm',that.FaceOpenStatue)
//0不自动更新 1自动更新不限次数 2没有考生更新2次 //0不自动更新 1自动更新不限次数 2没有考生更新2次
if (that.studentRefreshStatue == '2') { if (that.studentRefreshStatue == '2') {
clearInterval(that.interval2) clearInterval(that.interval)
that.interval2 = setInterval(() => { that.interval = setInterval(() => {
if (that.dataList.length == 0 && that.numCount < 3) { if (that.dataList.length == 0 && that.numCount < 3) {
that.numCount++ that.numCount++
that.getExaminationStudentInfoFn() that.getExaminationStudentInfoFn()
} }
}, 5000) }, 5000)
} else if (that.studentRefreshStatue == '1') { } else if (that.studentRefreshStatue == '1') {
clearInterval(that.interval2) clearInterval(that.interval)
that.interval2 = setInterval(() => { that.interval = setInterval(() => {
if (that.dataList.length == 0) { if (that.dataList.length == 0) {
that.getExaminationStudentInfoFn() that.getExaminationStudentInfoFn()
} }
@ -298,6 +303,7 @@ struct UserInfo {
} }
changeFaceCompareSuccess() { changeFaceCompareSuccess() {
globalThis.statue = 2
console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser))
if (this.faceCompareSucess > 0) { if (this.faceCompareSucess > 0) {
this.sfbdinterfaceFn() this.sfbdinterfaceFn()
@ -329,12 +335,12 @@ struct UserInfo {
if (!res) { if (!res) {
this.dataList = [] this.dataList = []
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
console.log('currentUser', JSON.stringify(this.currentUser))
this.errorMsg = decodeURI(res.getExaminationStudentInfoRsp.head.resultMessage) this.errorMsg = decodeURI(res.getExaminationStudentInfoRsp.head.resultMessage)
return return
} }
let dataList = [] let dataList = []
this.list = [] this.list = []
for (let key in res.getExaminationStudentInfoRsp.body) { for (let key in res.getExaminationStudentInfoRsp.body) {
const a = res.getExaminationStudentInfoRsp.body[key] const a = res.getExaminationStudentInfoRsp.body[key]
if (a instanceof Array) { if (a instanceof Array) {
@ -433,7 +439,7 @@ struct UserInfo {
ksxtbh: this.ksxtbh || '222', ksxtbh: this.ksxtbh || '222',
sfzmhm: this.currentUser.sfzmhm || '', sfzmhm: this.currentUser.sfzmhm || '',
ksysfzmhm: this.currentUser.ksy1sfzmhm || '', ksysfzmhm: this.currentUser.ksy1sfzmhm || '',
zp: encodeURIComponent(this.faceCatchImg || ''), zp: encodeURIComponent((this.faceCatchImg||this.currentUser.kszp.substr(22)) || ''),
kssj: dateFormat(date) || '', kssj: dateFormat(date) || '',
kchp: decodeURI(plateNo), kchp: decodeURI(plateNo),
Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || '' Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || ''
@ -450,6 +456,7 @@ struct UserInfo {
globalThis.lsh = this.currentUser.lsh globalThis.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
this.currentUser.id = '1' this.currentUser.id = '1'
console.log('codecode',code)
if (code) { if (code) {
this.AccountTable.query('0', (result) => { this.AccountTable.query('0', (result) => {
if (result.length == 0) { if (result.length == 0) {
@ -461,7 +468,8 @@ struct UserInfo {
url: 'pages/Judge', url: 'pages/Judge',
params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx } params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx }
}, router.RouterMode.Single); }, router.RouterMode.Single);
testNapi.StopReadCard(); this.stopDeviceById()
}) })
}) })
} else { } else {
@ -473,7 +481,7 @@ struct UserInfo {
params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx } params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx }
}, router.RouterMode.Single); }, router.RouterMode.Single);
globalThis.statue = 4 globalThis.statue = 4
testNapi.StopReadCard(); this.stopDeviceById()
}) })
}) })
} }
@ -487,8 +495,8 @@ struct UserInfo {
} }
outClick() { outClick() {
clearInterval(this.interval) clearInterval(this.interval)
clearInterval(this.interval2) this.stopDeviceById()
testNapi.StopReadCard(); globalThis.udpClient2.setMsgCallBack(()=>{})
} }
// 几个按钮公共样式 // 几个按钮公共样式
@Styles @Styles
@ -641,7 +649,7 @@ struct UserInfo {
router.pushUrl({ router.pushUrl({
url: 'pages/Judge', url: 'pages/Judge',
}, router.RouterMode.Single); }, router.RouterMode.Single);
testNapi.StopReadCard(); this.stopDeviceById()
}) })
}) })
} else { } else {
@ -650,14 +658,18 @@ struct UserInfo {
router.pushUrl({ router.pushUrl({
url: 'pages/Judge', url: 'pages/Judge',
}, router.RouterMode.Single); }, router.RouterMode.Single);
testNapi.StopReadCard(); this.stopDeviceById()
}) })
}) })
} }
}) })
return return
} }
if(this.FaceOpenStatue!='0'){
this.showFaceCompare = true this.showFaceCompare = true
}else{
this.sfbdinterfaceFn()
}
}) })
} }
} }
@ -669,8 +681,8 @@ struct UserInfo {
faceCompareSucess: $faceCompareSucess, faceCompareSucess: $faceCompareSucess,
getqkFlag: $getqkFlag, getqkFlag: $getqkFlag,
faceCatchImg: $faceCatchImg, faceCatchImg: $faceCatchImg,
lsh: globalThis.lsh,
showFaceCompare: $showFaceCompare, showFaceCompare: $showFaceCompare,
lsh: globalThis.lsh,
}) })
} }
if (this.qkFlag) { if (this.qkFlag) {

View File

@ -1,15 +1,11 @@
import TopLogo from './compontents/topLogo' import TopLogo from './compontents/topLogo'
import FileUtil from '../common/utils/File' import FileUtil from '../common/utils/File'
import { SourceType } from '@ohos.multimodalInput.touchEvent'
import { VideoConfig } from './interfaces' import { VideoConfig } from './interfaces'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import router from '@ohos.router' import promptAction from '@ohos.promptAction'
import onvifclient from '@ohos.onvifclient'; import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService'
import fs from '@ohos.file.fs' import configAddress from '../common/utils/FileConfig'
import prompt from '@ohos.prompt' import util from '@ohos.util';
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
// import { voiceService } from '../common/service/voiceService'
@Entry @Entry
@Component @Component
struct Index { struct Index {
@ -18,34 +14,27 @@ struct Index {
@State previewUri: Resource = $r('app.media.2_nor') @State previewUri: Resource = $r('app.media.2_nor')
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State inputFontSize: number = 10 //12 @State inputFontSize: number = 10 //12
@State rocord_handle1: number = 0 @State rocordHandleObj:any = {
@State rocord_handle2: number = 0 rocord_handle1:0,
@State rocord_handle3: number = 0 rocord_handle2:0,
@State rocord_handle4: number = 0 rocord_handle3:0,
@State filehandle1: number = 0 rocord_handle4:0
@State filehandle2: number = 0 }
@State filehandle3: number = 0
@State filehandle4: number = 0
@State file_asset1: any = 0
@State file_asset2: any = 0
@State file_asset3: any = 0
@State file_asset4: any = 0
// file_handle1
@State isAutoPlay: boolean = true @State isAutoPlay: boolean = true
@State showFlag: boolean = false @State showFlag: boolean = false
@State videoNum: string = '1'
private vocObj = null; private vocObj = null;
@State showControls: boolean = false @State showControls: boolean = false
private fileUtil: FileUtil private fileUtil: FileUtil
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@State oldParam: VideoConfig = { @State oldParam: VideoConfig = {
videoNum:'1',
spls: '1', spls: '1',
wz: '0,0', wz: '0,0',
faceFlag: false, faceFlag: false,
shuiying: true, shuiying: true,
pztd: '2', pztd: '2',
ljlx: '', ljlx: '',
ip: '192.168.7.112', ip: '192.168.36.94',
port: '554', port: '554',
userName: 'admin', userName: 'admin',
pwd: '12345qwe', pwd: '12345qwe',
@ -65,13 +54,14 @@ struct Index {
rlls: '1' rlls: '1'
} }
@State param: VideoConfig = { @State param: VideoConfig = {
videoNum:'1',
spls: '1', spls: '1',
wz: '0,0', wz: '0,0',
faceFlag: false, faceFlag: false,
shuiying: true, shuiying: true,
pztd: '2', pztd: '2',
ljlx: '', ljlx: '',
ip: '192.168.7.112', ip: '192.168.36.94',
port: '554', port: '554',
userName: 'admin', userName: 'admin',
pwd: '12345qwe', pwd: '12345qwe',
@ -91,68 +81,44 @@ struct Index {
rlls: '1' rlls: '1'
} }
@State openFlag: boolean = true @State openFlag: boolean = true
@State lsArr: Array<any> = [
{key:'第一路'},
{key:'第二路'},
{key:'第三路'},
{key:'第四路'},
]
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
private controller1: VideoController = new VideoController() private controller1: VideoController = new VideoController()
private controller2: VideoController = new VideoController() private controller2: VideoController = new VideoController()
private controller3: VideoController = new VideoController() private controller3: VideoController = new VideoController()
private controller4: VideoController = new VideoController() private controller4: VideoController = new VideoController()
@State videoArr: Array<any> = [
{td:'td1',controller:this.controller1},
{td:'td2',controller:this.controller2},
{td:'td3',controller:this.controller3},
{td:'td4',controller:this.controller4},
]
private inputController: TextInputController = new TextInputController() private inputController: TextInputController = new TextInputController()
// private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext)
build() { build() {
Column() { Column() {
TopLogo({ outFlag: $outFlag }) TopLogo({ outFlag: $outFlag })
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Column() { Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) {
Row() { ForEach(this.videoArr,(item,index)=>{
Video({ Video({
src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td1}/main/av_stream`:'', src: this.openFlag ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param[item.td]}/main/av_stream` : '',
currentProgressRate: this.curRate, currentProgressRate: this.curRate,
controller: this.controller1 controller: item.controller
}) })
.width(205 * this.ratio) .width(270 * this.ratio)
.height(168 * this.ratio) .height(230 * this.ratio)
.autoPlay(this.isAutoPlay) .autoPlay(this.isAutoPlay)
.controls(this.showControls) .controls(this.showControls)
.margin(10 * this.ratio) .margin(10 * this.ratio)
Video({
src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td2}/main/av_stream`:'',
currentProgressRate: this.curRate,
controller: this.controller1
}) })
.width(205 * this.ratio) }.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600*this.ratio).height(600*this.ratio)
.height(168 * this.ratio)
.autoPlay(this.isAutoPlay)
.controls(this.showControls)
.margin(10 * this.ratio)
}
Row() {
Video({
src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td3}/main/av_stream`:'',
currentProgressRate: this.curRate,
controller: this.controller3
})
.width(205 * this.ratio)
.height(168 * this.ratio)
.autoPlay(this.isAutoPlay)
.controls(this.showControls)
.margin(10 * this.ratio)
Video({
src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td4}/main/av_stream`:'',
// previewUri: this.previewUri,
currentProgressRate: this.curRate,
controller: this.controller4
})
.width(205 * this.ratio)
.height(168 * this.ratio)
.autoPlay(this.isAutoPlay)
.controls(this.showControls)
.margin(10 * this.ratio)
}
}.margin({ top: 37 * this.ratio, left: 30 * this.ratio })
Column() { Column() {
Image($r('app.media.shezhi')) Image($r('app.media.shezhi'))
@ -167,109 +133,28 @@ struct Index {
.height(64 * this.ratio) .height(64 * this.ratio)
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
.onClick(async () => { .onClick(async () => {
if (!this.param.videoRecord4 && !this.param.videoRecord3 && !this.param.videoRecord2 && !this.param.videoRecord1) { if (!this.param.videoRecord4 && !this.param.videoRecord3
prompt.showToast({ && !this.param.videoRecord2 && !this.param.videoRecord1) {
promptAction.showToast({
message: '请选择录像通道', message: '请选择录像通道',
duration: 3000 duration: 3000
}) })
return return
} }
if (this.rocord_handle1 || this.rocord_handle2 || this.rocord_handle3 || this.rocord_handle4) { if (this.rocordHandleObj.rocord_handle1
|| this.rocordHandleObj.rocord_handle2
|| this.rocordHandleObj.rocord_handle3
|| this.rocordHandleObj.rocord_handle4) {
return return
} }
if (this.param.videoRecord1) { for (let i = 1; i <= 4; i++) {
// var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } if (this.param['videoRecord'+i]) {
var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch1/main/av_stream`; // setTimeout(()=>{
var mediaTest = mediaLibrary.getMediaLibrary(this.context); this.getfilehandleCode(i)
let mediaType = mediaLibrary.MediaType.VIDEO; // },500)
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO;
const num = Math.floor(Math.random() * 10000)
const name = `movie_record${num}.mp4`
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
mediaTest.createAsset(mediaType, name, path, (error, asset) => {
this.file_asset1 = asset; // 记录 ,关闭时用到
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name;
var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd);
this.filehandle1 = fd; // 记录 ,关闭时用到
this.rocord_handle1 = result3.dataInt; // 记录 ,关闭时用到
} else {
console.error('baoyihu startRecordVideo File Open failed with error: ' + error);
} }
});
});
} }
if (this.param.videoRecord2) { promptAction.showToast({
// var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd }
var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch2/main/av_stream`;
var mediaTest = mediaLibrary.getMediaLibrary(this.context);
let mediaType = mediaLibrary.MediaType.VIDEO;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO;
const num = Math.floor(Math.random() * 10000)
var videoName = `movie_record${num}.mp4`
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
const that = this
mediaTest.createAsset(mediaType, videoName, path, (error, asset) => {
this.file_asset2 = asset; // 记录 ,关闭时用到
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + videoName;
that.filehandle2 = fd // 记录 ,关闭时用到
var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd);
this.rocord_handle2 = result3.dataInt; // 记录 ,关闭时用到
} else {
console.error(' startRecordVideo File Open failed with error: ' + error);
}
});
});
}
if (this.param.videoRecord3) {
// var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd }
var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch3/main/av_stream`;
var mediaTest = mediaLibrary.getMediaLibrary(this.context);
let mediaType = mediaLibrary.MediaType.VIDEO;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO;
const num = Math.floor(Math.random() * 10000)
const name = `movie_record${num}.mp4`
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
mediaTest.createAsset(mediaType, name, path, (error, asset) => {
this.file_asset3 = asset; // 记录 ,关闭时用到
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name;
var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd);
this.filehandle3 = fd; // 记录 ,关闭时用到
this.rocord_handle3 = result3.dataInt; // 记录 ,关闭时用到
} else {
console.error('baoyihu startRecordVideo File Open failed with error: ' + error);
}
});
});
}
if (this.param.videoRecord4) {
var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch4/main/av_stream`;
var mediaTest = mediaLibrary.getMediaLibrary(this.context);
let mediaType = mediaLibrary.MediaType.VIDEO;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO;
const num = Math.floor(Math.random() * 10000)
const name = `movie_record${num}.mp4`
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
mediaTest.createAsset(mediaType, name, path, (error, asset) => {
this.file_asset4 = asset; // 记录 ,关闭时用到
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name;
var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd);
this.filehandle4 = fd; // 记录 ,关闭时用到
this.rocord_handle4 = result3.dataInt; // 记录 ,关闭时用到
} else {
console.error('baoyihu startRecordVideo File Open failed with error: ' + error);
}
});
});
}
prompt.showToast({
message: '录像开始', message: '录像开始',
duration: 3000 duration: 3000
}) })
@ -277,41 +162,18 @@ struct Index {
Image($r('app.media.tingzhi')) Image($r('app.media.tingzhi'))
.width(215 * this.ratio) .width(215 * this.ratio)
.height(64 * this.ratio) .height(64 * this.ratio)
// .backgroundImage($r('app.media.button_nor'))
// .backgroundImageSize({ width: '100%', height: '100%' })
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
.onClick(() => { .onClick(() => {
if (this.rocord_handle4) { for (let i = 1; i <= 4; i++) {
var result4 = onvifclient.endRecordVideo(this.rocord_handle4); console.log('rocord_handle',JSON.stringify(this.rocordHandleObj))
this.rocord_handle4 = 0 if (this.rocordHandleObj['rocord_handle'+i]) {
fs.closeSync(this.filehandle4) endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
this.file_asset1.close(this.filehandle4); this.rocordHandleObj['rocord_handle'+i] = -1
} }
if (this.rocord_handle3) {
var result3 = onvifclient.endRecordVideo(this.rocord_handle3);
this.rocord_handle3 = 0
fs.closeSync(this.filehandle3);
this.file_asset2.close(this.filehandle3);
} }
if (this.rocord_handle2) {
console.log('tagtag',this.rocord_handle2,this.filehandle2)
var result = onvifclient.endRecordVideo(this.rocord_handle2);
this.rocord_handle2 = 0
fs.closeSync(this.filehandle2);
this.file_asset2.close(this.filehandle2);
} promptAction.showToast({
if (this.rocord_handle1) {
var result = onvifclient.endRecordVideo(this.filehandle1);
this.rocord_handle1 = 0
fs.closeSync(this.filehandle1);
this.file_asset2.close(this.filehandle1);
}
this.rocord_handle1 = 0
this.rocord_handle2 = 0
this.rocord_handle3 = 0
this.rocord_handle4 = 0
prompt.showToast({
message: '录像结束', message: '录像结束',
duration: 3000 duration: 3000
}) })
@ -320,56 +182,52 @@ struct Index {
.width(215 * this.ratio) .width(215 * this.ratio)
.height(64 * this.ratio) .height(64 * this.ratio)
.onClick(async () => { .onClick(async () => {
if (this.param.pztd != '1' && this.param.pztd != '2' && this.param.pztd != '3' && this.param.pztd != '4') { const arr=['1','2','3','4']
prompt.showToast({ if(!arr.includes(this.param.pztd)){
promptAction.showToast({
message: '请填写正确的拍照通道', message: '请填写正确的拍照通道',
duration: 3000 duration: 3000
}) })
return return
} }
// var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } try{
var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.pztd}/main/av_stream`; const buffer =await takePhoto(this.param,this.context,1,'pz/')
// let view: Uint8Array = new Uint8Array(buffer); // 使用Uint8Array读取arrayBuffer的数据
var mediaTest = mediaLibrary.getMediaLibrary(this.context); // let textDecoder: util.TextDecoder = util.TextDecoder.create(); // 调用util模块的TextDecoder类
let mediaType = mediaLibrary.MediaType.IMAGE; // const str = textDecoder.decodeWithStream(view).trim(); // 对view解码
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE; // console.log("daihai base64 str = " + str);
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); // console.log("daihai base64 length = " + str.length);
const randomNum = Math.floor(Math.random() * 100) promptAction.showToast({
mediaTest.createAsset(mediaType, "picture_record" + randomNum + ".jpg", path, (error, asset) => {
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/picture_record" + randomNum + ".jpg"
var result3 = onvifclient.getVideoSnapshot(video_uri, file_path, fd);
fs.closeSync(fd);
asset.close(fd);
prompt.showToast({
message: '抓图完成', message: '抓图完成',
duration: 3000 duration: 3000
}) })
} else { // takePhoto(this.param,this.context,1,'pz/').then((data) => {
console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error); // console.log('daihai suc')
} promptAction.showToast({
}); message: '抓图完成',
}); duration: 3000
})
// }).catch((err) => {
// console.log('daihai err: ' + err)
// })
}catch (error){
console.log('daihai',error)
}
// let mediaType = mediaLibrary.MediaType.FILE;
// let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
// const path = await this.mediaTest.getPublicDirectory(DIR_IMAGE);
// const asset = await this.mediaTest.createAsset(mediaType, 'picture_record'+randomNum+'.jpg', path);
// console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString);
}) })
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
}.margin({ right: 38 * this.ratio, top: 110 * this.ratio }) }.margin({ right: 38 * this.ratio, top: 110 * this.ratio })
}.backgroundColor('#1A1A1A') }.backgroundColor('#1A1A1A')
Column() { // Column() {
Text('提示信息:') // Text('提示信息:')
.fontSize(18 * this.ratio) // .fontSize(18 * this.ratio)
.fontColor('#fff') // .fontColor('#fff')
.margin({ left: 29 * this.ratio, top: 13 * this.ratio }) // .margin({ left: 29 * this.ratio, top: 13 * this.ratio })
.align(Alignment.Start) // .align(Alignment.Start)
.width('100%') // .width('100%')
}.width('100%').height(70 * this.ratio).backgroundColor('#333230').position({ x: 0, y: 470 * this.ratio }) // }.width('100%').height(70 * this.ratio).backgroundColor('#333230').position({ x: 0, y: 470 * this.ratio })
if (this.showFlag) { if (this.showFlag) {
Column() { Column() {
@ -401,7 +259,7 @@ struct Index {
Column() { Column() {
Row() { Row() {
Text('视频路数').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 13 * this.ratio }) Text('视频路数').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 13 * this.ratio })
TextInput({ text: this.videoNum, controller: this.inputController }) TextInput({ text: this.param.videoNum, controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
.borderRadius(0) .borderRadius(0)
.width(34 * this.ratio) .width(34 * this.ratio)
@ -414,10 +272,10 @@ struct Index {
}) })
Column() { Column() {
Image($r('app.media.shang')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { Image($r('app.media.shang')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => {
this.videoNum = (parseInt(this.videoNum) + 1).toString() this.param.videoNum = (parseInt(this.param.videoNum) + 1).toString()
}) })
Image($r('app.media.xia')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { Image($r('app.media.xia')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => {
this.videoNum = (parseInt(this.videoNum) - 1).toString() this.param.videoNum = (parseInt(this.param.videoNum) - 1).toString()
}) })
}.margin({ left: 5 * this.ratio, right: 10 * this.ratio }) }.margin({ left: 5 * this.ratio, right: 10 * this.ratio })
@ -461,11 +319,6 @@ struct Index {
.height(26 * this.ratio) .height(26 * this.ratio)
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.margin({ left: 10 * this.ratio, right: 15 * this.ratio }) .margin({ left: 10 * this.ratio, right: 15 * this.ratio })
// Select([{ value: '一路',},
// { value: '二路', },
// { value: '三路',},
// { value: '四路' }]).width(67 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio })
Text('信号大小').fontColor('#333333').fontSize(16 * this.ratio) Text('信号大小').fontColor('#333333').fontSize(16 * this.ratio)
TextInput({ text: this.param.spls, controller: this.inputController }) TextInput({ text: this.param.spls, controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
@ -492,7 +345,6 @@ struct Index {
Row() { Row() {
Row() { Row() {
}.width(70 * this.ratio) }.width(70 * this.ratio)
Text('IP地址') Text('IP地址')
.width(158 * this.ratio) .width(158 * this.ratio)
.fontSize(16 * this.ratio) .fontSize(16 * this.ratio)
@ -525,8 +377,9 @@ struct Index {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
} }
ForEach(this.lsArr,(item,index)=>{
Row() { Row() {
Text('第一路') Text(item.key)
.width(70 * this.ratio) .width(70 * this.ratio)
.fontColor('#333333') .fontColor('#333333')
.fontSize(16 * this.ratio) .fontSize(16 * this.ratio)
@ -542,7 +395,7 @@ struct Index {
.onChange((value: string) => { .onChange((value: string) => {
this.param.ip = value this.param.ip = value
}) })
TextInput({ text: this.param.td1, controller: this.inputController }) TextInput({ text: this.param['td'+(Number(index)+1)], controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
.borderRadius(2) .borderRadius(2)
.width(96 * this.ratio) .width(96 * this.ratio)
@ -551,7 +404,7 @@ struct Index {
.margin({ right: 10 * this.ratio }) .margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.onChange((value: string) => { .onChange((value: string) => {
this.param.td1 = value this.param['td'+(Number(index)+1)] = value
}) })
TextInput({ text: this.param.userName, controller: this.inputController }) TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
@ -587,212 +440,11 @@ struct Index {
this.param.port = value this.param.port = value
}) })
}.margin({ top: 10 * this.ratio }) }.margin({ top: 10 * this.ratio })
})
Row() {
Text('第二路')
.width(70 * this.ratio)
.fontColor('#333333')
.fontSize(16 * this.ratio)
.textAlign(TextAlign.Center)
TextInput({ text: this.param.ip, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.padding({ top:0,bottom:0 })
.width(158 * this.ratio)
.height(26 * this.ratio)
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.ip = value
})
TextInput({ text: this.param.td2, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(96 * this.ratio)
.height(26 * this.ratio)
.margin({ right: 10 * this.ratio })
.padding({ top:0,bottom:0 })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.td2 = value
})
TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(120 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.userName = value
})
TextInput({ text: this.param.pwd, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.padding({ top:0,bottom:0 })
.width(120 * this.ratio)
.height(26 * this.ratio)
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.pwd = value
})
TextInput({ text: this.param.port, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(60 * this.ratio)
.padding({ top:0,bottom:0 })
.height(26 * this.ratio)
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.port = value
})
}.margin({ top: 10 * this.ratio })
Row() {
Text('第三路')
.width(70 * this.ratio)
.fontColor('#333333')
.fontSize(16 * this.ratio)
.textAlign(TextAlign.Center)
TextInput({ text: this.param.ip, controller: this.inputController })
.type(InputType.Normal)
.fontSize(this.inputFontSize*this.ratio)
.borderRadius(2)
.width(158 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.onChange((value: string) => {
this.param.ip = value
})
TextInput({ text: this.param.td3, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(96 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.td3 = value
})
TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(120 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.userName = value
})
TextInput({ text: this.param.pwd, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(120 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.pwd = value
})
TextInput({ text: this.param.port, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(60 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.fontSize(this.inputFontSize*this.ratio)
.margin({ right: 10 * this.ratio })
.onChange((value: string) => {
this.param.port = value
})
}.margin({ top: 10 * this.ratio })
Row() {
Text('第四路')
.width(70 * this.ratio)
.fontColor('#333333')
.fontSize(16 * this.ratio)
.textAlign(TextAlign.Center)
TextInput({ text: this.param.ip, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(158 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.fontSize(this.inputFontSize*this.ratio)
.margin({ right: 10 * this.ratio })
.onChange((value: string) => {
this.param.ip = value
})
TextInput({ text: this.param.td4, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(96 * this.ratio)
.height(26 * this.ratio)
.fontSize(this.inputFontSize*this.ratio)
.margin({ right: 10 * this.ratio })
.padding({ top:0,bottom:0 })
.onChange((value: string) => {
this.param.td4 = value
})
TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(120 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.userName = value
})
TextInput({ text: this.param.pwd, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(120 * this.ratio)
.height(26 * this.ratio)
.margin({ right: 10 * this.ratio })
.padding({ top:0,bottom:0 })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.param.pwd = value
})
TextInput({ text: this.param.port, controller: this.inputController })
.type(InputType.Normal)
.borderRadius(2)
.width(60 * this.ratio)
.height(26 * this.ratio)
.padding({ top:0,bottom:0 })
.margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize*this.ratio)
.onChange((value: string) => {
this.oldParam.port = value
})
}.margin({ top: 10 * this.ratio })
}.width(672 * this.ratio).height(174 * this.ratio).backgroundColor('#EDEBE8') }.width(672 * this.ratio).height(174 * this.ratio).backgroundColor('#EDEBE8')
Column() { Column() {
Row() {
// Text('录像方式').fontSize(16*this.ratio).fontColor('#333333')
// TextInput({ text: this.param.spls, controller: this.inputController })
// .type(InputType.Number)
// .borderRadius(0)
// .width(160 * this.ratio)
// .height(26 * this.ratio)
// .margin({ left: 10 * this.ratio })
// Select([{ value: '一路',},
// { value: '二路', },
// { value: '三路',},
// { value: '四路' }]).width(160 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio })
}
Row() { Row() {
Text('录像范围').fontSize(16 * this.ratio).fontColor('#333333').margin({ top: 10 * this.ratio }) Text('录像范围').fontSize(16 * this.ratio).fontColor('#333333').margin({ top: 10 * this.ratio })
Row() { Row() {
@ -954,49 +606,14 @@ struct Index {
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.padding({ top: 0, bottom: 0 }) .padding({ top: 0, bottom: 0 })
}.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF') }.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF')
// Flex(){
// Text('本考车对应视频合成信息处理系统IP、本地响应端口')
// .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio})
// TextInput({ text: this.param.spls, controller: this.inputController })
// .type(InputType.Number)
// .borderRadius(0)
// .width(200 * this.ratio)
// .height(26 * this.ratio)
// .margin({ left: 10 * this.ratio })
// TextInput({ text: this.param.spls, controller: this.inputController })
// .type(InputType.Number)
// .borderRadius(0)
// .width(58 * this.ratio)
// .height(26 * this.ratio)
// .margin({ left: 10 * this.ratio })
// Text('填错或不填将可能导致录像丢失')
// .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio})
// }.align(Alignment.Start).margin({top:10*this.ratio})
// Flex(){
// Text('本考车对应视频合成服务器IP、端口')
// .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio})
// TextInput({ text: this.param.spls, controller: this.inputController })
// .type(InputType.Number)
// .borderRadius(0)
// .width(200 * this.ratio)
// .height(26 * this.ratio)
// .margin({ left: 10 * this.ratio })
// TextInput({ text: this.param.spls, controller: this.inputController })
// .type(InputType.Number)
// .borderRadius(0)
// .width(58 * this.ratio)
// .height(26 * this.ratio)
// .margin({ left: 10 * this.ratio })
// Text('填错将不能开始考试')
// .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio})
// }.align(Alignment.Start).margin({top:10*this.ratio})
}.width(946 * this.ratio).height(336 * this.ratio).backgroundColor('#E5E3DF').margin({ top: 13 * this.ratio }) }.width(946 * this.ratio).height(336 * this.ratio).backgroundColor('#E5E3DF').margin({ top: 13 * this.ratio })
} }
.width('100%') .width('100%')
.height(395 * this.ratio) .height(395 * this.ratio)
.backgroundColor('#CCC4B8') .backgroundColor('#CCC4B8')
.position({ x: 0, y: 146 * this.ratio }) .position({ x: 0, y: 260 * this.ratio })
.border({ radius: { topLeft: 24 * this.ratio, topRight: 24 * this.ratio } }) .border({ radius: { topLeft: 24 * this.ratio, topRight: 24 * this.ratio } })
} }
@ -1007,139 +624,34 @@ struct Index {
this.openFlag = true this.openFlag = true
const fileUtil = new FileUtil(this.context) const fileUtil = new FileUtil(this.context)
this.fileUtil = fileUtil this.fileUtil = fileUtil
//获取参数配置
// this.vocObj = new voiceService(async (status, val) => {
// if (status == 'idle') {
//
// }
// });
this.getVideoConfig() this.getVideoConfig()
// return
// // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd }
//
// var
// loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' }
//
// // var result = onvifclient.getAllOSD(loginInfo);
// // var create_str = "{\"VideoSourceToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}"
// var create_str = {
// "ConfigurationToken": "VideoSourceToken",
// "Type": "Text",
// "PositionType": "Custom",
// "Position_X": 0.15454499125480652,
// "Position_Y": -0.477780294418335,
// "TextType": "Plain",
// "FontSize": 32,
// "PlainText": "Camera 99"
// }
// var result = onvifclient.createOSD(loginInfo, JSON.stringify(create_str));
// console.info(`baoyihu createOSD end result:` + result.result + ` dataString:` + result.dataString);
// console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString );
// var set_str = {"ConfigurationToken": "VideoSourceToken","OSDToken": "OsdToken_100","Type": "Text","PositionType": "Custom","Position_X": 0.45454499125480652,"Position_Y": -0.077780294418335,"TextType": "Plain","FontSize": 32,"PlainText": "baoyihu shige dahaoren"}
// console.info('Index onPageShow');
} }
async getfilehandleCode(td){
const record_handle = await startRecordVideo(this.param,td,this.context,'lp')
this.rocordHandleObj['rocord_handle'+td]=record_handle
}
outClick() { outClick() {
this.openFlag = false this.openFlag = false
} }
async init() {
}
async onPageShow() { async onPageShow() {
} }
async getVideoConfig() { async getVideoConfig() {
const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/config3.txt'); const data = await this.fileUtil.readFile(configAddress.comoonfileWriteAddress+'/config/config3.txt');
this.oldParam = JSON.parse(data) this.oldParam = JSON.parse(data)
this.param = JSON.parse(data) this.param = JSON.parse(data)
} }
async writeConfig() { async writeConfig() {
this.oldParam = JSON.parse(JSON.stringify(this.param)) this.oldParam = JSON.parse(JSON.stringify(this.param))
const param = { this.videoArr=JSON.parse(JSON.stringify(this.videoArr))
videoNum: this.videoNum, //视频路数 console.log('videoArr',JSON.stringify(this.videoArr))
faceFlag: this.param.faceFlag, //启用人脸比对 console.log('videoArr2',JSON.stringify(this.param))
pztd: this.param.pztd, //拍照通道
ljlx: this.param.ljlx,
ip: this.param.ip,
port: this.param.port,
userName: this.param.userName,
pwd: this.param.pwd,
td1: this.param.td1,
td2: this.param.td2,
td3: this.param.td3,
td4: this.param.td4,
wz: this.param.wz,
text3: this.param.text3,
text2: this.param.text2,
text1: this.param.text1,
dolt: this.param.dolt,
shuiying: this.param.shuiying,
fontSize: this.param.fontSize,
rlls: this.param.rlls,
videoRecord1:this.param.videoRecord1,
videoRecord2:this.param.videoRecord2,
videoRecord3:this.param.videoRecord3,
videoRecord4:this.param.videoRecord4
}
const folderPath = await this.fileUtil.initFolder(`/config`); const folderPath = await this.fileUtil.initFolder(`/config`);
this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(param), 'overWrite') this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite')
this.showFlag = false this.showFlag = false
// if(this.param.shuiying) {
// //查询水印
// var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' }
// var result = onvifclient.getAllOSD(loginInfo);
// console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString );
// let text=''
// if(this.param.dolt!=''){
// if(this.param.text1){
// text+=this.param.text1
// }
// if(this.param.text2){
// text+=this.param.dolt+this.param.text2
// }
// if(this.param.text3){
// text+=this.param.dolt+this.param.text3
// }
// }
// else{
// if(this.param.text1){
// text+=this.param.text1
// }
// if(this.param.text2){
// text+=','+this.param.text2
// }
// if(this.param.text3){
// text+=','+this.param.text3
// }
// }
// let x='0';
// let y='0'
// if(this.param.wz){
// x=this.param.wz.split(',')[0]
// y=this.param.wz.split(',')[0]
// }
// if(result.result){
// //存在
// var set_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"OSDToken\": \"OsdToken_100\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\":${x},\"Position_Y\": ${y},\"TextType\": \"Plain\",\"FontSize\": ${this.param.fontSize},\"PlainText\": \"${text}\"}`
// var result = onvifclient.setOSD(loginInfo,set_str);
// }else{
// var create_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}`
// var result = onvifclient.createOSD(loginInfo,create_str);
// console.info( `baoyihu createOSD end result:`+result.result+ ` dataString:`+result.dataString );
// }
// }else{
// // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd }
//
// var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' }
// var result1 = onvifclient.deleteOSD(loginInfo,"OsdToken_102");
// console.info( `baoyihu deleteOSD end result:`+result1.result+ ` dataString:`+result1.dataString );
// }
// const isEdit = this.fileUtilObj.editFile(`${folderPath}/videoConfig.txt`,param.toString())
} }
} }

View File

@ -1,32 +1,19 @@
//@ts-ignore //@ts-ignore
import camera from '@ohos.multimedia.camera';
import image from '@ohos.multimedia.image'
import util from '@ohos.util'; import util from '@ohos.util';
import { writeFile } from '../../common/service/fileService'
import TopLogo from '../compontents/topLogo'
import { cameraService } from '../../common/service/cameraService'
import { voiceService } from '../../common/service/voiceService' import { voiceService } from '../../common/service/voiceService'
import { faceCompare } from '../../api/userInfo' import { faceCompare } from '../../api/userInfo'
import prompt from '@ohos.prompt'
import grantPermission from '../../common/utils/PermissionUtils';
import CameraModel from '../../common/service/CameraModel';
import FileUtil from '../../common/utils/File' import FileUtil from '../../common/utils/File'
import { VideoConfig } from '../interfaces' import { VideoConfig } from '../interfaces'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import fs from '@ohos.file.fs'
import onvifclient from '@ohos.onvifclient';
import buffer from '@ohos.buffer';
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
// import MediaModel from '../../common/utils/MediaModel'; import { string2Bytes } from '../../common/utils/tools'
let previewWidth; import { takePhoto } from '../../common/service/videoService'
let previewHeight; import configAddress from '../../common/utils/FileConfig'
const PERMISSIONS: Array<string> = [
'ohos.permission.CAMERA']
@Component @Component
export default struct FaceCompare { struct FaceCompare {
constructor() { constructor() {
super() super()
} }
@ -35,21 +22,16 @@ export default struct FaceCompare {
@Prop sfzh: string; @Prop sfzh: string;
@Prop lsh: string; @Prop lsh: string;
@Prop firstImage: string; @Prop firstImage: string;
@Link showFaceCompare: boolean;
@Link faceCompareSucess: number; @Link faceCompareSucess: number;
@Link showFaceCompare: boolean;
@Link getqkFlag: boolean; @Link getqkFlag: boolean;
@Link faceCatchImg: string; @Link faceCatchImg: string;
@State imageThumbnail: string = ''; @State imageThumbnail: string = '';
private timer = null; //人脸比对执行任务定时器
private stopClose = false; // 阻止用户关闭此组件
private times = 1; //人脸比对失败次数, 超过3次将不会自动比对需要点击重新打开重新触发 private times = 1; //人脸比对失败次数, 超过3次将不会自动比对需要点击重新打开重新触发
private vocObj = null; private vocObj = null;
@State callBackFlag: boolean = false; @State callBackFlag: boolean = false;
@State @Watch('changeFaceCompareSuccess') showFaceCompare2: Boolean = false; @State @Watch('clearIntervalFn') showFaceCompareFlag: Boolean = false;
private surfaceId: string = '';
@State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream' @State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream'
private fileAsset: mediaLibrary.FileAsset = undefined;
@State previewUri: Resource = $r('app.media.2_nor') @State previewUri: Resource = $r('app.media.2_nor')
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State showControls: boolean = false @State showControls: boolean = false
@ -58,10 +40,9 @@ export default struct FaceCompare {
@State signNum: number = 0; @State signNum: number = 0;
private fileUtil: FileUtil private fileUtil: FileUtil
private interval: any private interval: any
private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext)
private fd: number = -1;
@State param: VideoConfig = { @State param: VideoConfig = {
spls: '', spls: '',
videoNum: '1',
faceFlag: false, faceFlag: false,
pztd: '1', pztd: '1',
ljlx: '', ljlx: '',
@ -93,7 +74,7 @@ export default struct FaceCompare {
Row() { Row() {
Row() { Row() {
Video({ Video({
src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`, src: this.showFaceCompare ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream` : '',
previewUri: this.previewUri, previewUri: this.previewUri,
currentProgressRate: PlaybackSpeed.Speed_Forward_1_00_X, currentProgressRate: PlaybackSpeed.Speed_Forward_1_00_X,
controller: this.controller, controller: this.controller,
@ -107,6 +88,7 @@ export default struct FaceCompare {
.width('48%') .width('48%')
.height('100%') .height('100%')
Row() { Row() {
Image(this.firstImage) Image(this.firstImage)
.width('100%') .width('100%')
@ -146,9 +128,7 @@ export default struct FaceCompare {
.backgroundImageSize({ width: '100%', height: '100%' }) .backgroundImageSize({ width: '100%', height: '100%' })
.onClick(async () => { .onClick(async () => {
this.times = 1; this.times = 1;
// this.takePhoto('face_check.mp3');
// this.readyToTakePhoto(this.surfaceId);
// await this.cameraObj.releaseSource()
}) })
} }
.width('88.9%') .width('88.9%')
@ -174,29 +154,11 @@ export default struct FaceCompare {
.backgroundImage($r('app.media.close')) .backgroundImage($r('app.media.close'))
.backgroundImageSize({ width: '100%', height: '100%' }) .backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => { .onClick(() => {
// prompt.showToast({
// message: '人脸比对程序正在执行,请等待程序执行完毕。',
// duration: 3000
// });
this.controller.stop() this.controller.stop()
this.vocObj && this.vocObj.releasePlayer() this.vocObj && this.vocObj.releasePlayer()
this.showFaceCompare = false this.showFaceCompare = !this.showFaceCompare
this.showFaceCompare2 = false this.showFaceCompareFlag=!this.showFaceCompareFlag
this.faceCompareSucess = -1 this.faceCompareSucess = -1
return
console.log('jiangsong close the faceCompare componet');
if (!this.stopClose) {
this.showFaceCompare = false
this.showFaceCompare2 = false
} else {
prompt.showToast({
message: '人脸比对程序正在执行,请等待程序执行完毕。',
duration: 3000
});
this.showFaceCompare = false
}
}) })
} }
.width('100%') .width('100%')
@ -206,97 +168,51 @@ export default struct FaceCompare {
} }
onPageShow() { onPageShow() {
// this.cameraModel.initCamera(this.surfaceId);
} }
changeFaceCompareSuccess(){
async aboutToAppear() {
const fileUtil = new FileUtil(this.context)
this.fileUtil = fileUtil
this.getVideoConfig()
}
clearIntervalFn() {
this.callBackFlag = false this.callBackFlag = false
clearInterval(this.interval) clearInterval(this.interval)
this.vocObj && this.vocObj.releasePlayer() this.vocObj && this.vocObj.releasePlayer()
} }
async aboutToAppear() {
this.callBackFlag=false
clearInterval(this.interval)
// this.mediaModel = MediaModel.getMediaInstance();
const fileUtil = new FileUtil(this.context)
this.fileUtil = fileUtil
this.getVideoConfig()
// this.cameraModel.setTakePictureHandleCallback(this.takePictureHandle.bind(this));
}
getqkFn() { getqkFn() {
let tmpList = []; let tmpList = [];
// const str =globalThis.signNum tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
// for (let i = 0;i < str.length; i++) { const param = {
// tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) id: 41,
// } list: tmpList,
// const arr = [globalThis.signNum||0, globalThis.statue||1] carNo: globalThis.carInfo.carNo,
// let tmpList = []; placeId: globalThis.carInfo.examinationRoomId
tmpList.push(this.string2Bytes(globalThis.signNum, 1 * 8)[0]) }
const param= {id: 41,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
globalThis.udpClient2.sendMsg(param, this.context) globalThis.udpClient2.sendMsg(param, this.context)
} }
async faceComparFn() { async faceComparFn() {
var loginInfo1 = { console.log('mmmmm0',1)
host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd }
// var file_dir = "/data/service/el1/public/netmanager/ethernet/";
// var result3 = onvifclient.getVideoSnapshot(loginInfo1, video_uri, file_dir);
// console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString);
var mediaTest = mediaLibrary.getMediaLibrary(this.context);
let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
const fileName = 'FaceCompar' + Math.floor(Math.random() * 1000) + '.jpg' const result = await takePhoto(this.param, this.context, 1,'jt/')
mediaTest.createAsset(mediaType, fileName, path, (error, asset) => { console.log('mmmmm8',9)
asset.open('rw', (error, fd) => {
if (fd > 0) {
var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/" + fileName
var result3 = onvifclient.getVideoSnapshot(`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`, file_path, fd);
fs.closeSync(fd);
asset.close(fd);
// let filePath = pathDir + "/test.txt";
fs.lstat(file_path).then((stat) => {
console.info("get link status succeed, the size of file is" + stat.size);
let file = fs.openSync(file_path, fs.OpenMode.READ_WRITE);
const size = Number(stat.size) + 100
let buf = new ArrayBuffer(size);
let num = fs.readSync(file.fd, buf);
var that = new util.Base64();
var array = new Uint8Array(buf);
var result = that.encodeToStringSync(array); //base64圖片
//
mediaTest.deleteAsset(file_path).then(() => {
console.log('delSuccess')
}).catch(() => {
console.log('delError')
})
this.fileUtil.deleteF(file_path, 3)
if(this.firstImage){
this.faceCatchImg = result
}else{
this.faceCatchImg = ''
}
faceCompare({ faceCompare({
sfzh: this.sfzh, sfzh: this.sfzh,
firstImage: this.firstImage.substr(22), firstImage: this.firstImage.substr(22),
// sfzh: '321281198605076819',
// firstImage: this.firstImage,
secondImage: result, secondImage: result,
type: 2, type: 2,
verifyType: 1 verifyType: 1
}).then(res => { }).then(res => {
console.log('mmmmm8',res)
if (res) { if (res) {
this.controller.stop() this.controller.stop()
console.log('jiangsong face compare success' + JSON.stringify(res)) this.showFaceCompare = !this.showFaceCompare
this.showFaceCompare = false this.showFaceCompareFlag=!this.showFaceCompareFlag
this.showFaceCompare2 = false
this.faceCompareSucess = 1; this.faceCompareSucess = 1;
// this.faceCatchImg = result // this.faceCatchImg = result
this.vocObj.playAudio({ this.vocObj.playAudio({
@ -304,116 +220,72 @@ export default struct FaceCompare {
name: 'yzcg.wav' name: 'yzcg.wav'
}) })
} else { } else {
console.log('jiangsong face compare faild')
// this.showFaceCompare = false
// this.faceCompareSucess = false;
this.times++; this.times++;
//3s后开始语音提示 //3s后开始语音提示
this.vocObj.playAudio({ this.vocObj.playAudio({
type: 1, type: 1,
name: 'face_fail.mp3' name: 'face_fail.mp3'
}) })
// this.timer = setTimeout(() => {
// this.takePhoto('face_fail.mp3');
// }, 3000)
}
})
// console.log(result)
//result base64
// this.fileUtil.deleteF(file_path,3)
}).catch((err) => {
console.info("get link status failed with error message: " + err.message + ", error code: " + err.code);
});
} else {
console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error);
}
});
});
} }
})
}
async heartMsg(context) { async heartMsg(context) {
let tmpList = [] let tmpList = []
const str = this.lsh const str = this.lsh
for (let i = 0;i < str.length; i++) { for (let i = 0;i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
} }
const param = { id: 46, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId,callback:()=>{ const param = {
console.log('46send') id: 46,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId,
sendCallback: () => {
this.callBackFlag = true this.callBackFlag = true
}} }
}
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context)
this.interval = setInterval(() => { this.interval = setInterval(() => {
console.log('klklklk',this.callBackFlag)
if (this.callBackFlag) { if (this.callBackFlag) {
console.log('klklklk') const param2 = {
const param2 = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } id: 47,
list: tmpList,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId,
}
globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context) globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context)
} }
}, 1000) }, 1000)
// const param = { id: 31, list: tmpList, carNo: 489, placeId: 62 } globalThis.udpClient2.setMsgCallBack((val) => {
globalThis.udpClient2&&globalThis.udpClient2.sendMsg(param, this.context) if (val.id == '48') {
if (val.body[13] == '1') {
this.showFaceCompareFlag=!this.showFaceCompareFlag
// return {id: 31,list:tmpList,carNo:489,placeId:62} this.showFaceCompare = !this.showFaceCompare
this.vocObj && this.vocObj.releasePlayer()
this.faceCompareSucess = 1
clearInterval(this.interval)
} else if (val.body[13] == '0' && this.callBackFlag) {
globalThis.statue = 2
this.vocObj && this.vocObj.playAudio({
type: 1,
name: 'face_chekc_fail.wav'
})
} }
}
})
}
async getVideoConfig() { async getVideoConfig() {
const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/config3.txt'); console.log('faceEnterIn')
console.log('data,data',data)
if(!data){
this.vocObj = new voiceService(async (status, val, next) => {
if (status == 'idle') {
if (val == 'face_check.mp3' || val == 'face_fail.mp3') {
console.log('this.time',this.times)
if (this.times >=3) {
this.vocObj&&this.vocObj.playAudio({
type: 1,
name: 'face_checking.wav'
})
// this.showFaceCompare = false
globalThis.statue=3
this.faceCompareSucess = -1;
this.heartMsg(this.context)
}else{
setTimeout(()=>{
this.faceComparFn()
},2000)
}
} else if (val == 'yzcg.wav') {
// this.sfbdinterfaceFn()
this.showFaceCompare = false
this.showFaceCompare2 = false
this.vocObj&&this.vocObj.releasePlayer()
globalThis.statue=4
this.faceCompareSucess = 1;
}else if(val=='face_checking.wav'){
// globalThis.statue=3
this.faceCompareSucess = -1;
this.callBackFlag=false
this.vocObj&&this.vocObj.releasePlayer()
}else if(val=='face_chekc_fail.wav'){
this.vocObj&&this.vocObj.releasePlayer()
this.faceCompareSucess=-1
this.showFaceCompare = false
this.showFaceCompare2 = false
this.callBackFlag=false
}
}
});
return
}
this.param = JSON.parse(data)
// this.param.userName = JSON.parse(data).userName
// this.param.ip = JSON.parse(data).ip
// this.param.pwd = JSON.parse(data).pwd
// this.param.port = JSON.parse(data).port
// this.param.rlls = JSON.parse(data).rlls
console.log('this.parm', this.param.userName, this.param.pwd, this.param.ip, this.param.port, this.param.rlls)
this.controller.start()
// this.video_url = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`;
this.vocObj = new voiceService(async (status, val, next) => { this.vocObj = new voiceService(async (status, val, next) => {
if (status == 'idle') { if (status == 'idle') {
if (val == 'face_check.mp3' || val == 'face_fail.mp3') { if (val == 'face_check.mp3' || val == 'face_fail.mp3') {
if (this.times >= 3) { if (this.times >= 3) {
// this.showFaceCompare = false
globalThis.statue = 3 globalThis.statue = 3
this.faceCompareSucess = -1; this.faceCompareSucess = -1;
this.vocObj && this.vocObj.playAudio({ this.vocObj && this.vocObj.playAudio({
@ -427,9 +299,8 @@ export default struct FaceCompare {
}, 2000) }, 2000)
} }
} else if (val == 'yzcg.wav') { } else if (val == 'yzcg.wav') {
// this.sfbdinterfaceFn() this.showFaceCompare = !this.showFaceCompare
this.showFaceCompare = false this.showFaceCompareFlag=!this.showFaceCompareFlag
this.showFaceCompare2 = false
globalThis.statue = 4 globalThis.statue = 4
this.faceCompareSucess = 1; this.faceCompareSucess = 1;
this.vocObj && this.vocObj.releasePlayer() this.vocObj && this.vocObj.releasePlayer()
@ -437,120 +308,35 @@ export default struct FaceCompare {
} else if (val == 'face_chekc_fail.wav') { } else if (val == 'face_chekc_fail.wav') {
this.vocObj && this.vocObj.releasePlayer() this.vocObj && this.vocObj.releasePlayer()
this.faceCompareSucess = -1 this.faceCompareSucess = -1
this.showFaceCompare = false this.showFaceCompare = !this.showFaceCompare
this.showFaceCompare2 = false this.showFaceCompareFlag=!this.showFaceCompareFlag
this.callBackFlag=false
} }
// else if(val=='face_checking.wav'){
// // console.log('kkkk')
// this.vocObj&&this.vocObj.releasePlayer()
// // globalThis.statue=3
// // this.faceCompareSucess = -1;
// }
} }
}); });
const data = await this.fileUtil.readFile(configAddress.comoonfileWriteAddress + '/config/config3.txt');
console.log('faceEnterIn,data',data)
setTimeout(() => { setTimeout(() => {
this.vocObj && this.vocObj.playAudio({ this.vocObj && this.vocObj.playAudio({
type: 1, type: 1,
name: 'face_check.mp3' name: 'face_check.mp3'
}) })
}, 1000) }, 1000)
this.setUdp() this.param = JSON.parse(data)
// this.cameraModel.initCamera(this.surfaceId); this.param.userName = JSON.parse(data).userName
this.param.ip = this.param.ip
} this.param.pwd = this.param.pwd
setUdp(){ this.param.port = this.param.port
const that=this this.param.rlls = this.param.rlls
globalThis.udpClient2&&globalThis.udpClient2.onMessage((val)=>{ this.controller.start()
console.log('qkqkqk',val.id,val.body)
if(val.id=='32'){
globalThis.signNum=val.body[1]
if(val.body[0]=='7'){
this.getqkFn()
this.signNum=val.body[1]
}
}else if(val.id=='48'){
if(val.body[13]=='1'){
that.showFaceCompare = false
that.showFaceCompare2 = false
that.vocObj&&that.vocObj.releasePlayer()
that.faceCompareSucess=1
this.callBackFlag=false
clearInterval(that.interval)
}else if(val.body[13]=='0'&&this.callBackFlag){
this.callBackFlag=false
globalThis.statue=2
console.log('callBackFlag',this.callBackFlag)
that.vocObj&&that.vocObj.playAudio({
type: 1,
name: 'face_chekc_fail.wav'
})
}
}else if(val.id=='42'){
console.log('qkqkqk')
this.getqkFlag=!this.getqkFlag
}
})
}
fillZero(str, len) {
str = str + '';
if (str.length > len || !len) {
return str
} }
let num = len - str.length;
let zeroStr = '';
for (var i = 0; i < num; i++) {
zeroStr = zeroStr + '0'
}
return zeroStr + str;
}
// takePictureHandle = (thumbnail: string) => {
// this.imageThumbnail = thumbnail;
// };
string2Bytes(number, len) {
// console.log('string2Bytes == ', number)
let str = (+number).toString(2);
if(str.length > len) {
console.log('数据长度不对~~');
return
}
var byteString = this.fillZero(str, len);
var arrBytes = new Array();
for (var i = byteString.length; i > 0;) {
let j = i - 8;
if (j < 0) {
j = 0
}
var s = byteString.slice(j, i);
var v = parseInt(s, 2);
arrBytes.push(v);
i = i - 8
}
return arrBytes;
}
async aboutToDisappear() { async aboutToDisappear() {
// this.mediaModel = MediaModel.getMediaInstance();
} }
takePhoto(name) {
this.stopClose = true;
if (this.times > 3) {
this.stopClose = false;
return;
}
this.times++;
// this.vocObj.playAudio({
// type: 1,
// name: name
// })
}
} }
export default FaceCompare

View File

@ -1,6 +1,8 @@
// @ts-nocheck // @ts-nocheck
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import apiJudgeSdk from 'libJudgeSdk.so'; import apiJudgeSdk from 'libJudgeSdk.so';
// import apiJudgeSdk from '@ohos.judgesdk';
import Judge from '../../judgeSDK/utils/judge-real' import Judge from '../../judgeSDK/utils/judge-real'
import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d' import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d'
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
@ -37,6 +39,7 @@ struct RealTime {
id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称注意这个ID要和C++侧一致,不能变 id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称注意这个ID要和C++侧一致,不能变
type: 'surface', type: 'surface',
libraryname: 'JudgeSdk' libraryname: 'JudgeSdk'
// libraryname: 'judgesdk'
}) })
.width(this.width) .width(this.width)
.height(this.height) .height(this.height)

View File

@ -1,4 +1,5 @@
import libJudgeSdk from 'libJudgeSdk.so' import libJudgeSdk from 'libJudgeSdk.so'
// import libJudgeSdk from '@ohos.judgesdk'
/** /**
* *

View File

@ -530,6 +530,7 @@ export const testRealExam = {
}, },
"extend": {} "extend": {}
} }
export const testAllitems = [ export const testAllitems = [
{name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'1'}, {name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'1'},
{name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'2'}, {name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'2'},

View File

@ -109,6 +109,7 @@ export default class Judge{
if(isTrajectoryOpen){ if(isTrajectoryOpen){
beginExamInfo = JSON.parse(strArr[1]) beginExamInfo = JSON.parse(strArr[1])
}else{ }else{
//获取开始考试数据
beginExamInfo = await getJudgeBeginData() beginExamInfo = await getJudgeBeginData()
} }
await fileLog.setExamJudgeData(beginExamInfo) await fileLog.setExamJudgeData(beginExamInfo)
@ -153,6 +154,7 @@ export default class Judge{
const udpIndex = globalThis.udpIndex; const udpIndex = globalThis.udpIndex;
if(udpIndex % 5 === 0){ if(udpIndex % 5 === 0){
const judgeUdp = globalThis.judgeUdp const judgeUdp = globalThis.judgeUdp
//平台实时轨迹心跳
const bytes= await this.getMessageHeartbeat(); const bytes= await this.getMessageHeartbeat();
judgeUdp.send(bytes) judgeUdp.send(bytes)
} }
@ -295,14 +297,14 @@ export default class Judge{
//处理考试结束 //处理考试结束
public handEndExam = async ()=>{ public handEndExam = async ()=>{
const {isExam,judgeUI,endExam,avPlayer} = this; const {endExam,avPlayer} = this;
avPlayer.playAudio(['km2/exam_waiting.mp3'],true) avPlayer.playAudio(['km2/exam_waiting.mp3'],true)
this.isEnd = true this.isEnd = true
// 获取最后一次心跳
const bytes = await this.getMessageHeartbeat(true); const bytes = await this.getMessageHeartbeat(true);
const singlePlay = globalThis.singlePlay const singlePlay = globalThis.singlePlay
singlePlay || globalThis.judgeUdp.send(bytes) singlePlay || globalThis.judgeUdp.send(bytes)
//结束评判函数 // c++调用考试结束
await examJudgeEndExam(); await examJudgeEndExam();
globalThis.isJudge = false globalThis.isJudge = false
await endExam() await endExam()
@ -333,10 +335,14 @@ export default class Judge{
const markRuleListObj = this.judgeUI.markRuleListObj; const markRuleListObj = this.judgeUI.markRuleListObj;
const thisMark = markRuleListObj[code] const thisMark = markRuleListObj[code]
return { return {
//扣分描述
desc: thisMark.markshow, desc: thisMark.markshow,
//扣分分数
score: thisMark.markreal, score: thisMark.markreal,
markcatalog: thisMark.markcatalog, markcatalog: thisMark.markcatalog,
// 扣分编码
markserial:thisMark.markserial, markserial:thisMark.markserial,
// 扣分序号
kfxh:thisMark.kfxh kfxh:thisMark.kfxh
} }
} }
@ -412,7 +418,7 @@ export default class Judge{
xtlb:'17',jkxlh:serialNumber,jkid:'17C53', xtlb:'17',jkxlh:serialNumber,jkid:'17C53',
drvexam:{ drvexam:{
lsh,kskm:examSubject, lsh,kskm:examSubject,
// 通用评判科二10000科三30000 //TODO 通用评判科二10000科三30000
ksxm:project?project.projectCodeCenter:10000, ksxm:project?project.projectCodeCenter:10000,
kfxm:kf.markcatalog, kfxm:kf.markcatalog,
kfxmmx:`${ksxm},${kf.markserial}`, kfxmmx:`${ksxm},${kf.markserial}`,
@ -486,6 +492,7 @@ export default class Judge{
if(!isManual){ if(!isManual){
if(totalScore < 80){ if(totalScore < 80){
judgeUI.loadingPopupVisible = true judgeUI.loadingPopupVisible = true
//考试次数为1次
if(kssycs == 1){ if(kssycs == 1){
avPlayer.playAudio(['km2/unqualified_one.wav'],true) avPlayer.playAudio(['km2/unqualified_one.wav'],true)
}else{ }else{
@ -648,7 +655,6 @@ export default class Judge{
let tempArr = []; let tempArr = [];
arr.forEach(itemArr =>{ tempArr = tempArr.concat(itemArr)}) arr.forEach(itemArr =>{ tempArr = tempArr.concat(itemArr)})
this.serialIndex += 1; this.serialIndex += 1;
return Array2Byte(tempArr) return Array2Byte(tempArr)
} }
@ -733,6 +739,7 @@ export default class Judge{
return sbxh return sbxh
} }
//获取场地设备编码
getSbbm = (ksxm,xmxh) => { getSbbm = (ksxm,xmxh) => {
const {judgeUI} = this; const {judgeUI} = this;
const {cdsbInfoObj,projectsObj} = judgeUI; const {cdsbInfoObj,projectsObj} = judgeUI;
@ -783,7 +790,6 @@ export default class Judge{
return modelData return modelData
} }
private judgeUI private judgeUI
private fileLog private fileLog
private totalScore:number private totalScore:number

View File

@ -1,18 +1,10 @@
import { import {
examJudgeSetLogCallback,
examJudgeBeginExam,
examJudgeInit,
examJudgeRealExam,
examJudgeSetRealExamCallback,
examJudgeMapSetParam, examJudgeMapSetParam,
examJudgeMapSetDrawing,
examJudgeMapSetScaling examJudgeMapSetScaling
} from '../api/index' } from '../api/index'
import systemTime from '@ohos.systemDateTime';
import FileUtil from '../../../common/utils/File' import FileUtil from '../../../common/utils/File'
import FileModel from './../utils/file-model' import FileModel from './../utils/file-model'
import {testRealExam} from '../dataTest/index'
const judgeTag = 'SURENJUN_JUDGE' const judgeTag = 'SURENJUN_JUDGE'

View File

@ -3,7 +3,7 @@ import { getDeviceInfo} from '../common/service/terminalService'
import { registrationDeviceNo } from '../api/checkCar' import { registrationDeviceNo } from '../api/checkCar'
import { dateFormat} from '../common/utils/tools' import { dateFormat} from '../common/utils/tools'
import deviceManager from '@ohos.distributedHardware.deviceManager' import deviceManager from '@ohos.distributedHardware.deviceManager'
import { upDateTableConfig } from '../common/service/initable' import { upDateTableByArray } from '../common/service/initable'
import { voiceService } from '../common/service/voiceService' import { voiceService } from '../common/service/voiceService'
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction'
@Entry @Entry
@ -107,7 +107,7 @@ struct Index {
type:'1' type:'1'
} }
globalThis.deviceNo=this.ip globalThis.deviceNo=this.ip
upDateTableConfig('DeviceInfoTable',[{deviceId:this.ip}]) upDateTableByArray('DeviceInfoTable',[{deviceId:this.ip}])
registrationDeviceNo(param).then(res=>{ registrationDeviceNo(param).then(res=>{
if(res.registrationDeviceNoRsp.head.resultCode=='0'){ if(res.registrationDeviceNoRsp.head.resultCode=='0'){
promptAction.showToast({ promptAction.showToast({