tcp独立进程

This commit is contained in:
lixiao 2025-05-17 12:35:09 +08:00
parent 543e779107
commit 3b85961b86
4 changed files with 42 additions and 60 deletions

View File

@ -8,7 +8,6 @@ import { getEsCarModel, getSyncData, } from '../common/service/initable';
import { getUDP, getUDP2, getUDPGps2 } from '../common/utils/GlobalUdp'; import { getUDP, getUDP2, getUDPGps2 } from '../common/utils/GlobalUdp';
import { initJudgeUdp } from '../common/utils/UdpJudge'; import { initJudgeUdp } from '../common/utils/UdpJudge';
import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { judgeConfig } from './judgeSDK/utils/judgeConfig';
import { getTCP } from '../common/utils/GlobalTcp';
import { getSingleCenterTable, setliushuiNum, takePhotoFn } from '../common/service/indexService'; import { getSingleCenterTable, setliushuiNum, takePhotoFn } from '../common/service/indexService';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
@ -19,7 +18,6 @@ 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 { examJudgeVersion } from './judgeSDK/api'; import { examJudgeVersion } from './judgeSDK/api';
import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy';
import Want from '@ohos.app.ability.Want'; import Want from '@ohos.app.ability.Want';
@Entry @Entry
@ -41,7 +39,6 @@ struct Index {
@State initParamFlag: boolean = false @State initParamFlag: boolean = false
@State fd: number = -1; @State fd: number = -1;
@State num: number = 0; @State num: number = 0;
private serviceExtProxy: IdlServiceExtProxy
private fileHelper = null; private fileHelper = null;
private errorDialog: CustomDialogController = new CustomDialogController({ private errorDialog: CustomDialogController = new CustomDialogController({
builder: errorMsgDialog({ builder: errorMsgDialog({
@ -79,13 +76,14 @@ struct Index {
globalThis.lsh = '1111111111111' globalThis.lsh = '1111111111111'
globalThis.errorDialog = this.errorDialog globalThis.errorDialog = this.errorDialog
globalThis.udpEvent = new UdpEvent(); globalThis.udpEvent = new UdpEvent();
await this.startServiceAbility() this.startServiceAbility().catch((err) => {
console.log("tcp 启动tcp进程失败")
this.startServiceAbility()
})
getSyncData('MA_SYSSET').then(async (data: any[]) => { getSyncData('MA_SYSSET').then(async (data: any[]) => {
data.forEach(async sys => { data.forEach(async sys => {
//判断是否能点开始考试 //判断是否能点开始考试
if (sys.v_no === '305') { if (sys.v_no === '305') {
console.log('syssyssyssys')
delPic(Number(sys.v_value), 1) delPic(Number(sys.v_value), 1)
delPic(Number(sys.v_value), 2) delPic(Number(sys.v_value), 2)
} }
@ -100,43 +98,38 @@ struct Index {
bundleName: 'com.oh.dts', bundleName: 'com.oh.dts',
abilityName: 'ServiceExtAbility' abilityName: 'ServiceExtAbility'
}; };
return new Promise<void>((resolve, reject) => {
await this.context.startServiceExtensionAbility(want).then(() => { this.context.startServiceExtensionAbility(want).then(() => {
// 成功启动后台服务 // 成功启动后台服务
console.log('js-test index.ets Succeeded in starting ServiceExtensionAbility.'); console.log('tcp service Succeeded in starting ServiceExtensionAbility.');
let self = this;
let options: common.ConnectOptions = { let options: common.ConnectOptions = {
onConnect(elementName, remote): void { onConnect(_elementName, remote): void {
console.log('js-test index.ets onConnect callback'); console.log('tcp service onConnect callback');
if (remote === null) { if (remote === null) {
console.log(`js-test index.ets onConnect remote is null`); console.log(`tcp service onConnect remote is null`);
return; return;
} }
self.serviceExtProxy = new IdlServiceExtProxy(remote);
globalThis.serviceExtProxy = self.serviceExtProxy
console.log(`js-test index.ets processData, this.serviceExtProxy == `, self.serviceExtProxy);
}, },
onDisconnect(elementName): void { onDisconnect(_elementName): void {
console.log('js-test index.ets onDisconnect callback'); console.log('tcp service onDisconnect callback');
}, },
onFailed(code): void { onFailed(code): void {
console.log('js-test index.ets onFailed callback', JSON.stringify(code)); console.log('tcp service onFailed callback', JSON.stringify(code));
} }
} }
// 建立连接后返回的Id需要保存下来在解绑服务时需要作为参数传入
// let connectionId = context.connectServiceExtensionAbility(want, options);
try { try {
this.context.connectServiceExtensionAbility(want, options); this.context.connectServiceExtensionAbility(want, options);
} catch (e) { } catch (e) {
console.log('js-test index.ets connectServiceExtensionAbility err == ', JSON.stringify(e)); console.log('tcp service connectServiceExtensionAbility err == ', JSON.stringify(e));
} }
resolve()
// 成功连接后台服务 // 成功连接后台服务
console.log('js-test index.ets connectServiceExtensionAbility success'); console.log('tcp service connectServiceExtensionAbility success');
}).catch((err) => { }).catch((err) => {
console.log(`js-test index.ets Failed to start ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`); reject(err)
console.log(`tcp service Failed to start ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`);
}); });
})
} }
async networkExam(isSingle: boolean = false) { async networkExam(isSingle: boolean = false) {
@ -164,9 +157,6 @@ struct Index {
// A2牵引车2号导航仪 // A2牵引车2号导航仪
if (carInfo.kscx == 'A2' && !globalThis.udpClientGps2) { if (carInfo.kscx == 'A2' && !globalThis.udpClientGps2) {
await getUDPGps2(this.context, false) await getUDPGps2(this.context, false)
this.serviceExtProxy.processData("1", () => {
})
} }
getSyncData('MA_SYSSET').then((data: any[]) => { getSyncData('MA_SYSSET').then((data: any[]) => {
data.forEach(sys => { data.forEach(sys => {
@ -219,14 +209,10 @@ struct Index {
} }
async onPageShow() { async onPageShow() {
console.log('ttttt', 1111)
await this.userAuth(); await this.userAuth();
console.log('globalThis.singlePlay', globalThis.singlePlay)
if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) {
// setVideoParam()
console.log('diyidiy')
this.context.resourceManager.getRawFileContent("welcome.wav") this.context.resourceManager.getRawFileContent("welcome.wav")
.then(value => { .then(_value => {
this.avPlayer.playAudio(['welcome.wav']) this.avPlayer.playAudio(['welcome.wav'])
}) })
.catch(error => { .catch(error => {
@ -245,7 +231,6 @@ struct Index {
const time = await getCurrentTime() const time = await getCurrentTime()
const date = time.split(' ')[0] const date = time.split(' ')[0]
this.fileHelper.createAlbum('jt') this.fileHelper.createAlbum('jt')
// this.fileHelper.createAlbum('2025-01-02')
this.fileHelper.createAlbum('pz'); this.fileHelper.createAlbum('pz');
this.fileHelper.createAlbum(date); this.fileHelper.createAlbum(date);
@ -286,9 +271,6 @@ struct Index {
if (carInfo.kscx == 'A2') { if (carInfo.kscx == 'A2') {
console.log("GPS2 udp") console.log("GPS2 udp")
getUDPGps2(this.context, false) getUDPGps2(this.context, false)
this.serviceExtProxy.processData("1", () => {
})
} }
}) })
@ -446,12 +428,12 @@ struct Index {
Column() { Column() {
Row() { Row() {
Column() { Column() {
Text('V外壳' + this.version) Text('V外壳' + globalThis.version)
.fontColor('#CCAE7A') .fontColor('#CCAE7A')
.fontSize(18 * globalThis.ratio) .fontSize(18 * globalThis.ratio)
.width('30%') .width('30%')
.margin({ bottom: 10 }) .margin({ bottom: 10 })
Text('V评判' + this.judgeVersion) Text('V评判' + globalThis.judgeVersion)
.fontColor('#CCAE7A') .fontColor('#CCAE7A')
.fontSize(18 * globalThis.ratio) .fontSize(18 * globalThis.ratio)
.width('30%') .width('30%')

View File

@ -279,11 +279,11 @@ export default struct SignDisplayCom {
} else { } else {
ForEach(["GPS"], (item, i) => { ForEach(["GPS"], (item, i) => {
Row() { Row() {
Text(item).fontColor(this.gpsActive == i ? '#2D3C5A' : '#fff') Text(item).fontColor('#fff')
} }
.width(316 / 2 * this.ratio) .width(316 / 2 * this.ratio)
.height(24 * this.ratio) .height(24 * this.ratio)
.backgroundColor(this.gpsActive == i ? '#fff' : '#1A1A1A') .backgroundColor('#1A1A1A')
.margin({ left: (i === 0 ? 0 : 10) * this.ratio, right: (i === 1 ? 0 : 10) * this.ratio }) .margin({ left: (i === 0 ? 0 : 10) * this.ratio, right: (i === 1 ? 0 : 10) * this.ratio })
.justifyContent(FlexAlign.Center) .justifyContent(FlexAlign.Center)
.onClick(() => { .onClick(() => {

View File

@ -1,7 +1,7 @@
//考试回放开关 //考试回放开关
export const judgeConfig = { export const judgeConfig = {
// 外壳版本号 // 外壳版本号
version: "2025.05.15.01", version: "2025.05.17.01",
// 是否A1A3共用一车 // 是否A1A3共用一车
isUseSameCar: false, isUseSameCar: false,
//本地目录开关 //本地目录开关

View File

@ -24,13 +24,13 @@
"abilities": [ "abilities": [
{ {
"name": "EntryAbility", "name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ets", "srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc", "description": "$string:EntryAbility_desc",
"icon": "$media:logo_app", "icon": "$media:logo_app",
"label": "$string:EntryAbility_label", "label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon", "startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background", "startWindowBackground": "$color:start_window_background",
"visible": true, "exported": true,
"skills": [ "skills": [
{ {
"entities": [ "entities": [