Bläddra i källkod

小车调试修改

cjb 1 månad sedan
förälder
incheckning
831d1695ff

+ 197 - 23
entry/src/main/ets/component/RgvControlView.ets

@@ -190,42 +190,216 @@ export struct CommonConfirmDialog {
   build() {
     Column() {
       // 标题
-      Text(this.title)
-        .fontSize(20)
-        .fontColor($r('app.color.FFFFFF'))
-        .margin({ top: 24, bottom: 8 })
-
-      // 消息内容
-      Text(this.message)
-        .fontSize(16)
-        .fontColor($r('app.color.FFFFFF'))
-        .margin({ bottom: 24 })
-
-      // 按钮区域
-      Flex({ justifyContent: FlexAlign.SpaceAround }) {
-        Button(this.cancelText, { type: ButtonType.Normal })
-          .width('45%')
-          .backgroundColor('#0A84FF')
+      Column(){
+        Text(this.title)
           .fontColor($r('app.color.FFFFFF'))
-          .onClick(() => this.controller.close())
+          .fontSize($r('app.float.fontSize_15_2'))
+      }.height('30%')
+      .justifyContent(FlexAlign.Center)
+      Column(){
+        Text(this.message)
+          .fontColor($r('app.color.30FFFFFF'))
+          .fontSize($r('app.float.fontSize_12'))
+      }.height('30%')
+      .justifyContent(FlexAlign.Center)
 
-        Button(this.confirmText, { type: ButtonType.Normal })
-          .width('45%')
-          .backgroundColor($r('app.color.0A84FF'))
-          .fontColor($r('app.color.FFFFFF'))
+      Column(){
+        Divider()
+          .vertical(false)
+          .strokeWidth(1)
+          .color($r('app.color.20FFFFFF'))
+        Row(){
+          Row(){
+            Text('取消')
+              .fontColor($r('app.color.60FFFFFF'))
+              .fontSize($r('app.float.fontSize_12'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
+          .onClick(() => this.controller.close())
+          Divider()
+            .vertical(true)
+            .strokeWidth(1)
+            .color($r('app.color.20FFFFFF'))
+          Row(){
+            Text('确认')
+              .fontColor($r('app.color.007AFF'))
+              .fontSize($r('app.float.fontSize_12'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
           .onClick(() => {
             this.onConfirm();
             this.controller.close();
           })
+        }
       }
       .width('100%')
-      .margin({ bottom: 20 })
+      .height('30%')
+      // // 按钮区域
+      // Flex({ justifyContent: FlexAlign.SpaceAround }) {
+      //   Button(this.cancelText, { type: ButtonType.Normal })
+      //     .width('45%')
+      //     .backgroundColor('#0A84FF')
+      //     .fontColor($r('app.color.FFFFFF'))
+      //     .onClick(() => this.controller.close())
+      //
+      //   Button(this.confirmText, { type: ButtonType.Normal })
+      //     .width('45%')
+      //     .backgroundColor($r('app.color.0A84FF'))
+      //     .fontColor($r('app.color.FFFFFF'))
+      //     .onClick(() => {
+      //       this.onConfirm();
+      //       this.controller.close();
+      //     })
+      // }
+      // .width('100%')
+      // .margin({ bottom: 20 })
     }
-    .padding(20)
     .height(200)
     .width(400)
     .backgroundColor($r('app.color.2A2A2A'))
+    .justifyContent(FlexAlign.End)
     .borderRadius(16)
   }
 }
 
+// 弹窗组件定义
+@CustomDialog
+export struct MoveDialog {
+  @Link rgvEndX: number
+  @Link rgvEndY: number
+  controller: CustomDialogController
+  onConfirm: () => void = () => {}
+
+  build() {
+    Column() {
+      Column(){
+        Text('终点移动')
+          .fontColor($r('app.color.FFFFFF'))
+          .fontSize($r('app.float.fontSize_15_2'))
+      }.height('30%')
+      .justifyContent(FlexAlign.Center)
+
+      Text('设置终点坐标')
+        .fontColor($r('app.color.FFFFFF'))
+        .fontSize($r('app.float.fontSize_8'))
+        .width('70%')
+        .textAlign(TextAlign.Start)
+        .margin({ bottom: '2%'})
+
+      // 输入区域
+      Column() {
+        // 第一个X轴输入
+        Row() {
+          Text('X轴')
+            .fontColor($r('app.color.30FFFFFF'))
+            .fontSize($r('app.float.fontSize_12'))
+            .width('15%')
+            .textAlign(TextAlign.Center)
+            .margin({top:'10%',bottom:'10%'})
+
+          Divider()
+            .vertical(true)
+            .strokeWidth(1)
+            .color($r('app.color.20FFFFFF'))
+            .margin({top:'2%',bottom:'2%'})
+          TextInput({ text: `${this.rgvEndX }`})
+            .width('85%')
+            .height('100%')
+            .backgroundColor('#000000')
+            .fontSize($r('app.float.fontSize_12'))
+            .fontColor($r('app.color.FFFFFF'))
+            .type(InputType.Number)
+            .maxLength(2)
+            .onChange((value: string) => {
+              let num = Number(value);
+              num = Math.max(1, Math.min(num, 9));
+              this.rgvEndX = num;
+            })
+        }
+        .backgroundColor($r('app.color.000000'))
+        .width('70%')
+        .height('40%')
+        .borderRadius($r('app.float.virtualSize_11_6'))
+
+        // 第二个X轴输入
+        Row() {
+          Text('Y轴')
+            .fontColor($r('app.color.30FFFFFF'))
+            .fontSize($r('app.float.fontSize_12'))
+            .width('15%')
+            .textAlign(TextAlign.Center)
+          Divider()
+            .vertical(true)
+            .strokeWidth(1)
+            .color($r('app.color.20FFFFFF'))
+            .margin({top:'2%',bottom:'2%'})
+
+          TextInput({ text: String(this.rgvEndY)})
+            .width('85%')
+            .height('100%')
+            .backgroundColor('#000000')
+            .fontSize($r('app.float.fontSize_12'))
+            .fontColor($r('app.color.FFFFFF'))
+            .type(InputType.Number)
+            .maxLength(2)
+            .onChange((value: string) => {
+              let num = Number(value);
+              num = Math.max(1, Math.min(num, 13));
+              this.rgvEndY = num;
+            })
+        }
+        .width('70%')
+        .height('40%')
+        .backgroundColor($r('app.color.000000'))
+        .borderRadius($r('app.float.virtualSize_11_6'))
+      }
+      .justifyContent(FlexAlign.SpaceBetween)
+      .height('35%')
+      .margin({bottom:'10%'})
+      // 按钮区域
+      Column(){
+        Divider()
+          .vertical(false)
+          .strokeWidth(1)
+          .color($r('app.color.20FFFFFF'))
+        Row(){
+          Row(){
+            Text('取消')
+              .fontColor($r('app.color.60FFFFFF'))
+              .fontSize($r('app.float.fontSize_12'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
+          .onClick(() => this.controller.close())
+          Divider()
+            .vertical(true)
+            .strokeWidth(1)
+            .color($r('app.color.20FFFFFF'))
+          Row(){
+            Text('确认')
+              .fontColor($r('app.color.007AFF'))
+              .fontSize($r('app.float.fontSize_12'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
+          .onClick(() => {
+            this.onConfirm();
+            this.controller.close();
+          })
+        }
+      }
+      .width('100%')
+      .height('15%')
+
+    }
+    .height('40%')
+    .width('30%')
+    .backgroundColor($r('app.color.2A2A2A'))
+    .justifyContent(FlexAlign.End)
+    .borderColor($r('app.color.000000'))
+    .borderWidth(1)
+    .borderRadius($r('app.float.virtualSize_11_6'))
+  }
+}

+ 287 - 172
entry/src/main/ets/pages/RgvControl.ets

@@ -5,8 +5,8 @@ import router from '@ohos.router';
 import {InfoRow} from '../component/RgvControlView'
 import RobotErrorHandleRequest from '../common/util/request/RobotErrorHandleRequest'
 import WorkOrderInfo from '../viewmodel/wms/WorkOrderInfo'
-import {RgvButton,RobotSelector,MoveControllerButton,CommonConfirmDialog}from "../component/RgvControlView"
-import {RobotInfo,RgvInfo,RequestParam} from "../params/RobotsParam"
+import {RgvButton,RobotSelector,MoveControllerButton,CommonConfirmDialog,MoveDialog}from "../component/RgvControlView"
+import {RobotInfo,RgvInfo,ErrorMessage,RequestParam,ConfirmDialogParams,RobotSingleMovePost} from "../params/RobotsParam"
 import CommonConstants from '../common/constants/CommonConstants'
 const TAG: string = 'RGV'
 @Entry
@@ -25,17 +25,223 @@ struct RgvControl {
   @State selectRobotIndex : number = 0
   @State axisNumberX : number = 0
   @State axisNumberY : number = 0
+  @State rgvEndX : number = 0
+  @State rgvEndY : number = 0
   @State rgvPosition : string = ""
   @State rgvBatteryLevel  : string = ""
   @State rgvCurrentStatus: string = ""
   @State rgvInfoInterval: number | null = null;
 
   commonDialogController: CustomDialogController | null = null;
-
-  // 显示通用确认弹窗
+  // rgv开机
+  executePowerOn = async()=>{
+    try {
+      // 第一步:开启电机
+      let res: object= await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        option: 'motor'
+      } as RequestParam);
+      console.log(TAG,'电机启动:' + res.toString());
+
+      // 第二步:延迟 5 秒后开启主电源
+      await delayExecution(async () => {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          option: 'mainPower'
+        } as RequestParam);
+        console.log(TAG,'主电源启动:' + res.toString());
+      }, 5000);
+
+      // 第三步:再延迟 5 秒后开启 MCU
+      await delayExecution(async () => {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          option: 'mcu'
+        } as RequestParam);
+        console.log(TAG,'MCU 启动:' + res.toString());
+      }, 5000);
+
+    } catch (error) {
+      console.error(TAG,'开机流程失败:', error);
+    }
+  }
+  // rgv关机
   executeShutdown=async()=>{
-    console.info(TAG,"dasdasdasdsa")
-}
+    try {
+      let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        option: 'off'
+      } as RequestParam);
+
+      await delayExecution(async () => {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          option: 'motor'
+        } as RequestParam);
+        console.log(TAG,'motor 关闭:' + res.toString());
+      }, 5000);
+
+
+      // 第二步:延迟 5 秒后开启主电源
+      await delayExecution(async () => {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          option: 'mainPower'
+        } as RequestParam);
+        console.log(TAG,'mainPower 关闭:' + res.toString());
+      }, 5000);
+
+      // 第三步:再延迟 5 秒后开启 MCU
+      await delayExecution(async () => {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          option: 'mcu'
+        } as RequestParam);
+        console.log(TAG,'MCU 关闭:' + res.toString());
+      }, 5000);
+
+    } catch (error) {
+      console.error(TAG,'关机流程失败:', error);
+    }
+  }
+
+  //清除错误
+  executeCleanError = async()=>{
+    try {
+      let res: ErrorMessage = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/clearRgvError', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+      } as RequestParam)
+      console.log(TAG,'清除错误:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'清除错误失败:', error);
+    }
+  }
+  //开始充电
+  executeStartCharge = async()=>{
+    try {
+      let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        option: 'on'
+      } as RequestParam)
+      console.log(TAG,'开始充电:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'开始充电失败:', error);
+    }
+  }
+
+  //开始充电
+  executeStopCharge = async()=>{
+    try {
+      let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        option: 'off'
+      } as RequestParam)
+      console.log(TAG,'手动充电结束:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'手动充电结束失败:', error);
+    }
+  }
+
+  //吊盘升降
+  executeHangingLifting = async()=>{
+    try {
+      let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/moveBasket', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        level: this.hangingIndex.toString(),
+      } as RequestParam)
+      console.log(TAG,'移动吊盘:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'移动吊盘失败:', error);
+    }
+  }
+
+  //爪夹张开
+  executePawOpen = async()=>{
+    try {
+      let res: object =  await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/controlClip', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        action: '1',
+      } as RequestParam)
+      console.log(TAG,'抓夹张开:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'抓夹张开失败:', error);
+    }
+  }
+
+  //爪夹闭合
+  executePawClose = async()=>{
+    try {
+      let res: object =  await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/controlClip', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        action: '2',
+      } as RequestParam)
+      console.log(TAG,'抓夹闭合:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'抓夹闭合失败:', error);
+    }
+  }
+
+  //终点移动
+  executeEndMove = async()=>{
+    try {
+      let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/movergv', {
+        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+        destX: this.rgvEndX.toString(),
+        destY: this.rgvEndY.toString()
+      } as RequestParam)
+      console.log(TAG,'终点移动位置:' + res.toString())
+    } catch (error) {
+      console.error(TAG,'终点移动位置:', error);
+    }
+  }
+
+  //位移移动
+  executeAxisMove = async () => {
+    try {
+      let res: object;
+      // X轴移动判断
+      if (this.axisNumberX > 0) {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          direction: 'x+',
+          len: Math.abs(this.axisNumberX).toString() // 取绝对值确保长度为正
+        } as RobotSingleMovePost);
+        console.log(TAG, `小车X正向移动:${res.toString()}`);
+      }
+      else if (this.axisNumberX < 0) {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          direction: 'x-',
+          len: Math.abs(this.axisNumberX).toString()
+        } as RobotSingleMovePost);
+        console.log(TAG, `小车X负向移动:${res.toString()}`);
+      }
+
+      // Y轴移动判断(只有当X轴不移动时才会执行)
+      else if (this.axisNumberY > 0) {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          direction: 'y+',
+          len: Math.abs(this.axisNumberY).toString()
+        } as RobotSingleMovePost);
+        console.log(TAG, `小车Y正向移动:${res.toString()}`);
+      }
+      else if (this.axisNumberY < 0) {
+        res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/singleStepMoveRgv', {
+          rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
+          direction: 'y-',
+          len: Math.abs(this.axisNumberY).toString()
+        } as RobotSingleMovePost);
+        console.log(TAG, `小车Y负向移动:${res.toString()}`);
+      }
+      else {
+        console.log(TAG, '未指定移动方向(X和Y均为0)');
+      }
+    } catch (error) {
+      console.error(TAG, '移动命令执行失败:', error);
+    }
+  }
+
   private showConfirmDialog(params: ConfirmDialogParams) {
     if (this.commonDialogController) {
       this.commonDialogController.close()
@@ -50,17 +256,23 @@ struct RgvControl {
         onConfirm: params.onConfirm
       }),
       cancel: () => console.log('用户取消操作'),
-      customStyle: true
+      customStyle: true,
+      maskColor: 'rgba(0,0,0,0.6)'
     });
 
     this.commonDialogController.open();
   }
 
   dialogController: CustomDialogController = new CustomDialogController({
-    builder: MoveDialog(),
+    builder: MoveDialog({
+      rgvEndX:this.rgvEndX,
+      rgvEndY:this.rgvEndY,
+      onConfirm: () => { this.executeEndMove()}
+    }),
     cancel: () => console.log('弹窗关闭'),
     autoCancel: true, // 点击遮罩关闭
-    customStyle:true
+    customStyle: true,
+    maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
 
   loadRgvSelection=()=>{
@@ -75,7 +287,10 @@ struct RgvControl {
   loadRgvInfo = async () => {
     let res: RgvInfo = await RobotErrorHandleRequest.get('/api/v1/wcs/rgv/' + this.robotsList[this.selectRobotIndex].robotCode, {}) as RgvInfo
     this.rgvPosition = `X=${res.x},Y=${res.y}`
-    this.rgvBatteryLevel = `${res.batlevel}}`
+    if(res.batlevel)
+    {
+      this.rgvBatteryLevel = `${parseFloat(res.batlevel).toFixed(0)}%`;
+    }
     let status: string = res.status ?? '';
     this.rgvCurrentStatus = `${this.rgvStatus[status] || '故障'}`;
     console.info(TAG,this.robotsList[this.selectRobotIndex].robotCode+ this.rgvPosition)
@@ -143,6 +358,13 @@ struct RgvControl {
             setTimeout(() => {
               this.scaleValue = 1; // 0.2秒后恢复
             }, 200);
+            this.showConfirmDialog({
+              title: '清除错误',
+              message: `确定要清除错误吗?`,
+              onConfirm: ()=> {
+                this.executeCleanError()
+              }
+            });
           })
         } .height('4%').width('100%').justifyContent(FlexAlign.Start)
 
@@ -196,11 +418,13 @@ struct RgvControl {
                 label:"额定负载:",
                 value:"20kg",
               })
-            }.justifyContent(FlexAlign.Start)//.margin({top:'5%',left:'5%'})
+            }.justifyContent(FlexAlign.Start).margin({left:'10%'})//.margin({top:'5%',left:'5%'})
             Column(){
               Text("切换仓储机器人")
                 .fontColor($r('app.color.FFFFFF'))
                 .fontSize($r('app.float.fontSize_8'))
+                .width('80%')
+                .textAlign(TextAlign.Start)
               // RobotSelector({robotsList:this.robotArray}).width('80%').height('95%').margin({top:'1%'})
               Select(this.robotArray)
                 .selected(0)
@@ -235,78 +459,26 @@ struct RgvControl {
                 text:"开机",
                 icon:$r('app.media.rgv_turn_on'),
                 onButtonClick: async () => {
-                  try {
-                    // 第一步:开启电机
-                    let res: object= await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
-                      rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                      option: 'motor'
-                    } as RequestParam);
-                    console.log(TAG,'电机启动:' + res.toString());
-
-                    // 第二步:延迟 5 秒后开启主电源
-                    await delayExecution(async () => {
-                      res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
-                        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                        option: 'mainPower'
-                      } as RequestParam);
-                      console.log(TAG,'主电源启动:' + res.toString());
-                    }, 5000);
-
-                    // 第三步:再延迟 5 秒后开启 MCU
-                    await delayExecution(async () => {
-                      res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOn', {
-                        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                        option: 'mcu'
-                      } as RequestParam);
-                      console.log(TAG,'MCU 启动:' + res.toString());
-                    }, 5000);
-
-                  } catch (error) {
-                    console.error('开机流程失败:', error);
-                  }
+                  this.showConfirmDialog({
+                    title: '开机确认',
+                    message: `确定要开启 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人吗?`,
+                    onConfirm: ()=> {
+                      this.executePowerOn()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'15%'})
               RgvButton({
                 text:"关机",
                 icon:$r('app.media.rgv_turn_off'),
                 onButtonClick: async () => {
-                  try {
-
-                    let res: object = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/TurnChargingSwitch', {
-                      rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                      option: 'off'
-                    } as RequestParam);
-
-                    await delayExecution(async () => {
-                      res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
-                      rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                      option: 'motor'
-                    } as RequestParam);
-                      console.log(TAG,'motor 关闭:' + res.toString());
-                    }, 5000);
-
-
-                    // 第二步:延迟 5 秒后开启主电源
-                    await delayExecution(async () => {
-                      res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
-                        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                        option: 'mainPower'
-                      } as RequestParam);
-                      console.log(TAG,'mainPower 关闭:' + res.toString());
-                    }, 5000);
-
-                    // 第三步:再延迟 5 秒后开启 MCU
-                    await delayExecution(async () => {
-                      res = await RobotErrorHandleRequest.post('/api/v1/wcs/rgv/rgvPowerOff', {
-                        rgvNo: this.robotsList[this.selectRobotIndex].robotCode,
-                        option: 'mcu'
-                      } as RequestParam);
-                      console.log(TAG,'MCU 关闭:' + res.toString());
-                    }, 5000);
-
-                  } catch (error) {
-                    console.error('关机流程失败:', error);
-                  }
+                  this.showConfirmDialog({
+                    title: '关机确认',
+                    message: `确定要关闭 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人吗?`,
+                    onConfirm: ()=> {
+                      this.executeShutdown()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'10%'})
             }.height('48%')
