拉取SVN

This commit is contained in:
“wangzhongjie” 2024-05-16 09:53:10 +08:00
parent 70a5e3a0a0
commit 4fe8bc2a39
20 changed files with 312 additions and 261 deletions

View File

@ -15,6 +15,8 @@ import {
upDataZhongxinginitialization upDataZhongxinginitialization
} from '../../common/service/initable' } from '../../common/service/initable'
import { GlobalConfig } from '../../config/index' import { GlobalConfig } from '../../config/index'
import testNapi from '@ohos.hiserialsdk'
export async function getliushuiNum(){ export async function getliushuiNum(){
console.log('getLiushuihao') console.log('getLiushuihao')
this.fileUtil = new FileUtil(this.context) this.fileUtil = new FileUtil(this.context)
@ -153,13 +155,16 @@ export async function getSingleCenterTable() {
], ],
}) })
.then(data => { .then(data => {
reslove(false)
}) })
.catch(err => { .catch(err => {
reslove(false)
}) })
reslove(false) reslove(false)
} }
}).catch((error) => { }).catch((error) => {
reslove(false)
console.log(error) console.log(error)
}) })
@ -216,7 +221,7 @@ export async function takePhotoFn(context) {
param = JSON.parse(fileData) param = JSON.parse(fileData)
console.log('paramparam') console.log('paramparam')
clearInterval(interval) clearInterval(interval)
interval = setInterval(async () => { interval = setTimeout(async () => {
const arr = ['spzd1', 'spzd2', 'spzd3', 'spzd4'] const arr = ['spzd1', 'spzd2', 'spzd3', 'spzd4']
for (let key in map) { for (let key in map) {
@ -239,13 +244,62 @@ export async function takePhotoFn(context) {
map[key] = false map[key] = false
globalThis.spzd[key] = false globalThis.spzd[key] = false
} }
setTimeout(()=>{
takePhotoFn()
},3000)
}) })
} }
} }
globalThis.takePhotoNum++ globalThis.takePhotoNum++
if (globalThis.takePhotoNum >= 2) { if (globalThis.takePhotoNum >= 20) {
globalThis.takePhotoNum = 0 globalThis.takePhotoNum = 0
deleteAllFileByPiC('jt') // deleteAllFileByPiC('jt')
} }
}, 3000) }, 3000)
}
let fd
const devPath="/dev/ttyS3"
function openChuankouFn() {
fd = testNapi.SerialOpen(devPath);
globalThis.fd=fd
console.log('fdfd1111',globalThis.fd)
let parity = 0x4e; // 'N'
let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity);
}
function getChuankouFnMsg() {
let timeout = 50000; // 2秒超时
let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
console.log('fdfd',globalThis.fd)
let ret = testNapi.SerialSend(globalThis.fd, databuff);
console.log('mmmm',ret)
let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout);
console.log('revTestInfo',revTestInfo.recevedBuf.length)
const message = revTestInfo?.recevedBuf?.toString()
console.log('chuankou',message)
if (message == '') {
return
}
const msg = message?.split(',')
if(!msg?.length){
return
}
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return
}
globalThis.chuankoMsg=msg[9]
}
export async function getChuankouFn(){
if(globalThis.fd){
return
}
openChuankouFn()
setInterval(()=>{
getChuankouFnMsg()
},1000)
} }

View File

@ -368,6 +368,8 @@ export async function upDataZhongxinginitialization(){
} }
} }
resolve(true) resolve(true)
}).catch((Error)=>{
resolve(false)
}) })
}) })

View File

