import router from '@ohos.router'
import { DeviceDialog } from '../../../commont/component/DeviceDialog'
@Entry
@Component
struct AITest {
  //手势放大缩小
  @State scaleValue: number = 1;
  @State pinchValue: number = 1;
  @State pinchX: number = 0;
  @State pinchY: number = 0;
 @State Axis:number[][]=[[px2vp(100),px2vp(200)],[px2vp(120),px2vp(220)],
   [px2vp(300),px2vp(300)],
   [px2vp(500),px2vp(500)],
   [px2vp(600),px2vp(300)],
   [px2vp(800),px2vp(100)],
 ]
  //Y坐标
  @State YAxis:number[]=[10,9,8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10]
  //通道
  @State number:number=0
  controller: TextInputController = new TextInputController()
  //连接状态1有，0没有
  @State connect:number=0
  //采样频率
  @State samplingFrequency:string=''
  //采样范围
  @State SampleRange:string=''
  //实时数据

  @State RealTime:Array<RealTimeClass>=[
    {data:100,number:1},
    {data:100,number:2},
    {data:100,number:3},
    {data:100,number:4},
    {data:100,number:5},
    {data:100,number:6},
    {data:100,number:7},
    {data:100,number:8},
    {data:100,number:9},
    {data:100,number:10},
    {data:100,number:11},
    {data:100,number:12},
    {data:100,number:13},
    {data:100,number:14},
    {data:100,number:15},
    {data:100,number:16},
  ]
  //通道
  @State thoroughfare:Array<thoroughfareClass>=[
    {switch:0,number:1},
    {switch:0,number:2},
    {switch:0,number:3},
    {switch:0,number:4},
    {switch:0,number:5},
    {switch:0,number:6},
    {switch:0,number:7},
    {switch:0,number:8},
    {switch:0,number:9},
    {switch:0,number:10},
    {switch:0,number:11},
    {switch:0,number:12},
    {switch:0,number:13},
    {switch:0,number:14},
    {switch:0,number:15},
    {switch:0,number:16},
  ]
  @State select:number=0
  //过采样倍率
  @State OversamplingRate: 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>=[
    {OversamplingRate:'过采样倍率1'},
    {OversamplingRate:'过采样倍率2'},
    {OversamplingRate:'过采样倍率3'},
    {OversamplingRate:'过采样倍率4'},
    {OversamplingRate:'过采样倍率5'}]

