k5web/assets/index.ed153a06.js
2024-07-01 22:26:38 +08:00

2 lines
7.2 KiB
JavaScript

import{m as K,ak as j,_ as G}from"./index.3745f9af.js";/* empty css *//* empty css *//* empty css */import{d as W,r as Z,o as q,bI as Q,C as f,D as E,aI as c,aH as i,aM as m,aN as h,G as d,aK as x,aJ as S,F as D,aE as X,u as Y,a6 as ee,a$ as te,ba as oe,bJ as ae,bL as ne,be as re,bf as le,n as se}from"./arco.7f845a67.js";import{u as ie}from"./loading.1a4e75f4.js";import{i as ce,e as ue,s as M,h as N,g as de,l as pe,b as me}from"./serial.c6b76da8.js";import{B as _e}from"./index.9569a401.js";import{I as ge}from"./index.4da4cb96.js";import{C as fe}from"./index.10935cc5.js";import{S as he}from"./index.1722d344.js";import"./chart.3e6cb2f1.js";import"./vue.0bef8fc5.js";import"./useConfig.d93d68c1.js";import"./index.8a14470a.js";import"./helper.38552a88.js";import"./useDisabled.f946fc31.js";import"./useGlobalIcon.68d734e0.js";import"./slot.e92e5310.js";const B=F=>(re("data-v-46560f86"),F=F(),le(),F),Fe={class:"container"},be=B(()=>d("div",{style:{color:"red","font-weight":"bold"}},"\u26A0\uFF1A\u5B9E\u9A8C\u6027\u529F\u80FD \u4F7F\u7528\u53EF\u80FD\u4F1A\u635F\u574F\u624B\u53F0",-1)),we={style:{display:"flex","justify-content":"space-between","margin-left":"10px","margin-right":"10px","align-items":"flex-end","margin-bottom":"3px"}},ye=B(()=>d("div",null,"EEPROM\uFF1A",-1)),Ae={style:{width:"100%",overflow:"scroll","user-select":"none"}},Ee={style:{height:"328px",display:"flex","flex-direction":"column",margin:"0",padding:"0","flex-wrap":"wrap"}},ve=["onClick","ondragover","ondrop","title"],Ce=B(()=>d("br",null,null,-1)),Be=["innerHTML"],ke={name:"BL"},xe=W({...ke,setup(F){const p=K(),{loading:U,setLoading:b}=ie(!0),t=Z({calendar:[],rom:[],bl:void 0,nowDrag:-1,showAdd:"",status:""}),_=async(e=0,o,n="")=>{var s;for(let r=e;r<o.length+e;r+=192)await me(p.connectPort,r,o.slice(r-e,r-e+192),o.slice(r-e,r-e+192).length,(s=p.configuration)==null?void 0:s.uart),t.status=t.status+n+"\u5199\u5165\u8FDB\u5EA6\uFF1A"+((r-e)/o.length*100).toFixed(1)+"%<br/>",se(()=>{const a=document==null?void 0:document.getElementById("statusArea");a&&(a.scrollTop=a==null?void 0:a.scrollHeight)})},$=async e=>{t.showAdd=(e*64+262144).toString(16).toUpperCase(),setTimeout(()=>{t.showAdd=""},5e3)};q(()=>{L();const e=[];for(let o=0;o<262144/64;o++)o<278528/64/16-16?e.push(-2):e.push(-1);t.calendar=e});const L=async()=>{const e=await fetch("/L_BL001.bin");if(e.body){const o=e.body.getReader(),n=[];for(;;){const{done:r,value:a}=await o.read();if(r)break;n.push(...a)}let s=new Uint8Array(12288);s.set(n,0),t.bl=s,b(!1)}},I=async()=>{var r;if(p.connectState!=!0){alert(sessionStorage.getItem("noticeConnectK5"));return}const e=await ce(p.connectPort,(r=p.configuration)==null?void 0:r.uart);if(b(!0),e<524288){alert("\u53EA\u652F\u6301 4Mbit \u4EE5\u4E0A EEPROM \u5199\u5165"),b(!1);return}await ue(p.connectPort),await _(266240,t.bl,"\u5F15\u5BFC\u7A0B\u5E8F");const o=[];for(let a=256;a<4096;a++)t.calendar[a]>=0&&(console.log(a),o.push({...t.rom[t.calendar[a]],start:262144+a*64,end:262144+(a+Math.ceil(t.rom[t.calendar[a]].binaryFile.length/64))*64-1}),a+=Math.ceil(t.rom[t.calendar[a]].binaryFile.length/64)-1);await _(262144,new Uint8Array([o.length]),"\u56FA\u4EF6\u6570\u91CF");const n=new Uint8Array(8);n.set(M("L_BL001")),await _(262152,n,"\u5F15\u5BFC\u7A0B\u5E8F\u7248\u672C");const s=[];o.map(a=>{const w=new Uint8Array(16),y=new Uint8Array(4),A=new Uint8Array(4);w.set(M(a.binaryName)),y.set(N(a.start.toString(16))),A.set(N(a.end.toString(16))),s.push(...w,...y,...A,...new Uint8Array(8))}),await _(262176,s,"\u56FA\u4EF6\u5143\u6570\u636E");for(let a=0;a<o.length;a++)await _(o[a].start,o[a].binaryFile,o[a].binaryName+" \u56FA\u4EF6\u6587\u4EF6");await de(p.connectPort),b(!1)},P=()=>{const e=document.createElement("input");e.type="file",e.onchange=async()=>{if(e.files){const o=new Blob([e.files[0]],{type:"application/octet-stream"}),n=new Uint8Array(await o.arrayBuffer()),s={binaryFile:pe(n),binaryName:e.files[0].name,color:T()};t.rom.push(s)}},e.click()},R=(e,o)=>{if(!(o<256)&&!(o+Math.ceil(t.rom[t.nowDrag].binaryFile.length/64)>4096)&&e!=2){for(let n=o;n<o+Math.ceil(t.rom[t.nowDrag].binaryFile.length/64);n+=1)v(n);for(let n=o;n<o+Math.ceil(t.rom[t.nowDrag].binaryFile.length/64);n+=1)t.calendar[n]=t.nowDrag;console.log((o*64+262144).toString(16)),console.log((Math.ceil(t.rom[t.nowDrag].binaryFile.length/64)*64+(o*64+262144)-1).toString(16))}},T=()=>{for(var e="0123456789ABCDEF",o="#",n=0;n<6;n++)o+=e[Math.floor(Math.random()*16)];return o},v=e=>{if(e>4095||e<256)return;let o=0;t.calendar[e]!=-1&&(o=1,t.calendar[e]=-1),o&&(t.calendar[e-1]!=-1&&v(e-1),t.calendar[e+1]!=-1&&v(e+1))},C=e=>{if(e>4095||e<256)return;let o=-99;t.calendar[e]!=-1&&(o=t.calendar[e],t.calendar[e]=-1),t.calendar[e-1]===o&&C(e-1),t.calendar[e+1]===o&&C(e+1)},k=e=>{e>4095||e<256||(t.calendar[e]=-1,k(e+1))},V=e=>{t.rom[e].binaryName=t.rom[e].binaryName.replace(/[^\a-\z\A-\Z0-9.]/g,"")};return(e,o)=>{const n=j,s=ee,r=te,a=oe,w=ae,y=ne,A=_e,z=ge,O=fe,H=he,J=Q;return f(),E("div",Fe,[c(n,{items:[e.$t("menu.list"),e.$t("bl")]},null,8,["items"]),c(J,{class:"general-card",loading:Y(U)},{title:i(()=>[be,m(" "+h(e.$t("bl"))+" "+h(e.$t("global.onStart")),1)]),default:i(()=>[c(y,{style:{"margin-bottom":"16px"}},{default:i(()=>[c(w,{span:12},{default:i(()=>[c(a,{style:{width:"130%"}},{default:i(()=>[c(r,{onClick:I},{icon:i(()=>[c(s)]),default:i(()=>[m(" "+h(e.$t("cps.onDeviceWrite")),1)]),_:1}),m(" \uFF08\u56FA\u4EF6\u540D\u79F0\u4EC5\u652F\u6301\u82F1\u6587\uFF09 ")]),_:1})]),_:1})]),_:1}),d("div",we,[ye,d("div",null,[m(h(t.showAdd)+" ",1),c(A,{size:"small",variant:"outline",onClick:o[0]||(o[0]=l=>k(256))},{default:i(()=>[m("\u6E05\u7A7A")]),_:1})])]),d("div",Ae,[d("div",Ee,[(f(!0),E(x,null,S(t.calendar,(l,u)=>(f(),E("div",{onClick:g=>C(u),ondragover:g=>{$(u),g.preventDefault()},ondrop:()=>{R(l,u)},title:l==-2?"\u5F15\u5BFC\u7A0B\u5E8F\u5360\u7528\u533A":l!=-1?t.rom[l].binaryName:(u*64+262144).toString(16).toUpperCase()+" - "+(u*64+262144+63).toString(16).toUpperCase(),style:D(l==-1?"background-color: white; border: 1px solid #ddd; height: 10px;":l==-2?"background-color: #373737; border: 1px solid #ddd; height: 10px;":"background-color: "+t.rom[l].color+"; border: 1px solid #ddd; height: 10px;"),key:u}," \xA0 ",12,ve))),128))])]),c(r,{style:{"margin-bottom":"10px"},onClick:P},{default:i(()=>[m(h(t.binaryFile?t.binaryName:e.$t("tool.selectFirmware")),1)]),_:1}),m("\uFF08\u9009\u62E9\u56FA\u4EF6\u540E\u5C06\u56FA\u4EF6\u5361\u7247\u62D6\u62FD\u5230\u4E0A\u65B9 EEPROM\uFF09 "),Ce,c(H,{"break-line":""},{default:i(()=>[(f(!0),E(x,null,S(t.rom,(l,u)=>(f(),X(O,{draggable:"true",ondragstart:()=>{t.nowDrag=u},title:l.binaryName,bordered:!0,"hover-shadow":"",style:{width:"400px"}},{actions:i(()=>[d("div",{style:D("width: 10px; height: 10px; background-color: "+l.color+";")},null,4)]),default:i(()=>[c(z,{modelValue:l.binaryName,"onUpdate:modelValue":g=>l.binaryName=g,onChange:g=>V(u),"show-limit-number":"",maxlength:13},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["ondragstart","title"]))),256))]),_:1})]),_:1},8,["loading"]),d("div",{id:"statusArea",style:{height:"20em","background-color":"azure",color:"silver",overflow:"auto",padding:"20px","margin-top":"10px"},innerHTML:t.status},null,8,Be)])}}});const We=G(xe,[["__scopeId","data-v-46560f86"]]);export{We as default};