Compare commits
11 Commits
b6c153443a
...
cbb64fdf42
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbb64fdf42 | ||
|
|
a3d51c8a79 | ||
|
|
aa67ead81a | ||
|
|
fa80b4ca7b | ||
|
|
b9ed251380 | ||
|
|
1fb5fa23b9 | ||
|
|
6d3a5d2360 | ||
|
|
09096d8d6c | ||
|
|
801932c42e | ||
|
|
d35c015f7f | ||
|
|
a94575c6f1 |
6
Makefile
6
Makefile
@ -1,8 +1,8 @@
|
|||||||
gitLog:
|
gitLog:
|
||||||
git log --since="2025-08-08 14:00" --until="2025-08-19 15:00" --pretty=format:"<details>%n <summary>%s</summary>%n <span style=\"color: #888;\">[提交人]:</span><span style=\"color: #333;\">%an</span><br>%n <span style=\"color: #888;\">[提交时间]:</span><span style=\"color: #333;\">%ad</span><br>%n <span style=\"color: #888;\">[提交版本]:</span><span style=\"color: #333;\">%h</span>%n</details>%n" --date=format:"%Y-%m-%d %H:%M" > release_note.md
|
git log --since="2025-08-08 14:00" --until="2025-08-19 15:00" --pretty=format:"<details>%n <summary>%s</summary>%n <span style=\"color: #888;\">[提交人]:</span><span style=\"color: #333;\">%an</span><br>%n <span style=\"color: #888;\">[提交时间]:</span><span style=\"color: #333;\">%ad</span><br>%n <span style=\"color: #888;\">[提交版本]:</span><span style=\"color: #333;\">%h</span>%n</details>%n" --date=format:"%Y-%m-%d %H:%M" > release_note.md
|
||||||
|
|
||||||
re:
|
re:
|
||||||
hdc shell mount -o remount,rw /
|
hdc shell mount -o remount,rw /
|
||||||
|
|
||||||
pushJudge:
|
pushJudge:
|
||||||
hdc file send /Users/wangzhongjie/Desktop/duolun/openHarmony/car_next/ohos/so/libjudgesdk.z.so /system/lib/module/
|
hdc file send /Users/wangzhongjie/Desktop/duolun/openHarmony/car_next/ohos/so/libjudgesdk.z.so /system/lib/module/
|
||||||
|
uninstall:
|
||||||
|
hdc uninstall com.oh.dts
|
||||||
|
|||||||
@ -5,9 +5,9 @@
|
|||||||
"name": "default",
|
"name": "default",
|
||||||
"material": {
|
"material": {
|
||||||
"certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.cer",
|
"certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.cer",
|
||||||
"storePassword": "0000001BD807731D6FB9F044E3DF0E0429F4BB4214FE1608E25B4197041FBF36DDA3C6760585312F2864B6",
|
"storePassword": "0000001B42BCAC6B534ABB3B488F5C45764278201EE92A007F988939EC561EEB8ED64F737B8A11A7A72A1E",
|
||||||
"keyAlias": "debugKey",
|
"keyAlias": "debugKey",
|
||||||
"keyPassword": "0000001BFA38BF5235541496B5FF9ED9FFA764AB53FABC873D21DC230060209C2FF24ACE5DA09413B0C138",
|
"keyPassword": "0000001B2A149F63C38A6F5B972EC903EB0ADAB7978BA6C33B8E460C7353BD0BC2248776AB2FD2AE009A98",
|
||||||
"profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p7b",
|
"profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p7b",
|
||||||
"signAlg": "SHA256withECDSA",
|
"signAlg": "SHA256withECDSA",
|
||||||
"storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p12"
|
"storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p12"
|
||||||
|
|||||||
@ -8,10 +8,9 @@ import { BaseInfoType, CarInfoType, EnvironmentConfigurationType, ExaminerInfoTy
|
|||||||
import DB from '../utils/DbSql';
|
import DB from '../utils/DbSql';
|
||||||
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
|
import { DrivingDataStorage } from '../utils/business/DrivingDataStorage';
|
||||||
import { InitTable } from '../utils/table/Operation';
|
import { InitTable } from '../utils/table/Operation';
|
||||||
import FileUtils from '../utils/FileUtils';
|
|
||||||
import { EntryTag } from '../config';
|
import { EntryTag } from '../config';
|
||||||
import { dConsole } from '../utils/LogWorker';
|
import { dConsole } from '../utils/LogWorker';
|
||||||
import { UseAuth } from '../utils/Common';
|
import { ReadFileContent, UseAuth } from '../utils/Common';
|
||||||
import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker';
|
import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker';
|
||||||
|
|
||||||
export default class EntryAbility extends UIAbility {
|
export default class EntryAbility extends UIAbility {
|
||||||
@ -19,9 +18,8 @@ export default class EntryAbility extends UIAbility {
|
|||||||
console.log(EntryTag, "多伦鸿蒙车载程序启动")
|
console.log(EntryTag, "多伦鸿蒙车载程序启动")
|
||||||
await DB.init(this.context)
|
await DB.init(this.context)
|
||||||
try {
|
try {
|
||||||
let fileUtil = new FileUtils(this.context)
|
|
||||||
// 读取系统设置参数
|
// 读取系统设置参数
|
||||||
const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
|
const data = await ReadFileContent(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt')
|
||||||
if (data !== '' && data !== undefined) {
|
if (data !== '' && data !== undefined) {
|
||||||
const result: EnvironmentConfigurationType = JSON.parse(data)
|
const result: EnvironmentConfigurationType = JSON.parse(data)
|
||||||
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result)
|
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result)
|
||||||
@ -33,7 +31,7 @@ export default class EntryAbility extends UIAbility {
|
|||||||
AppStorage.setOrCreate<string>("host", host)
|
AppStorage.setOrCreate<string>("host", host)
|
||||||
}
|
}
|
||||||
// 读取视频配置
|
// 读取视频配置
|
||||||
const videoData = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/config3.txt');
|
const videoData = await ReadFileContent(GlobalConfig.commonFileWriteAddress + '/config/config3.txt')
|
||||||
if (videoData !== '' && videoData !== undefined) {
|
if (videoData !== '' && videoData !== undefined) {
|
||||||
const videoConfig: VideoConfig = JSON.parse(videoData)
|
const videoConfig: VideoConfig = JSON.parse(videoData)
|
||||||
AppStorage.setOrCreate<VideoConfig>("VideoConfig", videoConfig)
|
AppStorage.setOrCreate<VideoConfig>("VideoConfig", videoConfig)
|
||||||
@ -79,8 +77,7 @@ export default class EntryAbility extends UIAbility {
|
|||||||
})
|
})
|
||||||
AppStorage.setOrCreate('isJudgeInitBool', false)
|
AppStorage.setOrCreate('isJudgeInitBool', false)
|
||||||
|
|
||||||
let fileUtil = new FileUtils(this.context)
|
const data = await ReadFileContent(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt')
|
||||||
const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
|
|
||||||
if (data !== '' && data !== undefined) {
|
if (data !== '' && data !== undefined) {
|
||||||
const config: EnvironmentConfigurationType = JSON.parse(data)
|
const config: EnvironmentConfigurationType = JSON.parse(data)
|
||||||
await windowClass.setWindowLayoutFullScreen(true)
|
await windowClass.setWindowLayoutFullScreen(true)
|
||||||
|
|||||||
71
entry/src/main/ets/mock/TerminallInfo.ets
Normal file
71
entry/src/main/ets/mock/TerminallInfo.ets
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { CommonListType } from '../model'
|
||||||
|
|
||||||
|
export const RearMachineModelListData: CommonListType[] = [
|
||||||
|
{
|
||||||
|
label: '一型机',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '二型机',
|
||||||
|
value: '2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '三型机',
|
||||||
|
value: '3'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '一体机',
|
||||||
|
value: '4'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const BoardListData: CommonListType[] = [
|
||||||
|
{
|
||||||
|
label: '北云',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '天宝MB2',
|
||||||
|
value: '2'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const LogListData: CommonListType[] = [
|
||||||
|
{
|
||||||
|
label: '开启',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '关闭',
|
||||||
|
value: '0'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const CarTypeListData: CommonListType[] = [
|
||||||
|
{
|
||||||
|
label: '小车C1',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '小车C2',
|
||||||
|
value: '2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '大车',
|
||||||
|
value: '3'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '牵引车A2',
|
||||||
|
value: '4'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
export const ManufacturerListData: CommonListType[] = [
|
||||||
|
{
|
||||||
|
label: '诚迈',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '润和',
|
||||||
|
value: '2'
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -7,4 +7,5 @@ export * from "./Judge"
|
|||||||
export * from "./SignDisplay"
|
export * from "./SignDisplay"
|
||||||
|
|
||||||
export * from "./CarCheck"
|
export * from "./CarCheck"
|
||||||
export * from "./Test"
|
export * from "./Test"
|
||||||
|
export * from "./TerminallInfo"
|
||||||
@ -173,6 +173,8 @@ export interface EnvironmentConfigurationType {
|
|||||||
judgeVersion?: string
|
judgeVersion?: string
|
||||||
// 是否使用网络摄像头
|
// 是否使用网络摄像头
|
||||||
isUseNetworkCamera?: string
|
isUseNetworkCamera?: string
|
||||||
|
// 厂商 诚迈 1 润和 2
|
||||||
|
manufacturer?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
//全局配置
|
//全局配置
|
||||||
|
|||||||
@ -427,7 +427,8 @@ export struct JudgePage {
|
|||||||
const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist || "").split(',') || []);
|
const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist || "").split(',') || []);
|
||||||
const newKey = key.split('~').join('_')
|
const newKey = key.split('~').join('_')
|
||||||
const xmdm = Number(key.split('~')[0])
|
const xmdm = Number(key.split('~')[0])
|
||||||
const currentProject: ProjectInfo = Reflect.get(this.projectsObj, xmdm)
|
const data: ProjectInfos = JSON.parse(JSON.stringify(this.projectsObj))
|
||||||
|
const currentProject: ProjectInfo = Reflect.get(data, xmdm)
|
||||||
if (currentProject && (carlistArr.length == 0 || carlistArr.includes(this.carlist))) {
|
if (currentProject && (carlistArr.length == 0 || carlistArr.includes(this.carlist))) {
|
||||||
Reflect.set(this.itemInfoObj!, newKey, {
|
Reflect.set(this.itemInfoObj!, newKey, {
|
||||||
modelKey: newKey,
|
modelKey: newKey,
|
||||||
@ -461,7 +462,7 @@ export struct JudgePage {
|
|||||||
const examItems: string | undefined = currentParams?.examItems;
|
const examItems: string | undefined = currentParams?.examItems;
|
||||||
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
|
// 2024-01-03 16:29:26;0;20300,;2,4^2,4;null;
|
||||||
if (examItems !== '' && examItems !== undefined) {
|
if (examItems !== '' && examItems !== undefined) {
|
||||||
dConsole.info(JudgeTag, 'surenjun examItems=>', JSON.stringify(examItems))
|
dConsole.info(JudgeTag, 'surenjun examItems=>', examItems)
|
||||||
const examItemsArrs = examItems.split(';');
|
const examItemsArrs = examItems.split(';');
|
||||||
const startTime = examItemsArrs[0]
|
const startTime = examItemsArrs[0]
|
||||||
const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || []
|
const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || []
|
||||||
|
|||||||
@ -408,9 +408,9 @@ export class BaseJudge {
|
|||||||
const singlePlay = judgeUI.singlePlay
|
const singlePlay = judgeUI.singlePlay
|
||||||
//TODO 断网考试结束补传
|
//TODO 断网考试结束补传
|
||||||
// await uploadDisConnectData();
|
// await uploadDisConnectData();
|
||||||
let backTimeOut = setTimeout(() => {
|
// let backTimeOut = setTimeout(() => {
|
||||||
router.back()
|
// router.back()
|
||||||
}, 90 * 1000)
|
// }, 90 * 1000)
|
||||||
|
|
||||||
console.info(JudgeTag, '考试结束 end')
|
console.info(JudgeTag, '考试结束 end')
|
||||||
const param302 = judgeUI.judgeConfigObj.param_302;
|
const param302 = judgeUI.judgeConfigObj.param_302;
|
||||||
@ -427,11 +427,9 @@ export class BaseJudge {
|
|||||||
case 'voice/unqualified_one.wav':
|
case 'voice/unqualified_one.wav':
|
||||||
currentKssycs = 0;
|
currentKssycs = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'voice/unqualified_two.wav':
|
case 'voice/unqualified_two.wav':
|
||||||
currentKssycs = 1;
|
currentKssycs = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'voice/qualified.mp3':
|
case 'voice/qualified.mp3':
|
||||||
currentKssycs = 0;
|
currentKssycs = 0;
|
||||||
break;
|
break;
|
||||||
@ -474,7 +472,7 @@ export class BaseJudge {
|
|||||||
if (!singlePlay) {
|
if (!singlePlay) {
|
||||||
// await uploadProgressData();
|
// await uploadProgressData();
|
||||||
}
|
}
|
||||||
clearTimeout(backTimeOut)
|
// clearTimeout(backTimeOut)
|
||||||
//语音播放扣分项
|
//语音播放扣分项
|
||||||
let score = 0;
|
let score = 0;
|
||||||
//结束考试时候是否播报一遍所有扣分
|
//结束考试时候是否播报一遍所有扣分
|
||||||
@ -747,7 +745,7 @@ export class BaseJudge {
|
|||||||
}
|
}
|
||||||
// 考试结束
|
// 考试结束
|
||||||
case 5: {
|
case 5: {
|
||||||
dConsole.info(JudgeTag, "考试结束")
|
dConsole.info(JudgeTag, "考试结束距离1", ksjs)
|
||||||
that.ksjs = ksjs;
|
that.ksjs = ksjs;
|
||||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({
|
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({
|
||||||
method: 'examJudgeEndExam'
|
method: 'examJudgeEndExam'
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* 过程数据处理
|
* 过程数据处理
|
||||||
*/
|
*/
|
||||||
import { ExamProcessDataTag, ProcessDataTag, QueueTag } from '../../config';
|
import { ExamProcessDataTag, JudgeTag, ProcessDataTag, QueueTag } from '../../config';
|
||||||
import {
|
import {
|
||||||
CarInfoType,
|
CarInfoType,
|
||||||
CDSBInfo,
|
CDSBInfo,
|
||||||
@ -184,6 +184,7 @@ export const TheExamIsOver = async (judgeUI: JudgePage, that: JudgeBusiness, cal
|
|||||||
const carInfo: CarInfoType = AppStorage.get("carInfo")!
|
const carInfo: CarInfoType = AppStorage.get("carInfo")!
|
||||||
const photoBase64 = await GetPhotoBase64(judgeUI.context);
|
const photoBase64 = await GetPhotoBase64(judgeUI.context);
|
||||||
const ksjs = that.ksjs!
|
const ksjs = that.ksjs!
|
||||||
|
dConsole.log(JudgeTag, "考试结束距离", that.ksjs)
|
||||||
const data: RegulatoryInterfaceParams = {
|
const data: RegulatoryInterfaceParams = {
|
||||||
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
JGHOST: AppStorage.get<string>("JGHOST") || "",
|
||||||
xtlb: '17',
|
xtlb: '17',
|
||||||
@ -197,7 +198,8 @@ export const TheExamIsOver = async (judgeUI: JudgePage, that: JudgeBusiness, cal
|
|||||||
zp: photoBase64,
|
zp: photoBase64,
|
||||||
jssj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
|
jssj: dayTs().format("YYYY-MM-DD HH:mm:ss"),
|
||||||
kscj: (judgeUI.totalScore * 1) > 0 ? judgeUI.totalScore : 0,
|
kscj: (judgeUI.totalScore * 1) > 0 ? judgeUI.totalScore : 0,
|
||||||
kslc: Math.ceil(((ksjs?.qjjl! + ksjs?.dcjl!) || 0) / 100),
|
// kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100),
|
||||||
|
kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100),
|
||||||
dwlc: [ksjs.d1, ksjs.d2, ksjs.d3, ksjs.d4, ksjs!.d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`)
|
dwlc: [ksjs.d1, ksjs.d2, ksjs.d3, ksjs.d4, ksjs!.d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`)
|
||||||
.join(';'),
|
.join(';'),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,11 +99,12 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
|||||||
public async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) {
|
public async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) {
|
||||||
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
||||||
const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3'
|
const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3'
|
||||||
|
dConsole.log(JudgeTag, "itemInfoObj", itemInfoObj)
|
||||||
let allitems: ItemInfo[] = [];
|
let allitems: ItemInfo[] = [];
|
||||||
if (examSubject == '2' && itemInfoObj) {
|
if (examSubject == '2' && itemInfoObj) {
|
||||||
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
|
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
|
||||||
const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey);
|
// const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey);
|
||||||
|
const cdsb: CDSBInfo = Object.entries(itemInfoObj).find((arr: Array<string>) => arr[0] === cdsbKey)![1]
|
||||||
const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context)
|
const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context)
|
||||||
const temp: ItemInfo = {
|
const temp: ItemInfo = {
|
||||||
xmdm: cdsb?.xmdm || 0,
|
xmdm: cdsb?.xmdm || 0,
|
||||||
@ -298,7 +299,6 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
|
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
|
||||||
|
|
||||||
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
|
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
|
||||||
const trajectoryPath = JudgeConfig.trajectoryPath;
|
const trajectoryPath = JudgeConfig.trajectoryPath;
|
||||||
let strArr: string[] = [];
|
let strArr: string[] = [];
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
import HeaderComponent from './compontents/Header';
|
import HeaderComponent from './compontents/Header';
|
||||||
import { CommonListType, EnvironmentConfigurationType } from '../model';
|
import { CommonListType, EnvironmentConfigurationType } from '../model';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
import FileUtils from '../utils/FileUtils';
|
|
||||||
import { GlobalConfig, TerminalInfoTag } from '../config';
|
import { GlobalConfig, TerminalInfoTag } from '../config';
|
||||||
import ethernet from '@ohos.net.ethernet';
|
import ethernet from '@ohos.net.ethernet';
|
||||||
import { BusinessError } from '@ohos.base';
|
import { BusinessError } from '@ohos.base';
|
||||||
import Prompt from '@system.prompt';
|
import Prompt from '@system.prompt';
|
||||||
import { dConsole } from '../utils/LogWorker';
|
import { dConsole } from '../utils/LogWorker';
|
||||||
import window from '@ohos.window';
|
import window from '@ohos.window';
|
||||||
|
import { BoardListData, CarTypeListData, LogListData, ManufacturerListData, RearMachineModelListData } from '../mock';
|
||||||
|
import { OverWriteFile, ReadFileContent } from '../utils/Common';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
struct TerminalInfoPage {
|
struct TerminalInfoPage {
|
||||||
@State config: EnvironmentConfigurationType = {}
|
@State config: EnvironmentConfigurationType = {}
|
||||||
@State isProcessing: boolean = false;
|
@State isProcessing: boolean = false;
|
||||||
private fileUtil!: FileUtils
|
@State IpConfigFilePath: string = GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt'
|
||||||
private context = getContext(this) as common.UIAbilityContext;
|
private context = getContext(this) as common.UIAbilityContext;
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
this.fileUtil = new FileUtils(this.context)
|
const data = await ReadFileContent(this.IpConfigFilePath)
|
||||||
const data = await this.fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
|
|
||||||
dConsole.log(TerminalInfoTag, "data", data)
|
dConsole.log(TerminalInfoTag, "data", data)
|
||||||
if (data) {
|
if (data) {
|
||||||
this.config = JSON.parse(data)
|
this.config = JSON.parse(data)
|
||||||
@ -28,6 +28,10 @@ struct TerminalInfoPage {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async aboutToDisappear() {
|
||||||
|
dConsole.log(TerminalInfoTag, "TerminalInfoPage aboutToDisappear")
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
Flex({
|
Flex({
|
||||||
justifyContent: FlexAlign.Center,
|
justifyContent: FlexAlign.Center,
|
||||||
@ -225,6 +229,14 @@ struct TerminalInfoPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
blockComponent({
|
||||||
|
label: "前置机厂商",
|
||||||
|
type: 8,
|
||||||
|
value: this.config.manufacturer,
|
||||||
|
change: (value: string) => {
|
||||||
|
this.config.manufacturer = value;
|
||||||
|
}
|
||||||
|
})
|
||||||
}.margin(20)
|
}.margin(20)
|
||||||
}
|
}
|
||||||
.height(650)
|
.height(650)
|
||||||
@ -237,7 +249,7 @@ struct TerminalInfoPage {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Row() {
|
Row() {
|
||||||
Image($r('app.media.bc')).height(80).objectFit(ImageFit.Contain).onClick(() => {
|
Image($r('app.media.bc')).height(80).objectFit(ImageFit.Contain).onClick(async () => {
|
||||||
if (this.isProcessing) {
|
if (this.isProcessing) {
|
||||||
Prompt.showToast({
|
Prompt.showToast({
|
||||||
message: "请勿频繁点击",
|
message: "请勿频繁点击",
|
||||||
@ -248,33 +260,43 @@ struct TerminalInfoPage {
|
|||||||
this.isProcessing = true
|
this.isProcessing = true
|
||||||
dConsole.log(TerminalInfoTag, "保存配置", JSON.stringify(this.config))
|
dConsole.log(TerminalInfoTag, "保存配置", JSON.stringify(this.config))
|
||||||
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", this.config)
|
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", this.config)
|
||||||
this.fileUtil.addFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt', JSON.stringify(this.config))
|
// this.fileUtil.addFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt', JSON.stringify(this.config))
|
||||||
|
// 先删除文件
|
||||||
|
const result = await OverWriteFile(this.IpConfigFilePath, JSON.stringify(this.config))
|
||||||
|
if (result) {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: "保存配置文件成功",
|
||||||
|
duration: 3000
|
||||||
|
})
|
||||||
|
ethernet.setIfaceConfig("eth0", {
|
||||||
|
mode: ethernet.IPSetMode.STATIC,
|
||||||
|
ipAddr: this.config.udplocalIp,
|
||||||
|
route: "0.0.0.0",
|
||||||
|
gateway: this.config.gateway, //value.gateway网关
|
||||||
|
netMask: this.config.netMask, //value.netMask网络掩码
|
||||||
|
dnsServers: this.config.dnsServers,
|
||||||
|
domain: ""
|
||||||
|
}, (error: BusinessError) => {
|
||||||
|
if (error) {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: '设置失败' + JSON.stringify(error),
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Prompt.showToast({
|
||||||
|
message: '设置网络成功',
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
// 延迟几秒
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isProcessing = false
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
dConsole.init(this.config.isOpenLog)
|
dConsole.init(this.config.isOpenLog)
|
||||||
ethernet.setIfaceConfig("eth0", {
|
|
||||||
mode: ethernet.IPSetMode.STATIC,
|
|
||||||
ipAddr: this.config.udplocalIp,
|
|
||||||
route: "0.0.0.0",
|
|
||||||
gateway: this.config.gateway, //value.gateway网关
|
|
||||||
netMask: this.config.netMask, //value.netMask网络掩码
|
|
||||||
dnsServers: this.config.dnsServers,
|
|
||||||
domain: ""
|
|
||||||
}, (error: BusinessError) => {
|
|
||||||
if (error) {
|
|
||||||
Prompt.showToast({
|
|
||||||
message: '设置失败' + JSON.stringify(error),
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Prompt.showToast({
|
|
||||||
message: '设置成功',
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
// 延迟几秒
|
|
||||||
setTimeout(() => {
|
|
||||||
this.isProcessing = false
|
|
||||||
}, 3000)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -315,64 +337,13 @@ struct blockComponent {
|
|||||||
// 0 -输入框,1 -后置机类型,2 -日志开关,3 -板卡类型
|
// 0 -输入框,1 -后置机类型,2 -日志开关,3 -板卡类型
|
||||||
@State type: number = 0
|
@State type: number = 0
|
||||||
// '一型机', '二型机', '三型机', '一体机'
|
// '一型机', '二型机', '三型机', '一体机'
|
||||||
@State rearMachineModelList: CommonListType[] = [
|
@State rearMachineModelList: CommonListType[] = RearMachineModelListData
|
||||||
{
|
|
||||||
label: '一型机',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '二型机',
|
|
||||||
value: '2'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '三型机',
|
|
||||||
value: '3'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '一体机',
|
|
||||||
value: '4'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
// '北云', '天宝MB2'
|
// '北云', '天宝MB2'
|
||||||
@State boardList: CommonListType[] = [
|
@State boardList: CommonListType[] = BoardListData
|
||||||
{
|
@State logList: CommonListType[] = LogListData
|
||||||
label: '北云',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '天宝MB2',
|
|
||||||
value: '2'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@State logList: CommonListType[] = [
|
|
||||||
{
|
|
||||||
label: '开启',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '关闭',
|
|
||||||
value: '0'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
// 车型 "小车C1", "小车C2", "大车", "牵引车A2"
|
// 车型 "小车C1", "小车C2", "大车", "牵引车A2"
|
||||||
@State carTypeList: CommonListType[] = [
|
@State carTypeList: CommonListType[] = CarTypeListData
|
||||||
{
|
@State manufacturerList: CommonListType[] = ManufacturerListData
|
||||||
label: '小车C1',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '小车C2',
|
|
||||||
value: '2'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '大车',
|
|
||||||
value: '3'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '牵引车A2',
|
|
||||||
value: '4'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
}
|
}
|
||||||
@ -410,7 +381,7 @@ struct blockComponent {
|
|||||||
} else {
|
} else {
|
||||||
ForEach(this.type === 1 ? this.rearMachineModelList :
|
ForEach(this.type === 1 ? this.rearMachineModelList :
|
||||||
this.type === 2 || this.type === 5 || this.type === 6 || this.type === 7 ? this.logList :
|
this.type === 2 || this.type === 5 || this.type === 6 || this.type === 7 ? this.logList :
|
||||||
this.type === 3 ? this.boardList : this.carTypeList, (item: CommonListType, index) => {
|
this.type === 3 ? this.boardList : this.type === 8 ? this.manufacturerList : this.carTypeList, (item: CommonListType, index) => {
|
||||||
Radio({ value: item.label, group: 'terRadioGroup' + this.type })
|
Radio({ value: item.label, group: 'terRadioGroup' + this.type })
|
||||||
.borderColor('#E5CBA1')
|
.borderColor('#E5CBA1')
|
||||||
.checked(item.value === this.value ? true : false)
|
.checked(item.value === this.value ? true : false)
|
||||||
|
|||||||
@ -156,14 +156,6 @@ struct UserInfoPage {
|
|||||||
@State singlePlay: boolean = false
|
@State singlePlay: boolean = false
|
||||||
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||||
private avPlayer!: VoiceAnnounce
|
private avPlayer!: VoiceAnnounce
|
||||||
private labelBlocks: LabelBlockType[] = [
|
|
||||||
{ label: '考生姓名', key: 'xm' },
|
|
||||||
{ label: '身份证号', key: 'sfzmhm' },
|
|
||||||
{ label: ' 流 水 号 ', key: 'lsh' },
|
|
||||||
{ label: '考试路线', key: 'ksxl' },
|
|
||||||
{ label: '待考次数', key: 'kssycs' },
|
|
||||||
{ label: '考试员名', key: 'ksy2' },
|
|
||||||
]
|
|
||||||
//开始考试准备
|
//开始考试准备
|
||||||
prePareExam = async () => {
|
prePareExam = async () => {
|
||||||
dConsole.log(StartExamTag, 'prePareExam')
|
dConsole.log(StartExamTag, 'prePareExam')
|
||||||
@ -180,9 +172,12 @@ struct UserInfoPage {
|
|||||||
if (this.singlePlay) {
|
if (this.singlePlay) {
|
||||||
this.currentUser.id = '0'
|
this.currentUser.id = '0'
|
||||||
dConsole.log(StartExamTag, '开始考试3', this.currentUser)
|
dConsole.log(StartExamTag, '开始考试3', this.currentUser)
|
||||||
SqlInsertTable('USER', [this.currentUser]).catch((e: BusinessError) => {
|
try {
|
||||||
dConsole.log(StartExamTag, "error", JSON.stringify(e))
|
// let data: Array<User> = JSON.parse(JSON.stringify([this.currentUser]))
|
||||||
})
|
await SqlInsertTable('USER', [this.currentUser])
|
||||||
|
} catch (e) {
|
||||||
|
dConsole.error(StartExamTag, '开始考试插入用户表失败', JSON.stringify(e))
|
||||||
|
}
|
||||||
// 初始化开始考试过程数据文件夹
|
// 初始化开始考试过程数据文件夹
|
||||||
InitializeExamProcessData(this.currentUser)
|
InitializeExamProcessData(this.currentUser)
|
||||||
dConsole.log(StartExamTag, '开始考试4')
|
dConsole.log(StartExamTag, '开始考试4')
|
||||||
@ -213,6 +208,14 @@ struct UserInfoPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private labelBlocks: LabelBlockType[] = [
|
||||||
|
{ label: '考生姓名', key: 'xm' },
|
||||||
|
{ label: '身份证号', key: 'sfzmhm' },
|
||||||
|
{ label: ' 流 水 号 ', key: 'lsh' },
|
||||||
|
{ label: '考试路线', key: 'ksxl' },
|
||||||
|
{ label: '待考次数', key: 'kssycs' },
|
||||||
|
{ label: '考试员名', key: 'ksy2' },
|
||||||
|
]
|
||||||
|
|
||||||
async aboutToAppear() {
|
async aboutToAppear() {
|
||||||
this.avPlayer = new VoiceAnnounce(this.context);
|
this.avPlayer = new VoiceAnnounce(this.context);
|
||||||
|
|||||||
@ -109,11 +109,11 @@ export function NumberToByteArray(number: number | string, len: number): number[
|
|||||||
return arrBytes;
|
return arrBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 将字符串填充为指定长度的字符串,前面补0
|
* 将字符串填充为指定长度的字符串,前面补0
|
||||||
* @param str 要填充的字符串或数字
|
* @param str 要填充的字符串或数字
|
||||||
* @param len 目标长度
|
* @param len 目标长度
|
||||||
* @return 返回填充后的字符串
|
* @return 返回填充后的字符串
|
||||||
*/
|
*/
|
||||||
export function FillZero(str: string | number, len: number): string {
|
export function FillZero(str: string | number, len: number): string {
|
||||||
str = str.toString();
|
str = str.toString();
|
||||||
@ -176,10 +176,10 @@ export function DeepClone<T extends Object>(target: T): T {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 检查文件或目录是否存在
|
* 检查文件或目录是否存在
|
||||||
* @param path 文件或目录的路径
|
* @param path 文件或目录的路径
|
||||||
* @return 返回一个 Promise,解析为 true 如果存在,否则为 false
|
* @return 返回一个 Promise,解析为 true 如果存在,否则为 false
|
||||||
*/
|
*/
|
||||||
export function IsExit(path: string): Promise<boolean> {
|
export function IsExit(path: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -221,7 +221,37 @@ export function CreateDir(path: string): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 写文件
|
* 打开文件
|
||||||
|
*/
|
||||||
|
export function OpenFile(path: string): Promise<number> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.APPEND | fs.OpenMode.CREATE)
|
||||||
|
resolve(file.fd)
|
||||||
|
} catch (e) {
|
||||||
|
reject(-1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭文件
|
||||||
|
*/
|
||||||
|
export function CloseFile(fd: number): Promise<boolean> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
fs.closeSync(fd)
|
||||||
|
resolve(true)
|
||||||
|
} catch (e) {
|
||||||
|
reject(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追加写文件
|
||||||
|
* @params fd 文件描述符
|
||||||
|
* @params data 写入的数据
|
||||||
*/
|
*/
|
||||||
export function EditFile(fd: number, data: string): Promise<boolean> {
|
export function EditFile(fd: number, data: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -234,6 +264,31 @@ export function EditFile(fd: number, data: string): Promise<boolean> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 覆盖写文件
|
||||||
|
*/
|
||||||
|
export function OverWriteFile(path: string, data: string): Promise<boolean> {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
try {
|
||||||
|
// 先删除文件
|
||||||
|
const res = await DeleteFile(path);
|
||||||
|
if (res) {
|
||||||
|
// 创建文件
|
||||||
|
const fd = await CreateFile(path);
|
||||||
|
if (fd !== -1) {
|
||||||
|
// 写入数据
|
||||||
|
await EditFile(fd, data);
|
||||||
|
// 关闭文件
|
||||||
|
await CloseFile(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(true)
|
||||||
|
} catch (e) {
|
||||||
|
reject(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件
|
* 创建文件
|
||||||
* @params path 文件具体路径
|
* @params path 文件具体路径
|
||||||
@ -252,10 +307,41 @@ export function CreateFile(path: string): Promise<number> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
* 删除文件
|
||||||
* @param seconds 要转换的秒数
|
*/
|
||||||
* @return 返回格式化后的时间字符串
|
export function DeleteFile(path: string): Promise<boolean> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(path)
|
||||||
|
console.log(CommonFileTag, "删除文件成功", path)
|
||||||
|
resolve(true)
|
||||||
|
} catch (e) {
|
||||||
|
console.log(CommonFileTag, "删除文件失败", path)
|
||||||
|
reject(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取文件内容
|
||||||
|
* @params path 文件具体路径
|
||||||
|
*/
|
||||||
|
export function ReadFileContent(path: string): Promise<string> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const data = fs.readTextSync(path)
|
||||||
|
resolve(data)
|
||||||
|
} catch (e) {
|
||||||
|
reject(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将秒数转换为灵活的时间格式(HH:MM:SS)
|
||||||
|
* @param seconds 要转换的秒数
|
||||||
|
* @return 返回格式化后的时间字符串
|
||||||
*/
|
*/
|
||||||
export function FormatTimeFlexible(seconds: number): string {
|
export function FormatTimeFlexible(seconds: number): string {
|
||||||
if (seconds < 0) {
|
if (seconds < 0) {
|
||||||
@ -291,10 +377,10 @@ export function ApplyForAuthorization(context: Context, permissionList: Array<Pe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 使用权限
|
* 使用权限
|
||||||
* @param context 上下文
|
* @param context 上下文
|
||||||
* @return 返回一个 Promise,解析为 true 如果授权成功,否则为 false
|
* @return 返回一个 Promise,解析为 true 如果授权成功,否则为 false
|
||||||
*/
|
*/
|
||||||
export async function UseAuth(context: common.UIAbilityContext): Promise<boolean> {
|
export async function UseAuth(context: common.UIAbilityContext): Promise<boolean> {
|
||||||
const permissions: Array<Permissions> = [
|
const permissions: Array<Permissions> = [
|
||||||
@ -351,4 +437,5 @@ export const GetPhotoBase64 = async (context: common.UIAbilityContext): Promise<
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import testNapi from '@ohos.hiserialsdk';
|
|
||||||
import HiSerialSDK from '@ohos.hiserialsdk';
|
import HiSerialSDK from '@ohos.hiserialsdk';
|
||||||
import { SerialPortTag } from '../config';
|
import { SerialPortTag } from '../config';
|
||||||
|
|
||||||
// 打开串口工具
|
|
||||||
/*
|
/**
|
||||||
* @param serialPort 串口名称
|
* 打开串口工具
|
||||||
|
* @param serialPort 串口名称
|
||||||
*/
|
*/
|
||||||
export const OpenSerialPort = (serialPort: string) => {
|
export const OpenSerialPort = (serialPort: string) => {
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
testNapi.SerialOpenAsync(serialPort, (value: number) => {
|
HiSerialSDK.SerialOpenAsync(serialPort, (value: number) => {
|
||||||
if (value === -1) {
|
if (value === -1) {
|
||||||
console.error(SerialPortTag, "打开串口失败!")
|
console.error(SerialPortTag, "打开串口失败!")
|
||||||
reject(-1)
|
reject(-1)
|
||||||
@ -19,16 +19,17 @@ export const OpenSerialPort = (serialPort: string) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化串口数据
|
|
||||||
/*
|
/**
|
||||||
* @param fd 串口文件描述符
|
* 初始化串口数据
|
||||||
* @param speed 波特率
|
* @param fd 串口文件描述符
|
||||||
* @returns Promise<boolean> 成功返回true,失败返回false
|
* @param speed 波特率
|
||||||
|
* @returns Promise<boolean> 成功返回true,失败返回false
|
||||||
*/
|
*/
|
||||||
export const InitSerialPortData =
|
export const InitSerialPortData =
|
||||||
async (fd: number, speed: number) => {
|
async (fd: number, speed: number) => {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
testNapi.SerialSetAsync(fd, speed, 0, 8, 1, 0x4e, (value: number) => {
|
HiSerialSDK.SerialSetAsync(fd, speed, 0, 8, 1, 0x4e, (value: number) => {
|
||||||
// 0 成功 -1失败
|
// 0 成功 -1失败
|
||||||
if (value === 0) {
|
if (value === 0) {
|
||||||
console.log(SerialPortTag, "初始化成功!")
|
console.log(SerialPortTag, "初始化成功!")
|
||||||
@ -42,16 +43,17 @@ export const InitSerialPortData =
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送数据
|
/**
|
||||||
/*
|
* 发送数据
|
||||||
* @param fd 串口文件描述符
|
* @param fd 串口文件描述符
|
||||||
* @param data 要发送的数据数组
|
* @param data 要发送的数据数组
|
||||||
* @returns Promise<number> 成功返回发送的字节数,失败返回-1
|
* @returns Promise<number> 成功返回发送的字节数,失败返回-1
|
||||||
*/
|
*/
|
||||||
export const SendSerialPortData = (fd: number, data: number[]) => {
|
export const SendSerialPortData = (fd: number, data: number[]) => {
|
||||||
// console.log(SerialPortTag, "wzj-----发送数据")
|
console.log(SerialPortTag, "wzj-----发送数据")
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
testNapi.SerialSendAsync(fd, data, (value: number) => {
|
HiSerialSDK.SerialSendAsync(fd, data, (value: number) => {
|
||||||
|
console.log(SerialPortTag, "发送数据完成!")
|
||||||
if (value === -1) {
|
if (value === -1) {
|
||||||
console.error(SerialPortTag, "发送失败!")
|
console.error(SerialPortTag, "发送失败!")
|
||||||
reject(-1)
|
reject(-1)
|
||||||
@ -61,16 +63,16 @@ export const SendSerialPortData = (fd: number, data: number[]) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接受数据
|
/**
|
||||||
/*
|
* 接受数据
|
||||||
* @param fd 串口文件描述符
|
* @param fd 串口文件描述符
|
||||||
* @param timeout 超时时间,单位毫秒
|
* @param timeout 超时时间,单位毫秒
|
||||||
* @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1
|
* @returns Promise<HiSerialSDK.receiveInfo> 成功返回接收到的数据,失败返回-1
|
||||||
*/
|
*/
|
||||||
export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
||||||
// console.log(SerialPortTag, "wzj-----接受数据")
|
console.log(SerialPortTag, "wzj-----接受数据")
|
||||||
return new Promise<HiSerialSDK.receiveInfo>((resolve) => {
|
return new Promise<HiSerialSDK.receiveInfo>((resolve) => {
|
||||||
testNapi.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => {
|
HiSerialSDK.SerialRecvAsync(fd, timeout, (value: HiSerialSDK.receiveInfo) => {
|
||||||
resolve(value)
|
resolve(value)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -78,13 +80,13 @@ export const ReceiveSerialPortData = (fd: number, timeout: number,) => {
|
|||||||
|
|
||||||
// 主动接受数据
|
// 主动接受数据
|
||||||
export const ReceiveSerialPortDataBySelf = (fd: number, callback: Function) => {
|
export const ReceiveSerialPortDataBySelf = (fd: number, callback: Function) => {
|
||||||
testNapi.SerialListenCallbackSet(fd, callback)
|
HiSerialSDK.SerialListenCallbackSet(fd, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消主动接受
|
// 取消主动接受
|
||||||
export const CancelReceiveSerialPortData = async (fd: number) => {
|
export const CancelReceiveSerialPortData = async (fd: number) => {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
let result: number = testNapi.SerialListenCallbackCancel(fd)
|
let result: number = HiSerialSDK.SerialListenCallbackCancel(fd)
|
||||||
if (result === 0) {
|
if (result === 0) {
|
||||||
resolve(true)
|
resolve(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export default class UdpClient {
|
|||||||
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
|
address: this.oppositeIp, port: parseInt(this.oppositeIpPort), family: 1
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log(UDPTag, "udp发送成功", JSON.stringify(res))
|
// console.log(UDPTag, "udp发送成功", JSON.stringify(res))
|
||||||
}).catch((e: BusinessError) => {
|
}).catch((e: BusinessError) => {
|
||||||
console.error(UDPTag, "udp发送失败", JSON.stringify(e))
|
console.error(UDPTag, "udp发送失败", JSON.stringify(e))
|
||||||
})
|
})
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class CenterUDPBusiness {
|
|||||||
console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo))
|
console.log(CenterUdpTag, "心跳", JSON.stringify(this.carInfo))
|
||||||
// 组装消息,一秒发送一次
|
// 组装消息,一秒发送一次
|
||||||
this.timer = setInterval(() => {
|
this.timer = setInterval(() => {
|
||||||
console.log(CenterUdpTag, "发送心跳")
|
// console.log(CenterUdpTag, "发送心跳")
|
||||||
// 生成流水号
|
// 生成流水号
|
||||||
SerialNumberInstance.generate()
|
SerialNumberInstance.generate()
|
||||||
// console.log(CenterUdpTag, "流水号生成")
|
// console.log(CenterUdpTag, "流水号生成")
|
||||||
|
|||||||
@ -20,8 +20,6 @@ import { GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils';
|
|||||||
import { testKm2Items, testKm3Items } from '../../mock';
|
import { testKm2Items, testKm3Items } from '../../mock';
|
||||||
import { dConsole } from '../LogWorker';
|
import { dConsole } from '../LogWorker';
|
||||||
|
|
||||||
// import { examCalcGpsDistance } from '../../pages/Judge/JudgeUtils';
|
|
||||||
|
|
||||||
|
|
||||||
class JudgeUdpBusiness {
|
class JudgeUdpBusiness {
|
||||||
private static instance: JudgeUdpBusiness
|
private static instance: JudgeUdpBusiness
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
} from '../SerialPort';
|
} from '../SerialPort';
|
||||||
import Prompt from '@system.prompt';
|
import Prompt from '@system.prompt';
|
||||||
import { SerialPortTag } from '../../config';
|
import { SerialPortTag } from '../../config';
|
||||||
|
import { EnvironmentConfigurationType } from '../../model';
|
||||||
|
|
||||||
class serialPortService {
|
class serialPortService {
|
||||||
private fd: number = -1
|
private fd: number = -1
|
||||||
@ -20,6 +21,11 @@ class serialPortService {
|
|||||||
private tryCount: number = 0
|
private tryCount: number = 0
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
let config: EnvironmentConfigurationType = AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")!
|
||||||
|
if (config.manufacturer === "2") {
|
||||||
|
console.log(SerialPortTag, "更改润和串口端口")
|
||||||
|
this.serialPort = "/dev/ttyS7"
|
||||||
|
}
|
||||||
const res = await OpenSerialPort(this.serialPort)
|
const res = await OpenSerialPort(this.serialPort)
|
||||||
if (res === -1) {
|
if (res === -1) {
|
||||||
Prompt.showToast({
|
Prompt.showToast({
|
||||||
|
|||||||
@ -34,7 +34,10 @@ export function SqlInsertTable(tableName: string, data: Array<RecordType>, delFl
|
|||||||
const columns: string = columnsData?.filter((column) => column !== "id").join(",") || "";
|
const columns: string = columnsData?.filter((column) => column !== "id").join(",") || "";
|
||||||
const values = data.map(item => {
|
const values = data.map(item => {
|
||||||
const value = columnsData?.filter(column => column !== "id")
|
const value = columnsData?.filter(column => column !== "id")
|
||||||
.map((column) => `'${Reflect.get(item, column) || ""}'`)
|
.map((column) => {
|
||||||
|
// return `'${Reflect.get(item, column) || ""}'`
|
||||||
|
return `'${Object.entries(item).find((keyArr: Array<string>) => keyArr[0] === column)?.[1] || ""}'`
|
||||||
|
})
|
||||||
.join(",")
|
.join(",")
|
||||||
return `(${value})`
|
return `(${value})`
|
||||||
}).join(",")
|
}).join(",")
|
||||||
@ -52,8 +55,6 @@ export function SqlInsertTable(tableName: string, data: Array<RecordType>, delFl
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数平台
|
|
||||||
|
|
||||||
// TODO 后续废弃这个方法,直接调用SqlInsertTable
|
// TODO 后续废弃这个方法,直接调用SqlInsertTable
|
||||||
// 依据数组和表名更新sql表
|
// 依据数组和表名更新sql表
|
||||||
export function UpdateTableByArray(tableName: string, arr: Array<RecordType>): Promise<boolean> {
|
export function UpdateTableByArray(tableName: string, arr: Array<RecordType>): Promise<boolean> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user