|
@@ -1,5 +1,6 @@
|
|
|
// 工位的设备列表
|
|
|
import router from '@ohos.router'
|
|
|
+import axios from '@ohos/axios'
|
|
|
import EquipmentRequest from '../utils/EquipmentRequest'
|
|
|
|
|
|
|
|
@@ -41,22 +42,55 @@ 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> = [
|
|
|
- // {
|
|
|
- // name: '三色灯',
|
|
|
- // text: '装配工位001',
|
|
|
- // type: $r('app.media.sansedeng'),
|
|
|
- // open: $r('app.media.open'),
|
|
|
- // colse: $r('app.media.colse'),
|
|
|
- // select: true,
|
|
|
- // temp: 1,
|
|
|
- // deviceName: "三色灯"
|
|
|
- // }
|
|
|
+ {
|
|
|
+ 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"),
|
|
@@ -75,32 +109,35 @@ 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
|
|
|
-
|
|
|
- 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 ?? []
|
|
|
+
|
|
|
+ // 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 = {}
|
|
@@ -109,6 +146,9 @@ struct StationDevicesPage {
|
|
|
if (d.deviceName == "三色灯") {
|
|
|
this.lightDController.open()
|
|
|
}
|
|
|
+ else if (d.deviceName == "排烟机") {
|
|
|
+ this.paiyanjiController.open()
|
|
|
+ }
|
|
|
}
|
|
|
// 三色灯dialoag
|
|
|
lightDController = new CustomDialogController({
|
|
@@ -118,9 +158,55 @@ struct StationDevicesPage {
|
|
|
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()
|
|
|
+ // this.getDeviceList()
|
|
|
+ setInterval(() => {
|
|
|
+ this.getDeviceCurrentData()
|
|
|
+
|
|
|
+ }, 1500)
|
|
|
}
|
|
|
|
|
|
build() {
|
|
@@ -162,16 +248,18 @@ 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))
|
|
@@ -248,6 +336,77 @@ 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
|
|
@@ -416,3 +575,5 @@ struct ThreeColorsLight {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|