|
@@ -0,0 +1,987 @@
|
|
|
+import router from '@ohos.router'
|
|
|
+import { DeviceDialog } from '../../../commont/component/DeviceDialog'
|
|
|
+@Entry
|
|
|
+@Component
|
|
|
+struct BoardTesting {
|
|
|
+ @State number:number=0
|
|
|
+ controller: TextInputController = new TextInputController()
|
|
|
+ //单条发送
|
|
|
+ @State oneSending:string=''
|
|
|
+ //多条发送选择
|
|
|
+ @State MultipleTransmissions:number=0
|
|
|
+ //连接状态1有,0没有
|
|
|
+ @State connect:number=0
|
|
|
+ //校验位
|
|
|
+ @State checkBit:string=''
|
|
|
+ //数据位
|
|
|
+ @State dataBits:string=''
|
|
|
+ //波特率
|
|
|
+ @State BAUD:string=''
|
|
|
+ @State select:number=0
|
|
|
+ //串口号
|
|
|
+ @State serialPortName: string = '';
|
|
|
+ //停止位
|
|
|
+ @State stopBit:string=''
|
|
|
+ @State private manySendingList:Array<manySendingClass>=[
|
|
|
+ {content:'32845723425345',switch:1},
|
|
|
+ {content:'32845234425345',switch:0},
|
|
|
+ {content:'3282345345',switch:1},
|
|
|
+ {content:'328234234425345',switch:0},
|
|
|
+ {content:'32845723425345',switch:1},
|
|
|
+ {content:'32845723425345',switch:0},
|
|
|
+ {content:'3284234524355345',switch:1},
|
|
|
+ {content:'32845723425345',switch:0},
|
|
|
+ {content:'322423425345',switch:1},
|
|
|
+ {content:'32845723425345',switch:0},
|
|
|
+ {content:'3284234425345',switch:1},
|
|
|
+ {content:'3284523445',switch:0},
|
|
|
+ {content:'32845723425345',switch:1},
|
|
|
+ {content:'32845234425345',switch:0},
|
|
|
+ {content:'3282345345',switch:1},
|
|
|
+ {content:'328234234425345',switch:0},
|
|
|
+ {content:'32845723425345',switch:1},
|
|
|
+ {content:'32845723425345',switch:0},
|
|
|
+ {content:'3284234524355345',switch:1},
|
|
|
+ {content:'32845723425345',switch:0},
|
|
|
+ {content:'322423425345',switch:1},
|
|
|
+
|
|
|
+
|
|
|
+ ]
|
|
|
+ @State private serialPort:Array<serialPortClass>=[
|
|
|
+ {serialPortName:'串口号1'},
|
|
|
+ {serialPortName:'串口号2'},
|
|
|
+ {serialPortName:'串口号3'},
|
|
|
+ {serialPortName:'串口号4'},
|
|
|
+ {serialPortName:'串口号5'}]
|
|
|
+ @State private checkBitLink:Array<checkBitClass>=[
|
|
|
+ {checkBitName:'校验位1'},
|
|
|
+ {checkBitName:'校验位2'},
|
|
|
+ {checkBitName:'校验位3'},
|
|
|
+ {checkBitName:'校验位4'},
|
|
|
+ {checkBitName:'校验位5'}]
|
|
|
+
|
|
|
+ @State private BAUDNameList:Array<BAUDClass>=[
|
|
|
+ {BAUDName:'波特率1'},
|
|
|
+ {BAUDName:'波特率2'},
|
|
|
+ {BAUDName:'波特率3'},
|
|
|
+ {BAUDName:'波特率4'},
|
|
|
+ {BAUDName:'波特率5'}]
|
|
|
+ @State private dataBitsList:Array<dataBitsClass>=[
|
|
|
+ {dataBitsName:'数据位1'},
|
|
|
+ {dataBitsName:'数据位2'},
|
|
|
+ {dataBitsName:'数据位3'},
|
|
|
+ {dataBitsName:'数据位4'},
|
|
|
+ {dataBitsName:'数据位5'}]
|
|
|
+
|
|
|
+ @State private stopBitList:Array< stopBitClass>=[
|
|
|
+ {stopBitName:'停止位1'},
|
|
|
+ {stopBitName:'停止位2'},
|
|
|
+ {stopBitName:'停止位3'},
|
|
|
+ {stopBitName:'停止位4'},
|
|
|
+ {stopBitName:'停止位5'}]
|
|
|
+ //0:表示没有,1:表示AI,2:表示串口,3:表示CAN
|
|
|
+ @State select1:number=1
|
|
|
+ //todo 删除
|
|
|
+ @State select2:number=2
|
|
|
+ @State select3:number=3
|
|
|
+ @State select4:number=0
|
|
|
+ @State private Number:number[]=[1,2,3,4,5,6,7,8]
|
|
|
+ private dialogController: CustomDialogController = new CustomDialogController({
|
|
|
+ builder:DeviceDialog({
|
|
|
+ Number:this.Number,
|
|
|
+ select1:this.select1,
|
|
|
+ select2:this.select2,
|
|
|
+ select3:this.select3,
|
|
|
+ select4:this.select4,
|
|
|
+ }),
|
|
|
+ alignment: DialogAlignment.Center,
|
|
|
+ customStyle:true,
|
|
|
+ autoCancel:true,
|
|
|
+ })
|
|
|
+ serialPortController: CustomDialogController = new CustomDialogController({
|
|
|
+ builder:serialPort({
|
|
|
+ checkBitLink:this.checkBitLink,
|
|
|
+ checkBit:this.checkBit,
|
|
|
+ stopBitList:this.stopBitList,
|
|
|
+ stopBit:this.stopBit,
|
|
|
+ dataBits:this.dataBits,
|
|
|
+ BAUD:this.BAUD,
|
|
|
+ select:this.select,
|
|
|
+ serialPort:this.serialPort,
|
|
|
+ serialPortName:this.serialPortName,
|
|
|
+ BAUDNameList:this.BAUDNameList,
|
|
|
+ dataBitsList:this.dataBitsList
|
|
|
+ }),
|
|
|
+ alignment: DialogAlignment.Center,
|
|
|
+ customStyle:true,
|
|
|
+ autoCancel:true,
|
|
|
+ })
|
|
|
+ @State SerialNumber:number=0
|
|
|
+ aboutToAppear(): void {
|
|
|
+ const params = router.getParams() as Record<string, number>; // 获取传递过来的参数对象
|
|
|
+ if (params) {
|
|
|
+ this.SerialNumber = params.info as number; // 获取info属性的值
|
|
|
+ console.log("textTag"+this.SerialNumber)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ build() {
|
|
|
+ Column() {
|
|
|
+ Row() {
|
|
|
+ Row() {
|
|
|
+ Image($r('app.media.return'))
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ .objectFit(ImageFit.Contain)
|
|
|
+ .margin({ left: px2vp(40) })
|
|
|
+ }.width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .onClick(() => {
|
|
|
+ router.back();
|
|
|
+ })
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Text('板卡测试')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.black_100'))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .width(px2vp(608))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .borderRadius($r('app.float.borderRadius_16'))
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ Blank()
|
|
|
+ Row() {
|
|
|
+ Blank()
|
|
|
+ Image($r('app.media.homePage'))
|
|
|
+ .margin({ right: px2vp(40) })
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ .onClick(()=>{
|
|
|
+ router.pushUrl({
|
|
|
+ url:'pages/Index'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ Image($r('app.media.news'))
|
|
|
+ .margin({ right: px2vp(40) })
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ Image($r('app.media.personal'))
|
|
|
+ .margin({ right: px2vp(40) })
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ }.width(px2vp(500))
|
|
|
+
|
|
|
+ }.width(px2vp(1920))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ Row(){
|
|
|
+ Column(){
|
|
|
+ Column(){
|
|
|
+ Image(this.SerialNumber===1?$r('app.media.serial1'):this.SerialNumber===2?$r('app.media.serial2'):
|
|
|
+ this.SerialNumber===3?$r('app.media.serial3'):this.SerialNumber===4?$r('app.media.serial4'):
|
|
|
+ this.SerialNumber===5?$r('app.media.serial5'):this.SerialNumber===6?$r('app.media.serial6'):
|
|
|
+ this.SerialNumber===7?$r('app.media.serial7'):this.SerialNumber===8?$r('app.media.serial8'): '')
|
|
|
+ .width(px2vp(292))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ Row(){
|
|
|
+ Column(){
|
|
|
+ Text(this.SerialNumber.toString()+'#')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .width('100%')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Text('串口测试')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .width('100%')
|
|
|
+ .fontColor('#666666')
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ }
|
|
|
+ .width(px2vp(200))
|
|
|
+ Blank()
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+
|
|
|
+ }
|
|
|
+ .alignItems(VerticalAlign.Bottom)
|
|
|
+ .width(px2vp(292))
|
|
|
+ .height(px2vp(75))
|
|
|
+ }.width(px2vp(332))
|
|
|
+ .height(px2vp(215))
|
|
|
+ .padding(px2vp(20))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.dialogController.open()
|
|
|
+ })
|
|
|
+ Column(){
|
|
|
+ Text('配置')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .width('100%')
|
|
|
+ .height(px2vp(60))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .margin({bottom:px2vp(10)})
|
|
|
+ Stack(){
|
|
|
+ if (this.serialPortName===''){
|
|
|
+ Text('选择串口号')
|
|
|
+ .height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .fontColor($r('app.color.D1D1D1_100'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .padding({left:px2vp(20)})
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(this.serialPortName)
|
|
|
+ .width(px2vp(247))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+ }
|
|
|
+ .width(px2vp(45))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .border({width:1})
|
|
|
+ .onClick(()=>{
|
|
|
+ this.select=1
|
|
|
+ this.serialPortController.open()
|
|
|
+ })
|
|
|
+
|
|
|
+ Stack(){
|
|
|
+ if (this.BAUD===''){
|
|
|
+ Text('选择波特率')
|
|
|
+ .height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .fontColor($r('app.color.D1D1D1_100'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .padding({left:px2vp(20)})
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(this.BAUD)
|
|
|
+ .width(px2vp(247))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+ }
|
|
|
+ .width(px2vp(45))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .border({width:1})
|
|
|
+ .onClick(()=>{
|
|
|
+ this.select=2
|
|
|
+ this.serialPortController.open()
|
|
|
+ })
|
|
|
+
|
|
|
+ Stack(){
|
|
|
+ if (this.dataBits===''){
|
|
|
+ Text('选择数据位')
|
|
|
+ .height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .fontColor($r('app.color.D1D1D1_100'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .padding({left:px2vp(20)})
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(this.dataBits)
|
|
|
+ .width(px2vp(247))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+ }
|
|
|
+ .width(px2vp(45))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.select=3
|
|
|
+ this.serialPortController.open()
|
|
|
+ })
|
|
|
+
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .border({width:1})
|
|
|
+
|
|
|
+ Stack(){
|
|
|
+ if (this.stopBit===''){
|
|
|
+ Text('选择停止位')
|
|
|
+ .height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .fontColor($r('app.color.D1D1D1_100'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .padding({left:px2vp(20)})
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(this.stopBit)
|
|
|
+ .width(px2vp(247))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+ }
|
|
|
+ .width(px2vp(45))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .border({width:1})
|
|
|
+ .onClick(()=>{
|
|
|
+ this.select=4
|
|
|
+ this.serialPortController.open()
|
|
|
+ })
|
|
|
+
|
|
|
+ Stack(){
|
|
|
+ if (this.checkBit===''){
|
|
|
+ Text('选择校验位')
|
|
|
+ .height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .fontColor($r('app.color.D1D1D1_100'))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .padding({left:px2vp(20)})
|
|
|
+ }
|
|
|
+ Row(){
|
|
|
+ Text(this.checkBit)
|
|
|
+ .width(px2vp(247))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ Blank()
|
|
|
+ Column(){
|
|
|
+ Image($r('app.media.subscript_space'))
|
|
|
+ .height(px2vp(45))
|
|
|
+ .width(px2vp(45))
|
|
|
+ }
|
|
|
+ .width(px2vp(45))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+
|
|
|
+ }.height(px2vp(80))
|
|
|
+ .width(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .border({width:1})
|
|
|
+ .onClick(()=>{
|
|
|
+ this.select=5
|
|
|
+ this.serialPortController.open()
|
|
|
+ })
|
|
|
+ Blank()
|
|
|
+ Button(this.connect===0?'连接':'断开连接')
|
|
|
+ .width(px2vp(292))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.white_100'))
|
|
|
+ .backgroundColor(this.connect===0?$r('app.color.green_100'):$r('app.color.red_100'))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .onClick(()=>{
|
|
|
+ if (this.connect===0) {
|
|
|
+ this.connect=1
|
|
|
+ }else if (this.connect===1){
|
|
|
+ this.connect=0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ Row(){
|
|
|
+ Text('连接状态')
|
|
|
+ .fontSize($r('app.float.fontSize_20'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ .margin({right:px2vp(20)})
|
|
|
+ Text(this.connect===0?'未连接':'已连接')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ }
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+
|
|
|
+ }
|
|
|
+ .height(px2vp(725))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .padding({left:px2vp(20),right:px2vp(20)})
|
|
|
+ .width(px2vp(332))
|
|
|
+ .backgroundColor($r('app.color.white_60'))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }.height(px2vp(960))
|
|
|
+ .width(px2vp(332))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({left:px2vp(60)})
|
|
|
+ .padding({left:px2vp(20),right:px2vp(20)})
|
|
|
+
|
|
|
+ Column(){
|
|
|
+
|
|
|
+ if (this.MultipleTransmissions===0){
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text('接收区')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .height(px2vp(40))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Blank()
|
|
|
+ Text('显示时间')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ .margin({right:px2vp(30)})
|
|
|
+ Text('HEX显示')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ }.width(px2vp(1398))
|
|
|
+ .height(px2vp(40))
|
|
|
+ Column(){
|
|
|
+ Text('')
|
|
|
+ .width(px2vp(1398))
|
|
|
+ .height(px2vp(490))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .align(Alignment.TopStart)
|
|
|
+ .padding(px2vp(10))
|
|
|
+ Row(){
|
|
|
+ Image($r("app.media.delete1"))
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ .margin({right:px2vp(10),bottom:px2vp(10)})
|
|
|
+ }
|
|
|
+ .width(px2vp(1398))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(1398))
|
|
|
+ .height(px2vp(545))
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({top:px2vp(20),bottom:px2vp(20)})
|
|
|
+
|
|
|
+ }.width(px2vp(1448))
|
|
|
+ .height(px2vp(648))
|
|
|
+ .padding({left:px2vp(24),right:px2vp(24),top:px2vp(20),bottom:px2vp(20)})
|
|
|
+ .backgroundColor($r('app.color.white_60'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ }else if (this.MultipleTransmissions===1){
|
|
|
+ Row() {
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text('接收区')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .height(px2vp(40))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Blank()
|
|
|
+ Text('显示时间')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ .margin({right:px2vp(30)})
|
|
|
+ Text('HEX显示')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ }.width(px2vp(729))
|
|
|
+ .height(px2vp(40))
|
|
|
+ Column(){
|
|
|
+ Text('接收内容')
|
|
|
+ .width(px2vp(729))
|
|
|
+ .height(px2vp(490))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .align(Alignment.TopStart)
|
|
|
+ .padding(px2vp(10))
|
|
|
+ Row(){
|
|
|
+ Image($r("app.media.delete1"))
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ .margin({right:px2vp(10),bottom:px2vp(10)})
|
|
|
+ }
|
|
|
+ .width(px2vp(729))
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(729))
|
|
|
+ .height(px2vp(545))
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({top:px2vp(20),bottom:px2vp(20)})
|
|
|
+
|
|
|
+ }.width(px2vp(779))
|
|
|
+ .height(px2vp(648))
|
|
|
+ .padding({left:px2vp(24),right:px2vp(24),top:px2vp(20),bottom:px2vp(20)})
|
|
|
+ .backgroundColor($r('app.color.white_60'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text('多条发送区')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .height(px2vp(40))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Blank()
|
|
|
+ Text('HEX发送')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(602))
|
|
|
+ .height(px2vp(40))
|
|
|
+ Column(){
|
|
|
+ List(){
|
|
|
+ ForEach(this.manySendingList, (item:manySendingClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Row(){
|
|
|
+ Toggle({ type: ToggleType.Checkbox, isOn: item.switch===1?true:false })
|
|
|
+ .size({ width: px2vp(24), height: px2vp(24) })
|
|
|
+ .selectedColor('#007DFF')
|
|
|
+ .onChange((isOn: boolean) => {
|
|
|
+ console.info('Component status:' + isOn)
|
|
|
+ })
|
|
|
+ .borderRadius(px2vp(56))
|
|
|
+
|
|
|
+ Text('命令'+index)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.black_10'))
|
|
|
+ .borderRadius(px2vp(76))
|
|
|
+ .width(px2vp(130))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .onClick(()=>{
|
|
|
+ if (item.switch===0) {
|
|
|
+ this.manySendingList[index]={
|
|
|
+ switch:1,
|
|
|
+ content:item.content
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if (item.switch===1){
|
|
|
+ this.manySendingList[index]={
|
|
|
+ switch:0,
|
|
|
+ content:item.content
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ Blank()
|
|
|
+ TextInput({ text:item.content ,placeholder:'请输入发送内容', controller: this.controller })
|
|
|
+ .width(px2vp(469))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .border({width:1})
|
|
|
+ .onChange((value: string) => {
|
|
|
+ this.manySendingList[index].content = value
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(650))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ .padding({left:px2vp(20),right:px2vp(20)})
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }.width(px2vp(650))
|
|
|
+ .height(px2vp(458))
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .margin({left:px2vp(20),right:px2vp(20),bottom:px2vp(10)})
|
|
|
+ Button('发送')
|
|
|
+ .width(px2vp(292))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.white_100'))
|
|
|
+ .backgroundColor($r('app.color.blue_100'))
|
|
|
+ .margin({bottom:px2vp(10)})
|
|
|
+ .onClick(()=>{
|
|
|
+ for (let index = 0; index < this.manySendingList.length; index++) {
|
|
|
+ this.manySendingList[index] = {
|
|
|
+ switch:this.manySendingList[index].switch,
|
|
|
+ content:this.manySendingList[index].content,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(650))
|
|
|
+ .height(px2vp(558))
|
|
|
+ .margin({top:px2vp(20)})
|
|
|
+
|
|
|
+ }.width(px2vp(650))
|
|
|
+ .height(px2vp(648))
|
|
|
+ .padding({left:px2vp(24),right:px2vp(24),top:px2vp(20),bottom:px2vp(20)})
|
|
|
+ .backgroundColor($r('app.color.white_60'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({left:px2vp(20)})
|
|
|
+
|
|
|
+ }.width(px2vp(1448))
|
|
|
+ .height(px2vp(648))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Text('发送区')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .height(px2vp(40))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ Blank()
|
|
|
+ Text('多条发送')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn:this.MultipleTransmissions===0?false:true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ .margin({right:px2vp(30)})
|
|
|
+ .onChange(()=>{
|
|
|
+ if (this.MultipleTransmissions===0) {
|
|
|
+ this.MultipleTransmissions=1
|
|
|
+ }else if (this.MultipleTransmissions===1) {
|
|
|
+ this.MultipleTransmissions=0
|
|
|
+ }
|
|
|
+ })
|
|
|
+ Text('HEX发送')
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor($r('app.color.gray_6666'))
|
|
|
+ Toggle({ type: ToggleType.Switch, isOn: true })
|
|
|
+ .width(px2vp(72))
|
|
|
+ .height(px2vp(40))
|
|
|
+ }.width(px2vp(1398))
|
|
|
+ .height(px2vp(40))
|
|
|
+ Row(){
|
|
|
+ Column(){
|
|
|
+ TextInput({ text:this.oneSending ,placeholder:'请输入发送内容', controller: this.controller })
|
|
|
+ .width(px2vp(1299))
|
|
|
+ .height(px2vp(140))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .align(Alignment.TopStart)
|
|
|
+ .padding(px2vp(10))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ Image($r("app.media.delete1"))
|
|
|
+ .width(px2vp(48))
|
|
|
+ .height(px2vp(48))
|
|
|
+ .margin({right:px2vp(10),bottom:px2vp(10)})
|
|
|
+ }
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(1299))
|
|
|
+ .height(px2vp(190))
|
|
|
+ .alignItems(HorizontalAlign.End)
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ .margin({top:px2vp(20)})
|
|
|
+
|
|
|
+ Image($r('app.media.sending'))
|
|
|
+ .width(px2vp(80))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .margin({left:px2vp(20),top:px2vp(52)})
|
|
|
+
|
|
|
+
|
|
|
+ }.width(px2vp(1398))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }.width(px2vp(1448))
|
|
|
+ .height(px2vp(292))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .padding({left:px2vp(24),right:px2vp(24),top:px2vp(20),bottom:px2vp(20)})
|
|
|
+ .backgroundColor($r('app.color.white_60'))
|
|
|
+ .margin({top:px2vp(20)})
|
|
|
+
|
|
|
+ }.width(px2vp(1448))
|
|
|
+ .height(px2vp(960))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .margin({left:px2vp(24)})
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(1920))
|
|
|
+ .height(px2vp(960))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(1920))
|
|
|
+ .height(px2vp(1080))
|
|
|
+ .backgroundImage($r('app.media.BG_two'))
|
|
|
+ }
|
|
|
+}
|
|
|
+@CustomDialog
|
|
|
+struct serialPort {
|
|
|
+ @Link checkBit:string
|
|
|
+ @Link checkBitLink:checkBitClass[]
|
|
|
+ @Link stopBit:string
|
|
|
+ @Link stopBitList:stopBitClass[]
|
|
|
+ @Link dataBitsList:dataBitsClass[]
|
|
|
+ @Link dataBits:string
|
|
|
+ @Link BAUD:string
|
|
|
+ @Link BAUDNameList:BAUDClass[]
|
|
|
+ @Link select:number
|
|
|
+ @Link serialPortName:string
|
|
|
+ @Link serialPort:serialPortClass[]
|
|
|
+ CustomDialogController: CustomDialogController
|
|
|
+ build() {
|
|
|
+ Column(){
|
|
|
+ Text(this.select===1?'选择串口号':this.select===2?"选择波特率":this.select===3?'选择数据位':this.select===4?'选择停止位':this.select===5?'选择校验位':'')
|
|
|
+ .fontSize($r('app.float.fontSize_30'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .height(px2vp(60))
|
|
|
+ .margin({bottom:px2vp(20)})
|
|
|
+ if (this.select===1){
|
|
|
+ List({space:px2vp(20)}){
|
|
|
+ ForEach(this.serialPort, (item:serialPortClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Text(item.serialPortName)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.serialPortName=item.serialPortName!
|
|
|
+ this.CustomDialogController.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.white_f1f3f5'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(400))
|
|
|
+ }else if (this.select===2){
|
|
|
+ List({space:px2vp(20)}){
|
|
|
+ ForEach(this.BAUDNameList, (item:BAUDClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Text(item.BAUDName)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.BAUD=item.BAUDName!
|
|
|
+ this.CustomDialogController.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.white_f1f3f5'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(400))
|
|
|
+ }else if (this.select===3){
|
|
|
+ List({space:px2vp(20)}){
|
|
|
+ ForEach(this.dataBitsList, (item:dataBitsClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Text(item.dataBitsName)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.dataBits=item.dataBitsName!
|
|
|
+ this.CustomDialogController.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.white_f1f3f5'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(400))
|
|
|
+ }else if (this.select===4){
|
|
|
+ List({space:px2vp(20)}){
|
|
|
+ ForEach(this.stopBitList, (item:stopBitClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Text(item.stopBitName)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.stopBit=item.stopBitName!
|
|
|
+ this.CustomDialogController.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.white_f1f3f5'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(400))
|
|
|
+ }
|
|
|
+ else if (this.select===5){
|
|
|
+ List({space:px2vp(20)}){
|
|
|
+ ForEach(this.checkBitLink, (item:checkBitClass,index:number) => {
|
|
|
+ ListItem(){
|
|
|
+ Row(){
|
|
|
+ Text(item.checkBitName)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.fontSize_24'))
|
|
|
+ .width(px2vp(500))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .onClick(()=>{
|
|
|
+ this.checkBit=item.checkBitName!
|
|
|
+ this.CustomDialogController.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .backgroundColor($r('app.color.white_f1f3f5'))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(80))
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .scrollBar(BarState.Off)
|
|
|
+ .width(px2vp(600))
|
|
|
+ .height(px2vp(400))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ .width(px2vp(700))
|
|
|
+ .height(px2vp(500))
|
|
|
+ .borderRadius(px2vp(16))
|
|
|
+ .backgroundColor($r('app.color.white_100'))
|
|
|
+ .alignItems(HorizontalAlign.Center)
|
|
|
+ }
|
|
|
+}
|
|
|
+export class serialPortClass{
|
|
|
+ serialPortName?:string
|
|
|
+}
|
|
|
+export class BAUDClass{
|
|
|
+ BAUDName?:string
|
|
|
+}
|
|
|
+export class dataBitsClass{
|
|
|
+ dataBitsName?:string
|
|
|
+}
|
|
|
+export class stopBitClass{
|
|
|
+ stopBitName?:string
|
|
|
+}
|
|
|
+
|
|
|
+export class checkBitClass{
|
|
|
+ checkBitName?:string
|
|
|
+}
|
|
|
+export class manySendingClass{
|
|
|
+ content?:string
|
|
|
+ switch?:number
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|