import{_ as h,S as u,r as d,o as p,c as m,a as o,b as c,w as P,v as _}from"./index.822181e6.js";const f={components:{SVGAngle:u},data(){return{maxPosValue:4095,requiredPosition:this.requiredPosition,realPosition:0}},computed:{host(){return location.hostname},RequiredPositionDegrees(){return this.requiredPosition*360/this.maxPosValue},RrealPositionDegrees(){return this.realPosition*360/this.maxPosValue}},mounted(){this.timerId=setInterval(()=>this.getPosition(),100)},unmounted(){clearInterval(this.timerId)},methods:{fetch_execute:async function(t,e,s,r){try{let n=await(await fetch(t,e)).json();s&&s(n)}catch(i){r&&r(i)}finally{}},setPosition(){let t=[0,60,0,0,0,0,0,0];t[2]=Math.trunc(this.requiredPosition/255),t[3]=this.requiredPosition-t[2]*255;let e="http://"+this.host+":5000/packet/"+t.join("/");this.fetch_execute(e,{method:"GET",credentials:"same-origin",cache:"no-cache"},s=>{},s=>{console.log(s)})},sendPositionRequest(){let t=[0,61,0,0,0,0,0,0],e="http://"+this.host+":5000/packet/"+t.join("/");this.fetch_execute(e,{method:"GET",credentials:"same-origin",cache:"no-cache"},s=>{},s=>{console.log(s)})},getPosition(){let t="http://"+this.host+":5000/packets/";this.fetch_execute(t,{method:"GET",credentials:"same-origin",cache:"no-cache"},e=>{if(e.packets!=null&&typeof e.packets[0]!="undefined"){this.realPosition=e.packets[0][2]*255+e.packets[0][3];let s=e.packets[0][4]*255+e.packets[0][5];this.requiredPosition==null&&(this.requiredPosition=s)}this.sendPositionRequest()},e=>{console.log(e)})}},watch:{requiredPosition(){this.setPosition()}}},v=o("h1",null,"Position example",-1),g={class:"row"},q={class:"col-md pt-3"},x=o("h2",null,"Required Position",-1),k={class:"col-md pt-3"},V=o("h2",null,"Real Position",-1),w={class:"row"},R={class:"col-md pt-3"},G=["max"];function y(t,e,s,r,i,n){const l=d("SVGAngle");return p(),m("div",null,[v,o("div",g,[o("div",q,[x,c(l,{value:n.RequiredPositionDegrees},null,8,["value"])]),o("div",k,[V,c(l,{value:n.RrealPositionDegrees},null,8,["value"])])]),o("div",w,[o("div",R,[P(o("input",{"onUpdate:modelValue":e[0]||(e[0]=a=>i.requiredPosition=a),type:"range",min:"0",max:i.maxPosValue,step:"1",class:"w-100"},null,8,G),[[_,i.requiredPosition]])])])])}var I=h(f,[["render",y]]);export{I as default};