Przeglądaj źródła

新增类似三色灯的硬件。

jiaxiaoqiang 5 miesięcy temu
rodzic
commit
2b6af0d512

+ 1 - 1
entry/src/main/ets/pages/Index.ets

@@ -5,7 +5,7 @@ import uploadInstance from "../utils/UploadUtil"
 
 
 const TAG = "openHarmonyBridge" //webview和vue沟通的名称
-const webUrl = "192.168.100.10:8081"
+const webUrl = "http://10.88.11.200:11000"
 
 // const webUrl = "http://10.88.20.88:3005/"
 

+ 135 - 197
entry/src/main/ets/pages/StationDevicesPage.ets

@@ -1,6 +1,5 @@
 // 工位的设备列表
 import router from '@ohos.router'
-import axios from '@ohos/axios'
 import EquipmentRequest from '../utils/EquipmentRequest'
 
 
@@ -42,55 +41,22 @@ interface ImageDictModel {
   zhaomingdeng: ResourceStr
 }
 
-interface DeviceData {
-  data?: DeviceData2
-}
-
-interface DeviceData2 {
-  data?: deviceValueModel
-}
-
-interface deviceValueModel {
-  RFID?: string
-  temperature?: string
-  state?: string //静电手环
-}
 
 @Entry
 @Component
 struct StationDevicesPage {
   //注释掉的是假数据,实际更具请求硬件获取
   @State private items: Array<HardwareModel> = [
-    {
-      deviceName: '三色灯',
-      value: '',
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r("app.media.sansedeng"),
-    },
-    {
-      deviceName: '读卡器',
-      value: '',
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.dukaqi'),
-    },
-    {
-      deviceName: '电烙铁',
-      value: '',
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.dianlaotie'),
-    },
-    {
-      deviceName: '电子手环',
-      value: '',
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.zhaomingdeng'),
-    },
-    {
-      deviceName: '排烟机',
-      value: '',
-      deviceNo: "EC2A-IM24R-01",
-      imageSource: $r('app.media.paiyanji'),
-    }
+  //   {
+  //   name: '三色灯',
+  //   text: '装配工位001',
+  //   type: $r('app.media.sansedeng'),
+  //   open: $r('app.media.open'),
+  //   colse: $r('app.media.colse'),
+  //   select: true,
+  //   temp: 1,
+  //   deviceName: "三色灯"
+  // }
   ]
   imageDict: ImageDictModel = {
     sansedeng: $r("app.media.sansedeng"),
@@ -109,35 +75,32 @@ struct StationDevicesPage {
     let res: HardwareModel = await EquipmentRequest.get('/api/v1/device/list') as HardwareModel
 
     let deviceValues: HardwareModel = await EquipmentRequest.get('/api/v1/station/data') as HardwareModel
-    console.log("==========", JSON.stringify(res), JSON.stringify(deviceValues))
 
-    // let ybkc: HardwareModel = new HardwareModel()
-    // let gaoduchi: HardwareModel = new HardwareModel()
-    // deviceValues?.data?.forEach((item) => {
-    //   if (item.deviceNo == "1106-50100") {
-    //     ybkc.value = item.length
-    //   }
-    //   if (item.deviceNo == "1150-300C00") {
-    //     gaoduchi.value = item.height
-    //   }
-    // })
-
-
-    // let array: HardwareModel[] | undefined = res?.data?.filter((device) => {
-    //   device.imageSource = Reflect.get(this.imageDict, device.devicePic!)
-    //   return device.enable! === true || device.enable! === "true"
-    // })
-    // array?.forEach((item) => {
-    //   if (item.deviceNo == "1106-50100") {
-    //     item.value = ybkc.value
-    //   }
-    //   if (item.deviceNo == "1150-300C00") {
-    //     item.value = gaoduchi.value
-    //   }
-    // })
-    // this.items = array ?? []
-    //
-    // this.getDeviceCurrentData()
+    let ybkc: HardwareModel = new HardwareModel()
+    let gaoduchi: HardwareModel = new HardwareModel()
+    deviceValues?.data?.forEach((item) => {
+      if (item.deviceNo == "1106-50100") {
+        ybkc.value = item.length
+      }
+      if (item.deviceNo == "1150-300C00") {
+        gaoduchi.value = item.height
+      }
+    })
+
+    console.log("==========", JSON.stringify(res), JSON.stringify(deviceValues))
+    let array: HardwareModel[] | undefined = res?.data?.filter((device) => {
+      device.imageSource = Reflect.get(this.imageDict, device.devicePic!)
+      return device.enable! === true || device.enable! === "true"
+    })
+    array?.forEach((item) => {
+      if (item.deviceNo == "1106-50100") {
+        item.value = ybkc.value
+      }
+      if (item.deviceNo == "1150-300C00") {
+        item.value = gaoduchi.value
+      }
+    })
+    this.items = array ?? []
   }
   // 点击选择了设备之后
   @State currentDevice: HardwareModel = {}
@@ -146,8 +109,8 @@ struct StationDevicesPage {
     if (d.deviceName == "三色灯") {
       this.lightDController.open()
     }
-    else if (d.deviceName == "排烟机") {
-      this.paiyanjiController.open()
+    else if (d.deviceNo == "EC2A-IM24R00") {
+      this.theOtherController.open()
     }
   }
   // 三色灯dialoag
@@ -158,55 +121,17 @@ struct StationDevicesPage {
     alignment: DialogAlignment.Center,
     customStyle: true,
   })
-  // 排烟机
-  paiyanjiController = new CustomDialogController({
-    builder: PaiYanjiDialog({
+  // 另一个灯的
+  theOtherController = new CustomDialogController({
+    builder: TheOtherLight({
       device: this.currentDevice
     }),
     alignment: DialogAlignment.Center,
     customStyle: true,
   })
 
-  async getDeviceCurrentData() {
-    let rfidData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/YMC1502")
-    let hantaiData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/GT-615000")
-    let jingdianshouhuanData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/SP-JD01C00")
-
-
-    this.items[1] = {
-      deviceName: '读卡器',
-      value: rfidData?.data?.data?.RFID ?? "000",
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.dukaqi'),
-    }
-
-    this.items[2] = {
-      deviceName: '电烙铁',
-      value: hantaiData?.data?.data?.temperature + "℃",
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.dianlaotie'),
-    }
-
-    let state = jingdianshouhuanData?.data?.data?.state == "1" ? "未佩戴" : "已佩戴"
-    this.items[3] = {
-      deviceName: '电子手环',
-      value: state,
-      deviceNo: "ONNM4FUSB00",
-      imageSource: $r('app.media.dianzishouhuan'),
-    }
-
-
-    // console.log("==========", JSON.stringify(rfidData))
-    // console.log("==========", JSON.stringify(hantaiData))
-    // console.log("==========", JSON.stringify(jingdianshouhuanData))
-  }
-
   aboutToAppear(): void {
-    // this.getDeviceList()
-    setInterval(() => {
-      this.getDeviceCurrentData()
-
-    }, 1500)
+    this.getDeviceList()
   }
 
   build() {
@@ -248,18 +173,16 @@ struct StationDevicesPage {
                     .fontColor('#FFFFFF')
                     .fontWeight(FontWeight.Medium)
                     .fontSize(24)
-
-                  // Text(item.deviceNo)
-                  //   .fontColor('#FFFFFF')
-                  //   .opacity(0.6)
-                  //   .fontWeight(FontWeight.Regular)
-                  //   .fontSize(20)
+                  Text(item.deviceNo)
+                    .fontColor('#FFFFFF')
+                    .opacity(0.6)
+                    .fontWeight(FontWeight.Regular)
+                    .fontSize(20)
                   Text(item.value)
                     .fontColor('#ffffff')
                     .opacity(0.8)
                     .fontWeight(FontWeight.Regular)
                     .fontSize(18)
-                    .margin({ bottom: 8 })
                   Row() {
                     Image(item.imageSource)
                       .width(px2vp(120))
@@ -326,9 +249,10 @@ interface SSDModel {
 }
 
 interface SSDParamsData {
-  lighting: string
-  buzzer: string
-  flash: string
+  lighting?: string
+  buzzer?: string
+  flash?: string
+  outputs?: string
 }
 
 interface SSDParams {
@@ -336,77 +260,6 @@ interface SSDParams {
   data: SSDParamsData
 }
 
-interface PaiYanJiPData {
-  ch0?: string,
-  name?: string
-}
-
-interface PYJParams {
-  deviceNo: string
-  data?: PaiYanJiPData
-}
-
-@CustomDialog
-struct PaiYanjiDialog {
-  controller: CustomDialogController
-  @Prop device: HardwareModel
-
-  start() {
-
-
-    EquipmentRequest.post("/api/v1/device/setup", {
-      deviceNo: this.device.deviceNo ?? "",
-      data: {
-        ch0: "1"
-      },
-    } as PYJParams)
-  }
-
-  stop() {
-    EquipmentRequest.post("/api/v1/device/setup", {
-      deviceNo: this.device.deviceNo ?? "",
-      data: {
-        ch0: "0"
-      },
-    } as PYJParams)
-  }
-
-  build() {
-    Row() {
-      Button({ type: ButtonType.Capsule }) {
-        Text("开启")
-      }
-      .fontColor(Color.White)
-      .width(70)
-      .height(30)
-      .backgroundColor($r("app.color.green_100"))
-      .onClick(() => {
-        this.start()
-      })
-
-      Button({ type: ButtonType.Capsule }) {
-        Text("关闭")
-      }
-      .fontColor(Color.White)
-      .width(70)
-      .height(30)
-      .backgroundColor($r("app.color.gray_6666"))
-      .onClick(() => {
-        this.stop()
-      })
-
-    }
-    .justifyContent(FlexAlign.SpaceEvenly)
-    .padding({ left: 15 })
-    .width(300)
-    .height(190)
-    .backgroundColor(Color.White)
-    .borderRadius(10)
-
-  }
-}
-
-
 @CustomDialog
 struct ThreeColorsLight {
   controller: CustomDialogController
@@ -573,7 +426,92 @@ struct ThreeColorsLight {
   }
 }
 
+@CustomDialog
+struct TheOtherLight {
+  controller: CustomDialogController
+  @Prop device: HardwareModel
+  @State operations: SSDModel[][] = [
+    [
+      {
+        uiType: 'Button',
+        textValue: "红灯",
+        key: "outputs",
+        value: "4",
+        btnColor: $r("app.color.red_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "黄灯",
+        key: "outputs",
+        value: "7",
+        btnColor: $r("app.color.yellow_1")
+      },
+      {
+        uiType: 'Button',
+        textValue: "绿灯",
+        key: "outputs",
+        value: "1",
+        btnColor: $r("app.color.green_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "关闭",
+        key: "outputs",
+        value: "0",
+        btnColor: $r("app.color.gray_6666")
+      },
+    ],
+  ]
+  toOperation = (m: SSDModel) => {
+
+    let data: SSDParamsData = {
+      outputs: '',
+    }
+
+    Reflect.set(data, m.key, m.value)
+
+    EquipmentRequest.post("/api/v1/device/setup", {
+      deviceNo: this.device.deviceNo ?? "",
+      data: data
+    } as SSDParams)
+
+  }
+
+  build() {
+    Column() {
+
+      ForEach(this.operations, (ops: SSDModel[], index) => {
+        ListItem() {
+          Row({ space: 10 }) {
+            ForEach(ops, (op: SSDModel) => {
+              if (op.uiType === "Text") {
+                Text(op.textValue)
+              }
+              else {
+                Button({ type: ButtonType.Capsule }) {
+                  Text(op.textValue)
+                }.DeviceBtnS(op.btnColor)
+                .onClick(() => {
+                  this.toOperation(op)
+                })
+              }
+            })
+
+          }
+        }
+      })
+
 
+    }
+    .justifyContent(FlexAlign.SpaceEvenly)
+    .alignItems(HorizontalAlign.Start)
+    .padding({ left: 15 })
+    .width(400)
+    .height(140)
+    .backgroundColor(Color.White)
+    .borderRadius(10)
 
+  }
+}
 
 

+ 579 - 0
entry/src/main/ets/pages/StationDevicesPage2.ets

@@ -0,0 +1,579 @@
+// 工位的设备列表
+import router from '@ohos.router'
+import axios from '@ohos/axios'
+import EquipmentRequest from '../utils/EquipmentRequest'
+
+
+export class HardwareModel {
+  name?: string
+  text?: string
+  type?: Resource
+  open?: Resource
+  colse?: Resource
+  select?: boolean
+  temp?: number
+  manufacturer?: string //: "厂家",
+  brand?: string //"品牌或型号,比如JBC",
+  deviceName?: string //"设备自定义名称或资产编号",
+  deviceType?: string // "类别,比如电络铁",
+  deviceNo?: string // "设备编号,唯一号",
+  devicePic?: string // "图片",
+  state?: number //"状态:0正常,-1:离线,1故障",
+  workshop?: string //"产线",
+  station?: string //"工站/工位",
+  devicePosition?: string // "空间位置,目前暂时不用",
+  data?: HardwareModel[]
+  enable?: boolean | string //是否启用了设备
+  imageSource?: ResourceStr
+  length?: string
+  height?: string
+  value?: string //硬件设备的一个数据
+}
+
+interface ImageDictModel {
+  sansedeng: ResourceStr
+  saomaqiang: ResourceStr
+  diannengbiao: ResourceStr
+  multimeter: ResourceStr
+  dukaqi: ResourceStr
+  chengkongdianyuan: ResourceStr
+  shukongdian: ResourceStr
+  diandongluosidao: ResourceStr
+  zhaomingdeng: ResourceStr
+}
+
+interface DeviceData {
+  data?: DeviceData2
+}
+
+interface DeviceData2 {
+  data?: deviceValueModel
+}
+
+interface deviceValueModel {
+  RFID?: string
+  temperature?: string
+  state?: string //静电手环
+}
+
+@Entry
+@Component
+struct StationDevicesPage {
+  //注释掉的是假数据,实际更具请求硬件获取
+  @State private items: Array<HardwareModel> = [
+    {
+      deviceName: '三色灯',
+      value: '',
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r("app.media.sansedeng"),
+    },
+    {
+      deviceName: '读卡器',
+      value: '',
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.dukaqi'),
+    },
+    {
+      deviceName: '电烙铁',
+      value: '',
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.dianlaotie'),
+    },
+    {
+      deviceName: '电子手环',
+      value: '',
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.zhaomingdeng'),
+    },
+    {
+      deviceName: '排烟机',
+      value: '',
+      deviceNo: "EC2A-IM24R-01",
+      imageSource: $r('app.media.paiyanji'),
+    }
+  ]
+  imageDict: ImageDictModel = {
+    sansedeng: $r("app.media.sansedeng"),
+    saomaqiang: $r('app.media.saomaqiang'),
+    diannengbiao: $r('app.media.diannengbiao'),
+    multimeter: $r('app.media.multimeter'),
+    dukaqi: $r('app.media.dukaqi'),
+    chengkongdianyuan: $r('app.media.chengkongdianyuan'),
+    shukongdian: $r('app.media.shukongdian'),
+    diandongluosidao: $r('app.media.diandongluosidao'),
+    zhaomingdeng: $r('app.media.zhaomingdeng')
+  }
+  scroller: Scroller = new Scroller()
+  getDeviceList = async () => {
+    console.log("==========")
+    let res: HardwareModel = await EquipmentRequest.get('/api/v1/device/list') as HardwareModel
+
+    let deviceValues: HardwareModel = await EquipmentRequest.get('/api/v1/station/data') as HardwareModel
+    console.log("==========", JSON.stringify(res), JSON.stringify(deviceValues))
+
+    // let ybkc: HardwareModel = new HardwareModel()
+    // let gaoduchi: HardwareModel = new HardwareModel()
+    // deviceValues?.data?.forEach((item) => {
+    //   if (item.deviceNo == "1106-50100") {
+    //     ybkc.value = item.length
+    //   }
+    //   if (item.deviceNo == "1150-300C00") {
+    //     gaoduchi.value = item.height
+    //   }
+    // })
+
+
+    // let array: HardwareModel[] | undefined = res?.data?.filter((device) => {
+    //   device.imageSource = Reflect.get(this.imageDict, device.devicePic!)
+    //   return device.enable! === true || device.enable! === "true"
+    // })
+    // array?.forEach((item) => {
+    //   if (item.deviceNo == "1106-50100") {
+    //     item.value = ybkc.value
+    //   }
+    //   if (item.deviceNo == "1150-300C00") {
+    //     item.value = gaoduchi.value
+    //   }
+    // })
+    // this.items = array ?? []
+    //
+    // this.getDeviceCurrentData()
+  }
+  // 点击选择了设备之后
+  @State currentDevice: HardwareModel = {}
+  openDeviceOperationDialog = (d: HardwareModel) => {
+    this.currentDevice = d
+    if (d.deviceName == "三色灯") {
+      this.lightDController.open()
+    }
+    else if (d.deviceName == "排烟机") {
+      this.paiyanjiController.open()
+    }
+  }
+  // 三色灯dialoag
+  lightDController = new CustomDialogController({
+    builder: ThreeColorsLight({
+      device: this.currentDevice
+    }),
+    alignment: DialogAlignment.Center,
+    customStyle: true,
+  })
+  // 排烟机
+  paiyanjiController = new CustomDialogController({
+    builder: PaiYanjiDialog({
+      device: this.currentDevice
+    }),
+    alignment: DialogAlignment.Center,
+    customStyle: true,
+  })
+
+  async getDeviceCurrentData() {
+    let rfidData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/YMC1502")
+    let hantaiData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/GT-615000")
+    let jingdianshouhuanData: DeviceData = await axios.get("http://192.168.100.146:8000/api/v1/device/data/recentlyRecord/SP-JD01C00")
+
+
+    this.items[1] = {
+      deviceName: '读卡器',
+      value: rfidData?.data?.data?.RFID ?? "000",
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.dukaqi'),
+    }
+
+    this.items[2] = {
+      deviceName: '电烙铁',
+      value: hantaiData?.data?.data?.temperature + "℃",
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.dianlaotie'),
+    }
+
+    let state = jingdianshouhuanData?.data?.data?.state == "1" ? "未佩戴" : "已佩戴"
+    this.items[3] = {
+      deviceName: '电子手环',
+      value: state,
+      deviceNo: "ONNM4FUSB00",
+      imageSource: $r('app.media.dianzishouhuan'),
+    }
+
+
+    // console.log("==========", JSON.stringify(rfidData))
+    // console.log("==========", JSON.stringify(hantaiData))
+    // console.log("==========", JSON.stringify(jingdianshouhuanData))
+  }
+
+  aboutToAppear(): void {
+    // this.getDeviceList()
+    setInterval(() => {
+      this.getDeviceCurrentData()
+
+    }, 1500)
+  }
+
+  build() {
+
+    Column() {
+      Row() {
+        Image($r('app.media.back_white'))
+          .height(px2vp(48))
+          .width(px2vp(48))
+          .onClick(async () => {
+            router.back()
+          })
+
+        Text("刷新")
+          .fontColor('#FFFFFF')
+          .fontWeight(FontWeight.Medium)
+          .fontSize(24)
+          .margin({ left: 20 })
+          .onClick(() => {
+            this.getDeviceList()
+          })
+
+      }
+      .width('100%')
+      .height('8%')
+      .alignItems(VerticalAlign.Center)
+      .justifyContent(FlexAlign.Start)
+
+      Column() {
+
+        //  Scroll(this.scroller){
+        Grid(this.scroller) {
+          ForEach(this.items, (item: HardwareModel, index) => {
+            GridItem() {
+
+              Row() {
+                Column() {
+                  Text(item.deviceName)
+                    .fontColor('#FFFFFF')
+                    .fontWeight(FontWeight.Medium)
+                    .fontSize(24)
+
+                  // Text(item.deviceNo)
+                  //   .fontColor('#FFFFFF')
+                  //   .opacity(0.6)
+                  //   .fontWeight(FontWeight.Regular)
+                  //   .fontSize(20)
+                  Text(item.value)
+                    .fontColor('#ffffff')
+                    .opacity(0.8)
+                    .fontWeight(FontWeight.Regular)
+                    .fontSize(18)
+                    .margin({ bottom: 8 })
+                  Row() {
+                    Image(item.imageSource)
+                      .width(px2vp(120))
+                      .height(px2vp(120))
+
+                  }.height('50%')
+                  .width('100%')
+                  .padding({ left: 10 })
+                }
+                .width('100%')
+                .padding(10)
+                .borderRadius(10)
+                .alignItems(HorizontalAlign.Start)
+                .height('100%')
+              }
+              .width('100%')
+              .height('30%')
+              .padding({ left: 10 })
+              .borderRadius(10)
+              .backgroundColor('#66ffffff')
+              .onClick(() => {
+                this.openDeviceOperationDialog(item)
+              })
+            }
+          })
+        }
+        .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr')
+        .columnsGap(10)
+        .rowsGap(10)
+        .width('100%')
+        .height('100%')
+        .editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem
+        .supportAnimation(true) //设置Grid是否开启拖拽补位动画
+        .height('80%')
+        .width('100%')
+        .padding({ top: 10 })
+
+      }
+    }
+    .backgroundImage($r('app.media.zhihuigc'))
+    .backgroundImageSize({ width: '100%', height: '100%' })
+    .width('100%')
+    .height('100%')
+    .padding(20)
+
+  }
+}
+
+
+@Extend(Button)
+function DeviceBtnS(color: ResourceColor) {
+  .fontColor(Color.White).width(70).height(30).backgroundColor(color)
+
+}
+
+
+// 三色灯
+interface SSDModel {
+  uiType: "Text" | "Button",
+  textValue: string,
+  key: string
+  value: string
+  btnColor: ResourceColor
+}
+
+interface SSDParamsData {
+  lighting: string
+  buzzer: string
+  flash: string
+}
+
+interface SSDParams {
+  deviceNo: string
+  data: SSDParamsData
+}
+
+interface PaiYanJiPData {
+  ch0?: string,
+  name?: string
+}
+
+interface PYJParams {
+  deviceNo: string
+  data?: PaiYanJiPData
+}
+
+@CustomDialog
+struct PaiYanjiDialog {
+  controller: CustomDialogController
+  @Prop device: HardwareModel
+
+  start() {
+
+
+    EquipmentRequest.post("/api/v1/device/setup", {
+      deviceNo: this.device.deviceNo ?? "",
+      data: {
+        ch0: "1"
+      },
+    } as PYJParams)
+  }
+
+  stop() {
+    EquipmentRequest.post("/api/v1/device/setup", {
+      deviceNo: this.device.deviceNo ?? "",
+      data: {
+        ch0: "0"
+      },
+    } as PYJParams)
+  }
+
+  build() {
+    Row() {
+      Button({ type: ButtonType.Capsule }) {
+        Text("开启")
+      }
+      .fontColor(Color.White)
+      .width(70)
+      .height(30)
+      .backgroundColor($r("app.color.green_100"))
+      .onClick(() => {
+        this.start()
+      })
+
+      Button({ type: ButtonType.Capsule }) {
+        Text("关闭")
+      }
+      .fontColor(Color.White)
+      .width(70)
+      .height(30)
+      .backgroundColor($r("app.color.gray_6666"))
+      .onClick(() => {
+        this.stop()
+      })
+
+    }
+    .justifyContent(FlexAlign.SpaceEvenly)
+    .padding({ left: 15 })
+    .width(300)
+    .height(190)
+    .backgroundColor(Color.White)
+    .borderRadius(10)
+
+  }
+}
+
+
+@CustomDialog
+struct ThreeColorsLight {
+  controller: CustomDialogController
+  @Prop device: HardwareModel
+  @State operations: SSDModel[][] = [
+    [{
+      uiType: 'Text',
+      textValue: "亮灯",
+      key: "lighting",
+      value: "todo",
+      btnColor: $r("app.color.red_100")
+    },
+      {
+        uiType: 'Button',
+        textValue: "红灯",
+        key: "lighting",
+        value: "red",
+        btnColor: $r("app.color.red_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "黄灯",
+        key: "lighting",
+        value: "yellow",
+        btnColor: $r("app.color.yellow_1")
+      },
+      {
+        uiType: 'Button',
+        textValue: "绿灯",
+        key: "lighting",
+        value: "green",
+        btnColor: $r("app.color.green_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "关闭",
+        key: "lighting",
+        value: "off",
+        btnColor: $r("app.color.gray_6666")
+      },
+    ],
+    [{
+      uiType: 'Text',
+      textValue: "蜂鸣",
+      key: "buzzer",
+      value: "todo",
+      btnColor: $r("app.color.red_100")
+    },
+      {
+        uiType: 'Button',
+        textValue: "大声",
+        key: "buzzer",
+        value: "loud",
+        btnColor: $r("app.color.red_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "小声",
+        key: "buzzer",
+        value: "low",
+        btnColor: $r("app.color.green_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "关闭",
+        key: "buzzer",
+        value: "off",
+        btnColor: $r("app.color.gray_6666")
+      },
+    ],
+
+
+    [{
+      uiType: 'Text',
+      textValue: "闪光",
+      key: "flash",
+      value: "todo",
+      btnColor: $r("app.color.red_100")
+    },
+      {
+        uiType: 'Button',
+        textValue: "闪光快",
+        key: "flash",
+        value: "fast",
+        btnColor: $r("app.color.red_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "闪光中",
+        key: "flash",
+        value: "middle",
+        btnColor: $r("app.color.yellow_1")
+      },
+      {
+        uiType: 'Button',
+        textValue: "闪光慢",
+        key: "flash",
+        value: "slow",
+        btnColor: $r("app.color.green_100")
+      },
+      {
+        uiType: 'Button',
+        textValue: "关闭",
+        key: "flash",
+        value: "off",
+        btnColor: $r("app.color.gray_6666")
+      },
+    ],
+  ]
+  toOperation = (m: SSDModel) => {
+    console.log("toOperation", JSON.stringify(m))
+    let data: SSDParamsData = {
+      lighting: '',
+      buzzer: '',
+      flash: ''
+    }
+
+    Reflect.set(data, m.key, m.value)
+
+
+    console.log("toOperation", JSON.stringify(data))
+
+    EquipmentRequest.post("/api/v1/device/setup", {
+      deviceNo: this.device.deviceNo ?? "",
+      data: data
+    } as SSDParams)
+
+  }
+
+  build() {
+    Column() {
+
+      ForEach(this.operations, (ops: SSDModel[], index) => {
+        ListItem() {
+          Row({ space: 10 }) {
+            ForEach(ops, (op: SSDModel) => {
+              if (op.uiType === "Text") {
+                Text(op.textValue)
+              }
+              else {
+                Button({ type: ButtonType.Capsule }) {
+                  Text(op.textValue)
+                }.DeviceBtnS(op.btnColor)
+                .onClick(() => {
+                  this.toOperation(op)
+                })
+              }
+            })
+
+          }
+        }
+      })
+
+
+    }
+    .justifyContent(FlexAlign.SpaceEvenly)
+    .alignItems(HorizontalAlign.Start)
+    .padding({ left: 15 })
+    .width(400)
+    .height(240)
+    .backgroundColor(Color.White)
+    .borderRadius(10)
+
+  }
+}
+
+
+
+
+

+ 2 - 1
entry/src/main/ets/utils/Request.ets

@@ -12,7 +12,8 @@ import { printError, printRequest, printResponse, handleRes } from './Helps';
 import RequestParamsModel from './requestParams';
 import uploadInstance from './UploadUtil';
 
-export const JGRequestBaseUrl = "http://192.168.100.10:8079/"
+
+export  const JGRequestBaseUrl = "http://10.88.11.200:8079/"
 
 const DEBUG = true //
 

+ 1 - 1
entry/src/main/ets/utils/UploadUtil.ets

@@ -40,7 +40,7 @@ interface FileDataModel {
 
 class UploadUtil {
   private baseUrl: string = JGRequestBaseUrl
-  private fileUrl: string = "http://192.168.100.10:9000" //上传完成后可以查看的
+  private fileUrl: string = "http://10.88.11.201:9000" //上传完成后可以查看的
   private uploadPath: string = "/api/v1/base/upload"
   controller: web_webview.WebviewController | null = null
   ports: web_webview.WebMessagePort[] = [];