forked from harmony_car/subject-two
111
This commit is contained in:
parent
4c2515c1fb
commit
f49c68a3a5
@ -51,6 +51,7 @@ const map = {
|
|||||||
'MA_ITEMINFO': MA_ITEMINFO,
|
'MA_ITEMINFO': MA_ITEMINFO,
|
||||||
'MA_T_CARPARMSET': MA_T_CARPARMSET,
|
'MA_T_CARPARMSET': MA_T_CARPARMSET,
|
||||||
'ES_CAR_VIDEO_PARAMETER': ES_CAR_VIDEO_PARAMETER,
|
'ES_CAR_VIDEO_PARAMETER': ES_CAR_VIDEO_PARAMETER,
|
||||||
|
'USER':USER
|
||||||
}
|
}
|
||||||
const centerToMap={
|
const centerToMap={
|
||||||
'ItemInfo':MA_ITEMINFO,
|
'ItemInfo':MA_ITEMINFO,
|
||||||
@ -77,7 +78,7 @@ function sqlInsertCommonFn(tableName,resultArr){
|
|||||||
const accountTable = new AccountTable(() => {
|
const accountTable = new AccountTable(() => {
|
||||||
}, map[tableName]);
|
}, map[tableName]);
|
||||||
accountTable.getRdbStore(() => {
|
accountTable.getRdbStore(() => {
|
||||||
accountTable.query('0', async (result) => {
|
accountTable.query('0', (result) => {
|
||||||
if (result.length == 0) {
|
if (result.length == 0) {
|
||||||
let INSERT_SQL = "INSERT INTO "+tableName
|
let INSERT_SQL = "INSERT INTO "+tableName
|
||||||
+ " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
|
+ " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
|
||||||
@ -106,9 +107,8 @@ function sqlInsertCommonFn(tableName,resultArr){
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await delSyncTable(tableName)
|
delSyncTable(tableName).then(()=>{
|
||||||
let INSERT_SQL = "INSERT INTO "+tableName
|
let INSERT_SQL2 = "INSERT INTO "+tableName + " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
|
||||||
+ " ("+ map[tableName].ACCOUNT_TABLE.columns.toString()+") VALUES "
|
|
||||||
|
|
||||||
resultArr.map((data,i) => {
|
resultArr.map((data,i) => {
|
||||||
data.id=`${i}`
|
data.id=`${i}`
|
||||||
@ -125,12 +125,14 @@ function sqlInsertCommonFn(tableName,resultArr){
|
|||||||
}else{
|
}else{
|
||||||
str+='),'
|
str+='),'
|
||||||
}
|
}
|
||||||
INSERT_SQL+=str
|
INSERT_SQL2+=str
|
||||||
})
|
})
|
||||||
|
|
||||||
accountTable.sqlOperate(INSERT_SQL,tableName,(val)=>{
|
accountTable.sqlOperate(INSERT_SQL2,tableName,(val)=>{
|
||||||
resolve(val)
|
resolve(true)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,367 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import prompt from '@ohos.promptAction';
|
|
||||||
import camera from '@ohos.multimedia.camera';
|
|
||||||
import CameraModel from '../common/service/CameraModel';
|
|
||||||
import { VideoFrame } from '../common/service/CameraModel';
|
|
||||||
import grantPermission from '../common/utils/PermissionUtils';
|
|
||||||
import Logger from '../common/utils/Logger';
|
|
||||||
|
|
||||||
const CameraMode = {
|
|
||||||
modePhoto: 0, // 拍照模式
|
|
||||||
modeVideo: 1 // 录像模式
|
|
||||||
}
|
|
||||||
|
|
||||||
const TAG: string = '[CameraPage]';
|
|
||||||
|
|
||||||
@Component
|
|
||||||
struct CameraPage {
|
|
||||||
private mXComponentController: XComponentController = new XComponentController();
|
|
||||||
private surfaceId: string = '-1';
|
|
||||||
private cameraModel: CameraModel = new CameraModel();
|
|
||||||
@State imageThumbnail: string = '';
|
|
||||||
@State videoThumbnail: Resource | undefined = undefined;
|
|
||||||
@State currentModel: number = CameraMode.modePhoto;
|
|
||||||
@State isRecording: boolean = false;
|
|
||||||
@State textMove: number = 45;
|
|
||||||
@State isPointShow: boolean = true;
|
|
||||||
@State isTitleShow: boolean = true;
|
|
||||||
@StorageLink('selectType_0') @Watch('rotationChange') rotation: number = 0;
|
|
||||||
@StorageLink('selectType_1') @Watch('resolutionChange') resolution: number = 0;
|
|
||||||
@State timeShow: boolean = false;
|
|
||||||
private textTimerController: TextTimerController = new TextTimerController();
|
|
||||||
@State format: string = 'mm:ss';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 旋转角度改变监听方法
|
|
||||||
*/
|
|
||||||
rotationChange() {
|
|
||||||
Logger.info(TAG, `rotationChange begin ${this.rotation}`);
|
|
||||||
// 0°
|
|
||||||
if (this.rotation == 0) {
|
|
||||||
Logger.info(TAG, `rotationChange ${this.rotation}`);
|
|
||||||
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_0);
|
|
||||||
// 90°
|
|
||||||
} else if (this.rotation == 1) {
|
|
||||||
Logger.info(TAG, `rotationChange ${this.rotation}`);
|
|
||||||
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_90);
|
|
||||||
// 180°
|
|
||||||
} else if (this.rotation == 2) {
|
|
||||||
Logger.info(TAG, `rotationChange ${this.rotation}`);
|
|
||||||
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_180);
|
|
||||||
// 270°
|
|
||||||
} else if (this.rotation == 3) {
|
|
||||||
Logger.info(TAG, `rotationChange ${this.rotation}`);
|
|
||||||
this.cameraModel.setImageRotation(camera.ImageRotation.ROTATION_270);
|
|
||||||
}
|
|
||||||
Logger.info(TAG, 'rotationChange end');
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 分辨率改变监听方法
|
|
||||||
*/
|
|
||||||
resolutionChange() {
|
|
||||||
Logger.info(TAG, `resolutionChange begin ${this.resolution}`);
|
|
||||||
// 不支持 则为默认800*600
|
|
||||||
if (this.resolution == 0) {
|
|
||||||
Logger.info(TAG, `resolutionChange ${this.resolution}`);
|
|
||||||
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1920_1080);
|
|
||||||
} else if (this.resolution == 1) {
|
|
||||||
Logger.info(TAG, `resolutionChange ${this.resolution}`);
|
|
||||||
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1920_1080);
|
|
||||||
// 1280*720
|
|
||||||
} else if (this.resolution == 2) {
|
|
||||||
Logger.info(TAG, `resolutionChange ${this.resolution}`);
|
|
||||||
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_1280_720);
|
|
||||||
// 800*600
|
|
||||||
} else if (this.resolution == 3) {
|
|
||||||
Logger.info(TAG, `resolutionChange ${this.resolution}`);
|
|
||||||
this.cameraModel.setVideoFrameWH(VideoFrame.VIDEOFRAME_800_600);
|
|
||||||
}
|
|
||||||
Logger.info(TAG, 'resolutionChange end');
|
|
||||||
}
|
|
||||||
|
|
||||||
async aboutToAppear() {
|
|
||||||
|
|
||||||
await grantPermission().then(res => {
|
|
||||||
Logger.info(TAG, `权限申请成功 ${JSON.stringify(res)}`);
|
|
||||||
if (this.surfaceId) {
|
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
}
|
|
||||||
}).catch(rej => {
|
|
||||||
Logger.info(TAG, `权限申请失败 ${JSON.stringify(rej)}`);
|
|
||||||
})
|
|
||||||
|
|
||||||
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
|
|
||||||
Logger.info(TAG, `aboutToAppear,surfaceId=${this.surfaceId}`);
|
|
||||||
this.cameraModel.setTakePictureHandleCallback(this.takePictureHandle.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
onPageHide() {
|
|
||||||
Logger.info(TAG, 'onPageHide begin');
|
|
||||||
if (this.isRecording) {
|
|
||||||
Logger.info(TAG, 'stopVideo begin');
|
|
||||||
this.timeShow = false;
|
|
||||||
this.textTimerController.pause();
|
|
||||||
this.cameraModel.stopVideo();
|
|
||||||
this.isRecording = false;
|
|
||||||
this.cameraModel.cameraRelease();
|
|
||||||
// this.videoThumbnail = $r('app.media.video_poster');
|
|
||||||
}
|
|
||||||
Logger.info(TAG, 'onPageHide end');
|
|
||||||
}
|
|
||||||
|
|
||||||
onPageShow() {
|
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCameraIcon() {
|
|
||||||
// if (this.currentModel === CameraMode.modePhoto) {
|
|
||||||
// return $r('app.media.take_photo_normal');
|
|
||||||
// } else {
|
|
||||||
// if (this.isRecording) {
|
|
||||||
// return $r('app.media.take_video_stop');
|
|
||||||
// } else {
|
|
||||||
// return $r('app.media.take_video_normal');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshVideoState() {
|
|
||||||
if (this.isRecording) {
|
|
||||||
Logger.info(TAG, 'stopVideo begin');
|
|
||||||
this.timeShow = false;
|
|
||||||
this.textTimerController.pause();
|
|
||||||
this.cameraModel.stopVideo();
|
|
||||||
this.isRecording = false;
|
|
||||||
// this.videoThumbnail = $r('app.media.video_poster');
|
|
||||||
} else {
|
|
||||||
Logger.info(TAG, 'startVideo begin');
|
|
||||||
this.timeShow = true;
|
|
||||||
this.textTimerController.reset();
|
|
||||||
this.textTimerController.start();
|
|
||||||
this.cameraModel.startVideo();
|
|
||||||
this.isRecording = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startAbilityToPhoto() {
|
|
||||||
globalThis.cameraContext.startAbility({
|
|
||||||
bundleName: 'com.ohos.photos',
|
|
||||||
abilityName: 'com.ohos.photos.MainAbility'
|
|
||||||
}, (error) => {
|
|
||||||
Logger.info(TAG, `error.code = ${error.code}`)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
takePictureHandle = (thumbnail: string) => {
|
|
||||||
this.imageThumbnail = thumbnail;
|
|
||||||
Logger.info(TAG, `takePicture end , thumbnail: ${this.imageThumbnail}`);
|
|
||||||
};
|
|
||||||
animateParam = {
|
|
||||||
duration: 500,
|
|
||||||
onFinish: () => {
|
|
||||||
this.isPointShow = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拍照事件
|
|
||||||
*/
|
|
||||||
photoEvent() {
|
|
||||||
if (this.currentModel === CameraMode.modeVideo) {
|
|
||||||
animateTo(this.animateParam, () => {
|
|
||||||
this.isPointShow = false;
|
|
||||||
this.textMove = this.textMove + 56;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.isRecording) {
|
|
||||||
this.timeShow = false;
|
|
||||||
this.isRecording = false;
|
|
||||||
this.cameraModel.stopVideo();
|
|
||||||
}
|
|
||||||
this.currentModel = CameraMode.modePhoto;
|
|
||||||
this.videoThumbnail = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 录像事件
|
|
||||||
*/
|
|
||||||
videoEvent() {
|
|
||||||
if (this.currentModel === CameraMode.modePhoto) {
|
|
||||||
animateTo(this.animateParam, () => {
|
|
||||||
this.isPointShow = false;
|
|
||||||
this.textMove = this.textMove - 56;
|
|
||||||
});
|
|
||||||
this.currentModel = CameraMode.modeVideo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
Stack({ alignContent: Alignment.Bottom }) {
|
|
||||||
Stack({ alignContent: Alignment.TopStart }) {
|
|
||||||
XComponent({
|
|
||||||
id: 'componentId',
|
|
||||||
type: 'surface',
|
|
||||||
controller: this.mXComponentController
|
|
||||||
})
|
|
||||||
.onLoad(() => {
|
|
||||||
Logger.info(TAG, 'onLoad is called');
|
|
||||||
this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 640, surfaceHeight: 480 });
|
|
||||||
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
|
|
||||||
Logger.info(TAG, `onLoad surfaceId: ${this.surfaceId}`);
|
|
||||||
this.currentModel = CameraMode.modePhoto;
|
|
||||||
this.cameraModel.initCamera(this.surfaceId);
|
|
||||||
})
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
.margin({ bottom: 152 })
|
|
||||||
.gesture(
|
|
||||||
SwipeGesture({ direction: SwipeDirection.Horizontal, speed: 40 })
|
|
||||||
.onAction((event: GestureEvent) => {
|
|
||||||
Logger.info(TAG, `SwipeGesture event: ${JSON.stringify(event)}`);
|
|
||||||
// 右滑
|
|
||||||
if (event.angle > 0) {
|
|
||||||
this.photoEvent();
|
|
||||||
} else {
|
|
||||||
this.videoEvent();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
TextTimer({ isCountDown: false, count: 60000, controller: this.textTimerController })
|
|
||||||
.height(60)
|
|
||||||
.fontSize(24)
|
|
||||||
.format(this.format)
|
|
||||||
.fontColor(Color.Red)
|
|
||||||
.fontSize(50)
|
|
||||||
}
|
|
||||||
.justifyContent(FlexAlign.Start)
|
|
||||||
.visibility(this.timeShow ? Visibility.Visible : Visibility.Hidden)
|
|
||||||
.width('100%')
|
|
||||||
.height('30%')
|
|
||||||
}
|
|
||||||
.width('97%')
|
|
||||||
.height('100%')
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
Row() {
|
|
||||||
Column() {
|
|
||||||
Text('1')
|
|
||||||
.id('photo')
|
|
||||||
.fontSize(14)
|
|
||||||
.fontColor(this.currentModel === CameraMode.modePhoto ? Color.White : Color.Gray)
|
|
||||||
.onClick(() => {
|
|
||||||
this.photoEvent();
|
|
||||||
})
|
|
||||||
if (this.currentModel === CameraMode.modePhoto) {
|
|
||||||
Text()
|
|
||||||
.width(4)
|
|
||||||
.height(4)
|
|
||||||
.margin({ top: 5 })
|
|
||||||
.borderRadius(2)
|
|
||||||
.backgroundColor(Color.Red)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
Text('1')
|
|
||||||
.fontColor(this.currentModel === CameraMode.modeVideo ? Color.White : Color.Gray)
|
|
||||||
.fontSize(14)
|
|
||||||
.id('video')
|
|
||||||
.margin({ left: 30 })
|
|
||||||
.onClick(() => {
|
|
||||||
this.videoEvent();
|
|
||||||
})
|
|
||||||
if (this.currentModel === CameraMode.modeVideo) {
|
|
||||||
Text()
|
|
||||||
.width(4)
|
|
||||||
.height(4)
|
|
||||||
.margin({ left: 30, top: 5 })
|
|
||||||
.borderRadius(2)
|
|
||||||
.backgroundColor(Color.Red)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.offset({ x: this.textMove })
|
|
||||||
.size({ height: 40, width: '100%' })
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
if (this.currentModel === CameraMode.modeVideo) {
|
|
||||||
Image(this.videoThumbnail)
|
|
||||||
.id('intoPhoto')
|
|
||||||
.objectFit(ImageFit.Fill)
|
|
||||||
.margin({ left: 24 })
|
|
||||||
.borderRadius(5)
|
|
||||||
.aspectRatio(1)
|
|
||||||
.backgroundColor(Color.Gray)
|
|
||||||
.size({ width: 40, height: 40 })
|
|
||||||
.onClick(e => {
|
|
||||||
this.startAbilityToPhoto();
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Image(this.imageThumbnail)
|
|
||||||
.id('intoPhoto')
|
|
||||||
.objectFit(ImageFit.Fill)
|
|
||||||
.margin({ left: 24 })
|
|
||||||
.borderRadius(5)
|
|
||||||
.aspectRatio(1)
|
|
||||||
.backgroundColor(Color.Gray)
|
|
||||||
.size({ width: 40, height: 40 })
|
|
||||||
.onClick(e => {
|
|
||||||
this.startAbilityToPhoto();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
}
|
|
||||||
.width(40)
|
|
||||||
.height(40)
|
|
||||||
}
|
|
||||||
.size({ height: 80, width: '100%' })
|
|
||||||
.margin({ right: 10 })
|
|
||||||
.justifyContent(FlexAlign.SpaceBetween)
|
|
||||||
}
|
|
||||||
.padding({ bottom: 10 })
|
|
||||||
// .backgroundColor($r('app.color.COLOR_000000'))
|
|
||||||
.alignItems(HorizontalAlign.Start)
|
|
||||||
.size({ height: 130, width: '100%' })
|
|
||||||
}
|
|
||||||
.layoutWeight(1)
|
|
||||||
// .backgroundColor($r('app.color.COLOR_000000'))
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
}
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
}
|
|
||||||
|
|
||||||
async aboutToDisappear() {
|
|
||||||
if (this.isRecording) {
|
|
||||||
await this.cameraModel.stopVideo();
|
|
||||||
}
|
|
||||||
await this.cameraModel.cameraRelease();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default CameraPage
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
import FaceCompare from './compontents/faceCompare'
|
|
||||||
import { voiceService } from '../common/service/voiceService'
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct Hello {
|
|
||||||
@State message: string = 'Hello World'
|
|
||||||
@State showFaceCompare: boolean = true;
|
|
||||||
@State count: number = 1;
|
|
||||||
@State @Watch('changefaceCompareSucess') faceCompareSucess: boolean = false;
|
|
||||||
|
|
||||||
build() {
|
|
||||||
Row() {
|
|
||||||
if(this.showFaceCompare) {
|
|
||||||
FaceCompare({ showFaceCompare: $showFaceCompare, sfzh: '1234', firstImage: '',faceCompareSucess: $faceCompareSucess })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Text('click me').onClick(async () => {
|
|
||||||
// console.info("jiangsong click me ");
|
|
||||||
//
|
|
||||||
// voiceService({
|
|
||||||
// type: 1,
|
|
||||||
// name: 'face_check.mp3',
|
|
||||||
// callBack: (status) => {
|
|
||||||
// console.log('jiangsong audio play callback status ' + status)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
|
|
||||||
// globalThis.context.resourceManager.getMediaContent($r('app.media.face_check').id, (error, value) => {
|
|
||||||
// if (error != null) {
|
|
||||||
// console.info("jiangsong error is " + error);
|
|
||||||
// } else {
|
|
||||||
// console.info('jiangsong get resource success')
|
|
||||||
//
|
|
||||||
// voiceService({
|
|
||||||
// type: 1,
|
|
||||||
// resource: value,
|
|
||||||
// callBack: (status) => {
|
|
||||||
// console.log('jiangsong audio play status' + status)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// })
|
|
||||||
// .width('200px')
|
|
||||||
// .height('200px')
|
|
||||||
// .backgroundColor(Color.Yellow)
|
|
||||||
}
|
|
||||||
.height('100%')
|
|
||||||
.width('100%')
|
|
||||||
}
|
|
||||||
changefaceCompareSucess() {
|
|
||||||
console.log('jiangsong changefaceCompareSucess = ' + this.faceCompareSucess)
|
|
||||||
}
|
|
||||||
// @Watch('faceCompareSucess')
|
|
||||||
}
|
|
||||||
@ -1,416 +0,0 @@
|
|||||||
import deviceInfo from '@ohos.deviceInfo'
|
|
||||||
import prompt from '@ohos.prompt'
|
|
||||||
import router from '@ohos.router'
|
|
||||||
import { timeSynchronize } from '../common/service/timeService'
|
|
||||||
import { getCarInfo } from '../common/service/terminalService'
|
|
||||||
import { dateFormat } from '../common/utils/tools'
|
|
||||||
import ethernet from '@ohos.net.ethernet';
|
|
||||||
import UdpClient from '../common/utils/UdpClient';
|
|
||||||
import FileLog from './judgeSDK/utils/file-log'
|
|
||||||
import TopLogo from './compontents/topLogo'
|
|
||||||
import { voiceService } from '../common/service/voiceService'
|
|
||||||
|
|
||||||
@Entry
|
|
||||||
@Component
|
|
||||||
struct Index {
|
|
||||||
@State mlxhColum: Array<any> = [{ key: '车速', value: '0' }, { key: '倒车时速', value: '0' }, {
|
|
||||||
key: '档位',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '溜车距离', value: '0' }, { key: '熄火次数', value: '0' }, { key: '累计距离', value: '0' }, {
|
|
||||||
key: '发动机转速',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '项目距离', value: '0' }, { key: '倒车距离', value: '0' }, { key: '左前超声波', value: '0' }, {
|
|
||||||
key: '右后超声波',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '右前超声波', value: '0' }, { key: '左后超声波', value: '0' }, { key: '前磁计数s', value: '0' }, {
|
|
||||||
key: '左前磁计数s',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '右前磁计数s', value: '0' }, { key: '左后磁计数s', value: '0' }, { key: '右后磁计数s', value: '0' }, {
|
|
||||||
key: '左后外磁计数',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '右后外磁计数s', value: '0' }, { key: '累计脉冲', value: '0' },
|
|
||||||
{ key: '倒车脉冲', value: '0' }, { key: '溜车脉冲', value: '0' }, { key: '前磁计数n', value: '0' }
|
|
||||||
, { key: '左后外磁计数n', value: '0' }, { key: '右后外磁计数n', value: '0' }, { key: '前磁ns脉冲', value: '0' },
|
|
||||||
{ key: '左前磁ns脉冲', value: '0' }, { key: '右前磁ns脉冲', value: '0' }, { key: '左后磁ns脉冲', value: '0' },
|
|
||||||
{ key: '右后磁ns脉冲', value: '0' }, { key: '超声波1', value: '0' }, { key: '超声波2', value: '0' }, {
|
|
||||||
key: 'X坐标',
|
|
||||||
value: '0'
|
|
||||||
}, { key: 'Y坐标', value: '0' }
|
|
||||||
, { key: '左后外磁计数s', value: '0' }, { key: '右后外磁计数s', value: '0' }, { key: '差分改正数', value: '0' },
|
|
||||||
]
|
|
||||||
@State sjxhColum: Array<any> = [{ key: '应答位', value: '0' }, { key: '左方向灯', value: '0' }, {
|
|
||||||
key: '右方向灯',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '双跳灯', value: '0' }, { key: '远光灯', value: '0' }, { key: '近光灯', value: '0' }, {
|
|
||||||
key: '视宽灯',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '点火1', value: '0' }, { key: '点火2', value: '0' }, { key: '离合器', value: '0' }, {
|
|
||||||
key: '脚刹',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '手刹', value: '0' }, { key: '副刹', value: '0' }, { key: '喇叭', value: '0' }, { key: '门开关', value: '0' }, {
|
|
||||||
key: '安全带',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '雾灯', value: '0' }, { key: '闪灯', value: '0' }, { key: '方向盘', value: '0' }, { key: '计时', value: '0' }, {
|
|
||||||
key: '前进状态',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '后退状态', value: '0' }, { key: '停车状态', value: '0' }, { key: '加减档错', value: '0' }, {
|
|
||||||
key: '1-2',
|
|
||||||
value: ''
|
|
||||||
}, { key: '震动', value: '0' }, { key: '前磁s', value: '0' }, { key: '左前磁s', value: '0' }, {
|
|
||||||
key: '右前磁s',
|
|
||||||
value: ''
|
|
||||||
}, { key: '左后磁s', value: '0' }, { key: '右后磁s', value: '0' }, { key: '左后外磁s', value: '0' }, {
|
|
||||||
key: '右后外磁s',
|
|
||||||
value: ''
|
|
||||||
}, { key: '前磁n', value: '0' }, { key: '左前磁n', value: '0' }, { key: '右前磁n', value: '0' }, {
|
|
||||||
key: '左后磁n',
|
|
||||||
value: '0'
|
|
||||||
}, { key: '右后磁n', value: '0' }, { key: '左后外磁n', value: '0' }, { key: '右后外磁n', value: '0' }, {
|
|
||||||
key: '雨刮器',
|
|
||||||
value: '0'
|
|
||||||
}]
|
|
||||||
@State ratio: number = 1280 / 960
|
|
||||||
@State gpsActive: number = 1
|
|
||||||
@State active: number = 0
|
|
||||||
@State msg: string = ''
|
|
||||||
@State @Watch('outClick') outFlag: boolean = false;
|
|
||||||
private timer = null
|
|
||||||
private udpClient: UdpClient = null
|
|
||||||
private FileLog: FileLog
|
|
||||||
private vocObj = null;
|
|
||||||
@State url: string = ''
|
|
||||||
// @State gpsList: Array<any> = []
|
|
||||||
build() {
|
|
||||||
Column() {
|
|
||||||
TopLogo({outFlag:$outFlag})
|
|
||||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
|
||||||
Row() {
|
|
||||||
// Image($r('app.media.signal_logoS')).width(30 * this.ratio).height(24 * this.ratio)
|
|
||||||
Row() {
|
|
||||||
Text('PLC信号').fontColor(this.active == 0 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
|
|
||||||
}
|
|
||||||
.backgroundImage(this.active == 0 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
|
|
||||||
.width(144 * this.ratio)
|
|
||||||
.height(50 * this.ratio)
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
.onClick(() => {
|
|
||||||
this.active = 0
|
|
||||||
})
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
|
|
||||||
}
|
|
||||||
.backgroundImage(this.active == 1 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
|
|
||||||
.width(144 * this.ratio)
|
|
||||||
.height(50 * this.ratio)
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
.onClick(() => {
|
|
||||||
this.active = 1
|
|
||||||
})
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Text('原始数据').fontColor(this.active == 2 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio)
|
|
||||||
}
|
|
||||||
.backgroundImage(this.active == 2 ? $r('app.media.signal_tabS') : $r('app.media.signal_tab'))
|
|
||||||
.width(144 * this.ratio)
|
|
||||||
.height(50 * this.ratio)
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
.onClick(() => {
|
|
||||||
this.active = 2
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Image($r('app.media.topB_back')).width('16.7%').height('12.2%')
|
|
||||||
.onClick(()=>{
|
|
||||||
// router.back()
|
|
||||||
this.url='back'
|
|
||||||
// this.vocObj.playAudio({
|
|
||||||
// type: 1,
|
|
||||||
// name: 'media_button.wav'
|
|
||||||
// })
|
|
||||||
this.outFlag=true
|
|
||||||
})
|
|
||||||
|
|
||||||
// Row(){
|
|
||||||
// Text('保存日志').fontSize(21*this.ratio).fontColor('#fff')
|
|
||||||
// }.width(137*this.ratio).height(36*this.ratio).margin({left:12*this.ratio}).backgroundImageSize({width:'100%',height:'100%'}).backgroundImage($r('app.media.button_nor')).justifyContent(FlexAlign.Center).onClick(()=>{
|
|
||||||
// this.saveLog()
|
|
||||||
// })
|
|
||||||
// Row() {
|
|
||||||
// Text('关闭').fontSize(21 * this.ratio).fontColor('#fff')
|
|
||||||
// }
|
|
||||||
// .width(137 * this.ratio)
|
|
||||||
// .height(36 * this.ratio)
|
|
||||||
// .margin({ left: 12 * this.ratio })
|
|
||||||
// .backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
// .backgroundImage($r('app.media.button_nor'))
|
|
||||||
// .justifyContent(FlexAlign.Center)
|
|
||||||
// .onClick(() => {
|
|
||||||
// // globalThis.udpClient.closeUdp(()=>{
|
|
||||||
// router.back()
|
|
||||||
// // })
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Column() {
|
|
||||||
Text('数字信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
|
|
||||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
|
|
||||||
ForEach(this.sjxhColum, (item) => {
|
|
||||||
Row() {
|
|
||||||
Text(`${item.key}:${item.value}`)
|
|
||||||
.fontSize(14 * this.ratio)
|
|
||||||
.lineHeight(21 * this.ratio)
|
|
||||||
.fontColor('#fff')
|
|
||||||
}.width('33.3%').height(21 * this.ratio)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.width(440 * this.ratio)
|
|
||||||
.height(360 * this.ratio)
|
|
||||||
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
|
|
||||||
.backgroundColor('#282828')
|
|
||||||
}.width(460 * this.ratio).height('100%')
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
Text('模拟信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
|
|
||||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
|
|
||||||
ForEach(this.mlxhColum, (item) => {
|
|
||||||
Row() {
|
|
||||||
Text(`${item.key}:${item.value}`)
|
|
||||||
.fontSize(14 * this.ratio)
|
|
||||||
.lineHeight(21 * this.ratio)
|
|
||||||
.fontColor('#fff')
|
|
||||||
}.width('33.3%').height(21 * this.ratio)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.width(440 * this.ratio)
|
|
||||||
.height(360 * this.ratio)
|
|
||||||
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
|
|
||||||
.backgroundColor('#282828')
|
|
||||||
}.width(460 * this.ratio).height('100%')
|
|
||||||
|
|
||||||
Column() {
|
|
||||||
Text('模拟信号').fontSize(18 * this.ratio).margin({ top: 10 * this.ratio })
|
|
||||||
Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) {
|
|
||||||
ForEach(this.mlxhColum, (item) => {
|
|
||||||
Row() {
|
|
||||||
Text(`${item.key}:${item.value}`)
|
|
||||||
.fontSize(14 * this.ratio)
|
|
||||||
.lineHeight(21 * this.ratio)
|
|
||||||
.fontColor('#fff')
|
|
||||||
}.width('33.3%').height(21 * this.ratio)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.width(440 * this.ratio)
|
|
||||||
.height(360 * this.ratio)
|
|
||||||
.padding({ left: 10 * this.ratio, top: 10 * this.ratio })
|
|
||||||
.backgroundColor('#282828')
|
|
||||||
}.width(460 * this.ratio).height('100%')
|
|
||||||
}
|
|
||||||
.width(936 * this.ratio)
|
|
||||||
.height(420 * this.ratio)
|
|
||||||
.margin({ left: 10 * this.ratio })
|
|
||||||
.padding({ left: 10 * this.ratio, right: 10 * this.ratio })
|
|
||||||
.backgroundImage($r('app.media.km_open'))
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
.visibility(this.active == 0 ? Visibility.Visible : Visibility.None)
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Flex({ direction: FlexDirection.Column }) {
|
|
||||||
Row() {
|
|
||||||
Row() {
|
|
||||||
Text('GPS1').fontColor(this.gpsActive == 0 ? '#2D3C5A' : '#fff')
|
|
||||||
}
|
|
||||||
.width(72)
|
|
||||||
.height(24)
|
|
||||||
.backgroundColor(this.gpsActive == 0 ? '#fff' : '#1A1A1A')
|
|
||||||
.margin({ left: 10, right: 10 })
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
.onClick(() => {
|
|
||||||
this.gpsActive = 0
|
|
||||||
})
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
Text('GPS2').fontColor(this.gpsActive == 1 ? '#2D3C5A' : '#fff')
|
|
||||||
}
|
|
||||||
.width(72)
|
|
||||||
.height(24)
|
|
||||||
.backgroundColor(this.gpsActive == 1 ? '#fff' : '#1A1A1A')
|
|
||||||
.justifyContent(FlexAlign.Center)
|
|
||||||
.onClick(() => {
|
|
||||||
this.gpsActive = 1
|
|
||||||
})
|
|
||||||
}.margin({ top: 10 })
|
|
||||||
// ForEach(this.gpsList,(item)=>{
|
|
||||||
// Text()
|
|
||||||
// })
|
|
||||||
|
|
||||||
}
|
|
||||||
.width(168 * this.ratio)
|
|
||||||
.height(380 * this.ratio)
|
|
||||||
.backgroundColor('#282828')
|
|
||||||
.margin({ top: 6 * this.ratio, left: 10 * this.ratio })
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
|
|
||||||
}.width(168 * this.ratio).height(380 * this.ratio).backgroundColor('#1A1A1A').margin({ top: 6 * this.ratio })
|
|
||||||
|
|
||||||
Row() {
|
|
||||||
|
|
||||||
}
|
|
||||||
.width(550 * this.ratio)
|
|
||||||
.height(380 * this.ratio)
|
|
||||||
.backgroundColor('#1A1A1A')
|
|
||||||
.margin({ top: 6 * this.ratio, left: 6 * this.ratio })
|
|
||||||
|
|
||||||
}
|
|
||||||
.width(936 * this.ratio)
|
|
||||||
.height(420 * this.ratio)
|
|
||||||
.margin({ left: 10 * this.ratio })
|
|
||||||
.padding({ left: 10 * this.ratio, right: 10 * this.ratio })
|
|
||||||
.backgroundImage($r('app.media.km_open'))
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
.visibility(this.active == 1 ? Visibility.Visible : Visibility.None)
|
|
||||||
}
|
|
||||||
.width('100%')
|
|
||||||
.height('100%')
|
|
||||||
.backgroundImage($r('app.media.bg'))
|
|
||||||
.backgroundImageSize({ width: '100%', height: '100%' })
|
|
||||||
}
|
|
||||||
|
|
||||||
aboutToDisappear() {
|
|
||||||
this.vocObj = new voiceService(async (status,val) => {
|
|
||||||
if (status == 'idle') {
|
|
||||||
if(this.url=='back'){
|
|
||||||
router.back()
|
|
||||||
// that.udpClient.sendMsg('111')
|
|
||||||
}else {
|
|
||||||
router.pushUrl({
|
|
||||||
url: this.url,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// this.udpClient.closeUdp()
|
|
||||||
}
|
|
||||||
|
|
||||||
onPageShow() {
|
|
||||||
console.info('Index onPageShow');
|
|
||||||
const that = this
|
|
||||||
|
|
||||||
|
|
||||||
if (!globalThis.udpClient) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
globalThis.udpClient.onMessage((msg) => {
|
|
||||||
that.msg = msg
|
|
||||||
const signArr = msg.split(',')
|
|
||||||
that.sjxhColum[1].value = signArr[2]
|
|
||||||
that.sjxhColum[2].value = signArr[3]
|
|
||||||
that.sjxhColum[3].value = signArr[20]
|
|
||||||
that.sjxhColum[4].value = signArr[8]
|
|
||||||
that.sjxhColum[5].value = signArr[7]
|
|
||||||
// that.sjxhColum[6].value=signArr[7]//宽视灯
|
|
||||||
that.sjxhColum[7].value = signArr[5] //
|
|
||||||
that.sjxhColum[8].value = signArr[6] //
|
|
||||||
that.sjxhColum[9].value = signArr[17] //
|
|
||||||
that.sjxhColum[10].value = signArr[12]
|
|
||||||
that.sjxhColum[11].value = signArr[13]
|
|
||||||
that.sjxhColum[12].value = signArr[18]
|
|
||||||
that.sjxhColum[13].value = signArr[4]
|
|
||||||
that.sjxhColum[14].value = signArr[14]
|
|
||||||
that.sjxhColum[15].value = signArr[19]
|
|
||||||
that.sjxhColum[16].value = signArr[10]
|
|
||||||
// that.sjxhColum[17].value=signArr[10]//闪灯
|
|
||||||
that.sjxhColum[18].value = signArr[27]
|
|
||||||
// that.sjxhColum[19].value=signArr[27] //计时
|
|
||||||
// that.sjxhColum[20].value=signArr[27]//前进状态
|
|
||||||
// that.sjxhColum[21].value=signArr[27]//后退状态
|
|
||||||
// that.sjxhColum[22].value=signArr[27]//停车状态
|
|
||||||
// that.sjxhColum[23].value=signArr[27]//加减档错
|
|
||||||
// that.sjxhColum[24].value=signArr[27]//1-2
|
|
||||||
// that.sjxhColum[25].value=signArr[27]//震动
|
|
||||||
// that.sjxhColum[26].value=signArr[27]//震动
|
|
||||||
// that.sjxhColum[27].value=signArr[27]//前磁s
|
|
||||||
// that.sjxhColum[28].value=signArr[27]//左前磁s
|
|
||||||
// that.sjxhColum[29].value=signArr[27]//右前磁s
|
|
||||||
//that.sjxhColum[30].value=signArr[27]//左后磁s
|
|
||||||
//that.sjxhColum[31].value=signArr[27]//右后磁s
|
|
||||||
//that.sjxhColum[32].value=signArr[27]//左后外磁s
|
|
||||||
//that.sjxhColum[33].value=signArr[27]//左后外磁s
|
|
||||||
//that.sjxhColum[34].value=signArr[27]//前磁n
|
|
||||||
//that.sjxhColum[35].value=signArr[27]//左前磁n
|
|
||||||
//that.sjxhColum[36].value=signArr[27]//右前磁n
|
|
||||||
//that.sjxhColum[37].value=signArr[27]//左后磁n
|
|
||||||
//that.sjxhColum[38].value=signArr[27]//右后磁n
|
|
||||||
//that.sjxhColum[39].value=signArr[27]//左后外磁
|
|
||||||
//that.sjxhColum[40].value=signArr[27]//右后外磁
|
|
||||||
that.sjxhColum[40].value = signArr[11] //右后外磁
|
|
||||||
that.sjxhColum = JSON.parse(JSON.stringify((that.sjxhColum)))
|
|
||||||
|
|
||||||
that.mlxhColum[0].value = signArr[23]
|
|
||||||
// that.mlxhColum[1].value = signArr[28]
|
|
||||||
that.mlxhColum[2].value = signArr[28]
|
|
||||||
// that.mlxhColum[3].value = signArr[24]
|
|
||||||
that.mlxhColum[4].value = signArr[26]
|
|
||||||
// that.mlxhColum[5].value = signArr[29]
|
|
||||||
that.mlxhColum[6].value = signArr[25] //发动机转速
|
|
||||||
// that.mlxhColum[7].value = signArr[31]
|
|
||||||
// that.mlxhColum[8].value = signArr[32]
|
|
||||||
that.mlxhColum[9].value = signArr[29]
|
|
||||||
that.mlxhColum[10].value = signArr[30]
|
|
||||||
that.mlxhColum[11].value = signArr[31]
|
|
||||||
that.mlxhColum[12].value = signArr[32]
|
|
||||||
// that.mlxhColum[13].value = signArr[84]//前磁计数s
|
|
||||||
// that.mlxhColum[14].value = signArr[85]
|
|
||||||
// that.mlxhColum[15].value = signArr[86]
|
|
||||||
// that.mlxhColum[16].value = signArr[87]
|
|
||||||
// that.mlxhColum[17].value = signArr[88]
|
|
||||||
// that.mlxhColum[18].value = signArr[89]
|
|
||||||
// that.mlxhColum[19].value = signArr[90]
|
|
||||||
that.mlxhColum[20].value = signArr[24] //累计脉冲
|
|
||||||
that.mlxhColum[31].value = signArr[29] //超声波1
|
|
||||||
that.mlxhColum[32].value = signArr[30] //超声波2
|
|
||||||
that.mlxhColum[33].value = signArr[95]
|
|
||||||
that.mlxhColum[34].value = signArr[96]
|
|
||||||
that.mlxhColum = JSON.parse(JSON.stringify((that.mlxhColum)))
|
|
||||||
// if (that.timer) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// that.timer = setTimeout(() => {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// that.timer=null
|
|
||||||
// }, 1000)
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
outClick(){
|
|
||||||
}
|
|
||||||
saveLog() {
|
|
||||||
// this.FileLog.initFileLogo('d .0ateLog')
|
|
||||||
// this.FileLog.createFile('123')
|
|
||||||
}
|
|
||||||
// getDeviceNo() {
|
|
||||||
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-72'; //设备号
|
|
||||||
// }
|
|
||||||
|
|
||||||
// initTime() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// initCarInfo() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// getData() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user