Compare commits
No commits in common. "f9beb54a280f20e57e02972bff889fd5a78af492" and "920323bc786256be065a832ad9c0f42232897bbb" have entirely different histories.
f9beb54a28
...
920323bc78
@ -3,7 +3,7 @@ import { getSyncData } from '../service/initable';
|
|||||||
import hilog from '@ohos.hilog';
|
import hilog from '@ohos.hilog';
|
||||||
import FileUtil from '../../common/utils/File'
|
import FileUtil from '../../common/utils/File'
|
||||||
import { GlobalConfig } from '../../config/index'
|
import { GlobalConfig } from '../../config/index'
|
||||||
const TAG = 'socketTag[TcpDemo.TcpClient]'
|
|
||||||
export async function getTCP(flag=false) {
|
export async function getTCP(flag=false) {
|
||||||
globalThis.getCloseTcp=true
|
globalThis.getCloseTcp=true
|
||||||
const fileUtil = new FileUtil(globalThis.context)
|
const fileUtil = new FileUtil(globalThis.context)
|
||||||
@ -35,16 +35,10 @@ export async function getTCP(flag=false) {
|
|||||||
console.log('ttttttt00')
|
console.log('ttttttt00')
|
||||||
|
|
||||||
clearInterval(globalThis.intervalSendmsg)
|
clearInterval(globalThis.intervalSendmsg)
|
||||||
globalThis.intervalSendmsg=setInterval(async()=>{
|
globalThis.intervalSendmsg=setInterval(()=>{
|
||||||
console.log('getCloseTcp',globalThis.carInfo.carNo)
|
console.log('getCloseTcp',globalThis.carInfo.carNo)
|
||||||
if(!globalThis.getCloseTcp){
|
if(!globalThis.getCloseTcp){
|
||||||
await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
|
globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
|
||||||
globalThis.tcpStep+=1
|
|
||||||
if(globalThis.tcpStep>30){
|
|
||||||
console.log(TAG,'tcp重连开始')
|
|
||||||
globalThis.tcpStep=0
|
|
||||||
getTCP()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},1000/3)
|
},1000/3)
|
||||||
globalThis.TcpClient.onError((val) => {
|
globalThis.TcpClient.onError((val) => {
|
||||||
@ -74,16 +68,10 @@ export async function getTCP(flag=false) {
|
|||||||
console.log('ttttttt12')
|
console.log('ttttttt12')
|
||||||
|
|
||||||
clearInterval(globalThis.intervalSendmsg)
|
clearInterval(globalThis.intervalSendmsg)
|
||||||
globalThis.intervalSendmsg=setInterval(async()=>{
|
globalThis.intervalSendmsg=setInterval(()=>{
|
||||||
// console.log('getCloseTcp',globalThis.getCloseTcp)
|
// console.log('getCloseTcp',globalThis.getCloseTcp)
|
||||||
if(!globalThis.getCloseTcp){
|
if(!globalThis.getCloseTcp){
|
||||||
await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
|
globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002
|
||||||
globalThis.tcpStep+=1
|
|
||||||
if(globalThis.tcpStep>30){
|
|
||||||
console.log(TAG,'tcp重连开始')
|
|
||||||
globalThis.tcpStep=0
|
|
||||||
getTCP()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},1000/3)
|
},1000/3)
|
||||||
globalThis.TcpClient.onError((val) => {
|
globalThis.TcpClient.onError((val) => {
|
||||||
|
|||||||
@ -148,12 +148,13 @@ export default class TcpClient {
|
|||||||
this.tcpSendNum=0
|
this.tcpSendNum=0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
globalThis.getCloseTcp=true
|
||||||
console.log(`${TAG} TCPsend error ${JSON.stringify(err)}`)
|
console.log(`${TAG} TCPsend error ${JSON.stringify(err)}`)
|
||||||
// this.writeLog({
|
// this.writeLog({
|
||||||
// time:dateFormat(new Date()),
|
// time:dateFormat(new Date()),
|
||||||
// message: `${TAG} TCPsend error ${JSON.stringify(err)}`,
|
// message: `${TAG} TCPsend error ${JSON.stringify(err)}`,
|
||||||
// })
|
// })
|
||||||
reject(false)
|
reslove(false)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -164,7 +165,6 @@ export default class TcpClient {
|
|||||||
// time:dateFormat(new Date()),
|
// time:dateFormat(new Date()),
|
||||||
// PLC:`${TAG} Tcponmessage`,
|
// PLC:`${TAG} Tcponmessage`,
|
||||||
// })
|
// })
|
||||||
globalThis.tcpStep=0
|
|
||||||
globalThis.tcpUdpError = false
|
globalThis.tcpUdpError = false
|
||||||
if (value) {
|
if (value) {
|
||||||
callback && callback(value.message)
|
callback && callback(value.message)
|
||||||
|
|||||||
@ -37,8 +37,6 @@ export default class EntryAbility extends UIAbility {
|
|||||||
// this.context
|
// this.context
|
||||||
// Main window is created, set main page for this ability
|
// Main window is created, set main page for this ability
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
await tcpUtil.init()
|
|
||||||
globalThis.tcpStep=0
|
|
||||||
|
|
||||||
globalThis.carInfo = {}
|
globalThis.carInfo = {}
|
||||||
globalThis.examinerInfo = {}
|
globalThis.examinerInfo = {}
|
||||||
@ -66,15 +64,11 @@ export default class EntryAbility extends UIAbility {
|
|||||||
globalThis.pathDir = this.context.filesDir;
|
globalThis.pathDir = this.context.filesDir;
|
||||||
globalThis.context = this.context;
|
globalThis.context = this.context;
|
||||||
globalThis.isJudgeInitBool = false
|
globalThis.isJudgeInitBool = false
|
||||||
console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir);
|
|
||||||
// this.requestPermission(this.context)
|
|
||||||
// this.featureAbilityAuth()
|
|
||||||
|
|
||||||
const windowClass = await windowStage.getMainWindow();
|
const windowClass = await windowStage.getMainWindow();
|
||||||
globalThis.windowClass = windowClass
|
globalThis.windowClass = windowClass
|
||||||
// await windowClass.setWindowLayoutFullScreen(true)
|
await windowClass.setWindowLayoutFullScreen(true)
|
||||||
// await windowClass.setWindowSystemBarEnable([]) //全屏
|
await windowClass.setWindowSystemBarEnable([])
|
||||||
await windowClass.setWindowSystemBarEnable(['navigation'])
|
|
||||||
|
|
||||||
windowStage.loadContent('pages/Index', (err, data) => {
|
windowStage.loadContent('pages/Index', (err, data) => {
|
||||||
if (err.code) {
|
if (err.code) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user