k5web/assets/index.d3b3f2da.js
2024-02-05 02:59:32 +08:00

2 lines
10 KiB
JavaScript

import{e as rt,q as lt,_ as ut}from"./index.a77b0867.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{d as it,r as pt,bU as ct,aU as dt,bB as _t,bN as ft,bC as mt,C as m,D as h,aI as s,aH as r,u as gt,aK as S,aJ as A,aE as C,aM as g,aN as D,G as bt,n as Y,bX as yt,ba as wt,aZ as Ft,b8 as ht,bD as xt,bM as St}from"./arco.f883ed21.js";import{e as $,s as At,f as p,h as c,g as Ct}from"./serial.3518333f.js";import{u as Dt}from"./loading.50b9fdaf.js";import"./chart.977fd17b.js";import"./vue.170d1f1d.js";const Bt={class:"container"},Et=["innerHTML"],Vt={name:"Sat"},Tt=it({...Vt,setup(vt){const{loading:tt,setLoading:b}=Dt(!0),a=rt(),t=pt({status:"\u70B9\u51FB\u5199\u5165\u6309\u94AE\u5199\u5165\u536B\u661F\u6570\u636E\u5230\u8BBE\u5907<br/><br/>",sat:"",satData:[],lng:0,lat:0,alt:0,tx:0,rx:0,txTone:0,rxTone:0,CTCSSOption:[67,69.3,71.9,74.4,77,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100,103.5,107.2,110.9,114.8,118.8,123,127.3,131.8,136.5,141.3,146.2,151.4,156.7,159.8,162.2,165.5,167.9,171.3,173.8,177.3,179.9,183.5,186.2,189.9,192.8,196.6,199.5,203.5,206.5,210.7,218.1,225.7,229.1,233.6,241.8,250.3,254.1],pass:void 0,passOption:[]}),at=async u=>{const e=t.satData.find(o=>o.name==u);e&&e.path&&(t.status+="<br/>\u536B\u661F\u53C2\u6570\uFF1A<br/>",e.path.map(o=>{t.status+=o+"<br/>"})),Y(()=>{const o=document==null?void 0:document.getElementById("statusArea");o&&(o.scrollTop=o==null?void 0:o.scrollHeight)})};(async()=>{b(!0);const e=(await(await fetch("https://celestrak.org/NORAD/elements/amateur.txt")).text()).split(/\r?\n/),o=[];let l={};for(let i=0;i<e.length;i++)Number.isNaN(parseInt(e[i].substring(0,1)))?(l.name&&l.name!=""&&(o.push(l),l={}),l.name=e[i]):(l.path||(l.path=[]),l.path.push(e[i]));t.satData=o,b(!1)})();const P=async()=>{b(!0),navigator.geolocation.getCurrentPosition(u=>{u.coords&&(t.lat=u.coords.latitude,t.lng=u.coords.longitude,u.coords.altitude&&(t.alt=u.coords.altitude))}),b(!1)};P();const et=async(u=0,e)=>{var o;await $(a.connectPort);for(let l=u;l<e.length+u;l+=128)await p(a.connectPort,l,e.slice(l-u,l-u+128),128,(o=a.configuration)==null?void 0:o.uart),t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((l-u)/e.length*100).toFixed(1)+"%<br/>",Y(()=>{const i=document==null?void 0:document.getElementById("statusArea");i&&(i.scrollTop=i==null?void 0:i.scrollHeight)});t.status=t.status+"\u5199\u5165\u8FDB\u5EA6\uFF1A100.0%<br/>",await Ct(a.connectPort)},ot=async()=>{if(!t.sat){alert("\u8BF7\u9009\u62E9\u536B\u661F\uFF01");return}b(!0);const u=await(await fetch("https://k5.vicicode.com/api/pass",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({sat:t.sat,sat_line_1:t.satData.find(o=>o.name==t.sat).path[0],sat_line_2:t.satData.find(o=>o.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt})})).json(),e=[];for(let o=0;o<u.pass_times.length;o++)try{let l;Date.parse(u.departure_times[o])-Date.parse(u.pass_times[o])>0?l=[u.pass_times[o],u.departure_times[o]]:l=[u.pass_times[o],u.departure_times[o+1]],e.push(l)}catch{}e.length>0?t.pass=e[0][0]+"|"+e[0][1]:t.pass=void 0,t.passOption=e,b(!1)},nt=async()=>{var U,k,O,N,L,H,j,M,R,J,q,z,G,K,X,Z,Q;if(a.connectState!=!0){alert("\u8BF7\u5148\u8FDE\u63A5\u624B\u53F0\uFF01");return}if(!t.pass){alert("\u8BF7\u9009\u62E9\u8FC7\u5883\u65F6\u95F4\uFF01");return}b(!0);const u=await(await fetch("https://k5.vicicode.com/api/doppler",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({sat:t.sat,sat_line_1:t.satData.find(w=>w.name==t.sat).path[0],sat_line_2:t.satData.find(w=>w.name==t.sat).path[1],lat:t.lat,lng:t.lng,alt:t.alt,tx:t.tx,rx:t.rx,pass_time:t.pass.split("|")[0],departure_time:t.pass.split("|")[1]})})).json(),e=t.sat,o=t.pass.split("|")[0],l=o.split("-")[0].substring(2,4),i=o.split("-")[1],_=o.split("-")[2].split(" ")[0],y=o.split(" ")[1].split(":")[0],F=o.split(" ")[1].split(":")[1],B=o.split(" ")[1].split(":")[2],f=t.pass.split("|")[1],E=f.split("-")[0].substring(2,4),V=f.split("-")[1],T=f.split("-")[2].split(" ")[0],v=f.split(" ")[1].split(":")[0],n=f.split(" ")[1].split(":")[1],st=f.split(" ")[1].split(":")[2];await $(a.connectPort);let d=new Uint8Array(10);d.set(At(e.trim()).subarray(0,9)),await p(a.connectPort,11168,d,10,(U=a.configuration)==null?void 0:U.uart),await p(a.connectPort,11178,c(parseInt(l).toString(16)).subarray(0,1),1,(k=a.configuration)==null?void 0:k.uart),await p(a.connectPort,11179,c(parseInt(i).toString(16)).subarray(0,1),1,(O=a.configuration)==null?void 0:O.uart),await p(a.connectPort,11180,c(parseInt(_).toString(16)).subarray(0,1),1,(N=a.configuration)==null?void 0:N.uart),await p(a.connectPort,11181,c(parseInt(y).toString(16)).subarray(0,1),1,(L=a.configuration)==null?void 0:L.uart),await p(a.connectPort,11182,c(parseInt(F).toString(16)).subarray(0,1),1,(H=a.configuration)==null?void 0:H.uart),await p(a.connectPort,11183,c(parseInt(B).toString(16)).subarray(0,1),1,(j=a.configuration)==null?void 0:j.uart),await p(a.connectPort,11184,c(parseInt(E).toString(16)).subarray(0,1),1,(M=a.configuration)==null?void 0:M.uart),await p(a.connectPort,11185,c(parseInt(V).toString(16)).subarray(0,1),1,(R=a.configuration)==null?void 0:R.uart),await p(a.connectPort,11186,c(parseInt(T).toString(16)).subarray(0,1),1,(J=a.configuration)==null?void 0:J.uart),await p(a.connectPort,11187,c(parseInt(v).toString(16)).subarray(0,1),1,(q=a.configuration)==null?void 0:q.uart),await p(a.connectPort,11188,c(parseInt(n).toString(16)).subarray(0,1),1,(z=a.configuration)==null?void 0:z.uart),await p(a.connectPort,11189,c(parseInt(st).toString(16)).subarray(0,1),1,(G=a.configuration)==null?void 0:G.uart),d=new Uint8Array(2),d.set(c(((Date.parse(f)-Date.parse(o))/1e3).toString(16)).subarray(0,2)),await p(a.connectPort,11190,d,2,(K=a.configuration)==null?void 0:K.uart),d=new Uint8Array(2),t.txTone&&t.txTone>0&&d.set(c(t.txTone.toString(16)).subarray(0,2)),await p(a.connectPort,11192,d,2,(X=a.configuration)==null?void 0:X.uart),d=new Uint8Array(2),t.rxTone&&t.rxTone>0&&d.set(c(t.rxTone.toString(16)).subarray(0,2)),await p(a.connectPort,11194,d,2,(Z=a.configuration)==null?void 0:Z.uart),d=new Uint8Array(4),d.set(c(((Date.parse(o)-Date.parse("2000-01-01 00:00:00"))/1e3).toString(16)).subarray(0,4)),await p(a.connectPort,11196,d,4,(Q=a.configuration)==null?void 0:Q.uart);const I=[];u.shift_array.filter((w,x)=>x%2===0).map(w=>{const x=new Uint8Array(4),W=new Uint8Array(4);x.set(c(parseInt(((t.tx*1e6+w[0])/10).toFixed(0)).toString(16))),W.set(c(parseInt(((t.rx*1e6+w[1])/10).toFixed(0)).toString(16))),I.push(...x,...W)}),d=new Uint8Array(7680),d.set(new Uint8Array(I).subarray(0,7680)),await et(123392,d),b(!1)};return(u,e)=>{const o=lt,l=yt,i=ct,_=wt,y=dt,F=Ft,B=ht,f=_t,E=ft,V=mt,T=xt,v=St;return m(),h("div",Bt,[s(o,{items:["\u5C0F\u5DE5\u5177","\u536B\u661F\u5199\u5165"]}),s(v,{gutter:20,align:"stretch"},{default:r(()=>[s(T,{span:24},{default:r(()=>[s(V,{class:"general-card",title:"\u536B\u661F\u5199\u5165"},{default:r(()=>[s(E,{loading:gt(tt),style:{width:"100%"},tip:"\u6B63\u5728\u5904\u7406 ..."},{default:r(()=>[s(_,{"label-col-style":{width:"25%"},field:"sat",label:"\u9009\u62E9\u536B\u661F"},{default:r(()=>[s(i,{modelValue:t.sat,"onUpdate:modelValue":e[0]||(e[0]=n=>t.sat=n),onChange:at,placeholder:"\u9009\u62E9\u536B\u661F ...","allow-search":"","allow-clear":""},{default:r(()=>[(m(!0),h(S,null,A(t.satData,n=>(m(),C(l,{key:n.name,value:n.name},{default:r(()=>[g(D(n.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"lng",label:"\u53F0\u7AD9\u7ECF\u5EA6"},{default:r(()=>[s(y,{precision:6,modelValue:t.lng,"onUpdate:modelValue":e[1]||(e[1]=n=>t.lng=n)},null,8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"lat",label:"\u53F0\u7AD9\u7EAC\u5EA6"},{default:r(()=>[s(y,{precision:6,modelValue:t.lat,"onUpdate:modelValue":e[2]||(e[2]=n=>t.lat=n)},null,8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"alt",label:"\u53F0\u7AD9\u6D77\u62D4"},{default:r(()=>[s(y,{precision:0,modelValue:t.alt,"onUpdate:modelValue":e[3]||(e[3]=n=>t.alt=n)},null,8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},label:""},{default:r(()=>[s(B,null,{default:r(()=>[s(F,{onClick:P},{default:r(()=>[g("\u6D4F\u89C8\u5668\u83B7\u53D6\u7ECF\u7EAC\u5EA6")]),_:1}),s(F,{onClick:ot},{default:r(()=>[g("\u83B7\u53D6\u536B\u661F\u8FC7\u5883\u65F6\u95F4")]),_:1})]),_:1})]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"pass",label:"\u9009\u62E9\u8FC7\u5883\u65F6\u95F4"},{default:r(()=>[s(i,{modelValue:t.pass,"onUpdate:modelValue":e[4]||(e[4]=n=>t.pass=n),"allow-search":"","allow-clear":""},{default:r(()=>[(m(!0),h(S,null,A(t.passOption,n=>(m(),C(l,{key:n[0]+"|"+n[1],value:n[0]+"|"+n[1]},{default:r(()=>[g(D(n[0]+" - "+n[1]),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"tx",label:"\u4E0A\u884C\u9891\u7387"},{default:r(()=>[s(y,{precision:5,modelValue:t.tx,"onUpdate:modelValue":e[5]||(e[5]=n=>t.tx=n)},null,8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"txTone",label:"\u4E0A\u884C\u4E9A\u97F3"},{default:r(()=>[s(i,{modelValue:t.txTone,"onUpdate:modelValue":e[6]||(e[6]=n=>t.txTone=n),"allow-search":"","allow-clear":""},{default:r(()=>[s(l,{value:0},{default:r(()=>[g("\u5173\u95ED")]),_:1}),(m(!0),h(S,null,A(t.CTCSSOption,n=>(m(),C(l,{key:n,value:n},{default:r(()=>[g(D(n.toFixed(1)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"rx",label:"\u4E0B\u884C\u9891\u7387"},{default:r(()=>[s(y,{precision:5,modelValue:t.rx,"onUpdate:modelValue":e[7]||(e[7]=n=>t.rx=n)},null,8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},field:"rxTone",label:"\u4E0B\u884C\u4E9A\u97F3"},{default:r(()=>[s(i,{modelValue:t.rxTone,"onUpdate:modelValue":e[8]||(e[8]=n=>t.rxTone=n),"allow-search":"","allow-clear":""},{default:r(()=>[s(l,{value:0},{default:r(()=>[g("\u5173\u95ED")]),_:1}),(m(!0),h(S,null,A(t.CTCSSOption,n=>(m(),C(l,{key:n,value:n},{default:r(()=>[g(D(n.toFixed(1)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])]),_:1}),s(_,{"label-col-style":{width:"25%"},label:""},{default:r(()=>[s(F,{onClick:nt},{default:r(()=>[g("\u5199\u5165\u6570\u636E")]),_:1})]),_:1}),s(f),bt("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px"},innerHTML:t.status},null,8,Et)]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1})])}}});const Xt=ut(Tt,[["__scopeId","data-v-bfa7c89c"]]);export{Xt as default};