Compare commits

...

10 Commits

Author SHA1 Message Date
“wangzhongjie”
e53f84b3d3 提交 2024-02-23 15:23:48 +08:00
“wangzhongjie”
e6420a333d 1111 2024-02-23 10:43:11 +08:00
wangzhongjie
6db05ab2e1 feat:类型 2024-02-23 10:31:19 +08:00
wangzhongjie
a1ff0e8d2c Merge branch 'main' of http://88.22.20.16:3000/shutdown/subject-two 2024-02-23 10:10:38 +08:00
wangzhongjie
38d48e778b Merge branch 'main' of http://88.22.20.16:3000/shutdown/subject-two 2024-02-23 10:06:19 +08:00
“wangzhongjie”
62388d126a 提交 2024-02-23 10:04:12 +08:00
wangzhongjie
8e8afd92db feat: 优化 2024-02-23 10:03:43 +08:00
wangzhongjie
efc98c114b fix: 优化开始考试代码 2024-02-22 17:33:10 +08:00
“wangzhongjie”
f49c68a3a5 111 2024-02-22 13:35:56 +08:00
“wangzhongjie”
4c2515c1fb 22 2024-02-22 10:40:35 +08:00
36 changed files with 1622 additions and 3329 deletions

BIN
entry/src/main/ets/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -9,7 +9,7 @@ export async function timeSynchronization(params){
<head><time>${params.time}</time></head>
<body><deviceNo>${params.deviceNo}</deviceNo>
<shellVersion>${params.version}</shellVersion>
<judgeVersion>${params.version}</judgeVersion>
<judgeVersion>${params.judgeVersion}</judgeVersion>
</body>
</timeSynchronizationReq>`,
method:'post',

View File

@ -25,8 +25,8 @@ CommonConstants {
*/
static readonly ACCOUNT_TABLE = {
tableName: 'IpConfigTable',
sqlCreate: 'CREATE TABLE IF NOT EXISTS IpConfigTable(id INTEGER PRIMARY KEY AUTOINCREMENT,udplocalIp TEXT,udplocalIpPort TEXT, udpOppositeIp TEXT, udpOppositeIpPort TEXT,tcplocalIp TEXT,tcplocalIpPort TEXT,tcpOppositeIp TEXT,tcpOppositePort TEXT,gateway TEXT,netMask TEXT,dnsServers TEXT,centerIp TEXT,heartPort TEXT,gpsPort TEXT)',
columns: ['id','udplocalIp', 'udplocalIpPort', 'udpOppositeIp','udpOppositeIpPort','tcplocalIp','tcplocalIpPort','tcpOppositeIp','tcpOppositePort','gateway','netMask','dnsServers','centerIp','heartPort','gpsPort']
sqlCreate: 'CREATE TABLE IF NOT EXISTS IpConfigTable(id INTEGER PRIMARY KEY AUTOINCREMENT,udplocalIp TEXT,udplocalIpPort TEXT, udpOppositeIp TEXT, udpOppositeIpPort TEXT,tcplocalIp TEXT,tcplocalIpPort TEXT,tcpOppositeIp TEXT,tcpOppositePort TEXT,gateway TEXT,netMask TEXT,dnsServers TEXT)',
columns: ['id','udplocalIp', 'udplocalIpPort', 'udpOppositeIp','udpOppositeIpPort','tcplocalIp','tcplocalIpPort','tcpOppositeIp','tcpOppositePort','gateway','netMask','dnsServers']
};
/**

View File

@ -170,7 +170,7 @@ export default class Rdb {
return
}
console.log('ExecuteSqlsuccess')
callback('ExecuteSqlsuccess')
callback(true)
})
}

View File

@ -0,0 +1,127 @@
// @ts-nocheck
import promptAction from '@ohos.promptAction'
import router from '@ohos.router'
import { dateFormat} from '../utils/tools'
import FileUtil from '../../common/utils/File'
import AccountTable from '../../common/database/tables/AccountTable';
import MA_SYSSET from '../../common/constants/MA_SYSSET';
import {
getDataBaseTable,
upDateTable,
getMySystemSetTable,
delSyncTable,
upDataZhongxinginitialization
} from '../../common/service/initable'
import configAddress from '../../common/utils/FileConfig'
//配置流水号
export async function setliushuiNum(context){
const fileUtil = new FileUtil(context)
let res = fs.accessSync(configAddress.comoonfileWriteAddress+'/config/liushui.txt');
const fileData = await fileUtil.readFile(configAddress.comoonfileWriteAddress+'/config/liushui.txt');
if(res&&JSON.stringify(fileData).indexOf('u0000')<0) {
const date = new Date()
const time1 = JSON.parse(fileData).date.split(' ')[0]
const time2 = dateFormat(date).split(' ')[0]
if (time1 == time2) {
const date = new Date()
const param = {
date: dateFormat(date),
value: Number(JSON.parse(fileData).value) + 1
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
return
}
}
const date = new Date()
const param = {
date: dateFormat(date),
value: 0
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}
//双中心表
export async function getDoubleCeneterTable() {
return new Promise(async (reslove,reject)=>{
// MA_SYSSET双中心下做合并表格操作
const db = new AccountTable(() => {
}, MA_SYSSET);
db.getRdbStore(() => {
db.query('0', async (array) => {
if (array.length) {
delSyncTable('MA_SYSSET').then(async () => {
await getDataBaseTable({ tableName: 'MA_SYSSET' })
await getMySystemSetTable({ tableName: 'MA_SYSSET' })
})
} else {
await getDataBaseTable({ tableName: 'MA_SYSSET' })
await getMySystemSetTable({ tableName: 'MA_SYSSET' })
}
})
})
const typeObj = {
'MA_MARKRULE': false,
'MA_SYSTEMPARM': false,
'MA_MAP_COLLECT': false,
'MA_MAP_COLLECT_SHAPE': false,
'MA_MAP_ITEMCLASS': false,
'MA_MAP_POINT': false,
'MA_MAP_POINT_ITEM': false,
'MA_MAP_ROAD': false,
'MA_MAP_ROAD_LANE': false,
'MA_MAP_SUBITEM': false,
'ES_CARINFO': false,
'ES_EXAMPOINTDETAIL': false,
'MA_MARKRULESET': false,
'ES_CAR_VIDEO_PARAMETER': false,
'MA_CDSBINFO': false,
'MA_ITEMINFO': false,
'MA_T_CARPARMSET': false
}
for(let key in typeObj){
typeObj[key] = await upDateTable({ tableName: key })
if (!typeObj[key]) {
promptAction.showToast({
message: `未能查询到${key}表数据, 请先检查网络是否连接正常`,
duration: 3000
});
reslove(false)
return
}
}
reslove(true)
router.pushUrl({
url: 'pages/ExaminerLogin',
}, router.RouterMode.Single);
})
}
//单中心存表
export async function getSingleCenterTable() {
return new Promise((reslove,reject)=>{
upDataZhongxinginitialization().then((flag)=>{
if(flag){
router.pushUrl({
url: 'pages/ExaminerLogin',
}, router.RouterMode.Single)
reslove(true)
}else{
// router.pushUrl({
// url: 'pages/ExaminerLogin',
// }, router.RouterMode.Single)
// reslove(true)
promptAction.showToast({
message: '联网更新失败,请检查网络后重新更新',
duration: 1000
});
reslove(false)
}
}).catch((error)=>{
console.log(error)
})
})
}

View File

@ -51,6 +51,7 @@ const map = {
'MA_ITEMINFO': MA_ITEMINFO,
'MA_T_CARPARMSET': MA_T_CARPARMSET,
'ES_CAR_VIDEO_PARAMETER': ES_CAR_VIDEO_PARAMETER,
'USER':USER
}
const centerToMap={
'ItemInfo':MA_ITEMINFO,
@ -73,12 +74,11 @@ const centerToMap={
// 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER
}
function sqlInsertCommonFn(tableName,resultArr){
new Promise((reslove,reject)=>{
return new Promise((resolve,reject)=>{
const accountTable = new AccountTable(() => {
}, map[params.tableName]);
}, map[tableName]);
accountTable.getRdbStore(() => {
accountTable.query('0', async (result) => {
accountTable.query('0', (result) => {
if (result.length == 0) {
let INSERT_SQL = "INSERT INTO "+tableName
+ " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
@ -93,7 +93,7 @@ function sqlInsertCommonFn(tableName,resultArr){
str+=`"${data[res]||'1'}"`+','
}
})
if(i==res.body[tableName].length-1){
if(i==resultArr.length-1){
str+=')'
}else{
str+='),'
@ -101,37 +101,38 @@ function sqlInsertCommonFn(tableName,resultArr){
INSERT_SQL+=str
})
accountTable.sqlOperate(INSERT_SQL,tableName,()=>{
resolve(true)
accountTable.sqlOperate(INSERT_SQL,tableName,(val)=>{
resolve(val)
})
}
else {
await delSyncTable(tableName)
let INSERT_SQL = "INSERT INTO "+tableName
+ " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
delSyncTable(tableName).then(()=>{
let INSERT_SQL2 = "INSERT INTO "+tableName + " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
resultArr.map((data,i) => {
data.id=`${i}`
let str='('
map[tableName].ACCOUNT_TABLE.columns.map((res,index)=>{
if(map[tableName].ACCOUNT_TABLE.columns.length-1==index){
str+=`"${data[res]||'1'}"`
resultArr.map((data,i) => {
data.id=`${i}`
let str='('
map[tableName].ACCOUNT_TABLE.columns.map((res,index)=>{
if(map[tableName].ACCOUNT_TABLE.columns.length-1==index){
str+=`"${data[res]||'1'}"`
}else{
str+=`"${data[res]||'1'}"`+','
}
})
if(i==resultArr.length-1){
str+=')'
}else{
str+=`"${data[res]||'1'}"`+','
str+='),'
}
INSERT_SQL2+=str
})
accountTable.sqlOperate(INSERT_SQL2,tableName,(val)=>{
resolve(true)
})
if(i==res.body[tableName].length-1){
str+=')'
}else{
str+='),'
}
INSERT_SQL+=str
})
accountTable.sqlOperate(INSERT_SQL,tableName,()=>{
resolve(true)
})
}
}, true);
});
@ -200,7 +201,7 @@ export async function getDataBaseTable(params) {
}
export async function upDateTable(params) {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
const date = new Date()
let paraKdid=''
let examinationRoomId=''
@ -220,14 +221,19 @@ export async function upDateTable(params) {
}
}
const url=globalThis.timeInfo.url
let res: any = await initCenterCache(str,url)
if(!res||res==undefined||res==''){
resolve(false)
return
}
const result=await sqlInsertCommonFn(params.tableName,res.body[params.tableName])
resolve(result)
initCenterCache(str,url).then(async (res)=>{
if(!res||res==undefined||res==''){
resolve(false)
return
}
try {
const result=await sqlInsertCommonFn(params.tableName,res.body[params.tableName])
resolve(result)
}catch (error){
console.log(error)
}
})
});
}
@ -238,7 +244,7 @@ export async function upDateTableConfig(tableName,arr) {
}
//考试平台
export async function getMySystemSetTable(params) {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
const date = new Date()
if(!globalThis.timeInfo?.paraKdid){
prompt.showToast({
@ -255,13 +261,17 @@ export async function getMySystemSetTable(params) {
"typeRsp": "0" // 赋默认值0无需改变
}
}
let res: any = await initCenterCacheByKSPT(str)
if( res.body[params.tableName].length==0){
resolve();
return
}
const result=sqlInsertCommonFn(params.tableName,res.body[params.tableName])
resolve(result)
initCenterCacheByKSPT(str).then((res)=>{
if( res.body[params.tableName].length==0){
resolve();
return
}
sqlInsertCommonFn(params.tableName,res.body[params.tableName]).then((result)=>{
resolve(result)
})
})
})
}
@ -343,7 +353,7 @@ export async function getEsCarModel(context){
}
export async function upDataZhongxinginitialization(){
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
if(!globalThis.carInfo?.carId){
resolve(false)
@ -356,28 +366,33 @@ export async function upDataZhongxinginitialization(){
judgeVersion:globalThis.judgeVersion,
shellVersion: globalThis.version
}
let res: any = await initialization(str)
if(!res){
resolve(false)
return
}
let flag
for(let key in res.initializationRsp.body){
if(!centerToMap[key]){
continue
}
flag = await setSyncCenterSqlData(key,res)
if(!flag){
initialization(str).then(async(res)=>{
if(!res){
resolve(false)
return
}
}
resolve(true)
let flag
for(let key in res.initializationRsp.body){
if(!centerToMap[key]){
continue
}
try{
flag= await setSyncCenterSqlData(key,res)
}catch (error){
console.log(error)
}
if(!flag){
resolve(false)
return
}
}
resolve(true)
})
})
}
function setSyncCenterSqlData(key,res){
return new Promise(async (resolve,reject)=>{
return new Promise((resolve,reject)=>{
const mapName={
'ItemInfo':'MA_ITEMINFO',
'MarkRule':'MA_MARKRULE',
@ -406,7 +421,18 @@ function setSyncCenterSqlData(key,res){
}else{
arrList=[res.initializationRsp.body[key].record]
}
const reslut=await sqlInsertCommonFn(mapName[key],arrList)
resolve(reslut)
res
sqlInsertCommonFn(mapName[key],arrList).then((result)=>{
console.log(key,'表建立成功')
if(result){
resolve(true)
}else{
resolve(false)
}
}).catch((msg)=>{
reject(false)
console.log(msg)
})
})
}

View File

@ -4,23 +4,23 @@ import { dateFormat} from '../utils/tools'
//获取设备信息
export async function getDeviceInfo() {
// globalThis.deviceNo = 'J43405J003101'; //设备mac
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac
// globalThis.diskId = '1231231231'; //硬盘号
// globalThis.hasAuth = true;
globalThis.deviceNo = 'J43405J003101'; //设备mac
globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac
globalThis.diskId = '1231231231'; //硬盘号
globalThis.hasAuth = true;
//
// return null
return new Promise((resolve, reject) => {
getSyncData('DeviceInfoTable').then((result: Array<any>) => {
if (result.length) {
globalThis.deviceNo = result[0].deviceId
this.deviceId = result[0].deviceId
resolve(result[0].deviceId)
} else {
resolve('')
}
})
})
// return new Promise((resolve, reject) => {
// getSyncData('DeviceInfoTable').then((result: Array<any>) => {
// if (result.length) {
// globalThis.deviceNo = result[0].deviceId
// this.deviceId = result[0].deviceId
// resolve(result[0].deviceId)
// } else {
// resolve('')
// }
// })
// })
}
//获取考车信息

View File

@ -7,7 +7,7 @@ export async function timeSynchronize() {
let date = new Date();
console.info('jiangsong1:timeSynchronization begin ' );
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo,version:globalThis.version}
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo,version:globalThis.version,judgeVersion:globalThis.judgeVersion}
let res:any = await timeSynchronization(params)
res = res.timeSynchronizationRsp;
globalThis.timeInfo=res.body

View File

@ -0,0 +1,124 @@
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import onvifclient from '@ohos.onvifclient';
import fs from '@ohos.file.fs'
import util from '@ohos.util';
import configAddress from '../../common/utils/FileConfig'
import {getCurrentTime} from '../utils/tools'
//开始录屏
export async function startRecordVideo(param,td,context) {
return new Promise<videoPlayRes>(async (reslove,reject)=>{
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/" );
// const record_handle = result3.dataInt;
// console.info( `baoyihu startRecordVideo result:`+result3.result+ ` VideoFile:`+result3.dataString );
// reslove(record_handle)
// return
var mediaTest = mediaLibrary.getMediaLibrary(context);
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);
}
});
});
})
}
//结束录屏
export async function endRecordVideo(record_handle) {
if(this.record_handle >0)
{
var result = onvifclient.endRecordVideo(record_handle);
// this.record_handle = -1;
console.info( `baoyihu endRecordVideo result:`+result.result+ ` VideoFile:`+result.dataString );
}
else
{
console.info( `baoyihu endRecordVideo no task error`);
}
// var result = onvifclient.endRecordVideo(filehandle);
// fs.closeSync(filehandle);
// file_asset.close(filehandle);
}
/**
*
* @param param
* @param context
* @param type=0base64
*/
export async function takePhoto(param,context,type=0) {
return new Promise(async (reslove,reject)=>{
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
var mediaTest = mediaLibrary.getMediaLibrary(context);
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){
fs.lstat(file_path).then((stat) => {
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{
reslove('')
}
} else {
console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error);
}
});
});
})
}
export interface videoPlayRes {
rocord_handle?: number;
fd?: number;
file_asset?:any
}

View File

@ -0,0 +1,5 @@
export default {
comoonfileWriteAddress:'/mnt/hmdfs/100/account/device_view/localfiles/files',
videoSavePath:'/mnt/hmdfs/100/account/device_view/local/files/Videos/',
picSavePath:'/mnt/hmdfs/100/account/device_view/local/files/Pictures/'
}

View File

@ -1,88 +1,59 @@
import UdpClient from './UdpClient';
import UdpClientByCenter from './UdpClientByCenter';
import { getSyncData } from '../service/initable'
import { getSyncData} from '../service/initable'
import { dateFormat } from '../../common/utils/tools'
import prompt from '@ohos.prompt'
import TcpClient from './TcpClient';
// getSyncData('IpConfigTable').then((result)=>{
// console.log('result222',result)
// if(result){
// if(globalThis.udpClient){
// globalThis.udpClient.closeUdp()
// setTimeout(()=>{
// const udpClient: UdpClient =new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
// udpClient.bindUdp()
// udpClient.sendMsg('111')
// globalThis.udpClient = udpClient
// },1000)
// }else{
// const udpClient: UdpClient =new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
// udpClient.bindUdp()
// udpClient.sendMsg('111')
// globalThis.udpClient = udpClient
// }
// // globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
//
// }
// })
export async function sendMsg(val) {
globalThis.udpClient1 && globalThis.udpClient1.sendMsg(val)
export async function sendMsg(val){
globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
}
export async function getUDP() {
getSyncData('IpConfigTable').then((result: Array<any>) => {
console.log('result222', JSON.stringify(result))
if (result.length) {
if (globalThis.udpClient && globalThis.udpClient.closeUdp) {
globalThis.udpClient.closeUdp(() => {
getSyncData('IpConfigTable').then((result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
globalThis.udpClient.closeUdp(()=>{
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.rebindUdp('192.168.7.170', '20122','192.168.7.124','20022')
// setInterval(()=>{
// globalThis.udpClient.sendMsg('111')
// },1000)
globalThis.udpClient.sendMsg('111')
// globalThis.udpClient = udpClient
})
} else {
}else{
const udpClient: UdpClient = new UdpClient(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
const udpClient: UdpClient =new UdpClient(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
udpClient.bindUdp()
udpClient.sendMsg('111')
globalThis.udpClient = udpClient
}
// globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
} else {
globalThis.udpClient = {}
globalThis.udpClient.onMessage = () => {
}
}else{
globalThis.udpClient={}
globalThis.udpClient.onMessage=()=>{}
}
})
}
export async function getUDP2() {
getSyncData('IpConfigTable').then(async (result: Array<any>) => {
console.log('result222', JSON.stringify(result))
if (result.length) {
if (globalThis.udpClient2 && globalThis.udpClient2.closeUdp) {
globalThis.udpClient2.closeUdp(async () => {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
if(result.length){
if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){
globalThis.udpClient2.closeUdp(async ()=>{
// globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800','112.80.35.83','11056')
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800', result[0].centerIp, result[0].heartPort)
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))
})
})
} 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', result[0].centerIp, result[0].heartPort)
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)
@ -91,25 +62,20 @@ export async function getUDP2() {
// globalThis.udpClient2.sendMsg(heartMsg(context))
globalThis.udpClient2.onMessage((val) => {
globalThis.udpClient2.onMessage((val)=>{
if (val.id == '32') {
globalThis.signNum = val.body[1]
} else if (val.id == '46') {
if(val.id=='32'){
globalThis.signNum=val.body[1]
}else if(val.id=='46'){
let tmpList = []
console.log('lsh', globalThis.lsh)
console.log('lsh',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])
}
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)
}
@ -120,74 +86,23 @@ export async function getUDP2() {
// },1000)
})
}
} else {
globalThis.udpClient2 = {}
globalThis.udpClient2.onMessage = () => {
}
}else{
globalThis.udpClient2={}
globalThis.udpClient2.onMessage=()=>{}
}
})
}
function 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;
}
// function getByteToInt(arr){
// let a = list[0];
// let b = list[1];
// let c = '0x' + fillZero(b.toString(16),2) + fillZero(a.toString(16),2) ;
// let id = Math.floor(+c/1000)
// }
export async function getUDPByTopLine() {
getSyncData('IpConfigTable').then((result: Array<any>) => {
if (result.length) {
if (globalThis.udpClientByTopLine && globalThis.udpClientByTopLine.closeUdp) {
globalThis.udpClientByTopLine.closeUdp(() => {
globalThis.udpClientByTopLine.rebindUdp(result[0].udplocalIp, '5509', result[0].udpOppositeIp, result[0].udpOppositeIpPort)
// globalThis.udpClient.rebindUdp('192.168.7.170', '20122','192.168.7.124','20022')
})
} else {
const udpClient: UdpClient = new UdpClient(result[0].udplocalIp, '55509', result[0].udpOppositeIp, result[0].udpOppositeIpPort)
// const udpClient: UdpClient =new UdpClient(result[0].udplocalIp, '8800','192.168.36.9','11111')
// const udpClient: UdpClient =new UdpClient('192.168.7.170', '20122','192.168.7.124','20022')
// globalThis.udpClient2.rebindUdp('192.168.7.170', '20122','192.168.7.124','20022')
udpClient.bindUdp()
globalThis.udpClientByTopLine = udpClient
}
// globalThis.udpClient = new UdpClient(result[0].localIp, result[0].localIpPort,result[0].oppositeIp,result[0].oppositeIpPort)
} else {
globalThis.udpClientByTopLine = {}
globalThis.udpClientByTopLine.onMessage = () => {
}
}
})
}
export async function setTopLineUdp() {
export async function setTopLineUdp(){
const config = await getSyncData('IpConfigTable');
if (config && config[0] && config[0].udplocalIp) {
if(config && config[0] && config[0].udplocalIp){
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()
return {
send(bytes) {
send(bytes){
udpClient.sendHeadMsg(bytes)
}
}
@ -195,26 +110,21 @@ export async function setTopLineUdp() {
}
export async function setJudgeUdp() {
export async function setJudgeUdp(){
const config = await getSyncData('IpConfigTable');
if (config && config[0] && config[0].udplocalIp) {
const {udplocalIp,centerIp,gpsPort} = config[0];
if(config && config[0] && config[0].udplocalIp){
const {udplocalIp} = config[0];
// const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080','192.168.32.167','33333')
const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080', centerIp, gpsPort)
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')
udpClient.bindUdp()
udpClient.onMessage((val) => {
udpClient.onMessage((val)=>{
})
globalThis.judgeUdpClient = udpClient;
return {
send(bytes) {
console.log('carInfo111', JSON.stringify(globalThis.carInfo))
udpClient.sendMsg({
id: 45,
list: bytes,
carNo: globalThis.carInfo.carNo,
placeId: globalThis.carInfo.examinationRoomId
})
send(bytes){
console.log('carInfo111',JSON.stringify(globalThis.carInfo))
udpClient.sendMsg({id:45,list:bytes,carNo:globalThis.carInfo.carNo,placeId:globalThis.carInfo.examinationRoomId})
}
}
}

View File

@ -38,7 +38,7 @@ export default class UdpClientByCenter {
private sendId: any = 0
private lsh: string = null
private context
private stashFn
constructor(udplocalIp: string, udplocalIpPort:string,udpOppositeIp: string,udpOppositeIpPort:string) {
this.localIp = udplocalIp
this.oppositeIp = udpOppositeIp
@ -177,6 +177,7 @@ export default class UdpClientByCenter {
port: parseInt(this.oppositeIpPort),
}
});
this.stashFn=param.callback?param.callback:()=>{}
promise.then(() => {
if(this.sendId=='46'&&param.callback){
param.callback()
@ -203,7 +204,8 @@ export default class UdpClientByCenter {
for(let i=9;i<=9+length-1;i++){
list.push(arr[i])
}
this.stashFn({id,length,body:list,sendId:this.sendId})
this.stashFn=()=>{}
callback({id,length,body:list,sendId:this.sendId})
});

View File

@ -29,7 +29,7 @@ export default class EntryAbility extends UIAbility {
globalThis.deviceNo = '';
globalThis.hasAuth = false
globalThis.version = '2024.11.22.14'
globalThis.judgeVersion = '2023.10.31.17'
globalThis.judgeVersion = '2024.11.22.14'
// globalThis.version = '2022.03.14.01'
globalThis.context = this.context;

View File

@ -0,0 +1,257 @@
import {User} from "../pages/interfaces"
export const CandidateData: Array<User> = [
{
sfzmhm: '342323199501470011',
xm: '测试学员1',
lsh: '0000000000001',
ksy1: '考试员1',
id: '001',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '341182199308155624',
xm: '测试学员2',
lsh: '0000000000002',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '3423231995014700003',
xm: '测试学员3',
lsh: '0000000000003',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '3423231995014700004',
xm: '测试学员4',
lsh: '0000000000004',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '3423231995014700005',
xm: '测试学员5',
lsh: '0000000000004',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '342323199501470016',
xm: '测试学员6',
lsh: '0000000000005',
ksy1: '考试员1',
id: '001',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '3423231995014700007',
xm: '测试学员7',
lsh: '0000000000007',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
},
{
sfzmhm: '3423231995014700008',
xm: '测试学员8',
lsh: '0000000000008',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: ""
},
{
sfzmhm: '3423231995014700009',
xm: '测试学员9',
lsh: '0000000000009',
ksy1: '考试员2',
id: '002',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: ""
},
{
sfzmhm: '34232319950147000010',
xm: '测试学员10',
lsh: '002',
ksy1: '考试员2',
id: '0000000000010',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: '',
ksy2sfzmhm: "",
}]
export const EmptyCandidateObject = {
ksy2sfzmhm: "",
sfzmhm: '',
xm: '',
lsh: '',
ksy1: '',
id: '',
kszp: '',
ksmjzp: '',
bz1: '',
jxmc: '',
kchp: '',
kscx: '',
ksdd: '',
kssycs: '',
ksxl: '',
ksy1sfzmhm: '',
kszt: '',
xb: '',
xh: '',
xldm: '',
yycs: ''
}

View File

@ -1,367 +0,0 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@ohos.promptAction';
import camera from '@ohos.multimedia.camera';
import CameraModel from '../common/service/CameraModel';
import { VideoFrame } from '../common/service/CameraModel';
import grantPermission from '../common/utils/PermissionUtils';
import Logger from '../common/utils/Logger';
const CameraMode = {
modePhoto: 0, // 拍照模式
modeVideo: 1 // 录像模式
}
const TAG: string = '[CameraPage]';
@Component
struct CameraPage {
private mXComponentController: XComponentController = new XComponentController();
private surfaceId: string = '-1';
private cameraModel: CameraModel = new CameraModel();
@State imageThumbnail: string = '';
@State videoThumbnail: Resource | undefined = undefined;
@State currentModel: number = CameraMode.modePhoto;
@State isRecording: boolean = false;
@State textMove: number = 45;
@State isPointShow: boolean = true;
@State isTitleShow: boolean = true;
@StorageLink('selectType_0') @Watch('rotationChange') rotation: number = 0;
@StorageLink('selectType_1') @Watch('resolutionChange') resolution: number = 0;
@State timeShow: boolean = false;
private textTimerController: TextTimerController = new TextTimerController();
@State format: string = 'mm:ss';
/**
* 旋转角度改变监听方法
*/
rotationChange() {
Logger.info(TAG, `rotationChange begin ${this.rotation}`);
// 0°
if (this.rotation == 0) {
Logger.info(TAG, `rotationChange ${this.rotation}`);
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_0);
// 90°
} else if (this.rotation == 1) {
Logger.info(TAG, `rotationChange ${this.rotation}`);
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_90);
// 180°
} else if (this.rotation == 2) {
Logger.info(TAG, `rotationChange ${this.rotation}`);
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_180);
// 270°
} else if (this.rotation == 3) {
Logger.info(TAG, `rotationChange ${this.rotation}`);
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_270);
}
Logger.info(TAG, 'rotationChange end');
}
/**
* 分辨率改变监听方法
*/
resolutionChange() {
Logger.info(TAG, `resolutionChange begin ${this.resolution}`);
// 不支持 则为默认800*600
if (this.resolution == 0) {
Logger.info(TAG, `resolutionChange ${this.resolution}`);
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1920_1080);
} else if (this.resolution == 1) {
Logger.info(TAG, `resolutionChange ${this.resolution}`);
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1920_1080);
// 1280*720
} else if (this.resolution == 2) {
Logger.info(TAG, `resolutionChange ${this.resolution}`);
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1280_720);
// 800*600
} else if (this.resolution == 3) {
Logger.info(TAG, `resolutionChange ${this.resolution}`);
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_800_600);
}
Logger.info(TAG, 'resolutionChange end');
}
async aboutToAppear() {
await grantPermission().then(res => {
Logger.info(TAG, `权限申请成功 ${JSON.stringify(res)}`);
if (this.surfaceId) {
this.cameraModel.initCamera(this.surfaceId);
}
}).catch(rej => {
Logger.info(TAG, `权限申请失败 ${JSON.stringify(rej)}`);
})
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
Logger.info(TAG, `aboutToAppear,surfaceId=${this.surfaceId}`);
this.cameraModel.setTakePictureHandleCallback(this.takePictureHandle.bind(this));
}
onPageHide() {
Logger.info(TAG, 'onPageHide begin');
if (this.isRecording) {
Logger.info(TAG, 'stopVideo begin');
this.timeShow = false;
this.textTimerController.pause();
this.cameraModel.stopVideo();
this.isRecording = false;
this.cameraModel.cameraRelease();
// this.videoThumbnail = $r('app.media.video_poster');
}
Logger.info(TAG, 'onPageHide end');
}
onPageShow() {
this.cameraModel.initCamera(this.surfaceId);
}
getCameraIcon() {
// if (this.currentModel === CameraMode.modePhoto) {
// return $r('app.media.take_photo_normal');
// } else {
// if (this.isRecording) {
// return $r('app.media.take_video_stop');
// } else {
// return $r('app.media.take_video_normal');
// }
// }
}
refreshVideoState() {
if (this.isRecording) {
Logger.info(TAG, 'stopVideo begin');
this.timeShow = false;
this.textTimerController.pause();
this.cameraModel.stopVideo();
this.isRecording = false;
// this.videoThumbnail = $r('app.media.video_poster');
} else {
Logger.info(TAG, 'startVideo begin');
this.timeShow = true;
this.textTimerController.reset();
this.textTimerController.start();
this.cameraModel.startVideo();
this.isRecording = true;
}
}
startAbilityToPhoto() {
globalThis.cameraContext.startAbility({
bundleName: 'com.ohos.photos',
abilityName: 'com.ohos.photos.MainAbility'
}, (error) => {
Logger.info(TAG, `error.code = ${error.code}`)
});
}
takePictureHandle = (thumbnail: string) => {
this.imageThumbnail = thumbnail;
Logger.info(TAG, `takePicture end , thumbnail: ${this.imageThumbnail}`);
};
animateParam = {
duration: 500,
onFinish: () => {
this.isPointShow = true;
}
};
/**
* 拍照事件
*/
photoEvent() {
if (this.currentModel === CameraMode.modeVideo) {
animateTo(this.animateParam, () => {
this.isPointShow = false;
this.textMove = this.textMove + 56;
});
if (this.isRecording) {
this.timeShow = false;
this.isRecording = false;
this.cameraModel.stopVideo();
}
this.currentModel = CameraMode.modePhoto;
this.videoThumbnail = undefined;
}
}
/**
* 录像事件
*/
videoEvent() {
if (this.currentModel === CameraMode.modePhoto) {
animateTo(this.animateParam, () => {
this.isPointShow = false;
this.textMove = this.textMove - 56;
});
this.currentModel = CameraMode.modeVideo;
}
}
build() {
Column() {
Stack({ alignContent: Alignment.Bottom }) {
Stack({ alignContent: Alignment.TopStart }) {
XComponent({
id: 'componentId',
type: 'surface',
controller: this.mXComponentController
})
.onLoad(() => {
Logger.info(TAG, 'onLoad is called');
this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 640, surfaceHeight: 480 });
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
Logger.info(TAG, `onLoad surfaceId: ${this.surfaceId}`);
this.currentModel = CameraMode.modePhoto;
this.cameraModel.initCamera(this.surfaceId);
})
.width('100%')
.height('100%')
.margin({ bottom: 152 })
.gesture(
SwipeGesture({ direction: SwipeDirection.Horizontal, speed: 40 })
.onAction((event: GestureEvent) => {
Logger.info(TAG, `SwipeGesture event: ${JSON.stringify(event)}`);
// 右滑
if (event.angle > 0) {
this.photoEvent();
} else {
this.videoEvent();
}
})
)
Column() {
TextTimer({ isCountDown: false, count: 60000, controller: this.textTimerController })
.height(60)
.fontSize(24)
.format(this.format)
.fontColor(Color.Red)
.fontSize(50)
}
.justifyContent(FlexAlign.Start)
.visibility(this.timeShow ? Visibility.Visible : Visibility.Hidden)
.width('100%')
.height('30%')
}
.width('97%')
.height('100%')
Column() {
Row() {
Column() {
Text('1')
.id('photo')
.fontSize(14)
.fontColor(this.currentModel === CameraMode.modePhoto ? Color.White : Color.Gray)
.onClick(() => {
this.photoEvent();
})
if (this.currentModel === CameraMode.modePhoto) {
Text()
.width(4)
.height(4)
.margin({ top: 5 })
.borderRadius(2)
.backgroundColor(Color.Red)
}
}
Column() {
Text('1')
.fontColor(this.currentModel === CameraMode.modeVideo ? Color.White : Color.Gray)
.fontSize(14)
.id('video')
.margin({ left: 30 })
.onClick(() => {
this.videoEvent();
})
if (this.currentModel === CameraMode.modeVideo) {
Text()
.width(4)
.height(4)
.margin({ left: 30, top: 5 })
.borderRadius(2)
.backgroundColor(Color.Red)
}
}
}
.offset({ x: this.textMove })
.size({ height: 40, width: '100%' })
.justifyContent(FlexAlign.Center)
Row() {
if (this.currentModel === CameraMode.modeVideo) {
Image(this.videoThumbnail)
.id('intoPhoto')
.objectFit(ImageFit.Fill)
.margin({ left: 24 })
.borderRadius(5)
.aspectRatio(1)
.backgroundColor(Color.Gray)
.size({ width: 40, height: 40 })
.onClick(e => {
this.startAbilityToPhoto();
})
} else {
Image(this.imageThumbnail)
.id('intoPhoto')
.objectFit(ImageFit.Fill)
.margin({ left: 24 })
.borderRadius(5)
.aspectRatio(1)
.backgroundColor(Color.Gray)
.size({ width: 40, height: 40 })
.onClick(e => {
this.startAbilityToPhoto();
})
}
Column() {
}
.width(40)
.height(40)
}
.size({ height: 80, width: '100%' })
.margin({ right: 10 })
.justifyContent(FlexAlign.SpaceBetween)
}
.padding({ bottom: 10 })
// .backgroundColor($r('app.color.COLOR_000000'))
.alignItems(HorizontalAlign.Start)
.size({ height: 130, width: '100%' })
}
.layoutWeight(1)
// .backgroundColor($r('app.color.COLOR_000000'))
.width('100%')
.height('100%')
}
.width('100%')
.height('100%')
}
async aboutToDisappear() {
if (this.isRecording) {
await this.cameraModel.stopVideo();
}
await this.cameraModel.cameraRelease();
}
}
export default CameraPage

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,7 @@ struct Index {
// })
// this.url='pages/userInfo'
router.pushUrl({
url: 'pages/userInfo',
url: 'pages/UserInfo',
},router.RouterMode.Single);
console.log('res11',JSON.stringify(res))
globalThis.username=this.inputTextArr[0]

View File

@ -1,58 +0,0 @@
import FaceCompare from './compontents/faceCompare'
import { voiceService } from '../common/service/voiceService'
@Entry
@Component
struct Hello {
@State message: string = 'Hello World'
@State showFaceCompare: boolean = true;
@State count: number = 1;
@State @Watch('changefaceCompareSucess') faceCompareSucess: boolean = false;
build() {
Row() {
if(this.showFaceCompare) {
FaceCompare({ showFaceCompare: $showFaceCompare, sfzh: '1234', firstImage: '',faceCompareSucess: $faceCompareSucess })
}
// Text('click me').onClick(async () => {
// console.info("jiangsong click me ");
//
// voiceService({
// type: 1,
// name: 'face_check.mp3',
// callBack: (status) => {
// console.log('jiangsong audio play callback status ' + status)
// }
// })
// globalThis.context.resourceManager.getMediaContent($r('app.media.face_check').id, (error, value) => {
// if (error != null) {
// console.info("jiangsong error is " + error);
// } else {
// console.info('jiangsong get resource success')
//
// voiceService({
// type: 1,
// resource: value,
// callBack: (status) => {
// console.log('jiangsong audio play status' + status)
// }
// })
// }
// });
// })
// .width('200px')
// .height('200px')
// .backgroundColor(Color.Yellow)
}
.height('100%')
.width('100%')
}
changefaceCompareSucess() {
console.log('jiangsong changefaceCompareSucess = ' + this.faceCompareSucess)
}
// @Watch('faceCompareSucess')
}

View File

@ -3,34 +3,17 @@ import common from '@ohos.app.ability.common';
import router from '@ohos.router'
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'
import { setCurrentTime } from '../common/service/timeService'
import {Array2Byte} from '../common/utils/tools'
import {string2Bytes} from '../common/utils/tools'
import {
getDataBaseTable,
upDateTable,
getMySystemSetTable,
getSyncData,
delSyncTable,
getEsCarModel,
upDataZhongxinginitialization
} from '../common/service/initable'
import prompt from '@ohos.prompt'
import { dateFormat } from '../common/utils/tools'
import deviceManager from '@ohos.distributedHardware.deviceManager'
import AccountTable from '../common/database/tables/AccountTable';
import MA_SYSSET from '../common/constants/MA_SYSSET';
import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'
import {initJudgeUdp} from '../common/utils/UdpJudge'
import { getTCP } from '../common/utils/GlobleTcp'
import { voiceService } from '../common/service/voiceService'
import testNapi from '@ohos.hiserialsdk'
import TcpClient from '../common/utils/TcpClient';
import Router from '@system.router'
import socket from '@ohos.net.socket';
import fs from '@ohos.file.fs'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import FileUtil from '../common/utils/File'
import {setliushuiNum,getSingleCenterTable,getDoubleCeneterTable} from '../common/service/indexService'
@Entry
@Component
struct Index {
@ -58,8 +41,6 @@ struct Index {
if (this.loading) {
return
}
// this.url = 'pages/Settings'
router.pushUrl({
url: 'pages/Settings',
}, router.RouterMode.Single);
@ -69,12 +50,7 @@ struct Index {
if (this.loading) {
return
}
// getSyncData('MA_SYSSET')
router.back()
// this.url = 'back'
// app.terminate()
})
}
}
@ -85,27 +61,22 @@ struct Index {
Column() {
Row() {
if (!this.isSingle) {
Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(() => {
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(async() => {
if (this.loading) {
return
}
const that = this
this.loading = true
setTimeout(() => {
that.angle = 360
this.angle = 360
}, 1000)
that.angle = 0
// this.getCenterDataTable()
this.angle = 0
//mode为3双中心下载表
if(globalThis.timeInfo.mode=='3'){
this.upDateTable()
await getDoubleCeneterTable()
}else{
this.getCenterDataTable()
await getSingleCenterTable()
}
this.loading=false
})
}
@ -116,7 +87,7 @@ struct Index {
}
router.pushUrl({
url: 'pages/userInfo',
url: 'pages/UserInfo',
}, router.RouterMode.Single);
})
}
@ -124,11 +95,8 @@ struct Index {
if (this.loading) {
return
}
// globalThis.singlePlay = !globalThis.singlePlay
// this.isSingle = globalThis.singlePlay
// return
router.pushUrl({
url: 'pages/carCheck'
url: 'pages/CarCheck'
}, router.RouterMode.Single);
})
}
@ -193,8 +161,6 @@ struct Index {
.backgroundColor('#E6E3DF')
.borderRadius(19 * this.ratio)
}
}
.width('100%')
.height('100%')
@ -207,136 +173,20 @@ struct Index {
aboutToAppear() {
this.angle = 0
this.loading = false
// this.vocObj = new voiceService(async (status, val) => {
// if (status == 'idle') {
// if (this.url == 'back') {
// router.back()
// // that.udpClient.sendMsg('111')
// } else {
// router.pushUrl({
// url: this.url,
// });
// }
// }
// });
}
Array2Byte(array) {
var buf = new ArrayBuffer(array.length);
var view = new Uint8Array(buf);
for (var i = 0; i != array.length; ++i)
{
view[i] = array[i] & 0xFF;
}
return view;
}
openChuankouMsg() {
this.fd = testNapi.SerialOpen(this.devPath);
}
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;
}
//补0
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;
}
async heartMsg(context) {
const fileUtil = new FileUtil(context)
const fileData = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
let res = fs.accessSync('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
// TODO
return
if (res) {
if(JSON.stringify(fileData).indexOf('u0000')>=0){
const date = new Date()
const param = {
date: dateFormat(date),
value: 0
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}else{
const date = new Date()
const time1 = JSON.parse(fileData).date.split(' ')[0]
const time2 = dateFormat(date).split(' ')[0]
if (time1 == time2) {
const date = new Date()
const param = {
date: dateFormat(date),
value: Number(JSON.parse(fileData).value) + 1
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
} else {
const date = new Date()
const param = {
date: dateFormat(date),
value: 0
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}
}
}else
{
const date = new Date()
const param = {
date: dateFormat(date),
value: 0
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}
const arr = [globalThis.signNum||0, globalThis.statue||1]
let tmpList = [];
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
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(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
// const str ='1111160366580'
// for (let i = 0;i < str.length; i++) {
// tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
// }
// const param = { id: 46, list: tmpList, carNo: 489, placeId: 62 }
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
globalThis.udpClient2.sendMsg(param, this.context)
}
@ -347,6 +197,7 @@ struct Index {
getUDP()
getUDP2()
setInterval(() => {
setliushuiNum(this.context)
this.heartMsg(this.context)
}, 1000)
// getTCP()
@ -362,207 +213,23 @@ struct Index {
}
Array2Byte(array) {
var buf = new ArrayBuffer(array.length);
var view = new Uint8Array(buf);
for (var i = 0; i != array.length; ++i) {
view[i] = array[i] & 0xFF;
}
return view;
}
async initParams() {
this.loading=false
await getDeviceInfo()
// await this.getDeviceId()
await setCurrentTime();
await getCarInfo();
this.carNum = globalThis.carInfo.plateNo;
this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth;
initJudgeUdp()
// await this.getDataBaseTableFn()
//下载模型
// await this.getModel()
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
// globalThis.udpClientByTopLine.sendMsg(this.Array2Byte(arr).buffer)
// globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer)
}
getDeviceId() {
return new Promise((resolve, reject) => {
getSyncData('DeviceInfoTable').then((result: Array<any>) => {
if (result.length) {
globalThis.deviceNo = result[0].deviceId
this.deviceId = result[0].deviceId
resolve(result[0].deviceId)
} else {
// deviceManager.createDeviceManager('com.example.udptest', (error, value) => {
// if (error) {
// console.error('createDeviceManager failed.');
// return;
// }
// let dvMgrObj = value;
// globalThis.deviceNo=dvMgrObj.getLocalDeviceInfoSync().deviceName
// this.deviceId=globalThis.deviceNo
// resolve(dvMgrObj.getLocalDeviceInfoSync().deviceName)
// });
resolve('')
}
})
})
}
async getModel() {
const context = this.context;
//下载模型
await getEsCarModel(context)
}
async getDataBaseTableFn() {
// getDataBaseTable({ tableName: 'MA_MARKRULE' })
// getDataBaseTable({ tableName: 'MA_SYSTEMPARM' })
// await getDataBaseTable({ tableName: 'MA_SYSSET' })
// await getMySystemSetTable({ tableName: 'MA_SYSSET' })
//
// await getDataBaseTable({ tableName: 'MA_MAP_COLLECT' })
// await getDataBaseTable({ tableName: 'MA_MAP_COLLECT_SHAPE' })
// await getDataBaseTable({ tableName: 'MA_MAP_ITEMCLASS' })
// await getDataBaseTable({ tableName: 'MA_MAP_POINT' })
// await getDataBaseTable({ tableName: 'MA_MAP_POINT_ITEM' })
// await getDataBaseTable({ tableName: 'MA_MAP_ROAD' })
// await getDataBaseTable({ tableName: 'MA_MAP_ROAD_LANE' })
// await getDataBaseTable({ tableName: 'MA_MAP_SUBITEM' })
// await getDataBaseTable({ tableName: 'ES_CARINFO' })
// await getDataBaseTable({ tableName: 'ES_EXAMPOINTDETAIL' })
// await getDataBaseTable({ tableName: 'MA_MARKRULESET' })
// await getDataBaseTable({ tableName: 'ES_CAR_VIDEO_PARAMETER' })
// await getDataBaseTable({ tableName: 'MA_CDSBINFO' })
// await getDataBaseTable({ tableName: 'MA_ITEMINFO' })
// await getDataBaseTable({ tableName: 'MA_T_CARPARMSET' })
}
async getCenterDataTable() {
const flag= await upDataZhongxinginitialization()
this.loading = false
if(flag){
router.pushUrl({
url: 'pages/ExaminerLogin',
}, router.RouterMode.Single)
}else{
prompt.showToast({
message: '联网更新失败,请检查网络后重新更新',
duration: 1000
});
}
}
async upDateTable() {
// return
const db = new AccountTable(() => {
}, MA_SYSSET);
db.getRdbStore(() => {
db.query('0', async (array) => {
if (array.length) {
delSyncTable('MA_SYSSET').then(async () => {
// getSyncData('MA_SYSSET')
await getDataBaseTable({ tableName: 'MA_SYSSET' })
await getMySystemSetTable({ tableName: 'MA_SYSSET' })
})
} else {
await getDataBaseTable({ tableName: 'MA_SYSSET' })
await getMySystemSetTable({ tableName: 'MA_SYSSET' })
}
// console.log(markRuleParams)
})
})
const typeObj = {
'MA_MARKRULE': false,
'MA_SYSTEMPARM': false,
'MA_MAP_COLLECT': false,
'MA_MAP_COLLECT_SHAPE': false,
'MA_MAP_ITEMCLASS': false,
'MA_MAP_POINT': false,
'MA_MAP_POINT_ITEM': false,
'MA_MAP_ROAD': false,
'MA_MAP_ROAD_LANE': false,
'MA_MAP_SUBITEM': false,
'ES_CARINFO': false,
'ES_EXAMPOINTDETAIL': false,
'MA_MARKRULESET': false,
'ES_CAR_VIDEO_PARAMETER': false,
'MA_CDSBINFO': false,
'MA_ITEMINFO': false,
'MA_T_CARPARMSET': false
}
typeObj.MA_MARKRULE = await upDateTable({ tableName: 'MA_MARKRULE' })
typeObj.MA_SYSTEMPARM = await upDateTable({ tableName: 'MA_SYSTEMPARM' })
typeObj.MA_MAP_COLLECT = await upDateTable({ tableName: 'MA_MAP_COLLECT' })
typeObj.MA_MAP_COLLECT_SHAPE = await upDateTable({ tableName: 'MA_MAP_COLLECT_SHAPE' })
typeObj.MA_MAP_ITEMCLASS = await upDateTable({ tableName: 'MA_MAP_ITEMCLASS' })
typeObj.MA_MAP_POINT = await upDateTable({ tableName: 'MA_MAP_POINT' })
typeObj.MA_MAP_POINT_ITEM = await upDateTable({ tableName: 'MA_MAP_POINT_ITEM' })
typeObj.MA_MAP_ROAD = await upDateTable({ tableName: 'MA_MAP_ROAD' })
typeObj.MA_MAP_ROAD_LANE = await upDateTable({ tableName: 'MA_MAP_ROAD_LANE' })
typeObj.MA_MAP_SUBITEM = await upDateTable({ tableName: 'MA_MAP_SUBITEM' })
typeObj.ES_CARINFO = await upDateTable({ tableName: 'ES_CARINFO' })
typeObj.ES_EXAMPOINTDETAIL = await upDateTable({ tableName: 'ES_EXAMPOINTDETAIL' })
typeObj.MA_MARKRULESET = await upDateTable({ tableName: 'MA_MARKRULESET' })
typeObj.ES_CAR_VIDEO_PARAMETER = await upDateTable({ tableName: 'ES_CAR_VIDEO_PARAMETER' })
typeObj.MA_CDSBINFO = await upDateTable({ tableName: 'MA_CDSBINFO' })
typeObj.MA_ITEMINFO = await upDateTable({ tableName: 'MA_ITEMINFO' })
typeObj.MA_T_CARPARMSET = await upDateTable({ tableName: 'MA_T_CARPARMSET' })
for (let key in typeObj) {
if (!typeObj[key]) {
this.loading = false
prompt.showToast({
message: `未能查询到${key}表数据, 请先检查网络是否连接正常`,
duration: 3000
});
return
}
}
this.loading = false
// await getSyncData('MA_MARKRULE')
// await getSyncData('MA_SYSTEMPARM')
// await getSyncData('MA_MAP_COLLECT')
// await getSyncData('MA_MAP_COLLECT_SHAPE')
// await getSyncData('MA_MAP_ITEMCLASS')
// await getSyncData('MA_MAP_POINT')
// await getSyncData('MA_SYSTEMPARM')
// await getSyncData('MA_MAP_POINT_ITEM')
// await getSyncData('MA_MAP_POINT')
// await getSyncData('MA_MAP_POINT_ITEM')
// await getSyncData('MA_MAP_ROAD')
// await getSyncData('MA_MAP_ROAD_LANE')
// await getSyncData('MA_MAP_SUBITEM')
// await getSyncData('ES_CARINFO')
// await getSyncData('ES_EXAMPOINTDETAIL')
// await getSyncData('MA_CDSBINFO')
// await getSyncData('MA_T_CARPARMSET')
// if(!flag){
router.pushUrl({
url: 'pages/ExaminerLogin',
}, router.RouterMode.Single);
// return
// }
// await upDateTable({ tableName: 'MA_SYSSET' })
}
termialCheck() {
// if(!globalThis.deviceNo) {
// prompt.showToast({
// message: '未能查询到当前车辆信息, 请先注册该车辆, 或者检查网络是否连接正常!',
// duration: 3000
// });
//
// return false
// }
return true
}
}

View File

@ -112,7 +112,7 @@ struct Index {
}
router.pushUrl({
url: 'pages/userInfo',
url: 'pages/UserInfo',
}, router.RouterMode.Single);
})
}
@ -121,7 +121,7 @@ struct Index {
return
}
router.pushUrl({
url: 'pages/carCheck'
url: 'pages/CarCheck'
}, router.RouterMode.Single);
})
}

View File

@ -18,31 +18,18 @@ struct Index {
Column() {
Row() {
Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(()=>{
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
this.url='pages/register'
router.pushUrl({
url: this.url,
},router.RouterMode.Single);
})
Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(()=>{
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
this.url='pages/videoConfig'
router.pushUrl({
url: this.url,
},router.RouterMode.Single);
})
Image($r('app.media.setting_xtts')).width('30.5%').height('74%').onClick(()=>{
console.info('jiangsong Button onClick')
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
this.url='pages/TeminalInfos'
router.pushUrl({
url: this.url,
@ -74,21 +61,11 @@ struct Index {
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToAppear() {
console.info('jiangsong:index Index aboutToAppear');
this.carNum = globalThis.carInfo.plateNo;
this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth;
}
onPageShow() {
console.info('Index onPageShow');
// tF = new voiceService(async (status,val) => {
// if (status == 'idle') {
// router.pushUrl({
// url: this.url,
// });
// }
// });
}
outClick(){
}
}

View File

@ -1,10 +1,6 @@
import router from '@ohos.router'
import UdpClient from '../common/utils/UdpClient';
import FileLog from './judgeSDK/utils/file-log'
import { voiceService } from '../common/service/voiceService'
import prompt from '@ohos.prompt'
import SerialPortClient from '../common/utils/SerialPortClient'
import RealTime from './compontents/judge/real-time'
import signDisplayCom from './compontents/signDisplayCom'
@Entry
@Component

View File

@ -1,416 +0,0 @@
import deviceInfo from '@ohos.deviceInfo'
import prompt from '@ohos.prompt'
import router from '@ohos.router'
import { timeSynchronize } from '../common/service/timeService'
import { getCarInfo } from '../common/service/terminalService'
import { dateFormat } from '../common/utils/tools'
import ethernet from '@ohos.net.ethernet';
import UdpClient from '../common/utils/UdpClient';
import FileLog from './judgeSDK/utils/file-log'
import TopLogo from './compontents/topLogo'
import { voiceService } from '../common/service/voiceService'
@Entry
@Component
struct Index {
@State mlxhColum: Array<any> = [{ key: '车速', value: '0' }, { key: '倒车时速', value: '0' }, {
key: '档位',
value: '0'
}, { key: '溜车距离', value: '0' }, { key: '熄火次数', value: '0' }, { key: '累计距离', value: '0' }, {
key: '发动机转速',
value: '0'
}, { key: '项目距离', value: '0' }, { key: '倒车距离', value: '0' }, { key: '左前超声波', value: '0' }, {
key: '右后超声波',
value: '0'
}, { key: '右前超声波', value: '0' }, { key: '左后超声波', value: '0' }, { key: '前磁计数s', value: '0' }, {
key: '左前磁计数s',
value: '0'
}, { key: '右前磁计数s', value: '0' }, { key: '左后磁计数s', value: '0' }, { key: '右后磁计数s', value: '0' }, {
key: '左后外磁计数',
value: '0'
}, { key: '右后外磁计数s', value: '0' }, { key: '累计脉冲', value: '0' },
{ key: '倒车脉冲', value: '0' }, { key: '溜车脉冲', value: '0' }, { key: '前磁计数n', value: '0' }
, { key: '左后外磁计数n', value: '0' }, { key: '右后外磁计数n', value: '0' }, { key: '前磁ns脉冲', value: '0' },
{ key: '左前磁ns脉冲', value: '0' }, { key: '右前磁ns脉冲', value: '0' }, { key: '左后磁ns脉冲', value: '0' },
{ key: '右后磁ns脉冲', value: '0' }, { key: '超声波1', value: '0' }, { key: '超声波2', value: '0' }, {
key: 'X坐标',
value: '0'
}, { key: 'Y坐标', value: '0' }
, { key: '左后外磁计数s', value: '0' }, { key: '右后外磁计数s', value: '0' }, { key: '差分改正数', value: '0' },
]
@State sjxhColum: Array<any> = [{ key: '应答位', value: '0' }, { key: '左方向灯', value: '0' }, {
key: '右方向灯',
value: '0'
}, { key: '双跳灯', value: '0' }, { key: '远光灯', value: '0' }, { key: '近光灯', value: '0' }, {
key: '视宽灯',
value: '0'
}, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '离合器', value: '0' }, {
key: '脚刹',
value: '0'
}, { key: '手刹', value: '0' }, { key: '副刹', value: '0' }, { key: '喇叭', value: '0' }, { key: '门开关', value: '0' }, {
key: '安全带',
value: '0'
}, { key: '雾灯', value: '0' }, { key: '闪灯', value: '0' }, { key: '方向盘', value: '0' }, { key: '计时', value: '0' }, {
key: '前进状态',
value: '0'
}, { key: '后退状态', value: '0' }, { key: '停车状态', value: '0' }, { key: '加减档错', value: '0' }, {
key: '1-2',
value: ''
}, { key: '震动', value: '0' }, { key: '前磁s', value: '0' }, { key: '左前磁s', value: '0' }, {
key: '右前磁s',
value: ''
}, { key: '左后磁s', value: '0' }, { key: '右后磁s', value: '0' }, { key: '左后外磁s', value: '0' }, {
key: '右后外磁s',
value: ''
}, { key: '前磁n', value: '0' }, { key: '左前磁n', value: '0' }, { key: '右前磁n', value: '0' }, {
key: '左后磁n',
value: '0'
}, { key: '右后磁n', value: '0' }, { key: '左后外磁n', value: '0' }, { key: '右后外磁n', value: '0' }, {
key: '雨刮器',
value: '0'
}]
@State ratio: number = 1280 / 960
@State gpsActive: number = 1
@State active: number = 0
@State msg: string = ''
@State @Watch('outClick') outFlag: boolean = false;
private timer = null
private udpClient: UdpClient = null
private FileLog: FileLog
private vocObj = null;
@State url: string = ''
// @State gpsList: Array<any> = []
build() {
Column() {
TopLogo({outFlag:$outFlag})
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Row() {
// Image($r('app.media.signal_logoS')).width(30 * this.ratio).height(24 * this.ratio)
Row() {
Text('PLC信号').fontColor(this.active == 0 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
}
.backgroundImage(this.active == 0 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
.width(144 * this.ratio)
.height(50 * this.ratio)
.backgroundImageSize({ width: '100%', height: '100%' })
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.active = 0
})
Row() {
Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
}
.backgroundImage(this.active == 1 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
.width(144 * this.ratio)
.height(50 * this.ratio)
.backgroundImageSize({ width: '100%', height: '100%' })
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.active = 1
})
Row() {
Text('原始数据').fontColor(this.active == 2 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
}
.backgroundImage(this.active == 2 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
.width(144 * this.ratio)
.height(50 * this.ratio)
.backgroundImageSize({ width: '100%', height: '100%' })
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.active = 2
})
}
Row() {
Image($r('app.media.topB_back')).width('16.7%').height('12.2%')
.onClick(()=>{
// router.back()
this.url='back'
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
this.outFlag=true
})
// Row(){
// Text('保存日志').fontSize(21*this.ratio).fontColor('#fff')
// }.width(137*this.ratio).height(36*this.ratio).margin({left:12*this.ratio}).backgroundImageSize({width:'100%',height:'100%'}).backgroundImage($r('app.media.button_nor')).justifyContent(FlexAlign.Center).onClick(()=>{
// this.saveLog()
// })
// Row() {
// Text('关闭').fontSize(21 * this.ratio).fontColor('#fff')
// }
// .width(137 * this.ratio)
// .height(36 * this.ratio)
// .margin({ left: 12 * this.ratio })
// .backgroundImageSize({ width: '100%', height: '100%' })
// .backgroundImage($r('app.media.button_nor'))
// .justifyContent(FlexAlign.Center)
// .onClick(() => {
// // globalThis.udpClient.closeUdp(()=>{
// router.back()
// // })
// })
}
}
Row() {
Column() {
Text('数字信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
ForEach(this.sjxhColum, (item) => {
Row() {
Text(`${item.key}:${item.value}`)
.fontSize(14 * this.ratio)
.lineHeight(21 * this.ratio)
.fontColor('#fff')
}.width('33.3%').height(21 * this.ratio)
})
}
.width(440 * this.ratio)
.height(360 * this.ratio)
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
.backgroundColor('#282828')
}.width(460 * this.ratio).height('100%')
Column() {
Text('模拟信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
ForEach(this.mlxhColum, (item) => {
Row() {
Text(`${item.key}:${item.value}`)
.fontSize(14 * this.ratio)
.lineHeight(21 * this.ratio)
.fontColor('#fff')
}.width('33.3%').height(21 * this.ratio)
})
}
.width(440 * this.ratio)
.height(360 * this.ratio)
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
.backgroundColor('#282828')
}.width(460 * this.ratio).height('100%')
Column() {
Text('模拟信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
ForEach(this.mlxhColum, (item) => {
Row() {
Text(`${item.key}:${item.value}`)
.fontSize(14 * this.ratio)
.lineHeight(21 * this.ratio)
.fontColor('#fff')
}.width('33.3%').height(21 * this.ratio)
})
}
.width(440 * this.ratio)
.height(360 * this.ratio)
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
.backgroundColor('#282828')
}.width(460 * this.ratio).height('100%')
}
.width(936 * this.ratio)
.height(420 * this.ratio)
.margin({ left: 10 * this.ratio })
.padding({ left: 10 * this.ratio, right: 10 * this.ratio })
.backgroundImage($r('app.media.km_open'))
.backgroundImageSize({ width: '100%', height: '100%' })
.visibility(this.active == 0 ? Visibility.Visible : Visibility.None)
Row() {
Flex({ direction: FlexDirection.Column }) {
Row() {
Row() {
Text('GPS1').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff')
}
.width(72)
.height(24)
.backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A')
.margin({ left: 10, right: 10 })
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.gpsActive = 0
})
Row() {
Text('GPS2').fontColor(this.gpsActive == 1 ? '#2D3C5A' : '#fff')
}
.width(72)
.height(24)
.backgroundColor(this.gpsActive == 1 ? '#fff' : '#1A1A1A')
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.gpsActive = 1
})
}.margin({ top: 10 })
// ForEach(this.gpsList,(item)=>{
// Text()
// })
}
.width(168 * this.ratio)
.height(380 * this.ratio)
.backgroundColor('#282828')
.margin({ top: 6 * this.ratio, left: 10 * this.ratio })
Row() {
}.width(168 * this.ratio).height(380 * this.ratio).backgroundColor('#1A1A1A').margin({ top: 6 * this.ratio })
Row() {
}
.width(550 * this.ratio)
.height(380 * this.ratio)
.backgroundColor('#1A1A1A')
.margin({ top: 6 * this.ratio, left: 6 * this.ratio })
}
.width(936 * this.ratio)
.height(420 * this.ratio)
.margin({ left: 10 * this.ratio })
.padding({ left: 10 * this.ratio, right: 10 * this.ratio })
.backgroundImage($r('app.media.km_open'))
.backgroundImageSize({ width: '100%', height: '100%' })
.visibility(this.active == 1 ? Visibility.Visible : Visibility.None)
}
.width('100%')
.height('100%')
.backgroundImage($r('app.media.bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
}
aboutToDisappear() {
this.vocObj = new voiceService(async (status,val) => {
if (status == 'idle') {
if(this.url=='back'){
router.back()
// that.udpClient.sendMsg('111')
}else {
router.pushUrl({
url: this.url,
});
}
}
});
// this.udpClient.closeUdp()
}
onPageShow() {
console.info('Index onPageShow');
const that = this
if (!globalThis.udpClient) {
return
}
globalThis.udpClient.onMessage((msg) => {
that.msg = msg
const signArr = msg.split(',')
that.sjxhColum[1].value = signArr[2]
that.sjxhColum[2].value = signArr[3]
that.sjxhColum[3].value = signArr[20]
that.sjxhColum[4].value = signArr[8]
that.sjxhColum[5].value = signArr[7]
// that.sjxhColum[6].value=signArr[7]//宽视灯
that.sjxhColum[7].value = signArr[5] //
that.sjxhColum[8].value = signArr[6] //
that.sjxhColum[9].value = signArr[17] //
that.sjxhColum[10].value = signArr[12]
that.sjxhColum[11].value = signArr[13]
that.sjxhColum[12].value = signArr[18]
that.sjxhColum[13].value = signArr[4]
that.sjxhColum[14].value = signArr[14]
that.sjxhColum[15].value = signArr[19]
that.sjxhColum[16].value = signArr[10]
// that.sjxhColum[17].value=signArr[10]//闪灯
that.sjxhColum[18].value = signArr[27]
// that.sjxhColum[19].value=signArr[27] //计时
// that.sjxhColum[20].value=signArr[27]//前进状态
// that.sjxhColum[21].value=signArr[27]//后退状态
// that.sjxhColum[22].value=signArr[27]//停车状态
// that.sjxhColum[23].value=signArr[27]//加减档错
// that.sjxhColum[24].value=signArr[27]//1-2
// that.sjxhColum[25].value=signArr[27]//震动
// that.sjxhColum[26].value=signArr[27]//震动
// that.sjxhColum[27].value=signArr[27]//前磁s
// that.sjxhColum[28].value=signArr[27]//左前磁s
// that.sjxhColum[29].value=signArr[27]//右前磁s
//that.sjxhColum[30].value=signArr[27]//左后磁s
//that.sjxhColum[31].value=signArr[27]//右后磁s
//that.sjxhColum[32].value=signArr[27]//左后外磁s
//that.sjxhColum[33].value=signArr[27]//左后外磁s
//that.sjxhColum[34].value=signArr[27]//前磁n
//that.sjxhColum[35].value=signArr[27]//左前磁n
//that.sjxhColum[36].value=signArr[27]//右前磁n
//that.sjxhColum[37].value=signArr[27]//左后磁n
//that.sjxhColum[38].value=signArr[27]//右后磁n
//that.sjxhColum[39].value=signArr[27]//左后外磁
//that.sjxhColum[40].value=signArr[27]//右后外磁
that.sjxhColum[40].value = signArr[11] //右后外磁
that.sjxhColum = JSON.parse(JSON.stringify((that.sjxhColum)))
that.mlxhColum[0].value = signArr[23]
// that.mlxhColum[1].value = signArr[28]
that.mlxhColum[2].value = signArr[28]
// that.mlxhColum[3].value = signArr[24]
that.mlxhColum[4].value = signArr[26]
// that.mlxhColum[5].value = signArr[29]
that.mlxhColum[6].value = signArr[25] //发动机转速
// that.mlxhColum[7].value = signArr[31]
// that.mlxhColum[8].value = signArr[32]
that.mlxhColum[9].value = signArr[29]
that.mlxhColum[10].value = signArr[30]
that.mlxhColum[11].value = signArr[31]
that.mlxhColum[12].value = signArr[32]
// that.mlxhColum[13].value = signArr[84]//前磁计数s
// that.mlxhColum[14].value = signArr[85]
// that.mlxhColum[15].value = signArr[86]
// that.mlxhColum[16].value = signArr[87]
// that.mlxhColum[17].value = signArr[88]
// that.mlxhColum[18].value = signArr[89]
// that.mlxhColum[19].value = signArr[90]
that.mlxhColum[20].value = signArr[24] //累计脉冲
that.mlxhColum[31].value = signArr[29] //超声波1
that.mlxhColum[32].value = signArr[30] //超声波2
that.mlxhColum[33].value = signArr[95]
that.mlxhColum[34].value = signArr[96]
that.mlxhColum = JSON.parse(JSON.stringify((that.mlxhColum)))
// if (that.timer) {
// return
// }
// that.timer = setTimeout(() => {
//
//
// that.timer=null
// }, 1000)
})
}
outClick(){
}
saveLog() {
// this.FileLog.initFileLogo('d .0ateLog')
// this.FileLog.createFile('123')
}
// getDeviceNo() {
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-72'; //设备号
// }
// initTime() {
//
// }
//
// initCarInfo() {
//
// }
//
// getData() {
//
// }
}

View File

@ -9,12 +9,12 @@ import { voiceService } from '../common/service/voiceService'
@Entry
@Component
struct Index {
@State textList1: string[] = ['ftp服务器IP','响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:','中心服务器IP:','心跳响应端口:', 'GPS响应端口']
@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','192.168.36.9','11111','33333']
@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']
@ -101,13 +101,7 @@ struct Index {
.borderRadius('25px')
Column() {
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
upDateTableConfig('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],centerIp:this.inputTextList1[11],heartPort:this.inputTextList1[12],gpsPort:this.inputTextList1[13]}])
console.log('kkkk2',this.inputTextList2.toString())
upDateTableConfig('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],
@ -123,10 +117,10 @@ struct Index {
duration: 3000
});
} else {
prompt.showToast({
message: '设置成功',
duration: 3000
});
prompt.showToast({
message: '设置成功',
duration: 3000
});
}
});
})
@ -151,41 +145,41 @@ struct Index {
.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
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));
}
})
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() {

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ const PERMISSIONS: Array<string> = [
'ohos.permission.CAMERA']
@Component
struct FaceCompare {
export default struct FaceCompare {
constructor() {
super()
}
@ -45,7 +45,7 @@ struct FaceCompare {
private times = 1; //人脸比对失败次数, 超过3次将不会自动比对需要点击重新打开重新触发
private vocObj = null;
@State callBackFlag:boolean=false;
@State @Watch('changefaceCompareSucess') showFaceCompare2: Boolean = false;
@State @Watch('changeFaceCompareSuccess') showFaceCompare2: Boolean = false;
private surfaceId: string = '';
@State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream'
@ -209,7 +209,7 @@ struct FaceCompare {
// this.cameraModel.initCamera(this.surfaceId);
}
changefaceCompareSucess(){
changeFaceCompareSuccess(){
this.callBackFlag=false
clearInterval(this.interval)
this.vocObj&&this.vocObj.releasePlayer()
@ -554,4 +554,3 @@ struct FaceCompare {
}
}
export default FaceCompare

View File

@ -1,14 +1,9 @@
// @ts-nocheck
import hilog from '@ohos.hilog';
import apiJudgeSdk from 'libJudgeSdk.so';
import Judge from '../../JudgeSDK/utils/judge-real'
// import Judge from '../../judgeSDK/judge-track-playback'
import Judge from '../../judgeSDK/utils/judge-real'
import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d'
import AccountTable from '../../../common/database/tables/AccountTable';
import MA_SYSSET from '../../../common//constants/MA_SYSSET';
import common from '@ohos.app.ability.common';
import { getSyncData } from '../../../common/service/initable'
import {testAllitems,testUIAllitems,testMarkRules} from '../../judgeSDK/dataTest/index'
@Component
struct RealTime {

View File

@ -1,5 +1,29 @@
export interface User {
sfzmhm: string
xm: string
lsh: string
ksy1: string
id: string
kszp: string
ksmjzp: string
bz1: string
jxmc: string
kchp: string
kscx: string
ksdd: string
kssycs: string
ksxl: string
ksy1sfzmhm: string
kszt: string
xb: string
xh: string
xldm: string
yycs: string
ksy2sfzmhm: string
}
export interface VideoConfig{
videoNum?:string,
spls:string
faceFlag:boolean
pztd:string

View File

@ -1,13 +1,5 @@
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
import promptAction from '@ohos.promptAction'
import fileAccess from '@ohos.file.fileAccess'
import common from '@ohos.app.ability.common'
import Want from '@ohos.app.ability.Want'
import fs from '@ohos.file.fs'
import FileUtil from '../../../common/utils/File'
import zlib from '@ohos.zlib';
const MODELTAG = 'MODELTAG'
export default class FileModel{
//后续文件路径待替换
@ -26,9 +18,6 @@ export default class FileModel{
public initFolder = async () => {
const {fileUtil} = this
await fileUtil.initFolder(`/models/model_enc`);
//TODO 删除待优化
const isDeletedModelEnc= await this.fileUtil.deleteF('models/model_enc',1)
const isDeletedModels = await this.fileUtil.deleteF('models',1)
const folderPath = await fileUtil.initFolder(`/models`);
this.folderPath = folderPath;
}

View File

@ -30,7 +30,7 @@ export const getTranslateSignals = (tempItems) => {
return temp.map(item => string2Bytes(item , 8)[0])
}
// 当前考车行驶状态转换
// c++评判考车行驶状态转换
export function getCarStatus(status: -1 | 0 | 1):string {
switch (status){
case -1:return '后退'
@ -251,17 +251,21 @@ export const plcStrToWXJson = async (plc:string) =>{
return wuXiDataStr
}
//蓝灯
export function sendBlue(){
const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00];
const arrBlueBuffer= Array2Byte(arrBlue).buffer
globalThis.lightLineUdp.send(arrBlueBuffer);
}
//绿灯
export function sendGreen(){
const arrGreen = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x01];
const arrGreenBuffer= Array2Byte(arrGreen).buffer
globalThis.lightLineUdp.send(arrGreenBuffer);
}
//红灯
export function sendRed(){
const arrRed= [0x55, 0xaa, 0x01, 0x01, 0x02, 0x00, 0x03, 0x00];
const arrRedBuffer= Array2Byte(arrRed).buffer

View File

@ -7,9 +7,8 @@ export const judgeConfig = {
// 本地模型地址
modelPath: 'models/model_enc',
// 轨迹回放目录地址
trajectoryPath: '/logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt'
trajectoryPath: 'logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt'
}
// 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五
// 2024_01_24_10_25_41_2231212226990_330184200208281821_金晓婷

View File

@ -1,143 +0,0 @@
import FileModel from '../utils/file-model'
import {testAllitems,testRealExam} from '../dataTest/index'
import { getSyncData } from '../../../common/service/initable'
import systemTime from '@ohos.systemDateTime'
import {testMarkRules} from '../dataTest/index'
import AccountTable from '../../../common/database/tables/AccountTable'
import USER from '../../../common/constants/USER'
export default class JudgeData{
private fileModel:FileModel
private modelPath:string
private markRuleListObj:object
constructor(judgeUI) {
this.fileModel = new FileModel(judgeUI.context);
this.modelPath = 'models/model_enc'
this.markRuleListObj = {}
}
//获取项目、扣分表数据
getInitData = async ()=>{
}
// 获取项目信息
initProjectInfo = async () => {
//TODO 待优化
const systemParamsArr = await getSyncData('MA_SYSTEMPARM')
const itemInfoArr = await getSyncData('MA_ITEMINFO')
//@ts-ignore
const filterProjectsArr = systemParamsArr.filter(item => item.no1 == 6)
}
// 获取扣分代码信息
initMarkRules = async () => {
const markRuleParams = await getSyncData('MA_MARKRULE')
//@ts-ignore
markRuleParams.forEach(mark=>{
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
itemno:mark.itemno*1,
markcatalog:mark.markcatalog,
markshow:decodeURI(mark.markshow),
markreal:mark.markreal*1,
markserial:mark.markserial
};
})
}
//获取评判初始化数据
getJudgeInitData = async () => {
const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carNo } = carInfo;
const {getModelData,initProjectInfo,initMarkRules} = this;
await initProjectInfo()
await initMarkRules()
const { markRuleListObj }= this;
const initInfo = {
kskm:examSubject*1,
kchp:plateNo,
kchm:carNo*1,
//考试车型
kscx:'C1',
cxcode:'1',
name:'桑塔纳',
carmodel:getModelData(`C1.txt`),
// TODO 待替换
allitems:testAllitems.map((project) => {
//@ts-ignore
const modelKey = project.projectCode + '_' + project.type;
return {
//@ts-ignore
xmdm:project.projectCode*1,
xmxh:project.type+'',
model:getModelData(`${modelKey}.txt`)
}
}),
mark:Reflect.ownKeys(markRuleListObj).map(ruleKey=>(markRuleListObj[ruleKey])),
sysset:[{
key:606,
value:"1",
name:"倒车入库、桩考、侧方不可以取消项目"
}],
};
return initInfo
}
// 获取plc数据
getPlcData = async (plc:string) =>{
const p = plc.split(',').map((val,key)=>{
if(key !== 27 && key !== 92){
//@ts-ignore
return val*1
}else{
return val
}
});
let data:any = testRealExam;
const time = await systemTime.getCurrentTime()
const tempData = {
sensor:{
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
aqd:p[19], mkg:p[14], ssc:p[13], jsc:p[12], fsc:p[18], lhq:p[17], lb:p[4], skd:p[9], jgd:p[7], ygd:p[8],
//左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速
zfxd:p[2], yfxd:p[3], shtd:p[20],wd:p[10], ygq:p[11], dh1:p[5], dh2:p[6], fdjzs:p[25], dw:p[28], cs:p[23],
//@ts-ignore 方向盘
fxp:p[27].split('_')[0]*1,
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
ljmc:p[24], lcmc:0, csbzh:p[32], csbyh:p[30], csbyq:p[31], csbzq:p[29], zy:0, tbp:0, hsj:0, dcj:0, gx:0, yl:0
},
gps:{
//办卡类型 定位差分状态
bklx:p[56], dwzt:p[83],
//@ts-ignore 角度差分状态
jdzt:p[92].split('-')[0]*1,
//gps数据
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
sj:time, jd:p[96], wd:p[95], hxj:p[90], fyj:p[91], hbg:p[85], gdc:p[86], sd:p[97],
//龄期 经度因子 纬度因子 定位搜星数
age:p[87], jdyz:p[89], wdyz:p[88], dwsxs:p[84],
//@ts-ignore 角度搜星数
jdsxs:p[92].split('-')[1]*1
},
gps2:data.gps,
vision:data.vision,
radar:data.radar,
extend:{}
}
return tempData
}
// 获取模型数据
getModelData = (modelName) => {
const modelPath = this.modelPath
const fileModel = this.fileModel;
const modelData = fileModel.getModelContent(modelPath,modelName);
return modelData
}
}

View File

@ -1,130 +0,0 @@
import emitter from '@ohos.events.emitter'
export enum JudgeEvent{
//评判回调日志
JUDGE,
//实时过程数据
PERFORM,
//日志
LOG
}
const {IMMEDIATE,IDLE,HIGH} = emitter.EventPriority
import {
examJudgeSetLogCallback,
examJudgeBeginExam,
examJudgeInit,
examJudgeRealExam,
examJudgeSetRealExamCallback,
examJudgeSetPerformCallback,
examJudgeEndExam
} from '../api/index'
import JudgeData from './judge-data'
const judgeTag = 'SURENJUN_JUDGE'
export class GlobalJudge{
private judgeData:JudgeData
private initData:any
private fileLog:any
constructor(context) {
const {log} = this;
const judgeData = new JudgeData(context);
this.judgeData = judgeData;
}
// 评判初始化
public init = async () => {
const {log,judgeData} = this;
log('1.进入评判入口')
this.setLogCallback();
const initData = await judgeData.getJudgeInitData()
this.initData = initData;
log('2.获取评判初始化数据完成')
await examJudgeInit(initData);
log('3.评判初始化完成')
globalThis.isJudgeInitBool = true;
await this.setRealExamCallback()
await this.setJudgeSetPerformCallback()
}
// 开始考试
public startExam = async (beginData,fileLog) => {
const {log,initData} = this;
await fileLog.setExamJudgeData(initData)
await examJudgeBeginExam(beginData);
await fileLog.setExamJudgeData(beginData)
log('4.开始考试注册完成')
this.fileLog = fileLog;
}
// 传递实时数据
public executeGPSData = async (msg) => {
const {fileLog} = this;
const judgeData = this.judgeData;
const isString = typeof msg === 'string'
let plcData = {}
if(isString){
plcData = await judgeData.getPlcData(msg);
}else{
plcData = msg
}
await fileLog.setExamJudgeData(plcData)
await examJudgeRealExam(plcData)
}
// 结束考试
endExam = async () => {
await examJudgeEndExam()
}
// 评判过程回调
setRealExamCallback = async () => {
const JUDGE = JudgeEvent.JUDGE
const {log} = this;
let judgeEvent = {
eventId: JUDGE,
priority: IMMEDIATE
};
await examJudgeSetRealExamCallback(async (strData,len)=>{
log('评判回调数据' + strData)
emitter.emit(judgeEvent, strData);
})
}
// 实时数据回调
setJudgeSetPerformCallback = async () => {
const PERFORM = JudgeEvent.PERFORM
let performEvent = {
eventId: PERFORM,
priority: IDLE
};
await examJudgeSetPerformCallback(async (info)=>{
console.info('评判实时数据',info)
emitter.emit(performEvent , info);
})
}
// 通用日志回调
setLogCallback = async () => {
const LOG = JudgeEvent.LOG
let logEvent = {
eventId: LOG,
priority: IDLE
};
await examJudgeSetLogCallback(3, async (level, info,len)=>{
console.log('评判日志:' + info)
emitter.emit(logEvent, info);
})
}
log = (msg) => {
console.info(judgeTag,msg)
}
}

View File

@ -5,7 +5,7 @@ import { dateFormat} from '../common/utils/tools'
import deviceManager from '@ohos.distributedHardware.deviceManager'
import { upDateTableConfig } from '../common/service/initable'
import { voiceService } from '../common/service/voiceService'
import prompt from '@ohos.prompt'
import promptAction from '@ohos.promptAction'
@Entry
@Component
struct Index {
@ -19,8 +19,6 @@ struct Index {
@State @Watch('outClick') outFlag: boolean = false;
@State subType: string = '2';
onPageShow() {
// this.ip = globalThis.diskId
this.plateNo=globalThis.carInfo.plateNo
deviceManager.createDeviceManager('com.example.udptest', (error, value) => {
if (error) {
@ -29,9 +27,9 @@ struct Index {
}
let dvMgrObj = value;
this.deviceName = dvMgrObj.getLocalDeviceInfoSync().deviceName
this.deviceNo=dvMgrObj.getLocalDeviceInfoSync().deviceId
this.ip='MAC-'+this.deviceName.toUpperCase()
globalThis.deviceNo='MAC-'+this.deviceName
this.deviceNo=dvMgrObj.getLocalDeviceInfoSync().deviceId.substring(0,10).toUpperCase()
this.ip='MAC-'+this.deviceNo
globalThis.deviceNo='MAC-'+this.deviceNo
});
}
@ -46,16 +44,11 @@ struct Index {
.width(50).onChange((isChecked: boolean) => {
if(isChecked)
this.subType = '2'
this.ip='MAC-'+this.deviceName
this.ip='MAC-'+this.deviceNo
globalThis.deviceNo=this.ip
// this.ip = globalThis.diskId
})
Text('网卡').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 98.5 * this.ratio })
}.onClick(() => {
// this.checked = '0'
// this.ip = globalThis.diskId
})
}
Row() {
Radio({ value: '1', group: 'radioGroup' }).checked(this.subType=='3'?true:false)
@ -63,36 +56,15 @@ struct Index {
.width(50).onChange((isChecked: boolean) => {
if(isChecked)
this.subType = '3'
this.ip='DISK-'+this.deviceName
this.ip='DISK-'+this.deviceNo
globalThis.deviceNo=this.ip
// this.ip = ip
})
Text('硬盘').fontSize(34 * this.ratio).fontColor('#FFE0B2').margin({ right: 83 * this.ratio })
}.onClick(() => {
// this.checked = '1'
// this.ip = globalThis.deviceNo
})
// Image($r('app.media.huoqu_nor')).width(185 * this.ratio).height(89 * this.ratio).onClick(() => {
// // this.checked = '1111'
// getDeviceInfo()
// })
}
}.margin({ top: 35 * this.ratio })
Row() {
// Column(){
// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
// Text(this.plateNo).fontColor('#fff').fontSize(33.6 * this.ratio)
// }.width('100%')
// .height('100%')
// .padding({ left: 30 * this.ratio, right: 30 * this.ratio })
// }
// .backgroundImage($r('app.media.xk'))
// .backgroundImageSize({ width: '100%', height: '100%' })
// .width(220 * this.ratio)
// .height(108 * this.ratio)
Column(){
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(this.ip).fontColor('#fff')
@ -128,14 +100,9 @@ struct Index {
outClick(){
}
registrationDeviceNoFn(){
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
const date=new Date()
const param={
time: dateFormat(date),
// deviceNo:this.deviceNo,
deviceName:this.ip,
type:'1'
}
@ -143,7 +110,7 @@ struct Index {
upDateTableConfig('DeviceInfoTable',[{deviceId:this.ip}])
registrationDeviceNo(param).then(res=>{
if(res.registrationDeviceNoRsp.head.resultCode=='0'){
prompt.showToast({
promptAction.showToast({
message: decodeURIComponent(res.registrationDeviceNoRsp.head.resultMessage),
duration: 3000
});

View File

@ -16,7 +16,7 @@
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"icon": "$media:logo_app",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",

View File

@ -8,9 +8,7 @@
"pages/Settings",
"pages/TerminalInfo",
"pages/VideoConfig",
"pages/Hello",
"pages/Judge",
"pages/SignalDisplay",
"pages/SignDisplay",
"pages/RealTime"
],