@@ -327,12 +499,26 @@ struct RgvControl {
                 text:"开始充电",
                 icon:$r('app.media.rgv_start_charge'),
                 onButtonClick: () => {
+                  this.showConfirmDialog({
+                    title: '开始充电确认',
+                    message: `确定要给 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人充电吗?`,
+                    onConfirm: ()=> {
+                      this.executeStartCharge()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'15%'})
               RgvButton({
                 text:"结束充电",
                 icon:$r('app.media.rgv_stop_charge'),
                 onButtonClick: () => {
+                  this.showConfirmDialog({
+                    title: '结束充电确认',
+                    message: `确定要结束 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人充电吗?`,
+                    onConfirm: ()=> {
+                      this.executeStopCharge()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'10%'})
             }.height('48%')
@@ -417,6 +603,13 @@ struct RgvControl {
                 text:"移动",
                 icon:$r('app.media.rgv_move'),
                 onButtonClick: () => {
+                  this.showConfirmDialog({
+                    title: '移动确认',
+                    message: `确定要移动 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人吗?`,
+                    onConfirm: ()=> {
+                      this.executeAxisMove()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'10%'})
             }.height('48%')
@@ -488,6 +681,13 @@ struct RgvControl {
                 text:`升降`,
                 icon:$r('app.media.rgv_lifting'),
                 onButtonClick: () => {
+                  this.showConfirmDialog({
+                    title: '移动吊盘确认',
+                    message: `确定要移动吊盘吗?`,
+                    onConfirm: ()=> {
+                      this.executeHangingLifting()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'10%'})
             }.height('48%')
@@ -509,11 +709,10 @@ struct RgvControl {
                 icon:$r('app.media.rgv_paw_open'),
                 onButtonClick: () => {
                   this.showConfirmDialog({
-                    title: '关机确认',
-                    message: `确定要关闭 ${this.robotsList[this.selectRobotIndex].robotCode} 机器人吗?`,
-                    confirmText: '确认关机',
+                    title: '爪夹张开确认',
+                    message: `确定要爪夹张开吗?`,
                     onConfirm: ()=> {
-                      this.executeShutdown()
+                      this.executePawOpen()
                     }
                   });
                 }
@@ -522,6 +721,13 @@ struct RgvControl {
                 text:"爪夹闭合",
                 icon:$r('app.media.rgv_paw_close'),
                 onButtonClick: () => {
+                  this.showConfirmDialog({
+                    title: '爪夹闭合确认',
+                    message: `确定要爪夹闭合吗?`,
+                    onConfirm: ()=> {
+                      this.executePawClose()
+                    }
+                  });
                 }
               }).height('16%').width('80%').margin({top:'10%'})
             }.height('48%')
@@ -539,90 +745,6 @@ struct RgvControl {
 }
 
 
-// 弹窗组件定义
-@CustomDialog
-struct MoveDialog {
-  @State xValue1: string = ''
-  @State xValue2: string = ''
-  controller: CustomDialogController
-
-  build() {
-    Column() {
-      Column(){
-        Text('终点移动')
-          .fontColor($r('app.color.FFFFFF'))
-          .fontSize($r('app.float.fontSize_15_2'))
-      }.height('20%')
-      .justifyContent(FlexAlign.Center)
-
-      Text('设置终点坐标')
-        .fontColor($r('app.color.FFFFFF'))
-        .fontSize(14)
-        .margin({ bottom: 24 })
-
-      // 输入区域
-      Column() {
-        // 第一个X轴输入
-        Column() {
-          Text('X轴')
-            .fontColor($r('app.color.FFFFFF'))
-            .fontSize(14)
-            .margin({ bottom: 8 })
-
-          TextInput({ text: this.xValue1 })
-            .width('100%')
-            .height(48)
-            .backgroundColor('#000000')
-            .fontColor($r('app.color.FFFFFF'))
-            .caretColor('#0A84FF')
-            .borderRadius(8)
-        }
-        .margin({ bottom: 20 })
-
-        // 第二个X轴输入
-        Column() {
-          Text('X轴')
-            .fontColor($r('app.color.FFFFFF'))
-            .fontSize(14)
-            .margin({ bottom: 8 })
-
-          TextInput({ text: this.xValue2 })
-            .width('100%')
-            .height(48)
-            .backgroundColor('#000000')
-            .fontColor($r('app.color.FFFFFF'))
-            .caretColor('#0A84FF')
-            .borderRadius(8)
-        }
-      }
-      .padding(16)
-
-      // 按钮区域
-      Flex({ justifyContent: FlexAlign.SpaceBetween }) {
-        Button('取消', { type: ButtonType.Normal })
-          .width('45%')
-          .backgroundColor('#333333')
-          .fontColor('#FFFFFF')
-          .onClick(() => this.controller.close())
-
-        Button('移动', { type: ButtonType.Normal })
-          .width('45%')
-          .backgroundColor('#0A84FF')
-          .fontColor('#FFFFFF')
-          .onClick(() => {
-            console.log(`移动至坐标: ${this.xValue1}, ${this.xValue2}`)
-            this.controller.close()
-          })
-      }
-      .width('100%')
-      .padding({ left: 16, right: 16, bottom: 24 })
-    }
-    .height(365)
-    .width(540)
-    .backgroundColor($r('app.color.2A2A2A'))
-    .borderRadius(16)
-  }
-}
 
 function delayExecution(callback: Function, delay: number): Promise<void> {
   return new Promise((resolve) => {
@@ -633,10 +755,3 @@ function delayExecution(callback: Function, delay: number): Promise<void> {
   });
 }
 
-interface ConfirmDialogParams {
-  title?: string
-  message: string
-  confirmText?: string
-  cancelText?: string
-  onConfirm: () => void
-}

+ 20 - 0
entry/src/main/ets/params/RobotsParam.ets

@@ -56,3 +56,23 @@ export  class RequestParam {
   destX?:string
   destY?:string
 }
+
+export interface ConfirmDialogParams {
+  title?: string
+  message: string
+  confirmText?: string
+  cancelText?: string
+  onConfirm: () => void
+}
+
+export class RobotSingleMovePost{
+  rgvNo?:string
+  direction?:string;
+  len?:string;
+}
+
+export class ErrorMessage{
+  code?:string
+  message?:string
+  data?:string
+}