Compare commits
2 Commits
a617763947
...
f98ce3d832
| Author | SHA1 | Date | |
|---|---|---|---|
| f98ce3d832 | |||
| b89b0c911e |
@ -12,6 +12,7 @@ export async function getDeviceInfo(context) {
|
|||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const fileUtil = new FileUtil(context)
|
const fileUtil = new FileUtil(context)
|
||||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
|
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt');
|
||||||
|
console.log('globalThis.deviceNoglobalThis.deviceNo',data)
|
||||||
if (data === '' || data === undefined) {
|
if (data === '' || data === undefined) {
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
message: `请先进行设备注册`,
|
message: `请先进行设备注册`,
|
||||||
@ -21,7 +22,8 @@ export async function getDeviceInfo(context) {
|
|||||||
} else {
|
} else {
|
||||||
const fileData=JSON.parse(data)
|
const fileData=JSON.parse(data)
|
||||||
globalThis.deviceNo = fileData.deviceName
|
globalThis.deviceNo = fileData.deviceName
|
||||||
getCarInfo()
|
console.log('globalThis.deviceNo', globalThis.deviceNo)
|
||||||
|
// getCarInfo()
|
||||||
resolve(fileData.deviceName)
|
resolve(fileData.deviceName)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -30,6 +32,8 @@ export async function getDeviceInfo(context) {
|
|||||||
//获取考车信息
|
//获取考车信息
|
||||||
export async function getCarInfo() {
|
export async function getCarInfo() {
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
console.log('globalThis.carInfo2222', globalThis.deviceNo)
|
||||||
|
|
||||||
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo };
|
let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo };
|
||||||
let res: any = await obtainCarExamInfo(params)
|
let res: any = await obtainCarExamInfo(params)
|
||||||
if (!res?.obtainCarExamInfoRsp?.body) {
|
if (!res?.obtainCarExamInfoRsp?.body) {
|
||||||
@ -38,7 +42,7 @@ export async function getCarInfo() {
|
|||||||
// }, router.RouterMode.Single);
|
// }, router.RouterMode.Single);
|
||||||
} else {
|
} else {
|
||||||
globalThis.carInfo = res.obtainCarExamInfoRsp.body
|
globalThis.carInfo = res.obtainCarExamInfoRsp.body
|
||||||
console.log('globalThis.carInfo', JSON.stringify(globalThis.carInfo));
|
console.log('globalThis.carInfo2222', JSON.stringify(res));
|
||||||
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
|
// globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId
|
||||||
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
|
globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export async function getUDP(context,errorFlag?) {
|
|||||||
return new Promise(async (reslove,reject)=>{
|
return new Promise(async (reslove,reject)=>{
|
||||||
const fileUtil = new FileUtil(context)
|
const fileUtil = new FileUtil(context)
|
||||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt');
|
||||||
|
console.log('ttttt',data)
|
||||||
if (data === '' || data === undefined) {
|
if (data === '' || data === undefined) {
|
||||||
console.log(` getUDP has no IPConfigTable `);
|
console.log(` getUDP has no IPConfigTable `);
|
||||||
globalThis.udpClient = {}
|
globalThis.udpClient = {}
|
||||||
@ -45,6 +46,7 @@ export async function getUDP(context,errorFlag?) {
|
|||||||
else {
|
else {
|
||||||
// 未绑定
|
// 未绑定
|
||||||
console.log(` getUDP has no udclent and bind `);
|
console.log(` getUDP has no udclent and bind `);
|
||||||
|
console.log('ttttttdata',JSON.stringify(result))
|
||||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort)
|
||||||
udpClient.bindUdp()
|
udpClient.bindUdp()
|
||||||
udpClient.sendMsg('111')
|
udpClient.sendMsg('111')
|
||||||
@ -62,7 +64,7 @@ export async function getUDP(context,errorFlag?) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
getChuankouFn()
|
getChuankouFn()
|
||||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
reslove(`http://${result.centerIp}:${result.centerPort}`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import socket from '@ohos.net.socket';
|
import socket from '@ohos.net.socket';
|
||||||
import hilog from '@ohos.hilog';
|
import hilog from '@ohos.hilog';
|
||||||
import { getTCP } from './GlobalTcp';
|
import { getTCP } from './GlobalTcp';
|
||||||
|
import prompt from '@ohos.prompt';
|
||||||
|
|
||||||
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
||||||
|
|
||||||
@ -166,18 +167,22 @@ export default class TcpClient {
|
|||||||
} else {
|
} else {
|
||||||
callback && callback('')
|
callback && callback('')
|
||||||
}
|
}
|
||||||
setTimeout(async () => {
|
clearInterval(globalThis.intervaltcp)
|
||||||
//程序断开
|
globalThis.intervaltcp=setInterval(()=>{
|
||||||
if (globalThis.tcpUdpError) {
|
setTimeout(async () => {
|
||||||
this.num++
|
//程序断开
|
||||||
console.log(TAG,'tcp信号丢失')
|
if (globalThis.tcpUdpError) {
|
||||||
if(this.num==3){
|
console.log(TAG,'tcp信号丢失')
|
||||||
getTCP()
|
getTCP()
|
||||||
this.num=0
|
prompt.showToast({
|
||||||
|
message: 'tcp信号丢失',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
globalThis.tcpUdpError = true;
|
||||||
globalThis.tcpUdpError = true;
|
}, 2000)
|
||||||
}, 2000)
|
},3000)
|
||||||
|
|
||||||
// callback(value.message)
|
// callback(value.message)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,15 +176,15 @@ export default class UdpClient {
|
|||||||
//程序断开
|
//程序断开
|
||||||
lightLineUdp?.send(globalThis.plcUdpError ? arrRedBuffer : (isJudge ? arrGreenBugger : arrBlueBuffer));
|
lightLineUdp?.send(globalThis.plcUdpError ? arrRedBuffer : (isJudge ? arrGreenBugger : arrBlueBuffer));
|
||||||
if (globalThis.plcUdpError) {
|
if (globalThis.plcUdpError) {
|
||||||
num++
|
// num++
|
||||||
console.log(TAG,'plc udp信号丢失')
|
console.log(TAG,'plc udp信号丢失')
|
||||||
if(num==3){
|
// if(num==3){
|
||||||
getUDP(globalThis.context,true)
|
getUDP(globalThis.context,true)
|
||||||
// await this.bindUdp()
|
// await this.bindUdp()
|
||||||
// await this.sendMsg('111')
|
// await this.sendMsg('111')
|
||||||
// await this.onMessage(callback)
|
// await this.onMessage(callback)
|
||||||
num=0
|
// num=0
|
||||||
}
|
// }
|
||||||
prompt.showToast({
|
prompt.showToast({
|
||||||
message: 'plc udp信号丢失',
|
message: 'plc udp信号丢失',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
|
|||||||
@ -3,6 +3,9 @@ import convertxml from '@ohos.convertxml';
|
|||||||
import prompt from '@ohos.prompt'
|
import prompt from '@ohos.prompt'
|
||||||
import { sendGreen } from '../../pages/judgeSDK/utils/judgeCommon';
|
import { sendGreen } from '../../pages/judgeSDK/utils/judgeCommon';
|
||||||
import {GlobalConfig} from '../../config/index'
|
import {GlobalConfig} from '../../config/index'
|
||||||
|
import FileUtil from '../../common/utils/File';
|
||||||
|
import { dateFormat } from '../utils/tools'
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
host:GlobalConfig.host,
|
host:GlobalConfig.host,
|
||||||
}
|
}
|
||||||
@ -36,16 +39,31 @@ export default async function request(req: any) {
|
|||||||
try {
|
try {
|
||||||
let baseUrl=host?host:globalThis.host
|
let baseUrl=host?host:globalThis.host
|
||||||
// let baseUrl=host?config.csptHost:config.host'
|
// let baseUrl=host?config.csptHost:config.host'
|
||||||
console.log('响应头地址' + paramsStr)
|
|
||||||
|
console.log('响应头地址' + baseUrl)
|
||||||
|
// writeLog({
|
||||||
|
// time:dateFormat(new Date()),
|
||||||
|
// url,
|
||||||
|
// extraData: JSON.stringify(data),
|
||||||
|
// state:'start'
|
||||||
|
// })
|
||||||
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options);
|
const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options);
|
||||||
|
// fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(arrList))
|
||||||
|
// writeLog({
|
||||||
|
// time:dateFormat(new Date()),
|
||||||
|
// url,
|
||||||
|
// result:JSON.stringify(result),
|
||||||
|
// extraData: JSON.stringify(data),
|
||||||
|
// state:'end'
|
||||||
|
// })
|
||||||
console.log('响应头地址' + JSON.stringify(result))
|
console.log('响应头地址' + JSON.stringify(result))
|
||||||
let res:any = xml ? xmlToJson(result,url) : result;
|
let res:any = xml ? xmlToJson(result,url) : result;
|
||||||
console.log('响应头地址' + JSON.stringify(res))
|
console.log('响应头地址' + JSON.stringify(res))
|
||||||
|
|
||||||
let resObj = null;
|
let resObj = null;
|
||||||
if(typeof res === "string"){
|
if(typeof res === "string"){
|
||||||
res=JSON.parse(res)
|
res=JSON.parse(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理中心服务code
|
//处理中心服务code
|
||||||
if(res.Envelope){
|
if(res.Envelope){
|
||||||
const msgXml = res.Envelope.Body.writeObjectOutResponse.return;
|
const msgXml = res.Envelope.Body.writeObjectOutResponse.return;
|
||||||
@ -99,7 +117,12 @@ export default async function request(req: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
async function writeLog(param){
|
||||||
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
|
const folderPath = await fileUtil.initFolder(`/errorMsg/`);
|
||||||
|
fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(param)+`\n`)
|
||||||
|
|
||||||
|
}
|
||||||
//xml格式转JSON
|
//xml格式转JSON
|
||||||
function xmlToJson(result,url) {
|
function xmlToJson(result,url) {
|
||||||
console.log("xmlToJson begin",url);
|
console.log("xmlToJson begin",url);
|
||||||
|
|||||||
@ -319,7 +319,10 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onPageShow() {
|
async onPageShow() {
|
||||||
|
console.log('ttttt',1111)
|
||||||
this.userAuth();
|
this.userAuth();
|
||||||
|
console.log('ttttt2222',1111)
|
||||||
|
|
||||||
this.vocObj = new voiceService(async (status, val, next) => {
|
this.vocObj = new voiceService(async (status, val, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -336,15 +339,7 @@ struct Index {
|
|||||||
this.createAlbum()
|
this.createAlbum()
|
||||||
|
|
||||||
this.num=0
|
this.num=0
|
||||||
clearInterval(this.interval)
|
|
||||||
this.interval = setInterval(() => {
|
|
||||||
this.num++
|
|
||||||
setliushuiNum(this.context)
|
|
||||||
getliushuiNum(this.context)
|
|
||||||
if(this.num>=3){
|
|
||||||
this.heartMsg()
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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)
|
||||||
@ -388,18 +383,28 @@ struct Index {
|
|||||||
//设置plc udp 同步requesthost
|
//设置plc udp 同步requesthost
|
||||||
await getUDP(this.context,false)
|
await getUDP(this.context,false)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
takePhotoFn(this.context)
|
console.log('globalThis.deviceNo000')
|
||||||
await getDeviceInfo(this.context)
|
await getDeviceInfo(this.context)
|
||||||
// await getCarInfo()
|
await getCarInfo()
|
||||||
// await getUDP2(this.context,false)
|
await getUDP2(this.context,false)
|
||||||
// getTCP()
|
getTCP()
|
||||||
this.deviceId= globalThis.carInfo.carNo
|
this.deviceId= globalThis.carInfo.carNo
|
||||||
await setCurrentTime();
|
await setCurrentTime();
|
||||||
this.carNum = globalThis.carInfo.plateNo;
|
this.carNum = globalThis.carInfo.plateNo;
|
||||||
this.version = globalThis.version;
|
this.version = globalThis.version;
|
||||||
this.hasAuth = globalThis.hasAuth;
|
this.hasAuth = globalThis.hasAuth;
|
||||||
initJudgeUdp()
|
initJudgeUdp()
|
||||||
|
takePhotoFn(this.context)
|
||||||
console.log('deviceIddeviceId',globalThis.deviceNo,this.deviceNo)
|
console.log('deviceIddeviceId',globalThis.deviceNo,this.deviceNo)
|
||||||
|
clearInterval(this.interval)
|
||||||
|
this.interval = setInterval(() => {
|
||||||
|
this.num++
|
||||||
|
setliushuiNum(this.context)
|
||||||
|
getliushuiNum(this.context)
|
||||||
|
if(this.num>=3){
|
||||||
|
this.heartMsg()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
//下载模型
|
//下载模型
|
||||||
// await this.getModel()
|
// await this.getModel()
|
||||||
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user