Compare commits
No commits in common. "291e75c150a62323fd8cfd14e23d9ba6ed817449" and "79c8cba21fafbacc53bec23c60586648ff6247b7" have entirely different histories.
291e75c150
...
79c8cba21f
@ -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) => {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import appRecovery from '@ohos.app.ability.appRecovery';
|
|||||||
import power from '@ohos.power';
|
import power from '@ohos.power';
|
||||||
import preferences from '@ohos.data.preferences';
|
import preferences from '@ohos.data.preferences';
|
||||||
|
|
||||||
|
|
||||||
export const gpsConfig = [
|
export const gpsConfig = [
|
||||||
{ label: "差分状态", prop: "cfzt" },
|
{ label: "差分状态", prop: "cfzt" },
|
||||||
{ label: "经纬度收星数", prop: "sxs" },
|
{ label: "经纬度收星数", prop: "sxs" },
|
||||||
@ -70,18 +71,6 @@ enum EventCode {
|
|||||||
Reply
|
Reply
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ButtonEventType {
|
|
||||||
Single,
|
|
||||||
Double,
|
|
||||||
LongPress
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ToolEvent<T = any> {
|
|
||||||
code: EventCode,
|
|
||||||
data: T
|
|
||||||
id?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FileInfo {
|
interface FileInfo {
|
||||||
fileName: string
|
fileName: string
|
||||||
lastUpdateTime: string
|
lastUpdateTime: string
|
||||||
@ -96,13 +85,6 @@ interface PlatformEvent<T = any> {
|
|||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ButtonParams {
|
|
||||||
type: ButtonEventType
|
|
||||||
button: number
|
|
||||||
page: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CommandCallback = (button: number, reply: (result: number) => void) => void
|
|
||||||
|
|
||||||
const Tag = "[websocket]"
|
const Tag = "[websocket]"
|
||||||
const SystemLogDir = "/data/log/hilog"
|
const SystemLogDir = "/data/log/hilog"
|
||||||
@ -226,10 +208,6 @@ export class RemoteToolWebsocket {
|
|||||||
page: number,
|
page: number,
|
||||||
cb: () => void
|
cb: () => void
|
||||||
}> = []
|
}> = []
|
||||||
private onButtonCallback: Array<{
|
|
||||||
page: number,
|
|
||||||
cb: CommandCallback
|
|
||||||
}> = []
|
|
||||||
public isStart: boolean = false
|
public isStart: boolean = false
|
||||||
private isRegister: boolean = false
|
private isRegister: boolean = false
|
||||||
private context: common.UIAbilityContext
|
private context: common.UIAbilityContext
|
||||||
@ -396,34 +374,6 @@ export class RemoteToolWebsocket {
|
|||||||
this.sendReply(this.serialNumber, data.eventType)
|
this.sendReply(this.serialNumber, data.eventType)
|
||||||
break
|
break
|
||||||
case PlatFormEventType.ToolCommand:
|
case PlatFormEventType.ToolCommand:
|
||||||
let command = JSON.parse(data.data) as ToolEvent
|
|
||||||
switch (command.code) {
|
|
||||||
case EventCode.Data:
|
|
||||||
break
|
|
||||||
case EventCode.Button:
|
|
||||||
let button = JSON.parse(command.data) as ButtonParams
|
|
||||||
this.onButtonCallback.forEach(item => {
|
|
||||||
const reply = (result: number) => {
|
|
||||||
this.sendReply(this.serialNumber, PlatFormEventType.SyncData, JSON.stringify({
|
|
||||||
code: EventCode.Reply,
|
|
||||||
data: JSON.stringify(result),
|
|
||||||
id: command.id
|
|
||||||
} as ToolEvent))
|
|
||||||
}
|
|
||||||
if (item.page === button.page) {
|
|
||||||
item.cb(button.button, reply)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case EventCode.Router:
|
|
||||||
break
|
|
||||||
case EventCode.Function:
|
|
||||||
break
|
|
||||||
case EventCode.Reply:
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
console.warn("Unknown event type:", data.eventType);
|
console.warn("Unknown event type:", data.eventType);
|
||||||
@ -690,17 +640,6 @@ export class RemoteToolWebsocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
offStart(page: number) {
|
offStart(page: number) {
|
||||||
this.onStartCallback = this.onStartCallback.filter(item => item.page !== page)
|
this.onStartCallback = this.onStartCallback.filter(item => item.page != page)
|
||||||
}
|
|
||||||
|
|
||||||
onButton(cb: CommandCallback, page: number) {
|
|
||||||
this.onButtonCallback.push({
|
|
||||||
page,
|
|
||||||
cb
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
offButton(page: number) {
|
|
||||||
this.onButtonCallback = this.onButtonCallback.filter(item => item.page !== page)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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)
|
||||||
|
|||||||
@ -38,7 +38,6 @@ export default class EntryAbility extends UIAbility {
|
|||||||
|
|
||||||
async onWindowStageCreate(windowStage: window.WindowStage) {
|
async onWindowStageCreate(windowStage: window.WindowStage) {
|
||||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||||
globalThis.tcpStep=0
|
|
||||||
|
|
||||||
globalThis.carInfo = {}
|
globalThis.carInfo = {}
|
||||||
globalThis.examinerInfo = {}
|
globalThis.examinerInfo = {}
|
||||||
@ -64,15 +63,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) {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { delPic } from '../common/service/videoService';
|
|||||||
import imageBtn from './compontents/imageBtn';
|
import imageBtn from './compontents/imageBtn';
|
||||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||||
import { updateModelAndCar } from '../common/autoUpdate/index'
|
import { updateModelAndCar } from '../common/autoUpdate/index'
|
||||||
import { CommandCallback, RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket';
|
import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket';
|
||||||
import { UsbUtils } from '../common/utils/UsbUtils';
|
import { UsbUtils } from '../common/utils/UsbUtils';
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ struct Index {
|
|||||||
@State version: string = ''
|
@State version: string = ''
|
||||||
@State url: string = ''
|
@State url: string = ''
|
||||||
@State hasAuth: boolean = false;
|
@State hasAuth: boolean = false;
|
||||||
@State dialogVisible: boolean = false;
|
@State dialogVisiable: boolean = false;
|
||||||
@State isSingle: boolean = false;
|
@State isSingle: boolean = false;
|
||||||
@State deviceId: string = '';
|
@State deviceId: string = '';
|
||||||
@State angle: number = 0
|
@State angle: number = 0
|
||||||
@ -63,15 +63,6 @@ struct Index {
|
|||||||
private context = getContext(this) as common.UIAbilityContext;
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket()
|
private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket()
|
||||||
private usbUtils: UsbUtils = new UsbUtils(this.context)
|
private usbUtils: UsbUtils = new UsbUtils(this.context)
|
||||||
private onButtonCallback: CommandCallback = (button, reply) => {
|
|
||||||
switch (button) {
|
|
||||||
case 1:
|
|
||||||
this.onNetWork(reply)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Styles
|
@Styles
|
||||||
commStyle(){
|
commStyle(){
|
||||||
@ -100,7 +91,7 @@ struct Index {
|
|||||||
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
|
Image($r('app.media.btn_back')).width('14.4%').height('12.2%')
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
|
|
||||||
this.dialogVisible = true
|
this.dialogVisiable = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +104,40 @@ struct Index {
|
|||||||
if (!this.isSingle) {
|
if (!this.isSingle) {
|
||||||
imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') })
|
imageBtn({ btnWidth: '28%', btnHeight: '71%', imgSrc: $r('app.media.index_lw') })
|
||||||
.margin({ left: 80 * globalThis.ratio })
|
.margin({ left: 80 * globalThis.ratio })
|
||||||
.onClick(() => {
|
.onClick(async () => {
|
||||||
this.onNetWork()
|
|
||||||
|
if (this.loading) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.angle = 360
|
||||||
|
}, 1000)
|
||||||
|
this.angle = 0
|
||||||
|
if (!globalThis.timeInfo) {
|
||||||
|
globalThis.type = '1'
|
||||||
|
globalThis.title = '时间同步接口连接失败'
|
||||||
|
this.errorDialog.open()
|
||||||
|
promptAction.showToast({
|
||||||
|
message: `时间同步接口连接失败`,
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!globalThis.carInfo) {
|
||||||
|
promptAction.showToast({
|
||||||
|
message: `车辆信息接口获取失败`,
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
globalThis.type = '1'
|
||||||
|
globalThis.title = '车辆信息接口获取失败'
|
||||||
|
this.errorDialog.open()
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.testXMLToJSONInWorker()
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.isSingle) {
|
if (this.isSingle) {
|
||||||
@ -224,7 +247,8 @@ struct Index {
|
|||||||
.margin({ bottom: 10 })
|
.margin({ bottom: 10 })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.dialogVisible) {
|
//
|
||||||
|
if (this.dialogVisiable) {
|
||||||
Flex({ justifyContent: FlexAlign.Center }) {
|
Flex({ justifyContent: FlexAlign.Center }) {
|
||||||
Text('确认是否退出应用')
|
Text('确认是否退出应用')
|
||||||
.fontSize(28 * this.ratio * this.dialogRatio)
|
.fontSize(28 * this.ratio * this.dialogRatio)
|
||||||
@ -238,7 +262,7 @@ struct Index {
|
|||||||
}
|
}
|
||||||
.commStyle()
|
.commStyle()
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.dialogVisible = false
|
this.dialogVisiable = false
|
||||||
|
|
||||||
}).margin({ right: 10 * this.ratio })
|
}).margin({ right: 10 * this.ratio })
|
||||||
|
|
||||||
@ -288,6 +312,7 @@ struct Index {
|
|||||||
.backgroundColor('#E6E3DF')
|
.backgroundColor('#E6E3DF')
|
||||||
.borderRadius(19 * globalThis.ratio)
|
.borderRadius(19 * globalThis.ratio)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
Column() {
|
Column() {
|
||||||
Image($r('app.media.open_loading'))
|
Image($r('app.media.open_loading'))
|
||||||
@ -328,11 +353,13 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
this.remoteToolWebsocket.onButton(this.onButtonCallback, 1)
|
|
||||||
|
console.log('diyidiy')
|
||||||
|
|
||||||
this.avPlayer = new VoiceAnnounce();
|
this.avPlayer = new VoiceAnnounce();
|
||||||
this.initParamFlag = false
|
this.initParamFlag = false
|
||||||
this.delLoading = false
|
this.delLoading = false
|
||||||
this.dialogVisible = false
|
this.dialogVisiable = false
|
||||||
this.angle = 0
|
this.angle = 0
|
||||||
this.loading = false
|
this.loading = false
|
||||||
globalThis.lsh = '1111111111111'
|
globalThis.lsh = '1111111111111'
|
||||||
@ -359,46 +386,15 @@ struct Index {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aboutToDisappear() {
|
aboutToDisappear() {
|
||||||
this.remoteToolWebsocket.offButton(1)
|
// this.vocObj && this.vocObj.releasePlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
onNetWork(cb?: Function) {
|
async testXMLToJSONInWorker() {
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
|
||||||
this.angle = 360
|
|
||||||
}, 1000)
|
|
||||||
this.angle = 0
|
|
||||||
if (!globalThis.timeInfo) {
|
|
||||||
globalThis.type = '1'
|
|
||||||
globalThis.title = '时间同步接口连接失败'
|
|
||||||
this.errorDialog.open()
|
|
||||||
promptAction.showToast({
|
|
||||||
message: `时间同步接口连接失败`,
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!globalThis.carInfo) {
|
|
||||||
promptAction.showToast({
|
|
||||||
message: `车辆信息接口获取失败`,
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
globalThis.type = '1'
|
|
||||||
globalThis.title = '车辆信息接口获取失败'
|
|
||||||
this.errorDialog.open()
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.testXMLToJSONInWorker(cb)
|
|
||||||
}
|
|
||||||
|
|
||||||
async testXMLToJSONInWorker(cb?: Function) {
|
|
||||||
if (this.loading) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const param = {
|
const param = {
|
||||||
carId: globalThis.carInfo?.carId,
|
carId: globalThis.carInfo?.carId,
|
||||||
examinationRoomId: globalThis.carInfo?.examinationRoomId,
|
examinationRoomId: globalThis.carInfo?.examinationRoomId,
|
||||||
@ -452,14 +448,12 @@ struct Index {
|
|||||||
}
|
}
|
||||||
if (sys.v_no === '824' && decodeURIComponent(sys.v_value) == '0') {
|
if (sys.v_no === '824' && decodeURIComponent(sys.v_value) == '0') {
|
||||||
// this.Param612Str= decodeURIComponent(sys.v_value)
|
// this.Param612Str= decodeURIComponent(sys.v_value)
|
||||||
cb(1)
|
|
||||||
router.pushUrl({
|
router.pushUrl({
|
||||||
url: 'pages/CarCheck',
|
url: 'pages/CarCheck',
|
||||||
params: {
|
params: {
|
||||||
'fromIndex': true
|
'fromIndex': true
|
||||||
}
|
}
|
||||||
}, router.RouterMode.Single)
|
}, router.RouterMode.Single)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
router.pushUrl({
|
router.pushUrl({
|
||||||
url: 'pages/ExaminerLogin',
|
url: 'pages/ExaminerLogin',
|
||||||
@ -469,8 +463,6 @@ struct Index {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
|
||||||
cb(0)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +482,7 @@ struct Index {
|
|||||||
carNo: globalThis.carInfo.carNo,
|
carNo: globalThis.carInfo.carNo,
|
||||||
placeId: globalThis.carInfo.examinationRoomId
|
placeId: globalThis.carInfo.examinationRoomId
|
||||||
}
|
}
|
||||||
|
// globalThis.udpClient2.initHeartSendMsg(param,this.context)
|
||||||
if (globalThis.udpClient2.getStatus()) {
|
if (globalThis.udpClient2.getStatus()) {
|
||||||
globalThis.udpClient2.sendMsgExt(param, this.context)
|
globalThis.udpClient2.sendMsgExt(param, this.context)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user