| 1 |
- import{_ as e,c as s,a as t,w as l,F as i,d as a,r as c,i as o,o as d,j as n,t as r,m as p,I as u,u as h}from"./index-DT5wwjwL.js";import{U as y}from"./uni-icons.DYTdAnNN.js";import{U as m}from"./uni-popup.Op6c5J_7.js";const f={data:()=>({chassisType:0,IP:"192.168.40.62",isLoading:!1,isCycleRunning:!1,cycleTimer:null,currentCycleCmd:1,isCycleNum:0,cycleDelaySecond:10,cycleDelay:1e4,lineSpeed:.2,rotSpeed:.4}),onHide(){this.stopCycleTest(),this.sendStop()},onUnload(){this.stopCycleTest(),this.sendStop()},onLoad(){this.IP=localStorage.getItem("ip")},methods:{checkFloat(e){let s=this[e];"lineSpeed"===e?(s<0&&(this.lineSpeed=0),s>4&&(this.lineSpeed=4)):(s<0&&(this.rotSpeed=0),s>2&&(this.rotSpeed=2))},showNet(){this.$refs.mc.open("bottom")},closeMcPopup(){this.$refs.mc.close()},updateCycle(){this.cycleDelaySecond<0?a({title:"请输入你往返测试的时间",icon:"none"}):(this.cycleDelay=1e3*this.cycleDelaySecond,this.closeMcPopup(),this.startCycleTest())},sendStop(){const e=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:0,angular:0}});this.sendRequest(e),this.chassisType=5},goChassis(e){if(this.lineSpeed<0||this.lineSpeed>4)return void a({title:"直线速度范围0~4",icon:"none"});if(this.rotSpeed<0||this.rotSpeed>2)return void a({title:"旋转速度范围0~2",icon:"none"});if(5===e)return this.stopCycleTest(),void this.sendStop();if(this.chassisType==e)return;let s="";switch(e){case 1:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:this.lineSpeed,y_speed:0,angular:0}});break;case 2:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:this.lineSpeed,angular:0}});break;case 3:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:-this.lineSpeed,y_speed:0,angular:0}});break;case 4:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:-this.lineSpeed,angular:0}});break;case 5:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:0,angular:0}});break;case 6:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:0,angular:this.rotSpeed}});break;case 7:s=JSON.stringify({code:"",cmd:1015,msg:"",data:{x_speed:0,y_speed:0,angular:-this.rotSpeed}});break;default:s=""}s&&(this.sendRequest(s),this.chassisType=e)},sendRequest(e){c({url:"http://"+this.IP+":9002",method:"POST",header:{"Content-Type":"application/json"},data:e,fail:e=>console.error("底盘请求失败",e)})},toggleCycleTest(){this.isCycleRunning?this.stopCycleTest():this.showNet()},startCycleTest(){this.cycleTimer&&clearTimeout(this.cycleTimer),this.isCycleRunning=!0,this.currentCycleCmd=1,this.isCycleNum=0;const e=()=>{this.isCycleRunning&&(this.goChassis(this.currentCycleCmd),this.cycleTimer=setTimeout((()=>{this.currentCycleCmd=1===this.currentCycleCmd?3:1,this.isCycleNum++,e()}),this.cycleDelay))};e()},stopCycleTest(){this.isCycleRunning=!1,this.cycleTimer&&(clearTimeout(this.cycleTimer),this.cycleTimer=null),this.sendStop()}}},C=e(Object.assign(f,{__name:"remoteCtrl",setup:e=>(e,a)=>{const c=o,f=p,C=u,g=h;return d(),s(i,null,[t(c,{class:"container"},{default:l((()=>[t(c,{class:"footer"},{default:l((()=>[t(c,{class:"cxsm-wrap"},{default:l((()=>[t(c,{class:"control-wrap"},{default:l((()=>[t(c,{class:"direction-box"},{default:l((()=>[t(c,{class:"dir-btn top",onClick:a[0]||(a[0]=s=>e.goChassis(1))},{default:l((()=>[n("↑")])),_:1}),t(c,{class:"dir-btn right",onClick:a[1]||(a[1]=s=>e.goChassis(2))},{default:l((()=>[n("→")])),_:1}),t(c,{class:"dir-btn bottom",onClick:a[2]||(a[2]=s=>e.goChassis(3))},{default:l((()=>[n("↓")])),_:1}),t(c,{class:"dir-btn left",onClick:a[3]||(a[3]=s=>e.goChassis(4))},{default:l((()=>[n("←")])),_:1})])),_:1}),t(c,{class:"stop-btn",onClick:a[4]||(a[4]=s=>e.goChassis(5))},{default:l((()=>[t(f,null,{default:l((()=>[n("停止")])),_:1})])),_:1})])),_:1}),t(c,{class:"speed"},{default:l((()=>[t(f,null,{default:l((()=>[n("直线速度:")])),_:1}),t(C,{type:"number",step:"0.01",modelValue:e.lineSpeed,"onUpdate:modelValue":a[5]||(a[5]=s=>e.lineSpeed=s),modelModifiers:{number:!0},onInput:a[6]||(a[6]=s=>e.checkFloat("lineSpeed")),style:{border:"1px solid #ccc",padding:"8rpx",width:"140rpx"}},null,8,["modelValue"]),t(f,{style:{"margin-left":"20rpx"}},{default:l((()=>[n("旋转速度:")])),_:1}),t(C,{type:"number",step:"0.01",modelValue:e.rotSpeed,"onUpdate:modelValue":a[7]||(a[7]=s=>e.rotSpeed=s),modelModifiers:{number:!0},onInput:a[8]||(a[8]=s=>e.checkFloat("rotSpeed")),style:{border:"1px solid #ccc",padding:"8rpx",width:"140rpx"}},null,8,["modelValue"])])),_:1}),t(c,{class:"wrap-btn"},{default:l((()=>[t(g,{class:"red-button",onClick:a[9]||(a[9]=s=>e.goChassis(6))},{default:l((()=>[n("原地左转")])),_:1}),t(g,{class:"red-button",onClick:a[10]||(a[10]=s=>e.goChassis(7))},{default:l((()=>[n("原地右转")])),_:1}),t(g,{class:"red-button",onClick:e.toggleCycleTest},{default:l((()=>[n(r(e.isCycleRunning?"停止测试":"往返测试")+r(e.isCycleNum),1)])),_:1},8,["onClick"])])),_:1})])),_:1})])),_:1})])),_:1}),t(m,{ref:"mc",type:"bottom","background-color":"#fff","border-radius":"10px 10px 0 0",show:!0,onClose:e.closeMcPopup},{default:l((()=>[t(c,{style:{"border-bottom":"1rpx solid #E5E5E5",padding:"24rpx 0 32rpx","text-align":"center","font-weight":"bold","font-size":"17px"}},{default:l((()=>[n("返测试的时间设置")])),_:1}),t(c,{class:"flex-colomn"},{default:l((()=>[t(c,{class:"tet"},{default:l((()=>[t(f,{class:"bt_font"},{default:l((()=>[n("时间(秒)")])),_:1}),t(C,{class:"input",type:"number",placeholder:"请输入你往返测试的时间",modelValue:e.cycleDelaySecond,"onUpdate:modelValue":a[11]||(a[11]=s=>e.cycleDelaySecond=s)},null,8,["modelValue"])])),_:1}),t(c,{class:"tet_font"},{default:l((()=>[t(g,{class:"blue-button",onClick:a[12]||(a[12]=s=>e.updateCycle())},{default:l((()=>[n("保存")])),_:1})])),_:1}),t(y,{class:"close-btn",type:"closeempty",size:"20",onClick:e.closeMcPopup},null,8,["onClick"])])),_:1})])),_:1},8,["onClose"])],64)}}),[["__scopeId","data-v-3b3d69af"]]);export{C as default};
|