wirteLog
This commit is contained in:
parent
5fba22c2ed
commit
5a9af48cd9
@ -446,6 +446,10 @@ function setSyncCenterSqlData(key, res, param) {
|
|||||||
console.log('mapName[key]', mapName[key], key)
|
console.log('mapName[key]', mapName[key], key)
|
||||||
sqlInsertCommonFn(mapName[key], arrList, param.context).then((result) => {
|
sqlInsertCommonFn(mapName[key], arrList, param.context).then((result) => {
|
||||||
console.log(key, '表建立成功')
|
console.log(key, '表建立成功')
|
||||||
|
writeLog('PLC',{
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${key} 表建立成功`,
|
||||||
|
})
|
||||||
if (result) {
|
if (result) {
|
||||||
resolve(true)
|
resolve(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ 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';
|
import prompt from '@ohos.prompt';
|
||||||
|
import FileUtil from './File';
|
||||||
|
import { dateFormat } from './tools';
|
||||||
|
|
||||||
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
||||||
|
|
||||||
@ -25,6 +27,10 @@ export default class TcpClient {
|
|||||||
|
|
||||||
onError(callback?) {
|
onError(callback?) {
|
||||||
this.tcp.on('error', err => {
|
this.tcp.on('error', err => {
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} tcpOnerror ${JSON.stringify(err)}`,
|
||||||
|
})
|
||||||
console.log(TAG, 'tcpOnerror', JSON.stringify(err))
|
console.log(TAG, 'tcpOnerror', JSON.stringify(err))
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
getTCP()
|
getTCP()
|
||||||
@ -72,6 +78,10 @@ export default class TcpClient {
|
|||||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||||
}, err => {
|
}, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} testTag tcp bind faile ${JSON.stringify(err)}`,
|
||||||
|
})
|
||||||
console.log('testTag tcp bind faile');
|
console.log('testTag tcp bind faile');
|
||||||
globalThis.getCloseTcp = true
|
globalThis.getCloseTcp = true
|
||||||
hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
|
hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err));
|
||||||
@ -80,6 +90,10 @@ export default class TcpClient {
|
|||||||
}
|
}
|
||||||
globalThis.getCloseTcp = false
|
globalThis.getCloseTcp = false
|
||||||
console.log('testTag tcp bind success');
|
console.log('testTag tcp bind success');
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} testTag tcp bind success`,
|
||||||
|
})
|
||||||
resolve(false)
|
resolve(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -108,7 +122,10 @@ export default class TcpClient {
|
|||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
}, err => {
|
}, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('testTagtestTag000,error')
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} tcp connect rebind success`,
|
||||||
|
})
|
||||||
if(this.num>3){
|
if(this.num>3){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,8 +150,10 @@ export default class TcpClient {
|
|||||||
getTCP()
|
getTCP()
|
||||||
resolve(false)
|
resolve(false)
|
||||||
}, 2000)
|
}, 2000)
|
||||||
console.log('testTagtestTag000,error')
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} tcp connect error`,
|
||||||
|
})
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -155,6 +174,10 @@ export default class TcpClient {
|
|||||||
|
|
||||||
onMessage(callback?) {
|
onMessage(callback?) {
|
||||||
this.tcp.on('message', value => {
|
this.tcp.on('message', value => {
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} Tcponmessage`,
|
||||||
|
})
|
||||||
console.log(TAG, 'Tcponmessage', value)
|
console.log(TAG, 'Tcponmessage', value)
|
||||||
globalThis.tcpUdpError = false
|
globalThis.tcpUdpError = false
|
||||||
|
|
||||||
@ -188,7 +211,13 @@ export default class TcpClient {
|
|||||||
// callback(value.message)
|
// callback(value.message)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async writeLog(param){
|
||||||
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
|
const date=dateFormat(new Date).split(' ')[0]
|
||||||
|
const folderPath = await fileUtil.initFolder(`/PLC/${date}`);
|
||||||
|
fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||||
|
|
||||||
|
}
|
||||||
offTcp(callback) {
|
offTcp(callback) {
|
||||||
console.log(TAG, 'tcpofff')
|
console.log(TAG, 'tcpofff')
|
||||||
|
|
||||||
|
|||||||
@ -86,9 +86,17 @@ export default class UdpClientByCenter {
|
|||||||
// globalThis.closeHeartSocket=false
|
// globalThis.closeHeartSocket=false
|
||||||
this.isWorking = true
|
this.isWorking = true
|
||||||
console.log(`${TAG} getUDPudp rebind success`);
|
console.log(`${TAG} getUDPudp rebind success`);
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} getUDPudp rebind success`,
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
//globalThis.closeHeartSocket=true
|
//globalThis.closeHeartSocket=true
|
||||||
this.isWorking = false
|
this.isWorking = false
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`,
|
||||||
|
})
|
||||||
console.log(`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`);
|
console.log(`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,10 +107,16 @@ export default class UdpClientByCenter {
|
|||||||
});
|
});
|
||||||
promise.then(() => {
|
promise.then(() => {
|
||||||
this.isWorking = true
|
this.isWorking = true
|
||||||
console.log(`${TAG} getUDPudp bind success`);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} getUDPudp bind success`,
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.isWorking = false
|
this.isWorking = false
|
||||||
console.log(`${TAG} getUDPudp bind failed:${JSON.stringify(err)}`);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG} getUDPudp bind error${JSON.stringify(err)},localIp:${this.localIpPort},port:${this.localIpPort}`,
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +180,12 @@ export default class UdpClientByCenter {
|
|||||||
|
|
||||||
sendMsg(msg, sendCallback?)
|
sendMsg(msg, sendCallback?)
|
||||||
{
|
{
|
||||||
console.log(`${TAG}getUDPudpCLient sendMsg enter oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`);
|
|
||||||
if (!this.isWorking ) {
|
if (!this.isWorking ) {
|
||||||
console.log(`${TAG}getUDPudpCLient sendMsg is closed return `);
|
console.log(`${TAG}getUDPudpCLient sendMsg is closed return `);
|
||||||
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG}getUDPudpCLient sendMsg is closed return oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`,
|
||||||
|
})
|
||||||
if(sendCallback) {
|
if(sendCallback) {
|
||||||
sendCallback()
|
sendCallback()
|
||||||
}
|
}
|
||||||
@ -185,9 +202,15 @@ export default class UdpClientByCenter {
|
|||||||
if (sendCallback) {
|
if (sendCallback) {
|
||||||
sendCallback()
|
sendCallback()
|
||||||
}
|
}
|
||||||
console.log(`${TAG}getUDPudpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG}getUDPudpCLient udp send success: oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`,
|
||||||
|
})
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}${JSON.stringify(err)}`,
|
||||||
|
})
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
message:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`,
|
message:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`,
|
||||||
duration:4000
|
duration:4000
|
||||||
@ -208,7 +231,10 @@ export default class UdpClientByCenter {
|
|||||||
onError_Callback(callback?) {
|
onError_Callback(callback?) {
|
||||||
this.udp.on('error', async err => {
|
this.udp.on('error', async err => {
|
||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
console.log('getUDPUdpClientByCenter onError err:' + JSON.stringify(err),this.oppositeIpPort);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:'getUDPUdpClientByCenter onError err:' + JSON.stringify(err)+this.oppositeIpPort,
|
||||||
|
})
|
||||||
callback && callback()
|
callback && callback()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -216,10 +242,7 @@ export default class UdpClientByCenter {
|
|||||||
onError_resend(callback?) {
|
onError_resend(callback?) {
|
||||||
this.udp.on('error', async err => {
|
this.udp.on('error', async err => {
|
||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
console.log(TAG, 'getUDPudpError', JSON.stringify(err))
|
|
||||||
await this.bindUdp()
|
|
||||||
await this.sendMsg('111', null)
|
|
||||||
await this.onMessage_1(callback)
|
|
||||||
callback && callback()
|
callback && callback()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -265,13 +288,19 @@ export default class UdpClientByCenter {
|
|||||||
console.log('getUDPUdpClientByCenter enter closeUdp ip:' + this.localIp + ' port:' + this.localIpPort);
|
console.log('getUDPUdpClientByCenter enter closeUdp ip:' + this.localIp + ' port:' + this.localIpPort);
|
||||||
this.udp.close(err => {
|
this.udp.close(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('getUDPUdpClientByCenter closeUdp failed ip:' + this.localIp + ' port:' + this.localIpPort + ' err:' + JSON.stringify(err));
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:'getUDPUdpClientByCenter closeUdp err:' + JSON.stringify(err)+this.oppositeIpPort,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.isWorking = false
|
this.isWorking = false
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
console.log('getUDPUdpClientByCenter closeUdp succeed ip:' + this.localIp + ' port:' + this.localIpPort);
|
this.writeLog({
|
||||||
|
time:dateFormat(new Date()),
|
||||||
|
PLC:'getUDPUdpClientByCenter closeUdp succeed:' + JSON.stringify(err)+this.oppositeIpPort,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig';
|
|||||||
import { setJudgeUdp, setTopLineUdp } from './GlobalUdp';
|
import { setJudgeUdp, setTopLineUdp } from './GlobalUdp';
|
||||||
import { convertGpsCoord2 } from '../utils/tools';
|
import { convertGpsCoord2 } from '../utils/tools';
|
||||||
import {examCalcGpsDistance} from '../../pages/judgeSDK/api'
|
import {examCalcGpsDistance} from '../../pages/judgeSDK/api'
|
||||||
import GetDistance from './GetDistance'
|
import GetDistance from '../utils/GetDistance'
|
||||||
export const initJudgeUdp = async () => {
|
export const initJudgeUdp = async () => {
|
||||||
globalThis.serialIndex = 0;
|
globalThis.serialIndex = 0;
|
||||||
globalThis.udpIndex = 0;
|
globalThis.udpIndex = 0;
|
||||||
@ -35,7 +35,7 @@ export const initJudgeUdp = async () => {
|
|||||||
const jd = convertGpsCoord2(msgArr[96]*1);
|
const jd = convertGpsCoord2(msgArr[96]*1);
|
||||||
const wd = convertGpsCoord2(msgArr[95]*1 || 0);
|
const wd = convertGpsCoord2(msgArr[95]*1 || 0);
|
||||||
udp.send(bytes)
|
udp.send(bytes)
|
||||||
if(prevJd){
|
if(prevJd && msgArr[83] == 4){
|
||||||
const distance = await examCalcGpsDistance({
|
const distance = await examCalcGpsDistance({
|
||||||
jd1:prevJd,
|
jd1:prevJd,
|
||||||
wd1:preWd,
|
wd1:preWd,
|
||||||
@ -43,7 +43,11 @@ export const initJudgeUdp = async () => {
|
|||||||
wd2:wd,
|
wd2:wd,
|
||||||
h:msgArr[90]*1 || 1,
|
h:msgArr[90]*1 || 1,
|
||||||
})
|
})
|
||||||
globalThis.distanceClass.setTimeData(Math.floor(distance/100))
|
if(distance < 1){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
globalThis.distanceClass.setTimeData(((distance / 100).toFixed(2)) * 1)
|
||||||
}
|
}
|
||||||
prevJd = jd;
|
prevJd = jd;
|
||||||
preWd = wd;
|
preWd = wd;
|
||||||
@ -70,7 +74,7 @@ export const getMessageHeartbeat = async (msg) => {
|
|||||||
const examType = examSubject == 2?2:3
|
const examType = examSubject == 2?2:3
|
||||||
const {sensor,gps} = tempData;
|
const {sensor,gps} = tempData;
|
||||||
const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs} = sensor
|
const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs} = sensor
|
||||||
const {jd,wd, hxj, fyj, hbg,} = gps
|
const {jd,wd, hxj, fyj, hbg,sd} = gps
|
||||||
const translateSignals = getTranslateSignals(
|
const translateSignals = getTranslateSignals(
|
||||||
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0, 0, 0, ygq, sensor.wd, 0]
|
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0, 0, 0, ygq, sensor.wd, 0]
|
||||||
)
|
)
|
||||||
@ -81,6 +85,12 @@ export const getMessageHeartbeat = async (msg) => {
|
|||||||
const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit)
|
const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
|
const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
|
||||||
|
//@ts-ignore
|
||||||
|
let tempSd = (sd * 1.852).toFixed(0) * 1
|
||||||
|
if(tempSd < 1){
|
||||||
|
tempSd = 0
|
||||||
|
}
|
||||||
|
|
||||||
const arr = [
|
const arr = [
|
||||||
//考生号
|
//考生号
|
||||||
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
|
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
|
||||||
@ -92,7 +102,7 @@ export const getMessageHeartbeat = async (msg) => {
|
|||||||
string2Bytes(serialIndex, 2 * 8),
|
string2Bytes(serialIndex, 2 * 8),
|
||||||
translateSignals,
|
translateSignals,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
string2Bytes(Math.floor(gps.sd*1.852) * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
|
string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
|
||||||
//GPS东向距离
|
//GPS东向距离
|
||||||
string2Bytes(0, 4 * 8),
|
string2Bytes(0, 4 * 8),
|
||||||
//GPS北向距离
|
//GPS北向距离
|
||||||
|
|||||||
@ -70,11 +70,7 @@ export default async function request(req: any) {
|
|||||||
if(res.head.resultCode === '0'){
|
if(res.head.resultCode === '0'){
|
||||||
return res
|
return res
|
||||||
}else{
|
}else{
|
||||||
globalThis.type='1'
|
|
||||||
const resultMessage = res?.body?.resultMessage || res?.head?.resultMessage
|
const resultMessage = res?.body?.resultMessage || res?.head?.resultMessage
|
||||||
// AppStorage.SetOrCreate('errorMsg', 1);
|
|
||||||
globalThis.title=decodeURIComponent(resultMessage)
|
|
||||||
globalThis.errorDialog.open()
|
|
||||||
prompt.showToast({
|
prompt.showToast({
|
||||||
message: decodeURIComponent(resultMessage),
|
message: decodeURIComponent(resultMessage),
|
||||||
duration: 3000
|
duration: 3000
|
||||||
@ -89,14 +85,6 @@ export default async function request(req: any) {
|
|||||||
if(resObj.resultCode === '0') {
|
if(resObj.resultCode === '0') {
|
||||||
return res
|
return res
|
||||||
}else {
|
}else {
|
||||||
globalThis.type='1'
|
|
||||||
if(!host){
|
|
||||||
// AppStorage.SetOrCreate('errorMsg', 1);
|
|
||||||
globalThis.title=decodeURIComponent(resObj.resultMessage)
|
|
||||||
globalThis.errorDialog.open()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
prompt.showToast({
|
prompt.showToast({
|
||||||
message: decodeURIComponent(resObj.resultMessage),
|
message: decodeURIComponent(resObj.resultMessage),
|
||||||
duration: 3000
|
duration: 3000
|
||||||
@ -162,8 +150,9 @@ function handleCenterCode(msgXml,isNewCenter){
|
|||||||
const {code,message,keystr} = result
|
const {code,message,keystr} = result
|
||||||
if(code != '1'){
|
if(code != '1'){
|
||||||
const rMessage = decodeURIComponent(message as string)
|
const rMessage = decodeURIComponent(message as string)
|
||||||
globalThis.title=rMessage
|
// globalThis.title=rMessage
|
||||||
globalThis.errorDialog.open()
|
// globalThis.type='1'
|
||||||
|
// globalThis.errorDialog.open()
|
||||||
prompt.showToast({
|
prompt.showToast({
|
||||||
message:rMessage,
|
message:rMessage,
|
||||||
duration: 3000
|
duration: 3000
|
||||||
@ -186,8 +175,9 @@ function handleCenterCode(msgXml,isNewCenter){
|
|||||||
message: decodeURIComponent(message as string),
|
message: decodeURIComponent(message as string),
|
||||||
duration: 3000
|
duration: 3000
|
||||||
});
|
});
|
||||||
globalThis.title=decodeURIComponent(message as string)
|
// globalThis.type='1'
|
||||||
globalThis.errorDialog.open()
|
// globalThis.title=decodeURIComponent(message as string)
|
||||||
|
// globalThis.errorDialog.open()
|
||||||
return {code,message:decodeURIComponent(message)}
|
return {code,message:decodeURIComponent(message)}
|
||||||
}else{
|
}else{
|
||||||
return { code }
|
return { code }
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import systemTime from '@ohos.systemDateTime';
|
import systemTime from '@ohos.systemDateTime';
|
||||||
import { expect } from '@ohos/hypium';
|
import { expect } from '@ohos/hypium';
|
||||||
|
import FileUtil from './File';
|
||||||
|
|
||||||
|
export async function writeLog(path,param){
|
||||||
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
|
const date=dateFormat(new Date).split(' ')[0]
|
||||||
|
const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
|
||||||
|
fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`)
|
||||||
|
}
|
||||||
///**时间格式化*/
|
///**时间格式化*/
|
||||||
//export function dateFormat(fmt, date) {
|
//export function dateFormat(fmt, date) {
|
||||||
// var ret;
|
// var ret;
|
||||||
|
|||||||
@ -18,6 +18,8 @@ import { voiceService } from '../common/service/voiceService';
|
|||||||
import errorMsgDialog from './compontents/errorMsgDialog'
|
import errorMsgDialog from './compontents/errorMsgDialog'
|
||||||
import { getSyncData } from '../common/service/initable';
|
import { getSyncData } from '../common/service/initable';
|
||||||
import GetDistance from '../common/utils/GetDistance'
|
import GetDistance from '../common/utils/GetDistance'
|
||||||
|
// import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct Index {
|
struct Index {
|
||||||
@ -330,15 +332,16 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async heartMsg() {
|
async heartMsg() {
|
||||||
|
console.log('kkkkmmm')
|
||||||
const arr = [globalThis.signNum || 0, globalThis.statue || 1]
|
const arr = [globalThis.signNum || 0, globalThis.statue || 1]
|
||||||
let tmpList = [];d
|
let tmpList = [];
|
||||||
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
|
||||||
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
|
||||||
const str = globalThis.lsh || '0000000000000'
|
const str = globalThis.lsh || '0000000000000'
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
|
||||||
}
|
}
|
||||||
console.log('globalThis.carInfo', JSON.stringify(globalThis.carInfo))
|
console.log('kkkkmmm.carInfo', JSON.stringify(globalThis.carInfo))
|
||||||
|
|
||||||
const param = {
|
const param = {
|
||||||
id: 31,
|
id: 31,
|
||||||
@ -409,7 +412,7 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initParams() {
|
async initParams() {
|
||||||
deleteAllFIleLog()
|
deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/')
|
||||||
//设置plc udp 同步requesthost
|
//设置plc udp 同步requesthost
|
||||||
await getUDP(this.context, false)
|
await getUDP(this.context, false)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
@ -425,9 +428,9 @@ struct Index {
|
|||||||
this.hasAuth = globalThis.hasAuth;
|
this.hasAuth = globalThis.hasAuth;
|
||||||
initJudgeUdp()
|
initJudgeUdp()
|
||||||
takePhotoFn(this.context)
|
takePhotoFn(this.context)
|
||||||
console.log('deviceIddeviceId', globalThis.deviceNo, this.deviceNo)
|
|
||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
|
console.log('kkkkmmm')
|
||||||
this.num++
|
this.num++
|
||||||
setliushuiNum(this.context)
|
setliushuiNum(this.context)
|
||||||
getliushuiNum(this.context)
|
getliushuiNum(this.context)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user