@ -28,10 +28,10 @@ photoAccessHelper.PhotoKeys.TITLE,
photoAccessHelper.PhotoKeys.POSITION, photoAccessHelper.PhotoKeys.POSITION,
photoAccessHelper.PhotoKeys.DATE_TRASHED, photoAccessHelper.PhotoKeys.DATE_TRASHED,
photoAccessHelper.PhotoKeys.HIDDEN]; photoAccessHelper.PhotoKeys.HIDDEN];
const rtsp_server = record.createServer();
export async function startRecordVideo(param, td, context, dir) { export async function startRecordVideo(param, td, context, dir) {
return new Promise((reslove, reject) => { return new Promise((reslove, reject) => {
const rtsp_server = record.createServer();
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`;
if (rtsp_server != null) { if (rtsp_server != null) {
console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri); console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri);
@ -56,7 +56,6 @@ export async function startRecordVideo(param, td, context, dir) {
//结束录屏 //结束录屏
export async function endRecordVideo(record_handle) { export async function endRecordVideo(record_handle) {
const rtsp_server = record.createServer();
if (rtsp_server != null && record_handle > 0) { if (rtsp_server != null && record_handle > 0) {
console.log(`Rtsprecord endRecordVideo begin`); console.log(`Rtsprecord endRecordVideo begin`);
// @ts-ignore // @ts-ignore
@ -91,37 +90,51 @@ interface takePhotoParam {
* @param callback * @param callback
* @returns * @returns
*/ */
const fileHelper = new FileHelper();
export async function takePhoto(param, context,dir,flag=1,callback?) { export async function takePhoto(param, context,dir,flag=1,callback?) {
const rtsp_server = record.createServer();
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 video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
const num = Math.floor(Math.random() * 10000) const num = Math.floor(Math.random() * 10000)
const fileName = `picture_record${num}.jpg` const fileName = `picture_record${num}.jpg`
console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName` + fileName); console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName` + fileName);
// @ts-ignore // @ts-ignore
// var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir); // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir);
if(flag==0){ if(flag==0){
rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,false,(err,snapResult)=>{ rtsp_server.detectVideoSnapshotSize(video_uri,fileName,(err,snapResult)=>{
console.log(`baoyihu getVideoSnapshot return `); console.log("baohaowen_detectLoop round end size1:"+snapResult.fileSize);
console.log(`baoyihu getVideoSnapshot file_name` + snapResult.fileName); callback({fileSize:snapResult.fileSize })
console.log(`baoyihu getVideoSnapshot file_path` + snapResult.filePath);
console.log(`baoyihu getVideoSnapshot fileSize` + snapResult.fileSize);
callback({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize })
}); });
}else{ // rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,false,(err,snapResult)=>{
// console.log(`baoyihu getVideoSnapshot return `);
// console.log(`baoyihu getVideoSnapshot file_name` + snapResult.fileName);
// console.log(`baoyihu getVideoSnapshot file_path` + snapResult.filePath);
// console.log(`baoyihu getVideoSnapshot fileSize` + snapResult.fileSize);
// fileHelper.addFile(fileName,1)
// callback({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize })
// console.log('getmyLog01')
// });
}
else{
return new Promise<takePhotoParam>((resolve,reject)=>{ return new Promise<takePhotoParam>((resolve,reject)=>{
rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,true,(err,snapResult)=>{ rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,true,(err,snapResult)=>{
console.log('getPhtot')
resolve({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize }) resolve({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize })
}); });
}) })
console.log('getmyLog02')
} }
console.log('getmyLog03')
} }
export async function deleteAllFileByPiC(dirName) { export async function deleteAllFileByPiC(dirName) {
const fileHelper = new FileHelper(); // const fileHelper = new FileHelper();
fileHelper.deleteFileOfAlbum(dirName,1); fileHelper.deleteFileOfAlbum(dirName,1);
} }

View File

@ -1,34 +1,35 @@
import TcpClient from './TcpClient'; import TcpClient from './TcpClient';
import UdpClient from './UdpClient';
import {sendMsg} from './GlobleUdp'
import { getSyncData} from '../service/initable' import { getSyncData} from '../service/initable'
import prompt from '@ohos.prompt' import hilog from '@ohos.hilog';
export async function getTCP() { export async function getTCP() {
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{ getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
console.log('result222',JSON.stringify(result)) console.log('result222',JSON.stringify(result))
if(result.length){ if(result.length){
if(globalThis.TcpClient&&globalThis.TcpClient.closeTcp){ if(globalThis.TcpClient&&globalThis.TcpClient.closeTcp){
const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) globalThis.TcpClient.closeTcp(async ()=>{
globalThis.TcpClient = tcpClient // const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
await globalThis.TcpClient.bindTcp() // globalThis.TcpClient = tcpClient
await globalThis.TcpClient.connectTcp()
await globalThis.TcpClient.sendMsg('1002')//1002
// setInterval(()=>{
// globalThis.TcpClient.sendMsg('1002')//1002
//
// },2000)
await globalThis.TcpClient.onMessage((val)=>{
console.log('valvalval',val)
setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002
if(val){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient.sendMsg(val)
}
},1000)
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
await globalThis.TcpClient.connectTcp()
await globalThis.TcpClient.sendMsg('1002')//1002
globalThis.TcpClient.onError()
await globalThis.TcpClient.onMessage((val)=>{
hilog.info(0x0000, 'testTag', "valvalval1" + JSON.stringify(val));
// console.log('valvalval',val)
setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002
if(val){
// const msg=val.substring(5,val.length-1)
globalThis.udpClient?.sendMsg(val)
}
},1000)
})
}) })
}else{ }else{
// prompt.showToast({ // prompt.showToast({
// message:'初始化localIp'+ result[0].localIp+ result[0].localIpPort+'oppositeIp'+result[0].oppositeIp+result[0].oppositeIpPort, // message:'初始化localIp'+ result[0].localIp+ result[0].localIpPort+'oppositeIp'+result[0].oppositeIp+result[0].oppositeIpPort,
@ -43,13 +44,14 @@ export async function getTCP() {
// globalThis.TcpClient.sendMsg('1002')//1002 // globalThis.TcpClient.sendMsg('1002')//1002
// //
// },2000) // },2000)
globalThis.TcpClient.onError()
await globalThis.TcpClient.onMessage((val)=>{ await globalThis.TcpClient.onMessage((val)=>{
console.log('valvalval',val) hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
setTimeout(()=>{ setTimeout(()=>{
globalThis.TcpClient.sendMsg('1002')//1002 globalThis.TcpClient.sendMsg('1002')//1002
if(val){ if(val){
// const msg=val.substring(5,val.length-1) // const msg=val.substring(5,val.length-1)
globalThis.udpClient.sendMsg(val) globalThis.udpClient?.sendMsg(val)
} }
},1000) },1000)

View File

@ -6,11 +6,10 @@ import prompt from '@ohos.prompt'
import TcpClient from './TcpClient'; import TcpClient from './TcpClient';
import {string2Bytes} from '../../common/utils/tools' import {string2Bytes} from '../../common/utils/tools'
export async function sendMsg(val){ export async function sendMsg(val){
globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val) // globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
} }
export async function getUDP() { export async function getUDP() {
getSyncData('IpConfigTable').then((result:Array<any>)=>{ getSyncData('IpConfigTable').then((result:Array<any>)=>{
console.log('result222',JSON.stringify(result))
if(result.length){ if(result.length){
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){ if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
globalThis.udpClient.closeUdp(()=>{ globalThis.udpClient.closeUdp(()=>{
@ -51,13 +50,11 @@ export async function getUDP2() {
globalThis.udpClient2 = udpClient globalThis.udpClient2 = udpClient
globalThis.udpClient2.bindUdp() globalThis.udpClient2.bindUdp()
globalThis.udpClient2.onMessage((val)=>{ globalThis.udpClient2.onMessage((val)=>{
console.log('valval',JSON.stringify(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)
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])

View File

@ -3,7 +3,7 @@ import buffer from '@ohos.buffer';
const TAG = '[TcpDemo.TcpClient]' const TAG = '[TcpDemo.TcpClient]'
import prompt from '@ohos.prompt' import prompt from '@ohos.prompt'
import hilog from '@ohos.hilog';
export default class TcpClient { export default class TcpClient {
private localIp: string = '' private localIp: string = ''
@ -18,9 +18,19 @@ export default class TcpClient {
this.oppositeIp = tcpOppositeIp this.oppositeIp = tcpOppositeIp
this.localIpPort = tcplocalIpPort this.localIpPort = tcplocalIpPort
this.oppositeIpPort = tcpOppositePort this.oppositeIpPort = tcpOppositePort
console.log('tcp1111',this.localIp,this.localIpPort,this.oppositeIp,this.oppositeIpPort)
this.tcp = socket.constructTCPSocketInstance(); this.tcp = socket.constructTCPSocketInstance();
} }
onError(callback?){
this.tcp.on('error', err => {
hilog.info(0x0000, 'testTag', "on error, err:" + JSON.stringify(err));
this.bindTcp()
this.connectTcp()
// this.closeUdp(()=>{
// this.bindUdp()
// })
});
}
rebindTcp(localIp: string, localIpPort:string,oppositeIp: string,oppositeIpPort:string){ rebindTcp(localIp: string, localIpPort:string,oppositeIp: string,oppositeIpPort:string){
return new Promise((resolve, reject)=>{ return new Promise((resolve, reject)=>{
@ -30,12 +40,11 @@ export default class TcpClient {
this.oppositeIpPort = oppositeIpPort this.oppositeIpPort = oppositeIpPort
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => { let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
if (err) { if (err) {
console.log('bind fail'); hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
resolve(true) resolve(true)
} }
resolve(false) resolve(false)
console.log('bind success');
}) })
}) })
@ -50,7 +59,7 @@ export default class TcpClient {
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => { let promise=this.tcp.bind({ address: this.localIp, port:parseInt(this.localIpPort), family: 1 }, err => {
if (err) { if (err) {
console.log('bind fail'); hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
resolve(true) resolve(true)
} }
console.log('bind success'); console.log('bind success');
@ -83,15 +92,11 @@ export default class TcpClient {
// socketTimeout: 3000, // socketTimeout: 3000,
},err => { },err => {
if (err) { if (err) {
console.log('setExtraOptions fail');
return; return;
} }
console.log('setExtraOptions success');
}); });
console.log('connect success')
resolve(true) resolve(true)
}).catch(err => { }).catch(err => {
console.log('connect fail');
resolve(false) resolve(false)
}); });
}) })
@ -104,15 +109,12 @@ export default class TcpClient {
data:msg data:msg
}); });
promise.then(() => { promise.then(() => {
console.log('send success');
reslove(true) reslove(true)
}).catch(err => { }).catch(err => {
console.log('send fail');
reslove(false) reslove(false)
}); });
}) })
console.log('oppositeIpPort',this.oppositeIpPort)
// let promise = this.udp.send({ // let promise = this.udp.send({
// data: msg, // data: msg,
// address: { // address: {
@ -178,6 +180,7 @@ export default class TcpClient {
let promise = this.tcp.close(); let promise = this.tcp.close();
promise.then(() => { promise.then(() => {
console.log('close success'); console.log('close success');
callback()
reslove(true) reslove(true)
}).catch(err => { }).catch(err => {
console.log('close fail'); console.log('close fail');

View File

@ -15,11 +15,12 @@
import socket from '@ohos.net.socket'; import socket from '@ohos.net.socket';
import { Array2Byte } from '../utils/tools' import { Array2Byte } from '../utils/tools'
import {getChuankouFn} from '../../common/service/indexService'
const TAG = '[PLC.UdpClient]' const TAG = '[PLC.UdpClient]'
import prompt from '@ohos.prompt' import prompt from '@ohos.prompt'
import hilog from '@ohos.hilog';
export default class UdpClient { export default class UdpClient {
private localIp: string = '' private localIp: string = ''
private localIpPort: string = '' private localIpPort: string = ''
@ -34,6 +35,7 @@ export default class UdpClient {
this.oppositeIp = udpOppositeIp this.oppositeIp = udpOppositeIp
this.localIpPort = udplocalIpPort this.localIpPort = udplocalIpPort
this.oppositeIpPort = udpOppositeIpPort this.oppositeIpPort = udpOppositeIpPort
getChuankouFn()
// this.stashFn=()=>{} // this.stashFn=()=>{}
this.udp = socket.constructUDPSocketInstance(); this.udp = socket.constructUDPSocketInstance();
} }
@ -44,31 +46,33 @@ export default class UdpClient {
this.oppositeIp = oppositeIp this.oppositeIp = oppositeIp
this.localIpPort = localIpPort this.localIpPort = localIpPort
this.oppositeIpPort = oppositeIpPort this.oppositeIpPort = oppositeIpPort
hilog.info(0x0000, 'udpCLient', 'rebind'+this.localIp+this.localIpPort);
let promise = this.udp.bind({ let promise = this.udp.bind({
address: this.localIp, port: parseInt(this.localIpPort), family: 1 address: this.localIp, port: parseInt(this.localIpPort), family: 1
}); });
promise.then(() => { promise.then(() => {
console.log(`${TAG} udp bind success`); console.log(`${TAG}udpCLient udp rebind success`);
}).catch(err => { }).catch(err => {
console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); console.log(`${TAG}udpCLient udp rebind failed:${JSON.stringify(err)}`);
}); });
} }
bindUdp() { bindUdp() {
console.log('localIp', this.localIp) console.log('localIp', this.localIp)
console.log('localIpPort', this.localIpPort) console.log('localIpPort', this.localIpPort)
hilog.info(0x0000, 'udpCLient', 'bind'+ this.localIp+this.localIpPort);
let promise = this.udp.bind({ let promise = this.udp.bind({
// address: '192.168.7.170', port: 20122, family: 1 address: '192.168.7.170', port: 20122, family: 1
// address: '192.168.7.170', port: 31013, family: 1 // address: '192.168.7.170', port: 31013, family: 1
address: this.localIp, port: parseInt(this.localIpPort), family: 1 // address: this.localIp, port: parseInt(this.localIpPort), family: 1
}); });
promise.then(() => { promise.then(() => {
console.log(`${TAG} udp bind success`); console.log(`${TAG}udpCLient udp bind success`);
}).catch(err => { }).catch(err => {
console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); console.log(`${TAG}udpCLient udp bind failed:${JSON.stringify(err)}`);
}); });
} }
setMsgCallBack(callback){ setMsgCallBack(callback){
@ -76,28 +80,30 @@ export default class UdpClient {
} }
sendMsg(msg: string) { sendMsg(msg: string) {
console.log('sendsnd01') console.log('sendsnd01')
hilog.info(0x0000, 'udpCLient', 'send');
let promise = this.udp.send({ let promise = this.udp.send({
data: msg, data: msg,
address: { address: {
// address: '192.168.7.124', // address: '192.168.7.124',
// port: 30013, // port: 30013,
// address: '192.168.7.124', address: '192.168.7.124',
// port: 20022, port: 20022,
address: this.oppositeIp, // address: this.oppositeIp,
port: parseInt(this.oppositeIpPort), // port: parseInt(this.oppositeIpPort),
family: 1 family: 1
} }
}); });
promise.then(() => { promise.then(() => {
console.log(`${TAG} ${this.oppositeIpPort} udp send success:${msg}`); console.log(`${TAG}udpCLient udp send success:${msg}`);
}).catch(err => { }).catch(err => {
console.log(`${TAG} udp send fail:${JSON.stringify(err)}`); console.log(`${TAG}udpCLient udp send fail:${JSON.stringify(err)}`);
}); });
} }
onError(callback?){ onError(callback?){
this.udp.on('error', err => { this.udp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err)) hilog.info(0x0000, 'udpCLient', 'error'+ JSON.stringify(err));
console.log("on error, err:" + JSON.stringify(err))
// this.closeUdp(()=>{ // this.closeUdp(()=>{
// this.bindUdp() // this.bindUdp()
// }) // })
@ -108,7 +114,8 @@ export default class UdpClient {
this.udp.on('message', value => { this.udp.on('message', value => {
// 收到的是ArrayBuffer 需要进行转换解析 // 收到的是ArrayBuffer 需要进行转换解析
console.log('messageTimeStart') hilog.info(0x0000, 'udpCLient', 'onmessage');
globalThis.plcUdpError = false globalThis.plcUdpError = false
if (value) { if (value) {
@ -121,15 +128,18 @@ export default class UdpClient {
str += c str += c
} }
} }
console.log(`${TAG} udp on message array buffer:${str}`); console.log(`${TAG} udp on message array buffer:${str}`);
const strachArr = str.split(',') let strachArr = str.split(',')
if (strachArr[0] != '#DN_GD') { if (strachArr[0] != '#DN_GD') {
return return
} }
strachArr[28]=globalThis.chuankoMsg
// this.stashFn(str) // this.stashFn(str)
const newArr=JSON.parse(JSON.stringify(strachArr))
console.log('22222',strachArr[28],newArr)
// this.stashFn=()=>{} // this.stashFn=()=>{}
callback(str) callback(newArr.toString())
} else { } else {
callback('') callback('')
@ -167,7 +177,10 @@ export default class UdpClient {
closeUdp(callback) { closeUdp(callback) {
this.udp.close(err => { this.udp.close(err => {
hilog.info(0x0000, 'udpCLient', 'close');
if (err) { if (err) {
hilog.info(0x0000, 'udpCLient', 'closeonerror');
} else { } else {
this.udp.getState((err, data) => { this.udp.getState((err, data) => {

View File

@ -21,7 +21,7 @@ import {fillZero,string2Bytes} from '../utils/tools'
import { GlobalConfig } from '../../config/index' import { GlobalConfig } from '../../config/index'
const TAG = '[UdpDemo.UdpClient]' const TAG = '[UdpDemo.UdpClient]'
// import common from '@ohos.app.ability.common'; // import common from '@ohos.app.ability.common';
import hilog from '@ohos.hilog';
import prompt from '@ohos.prompt' import prompt from '@ohos.prompt'
import call from '@ohos.telephony.call'; import call from '@ohos.telephony.call';
@ -180,7 +180,6 @@ export default class UdpClientByCenter {
} }
onMessage(callback,type?) { onMessage(callback,type?) {
this.udp.on('message', value => { this.udp.on('message', value => {
console.log('tttttt')
let arr=[] let arr=[]
let dataView = new DataView(value.message) let dataView = new DataView(value.message)
for (let i = 0;i < dataView?.byteLength; ++i) { for (let i = 0;i < dataView?.byteLength; ++i) {
@ -188,7 +187,7 @@ export default class UdpClientByCenter {
} }
let idNum = '0x' + fillZero(arr[1].toString(16),2) + fillZero(arr[0].toString(16),2) ; let idNum = '0x' + fillZero(arr[1].toString(16),2) + fillZero(arr[0].toString(16),2) ;
let id = Math.floor(+idNum/1000) let id = Math.floor(+idNum/1000)
console.log('bitbit',arr) hilog.info(0x0000, 'bitbit', JSON.stringify(arr));
let lengthNum = '0x' + fillZero(arr[7].toString(16),2) + fillZero(arr[6].toString(16),2) ; let lengthNum = '0x' + fillZero(arr[7].toString(16),2) + fillZero(arr[6].toString(16),2) ;
let length= +lengthNum; let length= +lengthNum;
@ -208,7 +207,6 @@ export default class UdpClientByCenter {
}else{ }else{
this.udp.getState((err, data) => { this.udp.getState((err, data) => {
if (err) { if (err) {
console.log('getState fail');
return; return;
}else{ }else{
if(!data.isisClose){ if(!data.isisClose){
@ -217,7 +215,6 @@ export default class UdpClientByCenter {
},1000) },1000)
} }
} }
console.log('getState success:' + JSON.stringify(data));
}) })
// let promise = this.udp.getState({}); // let promise = this.udp.getState({});
// promise.then(data => { // promise.then(data => {

View File

@ -1,6 +1,6 @@
import systemTime from '@ohos.systemDateTime'; import systemTime from '@ohos.systemDateTime';
import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte} from '../../common/utils/tools' import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte} from '../../common/utils/tools'
import {testMarkRules,testAllitems,testRealExam,testUIAllitems,testKm2Items} from '../../pages/judgeSDK/dataTest/index' import {testMarkRules,testAllitems,testRealExam,testUIAllitems,testKmItems} from '../../pages/judgeSDK/dataTest/index'
import {setJudgeUdp,setTopLineUdp} from './GlobleUdp' import {setJudgeUdp,setTopLineUdp} from './GlobleUdp'
import {convertGpsCoord2} from '../utils/tools' import {convertGpsCoord2} from '../utils/tools'
@ -34,7 +34,6 @@ export const initJudgeUdp = async () => {
} }
globalThis.udpIndex+=1 globalThis.udpIndex+=1
}) })
} }
export const getMessageHeartbeat = async (msg) => { export const getMessageHeartbeat = async (msg) => {
@ -112,13 +111,13 @@ const getTranslateSignals = (tempItems) => {
// 中心所有项目转换 // 中心所有项目转换
const getTranslateProject = () => { const getTranslateProject = () => {
const allKm2ItemsObj = {}; const allKmItemsObj = {};
testKm2Items.forEach(item => { testKmItems.forEach(item => {
allKm2ItemsObj[item.code] = item; allKmItemsObj[item.code] = item;
}) })
const tempItems = testKm2Items.map(item=>{ const tempItems = testKmItems.map(item=>{
const current = allKm2ItemsObj[item.code]; const current = allKmItemsObj[item.code];
return { return {
code:item.code, code:item.code,
status:getCenterProjectStatus(current.status) status:getCenterProjectStatus(current.status)

View File

@ -10,7 +10,7 @@ import { dateFormat } from '../common/utils/tools';
@Component @Component
struct Index { struct Index {
@State angle: number = 0 @State angle: number = 0
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State index: number = -1 @State index: number = -1
@State time: string = '' @State time: string = ''
@State msg: string = '' @State msg: string = ''
@ -189,8 +189,9 @@ struct Index {
} }
@State len: any = '' @State len: any = ''
@State fd: number = -1; @State fd: number = -1;
@State devPath: string = "/dev/ttyS5" @State devPath: string = "/dev/ttyS3"
@State interval: any="" @State interval: any=""
@State chuankouFlag: any=""
@State stopFlag: boolean=false @State stopFlag: boolean=false
// private AccountTable = new AccountTable(()=>{},CommonConstants); // private AccountTable = new AccountTable(()=>{},CommonConstants);
onPageShow() { onPageShow() {
@ -211,15 +212,17 @@ struct Index {
}); });
this.carConfigurationInfoFn() this.carConfigurationInfoFn()
//todo串口 // //todo串口
this.openChuankouFn() // this.openChuankouFn()
this.interval=setInterval(()=>{ // // this.getChuankouFn()
const dwArr=[14,15,16,17,18,19,20] //
if(dwArr.indexOf(this.index)>=0&&!this.stopFlag){ // this.interval=setInterval(()=>{
this.getChuankouFn() // const dwArr=[14,15,16,17,18,19,20]
return // // if(dwArr.indexOf(this.index)>=0&&!this.stopFlag){
} // this.getChuankouFn()
},1000) // return
// // }
// },1000)
} }
openChuankouFn() { openChuankouFn() {
@ -229,11 +232,17 @@ struct Index {
} }
getChuankouFn() { getChuankouFn() {
let timeout = 2000000; // 2秒超时 let timeout = 50000; // 2秒超时
let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
let ret = testNapi.SerialSend(this.fd, databuff); let ret = testNapi.SerialSend(this.fd, databuff);
console.log('mmmm',ret)
let revTestInfo = testNapi?.SerialRecv(this.fd, timeout); let revTestInfo = testNapi?.SerialRecv(this.fd, timeout);
console.log('revTestInfo',revTestInfo.recevedBuf.length)
const message = revTestInfo?.recevedBuf?.toString() const message = revTestInfo?.recevedBuf?.toString()
console.log('chuankou',this.index,message)
if (message == '') { if (message == '') {
this.stopFlag=true this.stopFlag=true
return return
@ -245,25 +254,28 @@ struct Index {
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return return
} }
globalThis.chuankoMsg=msg[9]
if (msg[9] == this.dwMap[this.index]) { if (msg[9] == this.dwMap[this.index]) {
this.warnFlag[this.index] = '2' this.warnFlag[this.index] = '2'
} }
} }
async xhxs() { async xhxs() {
this.vocObj.avPlayerStop() this.vocObj.avPlayerStop()
this.vocObj.releasePlayer() this.vocObj.releasePlayer()
router.pushUrl({ router.pushUrl({
url: 'pages/SignDisplay', url: 'pages/SignDisplay',
}, router.RouterMode.Single); }, router.RouterMode.Single);
clearInterval(this.interval) // clearInterval(this.interval)
} }
// //
carConfigurationInfoFn() { carConfigurationInfoFn() {
if (globalThis.singlePlay) { if (globalThis.singlePlay) {
const str = "1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;10:2;11:2;12:2;13:2;14:2;15:2;16:5;17:5;18:2;19:2;20:2;21:2;22:2;23:2;24:2" // 1:5;2:5;3:5;4:5;5:5;6:5;7:5;8:5;9:5;
const str = "10:5;11:5;12:5;13:5;14:5;15:2;16:5;17:5;18:2;19:2;20:2;21:2;22:2;23:2;24:2"
const data = str.split(';') const data = str.split(';')
this.checkList = [] this.checkList = []
const list = data const list = data
@ -418,9 +430,13 @@ struct Index {
this.signArr = stachArr this.signArr = stachArr
const dw = [14, 15, 16, 17, 18, 19, 20]; const dw = [14, 15, 16, 17, 18, 19, 20];
const dwArr = [14, 15, 16, 17, 18, 19, 20] const dwArr = [14, 15, 16, 17, 18, 19, 20]
if (dwArr.indexOf(this.index) >= 0) {
return if(dwArr.indexOf(this.index)>=0){
if (stachArr[28] == this.dwMap[this.index]) {
this.warnFlag[this.index] = '2'
}
} }
if (this.subFlag) { if (this.subFlag) {
//进项目 //进项目
that.stachValue[that.index] = that.signArr[that.realNum[that.index]] that.stachValue[that.index] = that.signArr[that.realNum[that.index]]
@ -546,7 +562,7 @@ struct Index {
outClick() { outClick() {
this.vocObj&& this.vocObj.releasePlayer() this.vocObj&& this.vocObj.releasePlayer()
this.breakFlag = false this.breakFlag = false
clearInterval(this.interval) // clearInterval(this.interval)
} }
build() { build() {
@ -735,7 +751,7 @@ struct Index {
.backgroundImageSize({ width: '100%', height: '100%' }) .backgroundImageSize({ width: '100%', height: '100%' })
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
.onClick(() => { .onClick(() => {
console.log('xhsx')
this.xhxs() this.xhxs()
}) })
.zIndex(11) .zIndex(11)

View File

@ -7,7 +7,7 @@ import promptAction from '@ohos.promptAction'
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State ratio: number = 850 / 960 @State ratio: number = 1700 / 960
@State url: string = '' @State url: string = ''
@State inputPlaceholderArr: string[] = ['用户账户','密码']; @State inputPlaceholderArr: string[] = ['用户账户','密码'];
@State inputTextArr: string[] = ['','']; @State inputTextArr: string[] = ['',''];

View File

@ -29,7 +29,7 @@ struct Index {
@State deviceId: string = ''; @State deviceId: string = '';
private interval = null; private interval = null;
@State angle: number = 0 @State angle: number = 0
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State loading: boolean = true @State loading: boolean = true
@State fd: number = -1; @State fd: number = -1;
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
@ -106,11 +106,18 @@ struct Index {
this.angle = 360 this.angle = 360
}, 1000) }, 1000)
this.angle = 0 this.angle = 0
//mode为3双中心下载表 //mode为3双中心下载表
if(globalThis.timeInfo.mode=='3'){ if(globalThis.timeInfo?.mode=='3'){
await getDoubleCeneterTable() await getDoubleCeneterTable()
}else{ }else if(globalThis.timeInfo?.mode=='1'){
await getSingleCenterTable() await getSingleCenterTable()
}else{
promptAction.showToast({
message: `网络连接失败`,
duration: 3000
});
this.loading=false
} }
this.loading=false this.loading=false
@ -121,10 +128,13 @@ struct Index {
if (this.loading) { if (this.loading) {
return return
} }
router.pushUrl({ router.pushUrl({
url: 'pages/UserInfo', url: 'pages/UserInfo',
params: { judge: true }
}, router.RouterMode.Single); }, router.RouterMode.Single);
// router.pushUrl({
// url: 'pages/UserInfo',
// }, router.RouterMode.Single);
}) })
} }
Image($r('app.media.index_zj')).width('30.5%').height('74%').onClick(() => { Image($r('app.media.index_zj')).width('30.5%').height('74%').onClick(() => {
@ -235,14 +245,14 @@ struct Index {
getUDP2() getUDP2()
clearInterval(this.interval) clearInterval(this.interval)
this.interval=setInterval(() => { this.interval=setInterval(() => {
setliushuiNum() // setliushuiNum()
getliushuiNum() getliushuiNum()
this.heartMsg() this.heartMsg()
}, 1000) }, 1000)
takePhotoFn(this.context) takePhotoFn(this.context)
//
// 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) {

View File

@ -15,7 +15,7 @@ import MA_SYSSET from '../common/constants/MA_SYSSET';
import MA_CDSBINFO from '../common/constants/MA_CDSBINFO' import MA_CDSBINFO from '../common/constants/MA_CDSBINFO'
import ES_CARINFO from '../common/constants/ES_CARINFO' import ES_CARINFO from '../common/constants/ES_CARINFO'
import {getCurrentTime,formatTime,chunkArr,getCurrentHourTime} from '../common/utils/tools' import {getCurrentTime,formatTime,chunkArr,getCurrentHourTime} from '../common/utils/tools'
import {testUIAllitems,testMarkRules} from './judgeSDK//dataTest/index'
import { import {
examJudgeEndExam examJudgeEndExam
} from './judgeSDK/api/index' } from './judgeSDK/api/index'
@ -52,12 +52,13 @@ struct Index {
this.time = await getCurrentTime(); this.time = await getCurrentTime();
this.examTime += 1; this.examTime += 1;
},1000); },1000);
await this.initStudent(); await this.initStudent();
await this.initCar(); // await this.initCar();
await this.initSystemParam(); await this.initSystemParam();
await this.initMarkRules(); await this.initMarkRules();
await this.initSysset(); // await this.initSysset();
await this.initCDSBInfo() // await this.initCDSBInfo()
const {name,idCard,lsh,kszp} = this; const {name,idCard,lsh,kszp} = this;
@ -101,13 +102,17 @@ struct Index {
async initMarkRules(){ async initMarkRules(){
const markRuleParams = await getSyncData('MA_MARKRULE') const markRuleParams = await getSyncData('MA_MARKRULE')
//@ts-ignore //@ts-ignore
markRuleParams.forEach(mark=>{ testMarkRules.forEach(mark=>{
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = { this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
//@ts-ignore
itemno:mark.itemno*1, itemno:mark.itemno*1,
markcatalog:mark.markcatalog, markcatalog:mark.markcatalog,
markshow:decodeURI(mark.markshow), markshow:decodeURI(mark.markshow),
//@ts-ignore
markreal:mark.markreal*1, markreal:mark.markreal*1,
//@ts-ignore
markserial:mark.markserial, markserial:mark.markserial,
//@ts-ignore
kfxh:mark.kfxh kfxh:mark.kfxh
}; };
}) })
@ -141,41 +146,20 @@ struct Index {
//初始化systemParam表 //初始化systemParam表
async initSystemParam(){ async initSystemParam(){
const db = new AccountTable(()=>{},MA_SYSTEMPARM);
const systemParms:any = await getSyncData('MA_SYSTEMPARM')
const carName = this.carName;
let carNo2 = '',allItems = []; let carNo2 = '',allItems = [];
systemParms.forEach((systemParm)=>{ testUIAllitems.forEach((systemParm)=>{
const {no1,no2,no3} = systemParm;
//获取当前考车的no2 const currentProject = {
if(no1 == 3 && no3 == 1){ name:systemParm.name,
const txt1 = decodeURI(systemParm.txt1) abbreviation:systemParm.abbreviation,
if(txt1 === carName){ projectCode:systemParm.projectCode,
carNo2 = no2; projectCodeCenter:systemParm.projectCodeCenter
}
} }
//获取当前考车的考试项目 this.projectsObj[systemParm.projectCode] = currentProject
if(carNo2 !== '' && no2 == carNo2 && no3 == 10){ this.projectsCenterObj[systemParm.projectCodeCenter] = currentProject
allItems = decodeURIComponent(systemParm.txt1).split(',')
}
// 存储当前考车考试项目
if(allItems.length && no1 == 6 && allItems.includes(no2)){
const txt2 = decodeURIComponent(systemParm.txt2)
const currentProject = {
name:decodeURI(systemParm.txt1),
abbreviation:decodeURI(systemParm.txt3),
projectCode:no2,
projectCodeCenter:txt2
// sbxh:project.type
}
this.projectsObj[no2] = currentProject
this.projectsCenterObj[txt2] = currentProject
this.projects.push(currentProject) this.projects.push(currentProject)
}
}) })
const projects = this.projects; const projects = this.projects;
@ -375,11 +359,10 @@ struct Index {
this.endPopupVisible = false; this.endPopupVisible = false;
}, },
confirmFn:async ()=>{ confirmFn:async ()=>{
globalThis.udpClient.onMessage(()=>{});
examJudgeEndExam();
this.endPopupVisible = false; this.endPopupVisible = false;
this.loadingPopupVisible = true this.loadingPopupVisible = true
globalThis.isJudge = false globalThis.isJudge = false
examJudgeEndExam();
clearInterval(this.timer); clearInterval(this.timer);
clearInterval(globalThis.judgeTimer) clearInterval(globalThis.judgeTimer)
globalThis.windowClass.setWindowSystemBarEnable(['navigation']) globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
@ -399,9 +382,9 @@ struct Index {
Column() { Column() {
SignDisplayCom({ SignDisplayCom({
showBack:false, showBack:false,
scaleNum:0.95, scaleNum:1.2,
msgStr:this.judge.plcStr || '' msgStr:this.judge.plcStr || ''
}).margin({top:50}) }).margin({top:100})
Row(){} Row(){}
.width(60).height(60).position({x:'80%',y:80}).backgroundImage($rawfile('judge/close.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'33.33%',height:'33.33%'}) .width(60).height(60).position({x:'80%',y:80}).backgroundImage($rawfile('judge/close.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'33.33%',height:'33.33%'})

View File

@ -9,9 +9,9 @@ import { GlobalConfig } from '../config/index'
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State textList1: string[] = ['中心服务器IP','中心响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:','后置机IP','响应端口','tcp客户端端口'] @State textList1: string[] = ['差分服务器Ip','响应端口','中心服务器IP','响应端口', '子网掩码','默认网关','dns','后置机IP ', '响应端口','前置机IP','本地端口','平台服务器Ip','响应端口']
// @State textList2: string[] = [] // @State textList2: string[] = []
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State inputFontSize:number=12 //12 @State inputFontSize:number=12 //12
// //
// @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' + // @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' +
@ -19,7 +19,7 @@ struct Index {
// @State inputTextList2: string[] = ['192.168.7.124','20022'] // @State inputTextList2: string[] = ['192.168.7.124','20022']
@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.2','8000','192.168.36.91','20022','8083'] @State inputTextList1: string[] = ['112.80.35.83','11055','112.80.35.83','11052','255.255.255.0','192.168.7.1','114.114.114.114','192.168.7.124','20022','192.168.7.170','20122','112.80.35.83','11050']
// @State inputTextList2: string[] = [] // @State inputTextList2: string[] = []
// 112.80.35.83 11052 // 112.80.35.83 11052
// @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000'] // @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000']
@ -80,14 +80,14 @@ struct Index {
.borderRadius('25px') .borderRadius('25px')
Column() { Column() {
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{ Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{
upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[2],udplocalIpPort:this.inputTextList1[3],udpOppositeIp:this.inputTextList1[11],udpOppositeIpPort:this.inputTextList1[12],tcplocalIp:this.inputTextList1[0],tcplocalIpPort:this.inputTextList1[13],tcpOppositeIp:this.inputTextList1[9],tcpOppositePort:this.inputTextList1[10],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[8],centerIp:this.inputTextList1[0],centerPort:this.inputTextList1[1]}]) upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[9],udplocalIpPort:this.inputTextList1[10],udpOppositeIp:this.inputTextList1[7],udpOppositeIpPort:this.inputTextList1[8],tcplocalIp:this.inputTextList1[9],tcplocalIpPort:'8088',tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[1],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[6],centerIp:this.inputTextList1[2],centerPort:this.inputTextList1[3]}])
ethernet.setIfaceConfig("eth0", { ethernet.setIfaceConfig("eth0", {
mode: 0, mode: 0,
ipAddr:this.inputTextList1[2], ipAddr:this.inputTextList1[9],
route: "0.0.0.0", route: "0.0.0.0",
gateway: this.inputTextList1[5],//value.gateway网关 gateway: this.inputTextList1[5],//value.gateway网关
netMask: this.inputTextList1[4],//value.netMask网络掩码 netMask: this.inputTextList1[4],//value.netMask网络掩码
dnsServers: this.inputTextList1[8], dnsServers: this.inputTextList1[6],
// domain: "" // domain: ""
}, (error) => { }, (error) => {
if (error) { if (error) {
@ -129,20 +129,20 @@ struct Index {
console.log('result222',JSON.stringify(result)) console.log('result222',JSON.stringify(result))
if(result.length){ if(result.length){
console.log('tagtag',JSON.stringify(result)) console.log('tagtag',JSON.stringify(result))
this.inputTextList1[2]=result[0].udplocalIp this.inputTextList1[9]=result[0].udplocalIp
this.inputTextList1[3]=result[0].udplocalIpPort this.inputTextList1[10]=result[0].udplocalIpPort
this.inputTextList1[11]=result[0].udpOppositeIp this.inputTextList1[7]=result[0].udpOppositeIp
this.inputTextList1[12]=result[0].udpOppositeIpPort this.inputTextList1[8]=result[0].udpOppositeIpPort
// this.inputTextList1[0]=result[0].tcplocalIp // this.inputTextList1[0]=result[0].tcplocalIp
this.inputTextList1[13]=result[0].tcplocalIpPort // this.inputTextList1[13]=result[0].tcplocalIpPort
this.inputTextList1[9]=result[0].tcpOppositeIp this.inputTextList1[0]=result[0].tcpOppositeIp
this.inputTextList1[10]=result[0].tcpOppositePort this.inputTextList1[1]=result[0].tcpOppositePort
this.inputTextList1[5]=result[0].gateway this.inputTextList1[5]=result[0].gateway
this.inputTextList1[4]=result[0].netMask this.inputTextList1[4]=result[0].netMask
this.inputTextList1[8]=result[0].dnsServers this.inputTextList1[6]=result[0].dnsServers
this.inputTextList1[0]=result[0].centerIp this.inputTextList1[2]=result[0].centerIp
this.inputTextList1[1]=result[0].centerPort this.inputTextList1[3]=result[0].centerPort
} }
}) })
ethernet.getIfaceConfig("eth0", (error, value) => { ethernet.getIfaceConfig("eth0", (error, value) => {

View File

@ -9,23 +9,23 @@ import { GlobalConfig } from '../config/index'
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State textList1: string[] = ['ftp服务器IP','响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:',] @State textList1: string[] = ['中心服务器IP','中心响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:','后置机IP','响应端口','tcp客户端端口']
@State textList2: string[] = ['后置机IP','响应端口'] // @State textList2: string[] = []
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State inputFontSize:number=12 //12 @State inputFontSize:number=12 //12
// //
// @State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' +
@State inputTextList1: string[] = ['192.168.7.170','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11055' + // '',]
'',]
@State inputTextList2: string[] = ['192.168.7.124','20022']
// @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.2','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 inputTextList2: string[] = ['192.168.7.124','20022']
@State inputTextList1: string[] = ['122.80.35.83','8083','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','192.168.7.1','8000','192.168.7.124','20022','8083']
// @State inputTextList2: string[] = []
// 112.80.35.83 11052
// @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000']
// @State inputTextList2: string[] = ['192.168.36.139','20022']
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@ -66,35 +66,7 @@ struct Index {
.width('50%') .width('50%')
.height('16.7%') .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%') .width('95%')
@ -108,8 +80,7 @@ struct Index {
.borderRadius('25px') .borderRadius('25px')
Column() { Column() {
Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{ 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]}]) upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[2],udplocalIpPort:this.inputTextList1[3],udpOppositeIp:this.inputTextList1[0],udpOppositeIpPort:this.inputTextList1[1],tcplocalIp:this.inputTextList1[2],tcplocalIpPort:this.inputTextList1[1],tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[10],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[8]}])
GlobalConfig.host=this.inputTextList1[9]
ethernet.setIfaceConfig("eth0", { ethernet.setIfaceConfig("eth0", {
mode: 0, mode: 0,
ipAddr:this.inputTextList1[2], ipAddr:this.inputTextList1[2],
@ -160,19 +131,18 @@ struct Index {
console.log('tagtag',JSON.stringify(result)) console.log('tagtag',JSON.stringify(result))
this.inputTextList1[2]=result[0].udplocalIp this.inputTextList1[2]=result[0].udplocalIp
this.inputTextList1[3]=result[0].udplocalIpPort this.inputTextList1[3]=result[0].udplocalIpPort
this.inputTextList2[0]=result[0].udpOppositeIp this.inputTextList1[11]=result[0].udpOppositeIp
this.inputTextList2[1]=result[0].udpOppositeIpPort this.inputTextList1[12]=result[0].udpOppositeIpPort
this.inputTextList1[0]=result[0].tcplocalIp // this.inputTextList1[0]=result[0].tcplocalIp
this.inputTextList1[1]=result[0].tcplocalIpPort this.inputTextList1[13]=result[0].tcplocalIpPort
this.inputTextList1[9]=result[0].tcpOppositeIp this.inputTextList1[9]=result[0].tcpOppositeIp
this.inputTextList1[10]=result[0].tcpOppositePort this.inputTextList1[10]=result[0].tcpOppositePort
this.inputTextList1[5]=result[0].gateway this.inputTextList1[5]=result[0].gateway
this.inputTextList1[4]=result[0].netMask this.inputTextList1[4]=result[0].netMask
this.inputTextList1[8]=result[0].dnsServers this.inputTextList1[8]=result[0].dnsServers
this.inputTextList1[11]=result[0].centerIp this.inputTextList1[0]=result[0].centerIp
this.inputTextList1[12]=result[0].heartPort this.inputTextList1[1]=result[0].centerPort
this.inputTextList1[13]=result[0].gpsPort
} }
}) })
ethernet.getIfaceConfig("eth0", (error, value) => { ethernet.getIfaceConfig("eth0", (error, value) => {

View File

@ -21,7 +21,7 @@ import { getSyncData } from '../common/service/initable'
@Component @Component
struct UserInfo { struct UserInfo {
@State pageIndex: number = 0 @State pageIndex: number = 0
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State index: number = 0 @State index: number = 0
@State stepFlag: boolean = false; @State stepFlag: boolean = false;
@State errorMsg: string = '' @State errorMsg: string = ''
@ -86,6 +86,7 @@ struct UserInfo {
@State faceCatchImg: string = '' @State faceCatchImg: string = ''
async onPageShow() { async onPageShow() {
//语音功能 //语音功能
const systemParms:any = await getSyncData('MA_SYSTEMPARM') const systemParms:any = await getSyncData('MA_SYSTEMPARM')
console.log('systemParms',systemParms.length) console.log('systemParms',systemParms.length)
@ -227,7 +228,6 @@ struct UserInfo {
this.lsh = this.currentUser.lsh this.lsh = this.currentUser.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
globalThis.lsh = this.lsh globalThis.lsh = this.lsh
return
} else { } else {
// this.getExaminationStudentInfoFn() // this.getExaminationStudentInfoFn()
} }

View File

@ -8,8 +8,8 @@ import { GlobalConfig } from '../config/index'
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State ratio: number = 1280 / 960 @State ratio: number = 1700 / 960
@State videoSrc: string = 'rtsp://admin:12345qwe@192.168.36.94:554/h264/ch3/main/av_stream' @State videoSrc: string = 'rtsp://admin12345qwe@192.168.36.94:554/h264/ch3/main/av_stream'
@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
@ -117,7 +117,6 @@ struct Index {
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) { Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) {
ForEach(this.videoArr,(item,index)=>{ ForEach(this.videoArr,(item,index)=>{
Video({ Video({
// src: this.openFlag ? item.src: '',
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` : '', 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: item.controller controller: item.controller
@ -156,7 +155,7 @@ struct Index {
} }
for (let i = 1; i <= 4; i++) { for (let i = 1; i <= 4; i++) {
if (this.param['videoRecord'+i]) { if (this.param['videoRecord'+i]) {
this.getfilehandleCode(i) this.getfilehandleCode(i)
} }
} }
promptAction.showToast({ promptAction.showToast({
@ -196,11 +195,11 @@ struct Index {
return return
} }
try{ try{
await takePhoto(this.param,this.context,'pz/') await takePhoto(this.param,this.context,'pz/')
promptAction.showToast({ promptAction.showToast({
message: '抓图完成', message: '抓图完成',
duration: 3000 duration: 3000
}) })
// }).catch((err) => { // }).catch((err) => {
// console.log('daihai err: ' + err) // console.log('daihai err: ' + err)
// }) // })

View File

@ -79,7 +79,7 @@ struct SignDisplayCom {
] ]
@State ratio: number = 850 / 960 @State ratio: number = 850 / 960
@State gpsActive: number = 1 @State gpsActive: number = 1
@State active: number = 0 @Prop active: number = 0
@State msgStr: string = '' @State msgStr: string = ''
@State interval: any='' @State interval: any=''
@ -394,7 +394,6 @@ struct SignDisplayCom {
} }
aboutToAppear(){ aboutToAppear(){
this.ratio = this.ratio * (this.scaleNum || 1); this.ratio = this.ratio * (this.scaleNum || 1);
const that = this const that = this
const {showBack,getSignal} = this const {showBack,getSignal} = this
@ -404,27 +403,29 @@ struct SignDisplayCom {
this.interval=setInterval(() => { this.interval=setInterval(() => {
serialPortClient.SerialSend() serialPortClient.SerialSend()
const data = serialPortClient.SerialRecv() const data = serialPortClient.SerialRecv()
if (data?.recevedLen) { // if (data?.recevedLen) {
const msg = data.msg.split(',') // const msg = data.msg.split(',')
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { // if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return // return
} // }
this.sjxhColum[18].value = msg[9] // this.sjxhColum[18].value = msg[9]
} // }
}, 1000) }, 1000)
if(showBack){ if(showBack){
globalThis.udpClient.onMessage((msg) => { globalThis.udpClient.onMessage((msg) => {
console.log('msgmsg',msg) console.log('msgmsg',msg)
getSignal(msg) if(msg){
getSignal(msg)
}
}) })
}else{ }else{
clearInterval(globalThis.signalTimer) clearInterval(globalThis.signalTimer)
globalThis.signalTimer = setInterval(()=>{ globalThis.signalTimer = setInterval(()=>{
//TODO 临时方案
console.log('msgmsgq',globalThis.msgStr)
const msgStr = globalThis.msgStr const msgStr = globalThis.msgStr
getSignal(msgStr) if(msgStr){
getSignal(msgStr)
}
},200) },200)
} }
} }
@ -447,13 +448,13 @@ struct SignDisplayCom {
this.interval=setInterval(() => { this.interval=setInterval(() => {
serialPortClient.SerialSend() serialPortClient.SerialSend()
const data = serialPortClient.SerialRecv() const data = serialPortClient.SerialRecv()
if (data.recevedLen) { // if (data.recevedLen) {
const msg = data.msg.split(',') // const msg = data.msg.split(',')
if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { // if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) {
return // return
} // }
this.sjxhColum[18].value = msg[9] // this.sjxhColum[18].value = msg[9]
} // }
}, 1000) }, 1000)
const that = this const that = this
const showBack = this.showBack; const showBack = this.showBack;
@ -495,7 +496,7 @@ struct SignDisplayCom {
this.sjxhColum[15].value = this.signArr[19] this.sjxhColum[15].value = this.signArr[19]
this.sjxhColum[16].value = this.signArr[20] this.sjxhColum[16].value = this.signArr[20]
this.sjxhColum[17].value = this.signArr[23] //车速 this.sjxhColum[17].value = this.signArr[23] //车速
// this.sjxhColum[18].value=this.signArr[18] this.sjxhColum[18].value=this.signArr[28]//档位
this.sjxhColum[19].value = this.signArr[29] this.sjxhColum[19].value = this.signArr[29]
this.sjxhColum[20].value = this.signArr[30] this.sjxhColum[20].value = this.signArr[30]
this.sjxhColum[21].value = this.signArr[15] //NC this.sjxhColum[21].value = this.signArr[15] //NC

View File

@ -13,7 +13,6 @@ import {writeObjectOut,uploadExamProgressData} from '../../api/judge'
import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte,convertGpsCoord2} from '../../common/utils/tools' import {deepClone,getCurrentTime,stringToASC,string2Bytes,fillZero,Array2Byte,convertGpsCoord2} from '../../common/utils/tools'
import {getTranslateSignals,getCarStatus,getCarStatusType,getCenterProjectStatus,plcStrToJson,plcStrToWXJson,promptWxCode} from './utils//judge-common' import {getTranslateSignals,getCarStatus,getCarStatusType,getCenterProjectStatus,plcStrToJson,plcStrToWXJson,promptWxCode} from './utils//judge-common'
import {examJudgeSetLogCallback,examJudgeBeginExam,examJudgeInit,examJudgeRealExam,examJudgeSetRealExamCallback,examJudgeSetPerformCallback,examJudgeEndExam} from './api/index' import {examJudgeSetLogCallback,examJudgeBeginExam,examJudgeInit,examJudgeRealExam,examJudgeSetRealExamCallback,examJudgeSetPerformCallback,examJudgeEndExam} from './api/index'
const judgeTag = 'SURENJUN_JUDGE' const judgeTag = 'SURENJUN_JUDGE'
export default class Judge{ export default class Judge{
@ -92,7 +91,6 @@ export default class Judge{
} }
globalThis.isJudge = true globalThis.isJudge = true
// 2.评判过程回调 // 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData,len)=>{ await examJudgeSetRealExamCallback(async (strData,len)=>{
await fileLog.setExamJudgeCallbackData(strData) await fileLog.setExamJudgeCallbackData(strData)
@ -122,7 +120,7 @@ export default class Judge{
let num = 2; let num = 2;
const judgeTimer = setInterval(async ()=>{ const judgeTimer = setInterval(async ()=>{
const msg = JSON.parse(strArr[num]); const msg = JSON.parse(strArr[num]);
await fileLog.setExamJudgeData(msg) // await fileLog.setExamJudgeData(msg)
if(!msg){ if(!msg){
console.info(judgeTag,'模拟数据考试结束') console.info(judgeTag,'模拟数据考试结束')
examJudgeEndExam(); examJudgeEndExam();
@ -136,7 +134,7 @@ export default class Judge{
globalThis.msgStr= '' globalThis.msgStr= ''
await examJudgeRealExam(msg) await examJudgeRealExam(msg)
num++ num++
},100) },200)
globalThis.judgeTimer = judgeTimer; globalThis.judgeTimer = judgeTimer;
return return
} }
@ -157,7 +155,6 @@ export default class Judge{
const judgeUdp = globalThis.judgeUdp const judgeUdp = globalThis.judgeUdp
//平台实时轨迹心跳 //平台实时轨迹心跳
const bytes= await this.getMessageHeartbeat(); const bytes= await this.getMessageHeartbeat();
globalThis.udpIndex = 0
judgeUdp.send(bytes) judgeUdp.send(bytes)
} }
globalThis.udpIndex+=1 globalThis.udpIndex+=1
@ -247,7 +244,7 @@ export default class Judge{
//更改考试状态 //更改考试状态
goVoiceAnnounce = async (event,xmdm,kf,xmjs) => { goVoiceAnnounce = async (event,xmdm,kf,xmjs) => {
const projectsObj = this.judgeUI.projectsObj; const projectsObj = this.judgeUI.projectsObj;
const {beginProject,pointsDedute,endProject,avPlayer,uploadProgressPhoto,judgeTask,handEndExam,isExam} = this; const {beginProject,pointsDedute,endProject,avPlayer,uploadProgressPhoto,judgeTask,handEndExam} = this;
const xmhg = xmjs.xmhg const xmhg = xmjs.xmhg
const kfLen = kf.length const kfLen = kf.length
switch (event){ switch (event){
@ -275,9 +272,7 @@ export default class Judge{
// 扣分 // 扣分
case 3: case 3:
console.info(judgeTag ,kf[kfLen -1].markcatalog); console.info(judgeTag ,kf[kfLen -1].markcatalog);
if(!isExam){ avPlayer.playAudio([`km2/${kf[kfLen -1].markcatalog}.mp3`])
avPlayer.playAudio([`km2/${kf[kfLen -1].markcatalog}.mp3`])
}
await judgeTask.addTask(async ()=>{ await judgeTask.addTask(async ()=>{
console.info(judgeTag,'项目扣分 start') console.info(judgeTag,'项目扣分 start')
await pointsDedute(kf[kfLen -1].xmdm,kf[kfLen -1]) await pointsDedute(kf[kfLen -1].xmdm,kf[kfLen -1])
@ -303,18 +298,14 @@ export default class Judge{
public handEndExam = async ()=>{ public handEndExam = async ()=>{
const {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++调用考试结束 // c++调用考试结束
await examJudgeEndExam(); await examJudgeEndExam();
globalThis.isJudge = false globalThis.isJudge = false
//结束考试
globalThis.udpClient.onMessage(()=>{});
await endExam() await endExam()
} }
@ -513,6 +504,7 @@ export default class Judge{
console.info(judgeTag,`考试成绩:${totalScore}`) console.info(judgeTag,`考试成绩:${totalScore}`)
fileLog.setExamJudgeWuxiData(data) fileLog.setExamJudgeWuxiData(data)
await uploadProgressData(); await uploadProgressData();
setTimeout(()=>{ setTimeout(()=>{
router.back(); router.back();
},3000) },3000)

View File

@ -3,11 +3,11 @@
//考试回放开关 //考试回放开关
export const judgeConfig = { export const judgeConfig = {
//本地目录开关 //本地目录开关
isTrajectoryOpen: false, isTrajectoryOpen: true,
// 本地模型地址 // 本地模型地址
modelPath: 'models/model_enc', modelPath: 'models/model_enc',
// 轨迹回放目录地址 // 轨迹回放目录地址
trajectoryPath: 'logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt' trajectoryPath: 'logs/2024_04_02/judge_exam_data.txt'
} }
// 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五 // 2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五