  @State private SampleRangeNameList:Array<SampleRangeClass>=[
    {SampleRangeName:'采样范围1'},
    {SampleRangeName:'采样范围2'},
    {SampleRangeName:'采样范围3'},
    {SampleRangeName:'采样范围4'},
    {SampleRangeName:'采样范围5'}]
  @State private samplingFrequencyList:Array<samplingFrequencyClass>=[
    {samplingFrequencyName:'采样频率1'},
    {samplingFrequencyName:'采样频率2'},
    {samplingFrequencyName:'采样频率3'},
    {samplingFrequencyName:'采样频率4'},
    {samplingFrequencyName:'采样频率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({
      samplingFrequency:this.samplingFrequency,
      SampleRange:this.SampleRange,
      select:this.select,
      serialPort:this.serialPort,
      OversamplingRate:this.OversamplingRate,
      SampleRangeNameList:this.SampleRangeNameList,
      samplingFrequencyList:this.samplingFrequencyList
    }),
    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)
    }

  }
  thoroughfareController: CustomDialogController = new CustomDialogController({
    builder:thoroughfare({
      thoroughfare:this.thoroughfare,

    }),
    alignment: DialogAlignment.Center,
    customStyle:true,
    autoCancel:true,
  })
  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('AI测试')
                  .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.OversamplingRate===''){
                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.OversamplingRate)
                  .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.SampleRange===''){
                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.SampleRange)
                  .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.samplingFrequency===''){
                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.samplingFrequency)
                  .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})
            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(20)})
              .onClick(()=>{
                this.thoroughfareController.open()
              })
            List({space:px2vp(5)}){
              ForEach(this.thoroughfare, (item:thoroughfareClass,index:number) => {
                if (item.switch===1) {
                ListItem(){
                  Row(){
                      Text(item.number?.toString()+',')
                        .fontWeight(FontWeight.Medium)
                        .fontSize($r('app.float.fontSize_24'))
                        .textAlign(TextAlign.Center)
                        .borderRadius(px2vp(16))
                  }
                  .backgroundColor($r('app.color.white_f1f3f5'))
                  .borderRadius(px2vp(16))
                  .justifyContent(FlexAlign.Center)
                  }
                }

              })
            }.lanes(4)
            .scrollBar(BarState.Off)
            .width(px2vp(225))
            .height(px2vp(115))
            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(){
          Row(){
            Text('曲线')
            .fontSize($r('app.float.fontSize_30'))
            .fontWeight(FontWeight.Medium)
            .height(px2vp(40))
              .margin({left:px2vp(24)})
            .textAlign(TextAlign.Start)
            Blank()
            Text('实时数据(V)')
              .fontSize($r('app.float.fontSize_30'))
              .fontWeight(FontWeight.Medium)
              .height(px2vp(40))
              .margin({right:px2vp(60)})
              .textAlign(TextAlign.Start)
          }.width(px2vp(1448))
          .height(px2vp(60))
          Row(){
            Row(){
              Column(){
                Text('V')
                  .fontSize($r('app.float.fontSize_14'))
                  .fontWeight(FontWeight.Regular)
                  .fontColor($r('app.color.white_100'))
                  .height(px2vp(37))
                  .width(px2vp(60))
                List(){
                  ForEach(this.YAxis, (item:number[],index:number) => {
                    ListItem(){
                      Text(item.toString())
                        .fontWeight(FontWeight.Regular)
                        .fontSize($r('app.float.fontSize_14'))
                        .fontColor($r('app.color.white_100'))
                        .height(px2vp(38))
                    }

                  })
                }
                .scrollBar(BarState.Off)
                .width(px2vp(60))
                .height(px2vp(800))
                Text()
                  .height(px2vp(37))

              }.width(px2vp(60))
              .margin({left:px2vp(20)})
              .height(px2vp(872))
              Column(){
                Scroll(){
                  Stack(){
                    Text()
                      .borderRadius(px2vp(16))
                      .width(px2vp(1094))
                      .height(px2vp(812))
                      .backgroundColor($r('app.color.black_100'))

                    Polyline({ width: px2vp(10000), height: px2vp(812) })
                      .points([[0, 0], [30, 100], [120, 120]])
                      .fillOpacity(0)
                      .stroke(Color.Blue)
                      .strokeWidth(2)
                      .borderRadius(px2vp(16))
                    Polyline({ width: px2vp(10000), height: px2vp(812) })
                      .points(this.Axis)
                      .fillOpacity(0)
                      .stroke("#F9A01E")
                      .strokeWidth(3)
                      .borderRadius(px2vp(16))
                      .scale({ x: this.scaleValue, y: this.scaleValue, z: 1 })
                      .gesture(
                        // 在组件上绑定三指触发的捏合手势
                        PinchGesture({ fingers: 3 })
                          .onActionStart((event: GestureEvent|undefined) => {
                            console.info('Pinch start');
                          })
                            // 当捏合手势触发时，可以通过回调函数获取缩放比例，从而修改组件的缩放比例
                          .onActionUpdate((event: GestureEvent|undefined) => {
                            if(event){
                              this.scaleValue = this.pinchValue * event.scale;
                              this.pinchX = event.pinchCenterX;
                              this.pinchY = event.pinchCenterY;
                            }
                          })
                          .onActionEnd(() => {
                            this.pinchValue = this.scaleValue;
                            console.info('Pinch end');
                          })
                      )

                  }
                  .width(px2vp(10000))
                  .height(px2vp(812))


                } .width(px2vp(1094))
                .height(px2vp(812))
                .scrollable(ScrollDirection.Horizontal)




                List(){
                  ForEach(this.YAxis, (item:number[],index:number) => {
                    ListItem(){
                      Text(item.toString())
                        .fontWeight(FontWeight.Regular)
                        .fontSize($r('app.float.fontSize_14'))
                        .fontColor($r('app.color.white_100'))
                        .width(px2vp(38))
                    }

                  })
                }
                .width(px2vp(1094))
                .height(px2vp(37))
                .borderRadius(px2vp(16))
                .listDirection(Axis.Horizontal)

              }.width(px2vp(1094))
              .height(px2vp(872))

            }
            .width(px2vp(1174))
            .height(px2vp(872))
            .border({width:1})
            .margin({right:px2vp(24)})
            .backgroundColor($r('app.color.black_100'))
            .borderRadius(px2vp(16))
            Column(){
              List({space:px2vp(5)}){
                ForEach(this.RealTime, (item:RealTimeClass,index:number) => {
                    ListItem(){
                      Row(){
                        Text()
                          .width(px2vp(20))
                          .height(px2vp(20))
                          .borderRadius(px2vp(50))
                          .backgroundColor(index===0?'#564AF7':index===1?'#8981F7':index===2?'#AC49F5':index===3?'#C386F0':index===4?'#46B1E3'
                            :index===5?'#61CFBE':index===6?'#64BB5C':index===7?'#BDDB69':index===8?'#A5D61D':index===9?'#F7CE00'
                              :index===10?'#F9A01E':index===11?'#ED6F21':index===12?'#E87361':index===13?'#E67C92':index===14?'#E64566'
                                :index===15?'#E84026':'')
                          .margin({right:px2vp(20)})
                        Text(item.number?.toString())
                          .fontWeight(FontWeight.Medium)
                          .fontSize($r('app.float.fontSize_24'))
                          .textAlign(TextAlign.Center)
                          .borderRadius(px2vp(16))
                          .fontColor(index===0?'#564AF7':index===1?'#8981F7':index===2?'#AC49F5':index===3?'#C386F0':index===4?'#46B1E3'
                            :index===5?'#61CFBE':index===6?'#64BB5C':index===7?'#BDDB69':index===8?'#A5D61D':index===9?'#F7CE00'
                              :index===10?'#F9A01E':index===11?'#ED6F21':index===12?'#E87361':index===13?'#E67C92':index===14?'#E64566'
                                :index===15?'#E84026':'')
                          .width(px2vp(50))
                          .margin({right:px2vp(20)})
                        Text(item.data?.toString())
                          .fontWeight(FontWeight.Medium)
                          .fontSize($r('app.float.fontSize_24'))
                          .textAlign(TextAlign.Center)
                          .borderRadius(px2vp(16))
                          .fontColor($r('app.color.white_100'))
                      }
                      .height(px2vp(50))
                      .padding({left:px2vp(20),right:px2vp(20)})
                      .borderRadius(px2vp(16))
                      .justifyContent(FlexAlign.Center)
                    }
                })
              }.lanes(1)
              .scrollBar(BarState.Off)
              .width(px2vp(194))
              .height(px2vp(872))



            }.width(px2vp(194))
            .height(px2vp(872))
            .border({width:1})
            .backgroundColor($r('app.color.black_100'))
            .borderRadius(px2vp(16))
          }.width(px2vp(1386))
          .height(px2vp(872))

        }
        .width(px2vp(1448))
        .height(px2vp(960))
        .borderRadius(px2vp(16))
        .margin({left:px2vp(24)})
        .backgroundColor($r('app.color.white_60'))

      }
      .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 samplingFrequencyList:samplingFrequencyClass[]
  @Link samplingFrequency:string
  @Link SampleRange:string
  @Link SampleRangeNameList:SampleRangeClass[]
  @Link select:number
  @Link OversamplingRate:string
  @Link serialPort:serialPortClass[]
  CustomDialogController: CustomDialogController
  build() {
    Column(){
      Text(this.select===1?'过采样倍率':this.select===2?"采样范围":this.select===3?'采样频率':'')
        .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.OversamplingRate)
                  .fontWeight(FontWeight.Medium)
                  .fontSize($r('app.float.fontSize_24'))
                  .width(px2vp(500))
                  .height(px2vp(80))
                  .textAlign(TextAlign.Center)
                  .borderRadius(px2vp(16))
                  .onClick(()=>{
                    this.OversamplingRate=item.OversamplingRate!
                    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.SampleRangeNameList, (item:SampleRangeClass,index:number) => {
            ListItem(){
              Row(){
                Text(item.SampleRangeName)
                  .fontWeight(FontWeight.Medium)
                  .fontSize($r('app.float.fontSize_24'))
                  .width(px2vp(500))
                  .height(px2vp(80))
                  .textAlign(TextAlign.Center)
                  .borderRadius(px2vp(16))
                  .onClick(()=>{
                    this.SampleRange=item.SampleRangeName!
                    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.samplingFrequencyList, (item:samplingFrequencyClass,index:number) => {
            ListItem(){
              Row(){
                Text(item.samplingFrequencyName)
                  .fontWeight(FontWeight.Medium)
                  .fontSize($r('app.float.fontSize_24'))
                  .width(px2vp(500))
                  .height(px2vp(80))
                  .textAlign(TextAlign.Center)
                  .borderRadius(px2vp(16))
                  .onClick(()=>{
                    this.samplingFrequency=item.samplingFrequencyName!
                    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)
  }

}
@CustomDialog
struct thoroughfare {
  @Link thoroughfare:thoroughfareClass[]
  CustomDialogController: CustomDialogController
  build() {
    Column(){
      Text('选择通道')
        .fontSize($r('app.float.fontSize_30'))
        .fontWeight(FontWeight.Medium)
        .height(px2vp(60))
        .margin({bottom:px2vp(20)})
      List({space:px2vp(20)}){
        ForEach(this.thoroughfare, (item:thoroughfareClass,index:number) => {
          ListItem(){
            Row(){
              Toggle({ type: ToggleType.Checkbox,isOn:item.switch===0? false:true })
                .size({ width: px2vp(40), height: px2vp(40) })
                .selectedColor('#007DFF')
                .onClick(() => {
                  if (item.switch===0) {
                    this.thoroughfare[index]={
                      switch:1,
                      number:this.thoroughfare[index].number
                    }
                    console.info('textTag' +JSON.stringify(this.thoroughfare))
                  }else if (item.switch===1) {
                    this.thoroughfare[index] = {
                      switch: 0,
                      number: this.thoroughfare[index].number
                    }
                    console.info('textTag' +JSON.stringify(this.thoroughfare))
                  }
                })
              Text(item.number?.toString())
                .fontWeight(FontWeight.Medium)
                .fontSize($r('app.float.fontSize_24'))
                .width(px2vp(60))
                .height(px2vp(80))
                .textAlign(TextAlign.Center)
                .borderRadius(px2vp(16))
            }
            .backgroundColor($r('app.color.white_f1f3f5'))
            .borderRadius(px2vp(16))
            .width(px2vp(100))
            .height(px2vp(80))
            .justifyContent(FlexAlign.Center)
            .onClick(() => {
              if (item.switch===0) {
                this.thoroughfare[index]={
                  switch:1,
                  number:this.thoroughfare[index].number
                }
                console.info('textTag' +JSON.stringify(this.thoroughfare))
              }else if (item.switch===1) {
                this.thoroughfare[index] = {
                  switch: 0,
                  number: this.thoroughfare[index].number
                }
                console.info('textTag' +JSON.stringify(this.thoroughfare))
              }
            })

          }

        })
      }.lanes(4)
      .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{
  OversamplingRate?:string
}
export class SampleRangeClass{
  SampleRangeName?:string
}
export class samplingFrequencyClass{
  samplingFrequencyName?:string
}
export class stopBitClass{
  stopBitName?:string
}

export class checkBitClass{
  checkBitName?:string
}
export class manySendingClass{
  content?:string
  switch?:number

}
export class thoroughfareClass{
  switch?:number
  number?:number
}

export class RealTimeClass{
  number?:number
  data?:number
}




