forked from harmony_car/subject-two
		
	feat: 修复一些问题
This commit is contained in:
		
							parent
							
								
									ed60046db6
								
							
						
					
					
						commit
						ed236df1d6
					
				| @ -31,6 +31,7 @@ import TcpClient from './TcpClient'; | |||||||
| export async function sendMsg(val) { | export async function sendMsg(val) { | ||||||
|   globalThis.udpClient1 && globalThis.udpClient1.sendMsg(val) |   globalThis.udpClient1 && globalThis.udpClient1.sendMsg(val) | ||||||
| } | } | ||||||
|  | 
 | ||||||
| export async function getUDP() { | export async function getUDP() { | ||||||
|   getSyncData('IpConfigTable').then((result: Array<any>) => { |   getSyncData('IpConfigTable').then((result: Array<any>) => { | ||||||
|     console.log('result222', JSON.stringify(result)) |     console.log('result222', JSON.stringify(result)) | ||||||
| @ -58,7 +59,8 @@ export async function getUDP() { | |||||||
| 
 | 
 | ||||||
|     } else { |     } else { | ||||||
|       globalThis.udpClient = {} |       globalThis.udpClient = {} | ||||||
|       globalThis.udpClient.onMessage=()=>{} |       globalThis.udpClient.onMessage = () => { | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
| @ -102,7 +104,12 @@ export async function getUDP2() { | |||||||
|               tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) |               tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             const param = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } |             const param = { | ||||||
|  |               id: 47, | ||||||
|  |               list: tmpList, | ||||||
|  |               carNo: globalThis.carInfo.carNo, | ||||||
|  |               placeId: globalThis.carInfo.examinationRoomId | ||||||
|  |             } | ||||||
|             globalThis.udpClient2.send(param) |             globalThis.udpClient2.send(param) | ||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
| @ -115,10 +122,12 @@ export async function getUDP2() { | |||||||
|       } |       } | ||||||
|     } else { |     } else { | ||||||
|       globalThis.udpClient2 = {} |       globalThis.udpClient2 = {} | ||||||
|       globalThis.udpClient2.onMessage=()=>{} |       globalThis.udpClient2.onMessage = () => { | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  | 
 | ||||||
| function fillZero(str, len) { | function fillZero(str, len) { | ||||||
|   str = str + ''; |   str = str + ''; | ||||||
|   if (str.length > len || !len) { |   if (str.length > len || !len) { | ||||||
| @ -133,6 +142,7 @@ function fillZero(str, len) { | |||||||
| 
 | 
 | ||||||
|   return zeroStr + str; |   return zeroStr + str; | ||||||
| } | } | ||||||
|  | 
 | ||||||
| // function getByteToInt(arr){
 | // function getByteToInt(arr){
 | ||||||
| //   let a = list[0];
 | //   let a = list[0];
 | ||||||
| //   let b = list[1];
 | //   let b = list[1];
 | ||||||
| @ -162,10 +172,12 @@ export async function getUDPByTopLine() { | |||||||
| 
 | 
 | ||||||
|     } else { |     } else { | ||||||
|       globalThis.udpClientByTopLine = {} |       globalThis.udpClientByTopLine = {} | ||||||
|       globalThis.udpClientByTopLine.onMessage=()=>{} |       globalThis.udpClientByTopLine.onMessage = () => { | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  | 
 | ||||||
| export async function setTopLineUdp() { | export async function setTopLineUdp() { | ||||||
|   const config = await getSyncData('IpConfigTable'); |   const config = await getSyncData('IpConfigTable'); | ||||||
|   if (config && config[0] && config[0].udplocalIp) { |   if (config && config[0] && config[0].udplocalIp) { | ||||||
| @ -197,7 +209,12 @@ export async function setJudgeUdp(){ | |||||||
|     return { |     return { | ||||||
|       send(bytes) { |       send(bytes) { | ||||||
|         console.log('carInfo111', JSON.stringify(globalThis.carInfo)) |         console.log('carInfo111', JSON.stringify(globalThis.carInfo)) | ||||||
|         udpClient.sendMsg({id:45,list:bytes,carNo:globalThis.carInfo.carNo,placeId:globalThis.carInfo.examinationRoomId}) |         udpClient.sendMsg({ | ||||||
|  |           id: 45, | ||||||
|  |           list: bytes, | ||||||
|  |           carNo: globalThis.carInfo.carNo, | ||||||
|  |           placeId: globalThis.carInfo.examinationRoomId | ||||||
|  |         }) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -36,6 +36,7 @@ export default class UdpClient { | |||||||
| 
 | 
 | ||||||
|     this.udp = socket.constructUDPSocketInstance(); |     this.udp = socket.constructUDPSocketInstance(); | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|   rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) { |   rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) { | ||||||
| 
 | 
 | ||||||
|     this.localIp = localIp |     this.localIp = localIp | ||||||
| @ -55,6 +56,7 @@ export default class UdpClient { | |||||||
|       console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); |       console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|   bindUdp() { |   bindUdp() { | ||||||
|     console.log('localIp', this.localIp) |     console.log('localIp', this.localIp) | ||||||
|     console.log('localIpPort', this.localIpPort) |     console.log('localIpPort', this.localIpPort) | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ const PERMISSIONS: Array<string> = [ | |||||||
|   'ohos.permission.CAMERA'] |   'ohos.permission.CAMERA'] | ||||||
| 
 | 
 | ||||||
| @Component | @Component | ||||||
| struct FaceCompare { | export default struct FaceCompare { | ||||||
|   constructor() { |   constructor() { | ||||||
|     super() |     super() | ||||||
|   } |   } | ||||||
| @ -340,4 +340,4 @@ struct FaceCompare { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default FaceCompare | // export default FaceCompare | ||||||
| @ -400,11 +400,11 @@ struct FaceCompare { | |||||||
|       return |       return | ||||||
|     } |     } | ||||||
|     this.param = JSON.parse(data) |     this.param = JSON.parse(data) | ||||||
|     this.param.userName = JSON.parse(data).userName |     // this.param.userName = JSON.parse(data).userName | ||||||
|     this.param.ip = JSON.parse(data).ip |     // this.param.ip = JSON.parse(data).ip | ||||||
|     this.param.pwd = JSON.parse(data).pwd |     // this.param.pwd = JSON.parse(data).pwd | ||||||
|     this.param.port = JSON.parse(data).port |     // this.param.port = JSON.parse(data).port | ||||||
|     this.param.rlls = JSON.parse(data).rlls |     // this.param.rlls = JSON.parse(data).rlls | ||||||
|     console.log('this.parm', this.param.userName, this.param.pwd, this.param.ip, this.param.port, this.param.rlls) |     console.log('this.parm', this.param.userName, this.param.pwd, this.param.ip, this.param.port, this.param.rlls) | ||||||
|     this.controller.start() |     this.controller.start() | ||||||
|     // this.video_url = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`; |     // this.video_url = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`; | ||||||
|  | |||||||
							
								
								
									
										31
									
								
								entry/src/ohosTest/ets/test/GlobleUdp.test.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								entry/src/ohosTest/ets/test/GlobleUdp.test.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' | ||||||
|  | 
 | ||||||
|  | export default function GlobleUdpTest() { | ||||||
|  |   describe('GlobleUdpTest', () => { | ||||||
|  |     // Defines a test suite. Two parameters are supported: test suite name and test suite function. | ||||||
|  |     beforeAll(() => { | ||||||
|  |       // Presets an action, which is performed only once before all test cases of the test suite start. | ||||||
|  |       // This API supports only one parameter: preset action function. | ||||||
|  |     }) | ||||||
|  |     beforeEach(() => { | ||||||
|  |       // Presets an action, which is performed before each unit test case starts. | ||||||
|  |       // The number of execution times is the same as the number of test cases defined by **it**. | ||||||
|  |       // This API supports only one parameter: preset action function. | ||||||
|  |     }) | ||||||
|  |     afterEach(() => { | ||||||
|  |       // Presets a clear action, which is performed after each unit test case ends. | ||||||
|  |       // The number of execution times is the same as the number of test cases defined by **it**. | ||||||
|  |       // This API supports only one parameter: clear action function. | ||||||
|  |     }) | ||||||
|  |     afterAll(() => { | ||||||
|  |       // Presets a clear action, which is performed after all test cases of the test suite end. | ||||||
|  |       // This API supports only one parameter: clear action function. | ||||||
|  |     }) | ||||||
|  |     it('assertEqual', 0, () => { | ||||||
|  |       // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. | ||||||
|  |       let a = 'test' | ||||||
|  |       // Defines a variety of assertion methods, which are used to declare expected boolean conditions. | ||||||
|  |       expect(a).assertEqual('test') | ||||||
|  |     }) | ||||||
|  |   }) | ||||||
|  | } | ||||||
| @ -1,5 +1,7 @@ | |||||||
|  | import GlobleUdpTest from './GlobleUdp.test' | ||||||
| import abilityTest from './Ability.test' | import abilityTest from './Ability.test' | ||||||
| 
 | 
 | ||||||
| export default function testsuite() { | export default function testsuite() { | ||||||
|   abilityTest() |   abilityTest() | ||||||
|  |   GlobleUdpTest() | ||||||
| } | } | ||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "hvigorVersion": "2.1.1", |   "hvigorVersion": "3.0.9", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@ohos/hvigor-ohos-plugin": "2.1.1" |     "@ohos/hvigor-ohos-plugin": "3.0.9" | ||||||
|   } |   } | ||||||
| } | } | ||||||
							
								
								
									
										3
									
								
								hvigor/hvigor-wrapper.js
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										3
									
								
								hvigor/hvigor-wrapper.js
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user