import{m as V}from"./mqtt.esm-DNZjafBp.js";import{u as Q,r as c,o as q,a as N,c as P,b as t,t as d,d as u,F as H,e as T}from"./index-BkEAVEI4.js";const z={class:"container my-5"},R={class:"row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg"},j={class:"col-lg-7 p-3 p-lg-5 pt-lg-3"},G=t("h1",{class:"display-4 fw-bold lh-1 text-body-emphasis"},"智能交互花盆",-1),J={class:"row row-cols-3 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 py-5"},K={class:"fw-bold mb-0 fs-4 white-text"},W={class:"fw-bold mb-0 fs-4 white-text"},X={class:"fw-bold mb-0 fs-4 white-text"},Y=t("div",{class:"col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg"},null,-1),Z={class:"container px-4 py-5",id:"icon-grid"},tt=t("h2",{class:"pb-2 border-bottom fw-bold"},"AI引擎",-1),et=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AUTO自动控制",-1),st=t("p",null,"开启本功能,将启用AI自动控制模式,由AI模型进行自动化管理",-1),ot=[et,st],lt={class:"row row-cols-2 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 py-5"},nt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AI对话",-1),it=t("p",null,"为植物生成交互模型",-1),ct=[nt,it],at={class:"col d-flex align-items-start"},dt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AI生长预测",-1),ut=t("p",null,"为植物预测生长方向",-1),rt=[dt,ut],bt=t("h2",{class:"pb-2 border-bottom fw-bold"},"控制台",-1),mt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"环境恒温",-1),gt=t("p",null,"为植物土壤开启恒温模式",-1),pt=[mt,gt],ht=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"环境光照",-1),_t=t("p",null,"将为植物开启光合作用",-1),vt=[ht,_t],wt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"自动浇水",-1),ft=t("p",null,"土壤湿度不足时自动浇水",-1),yt=[wt,ft],Tt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"更新检查",-1),xt=t("p",null,"检测花盆版本,固件更新",-1),It=[Tt,xt],Lt={__name:"ControlView",setup(Ot){document.title="Flowerpot控制中心";const x=Q(),n=c(x.query.inputValue),I=c(n.value.match(/fp(\d+)/)[1]);let h=c(null),_=c(null),v=c(null);const O=c(null);let F=c([]),e=null,w=c("离线"),f=null,r=null,b=null,m=null,g=null;q(()=>{U()});const U=()=>{e=V.connect("mqtt://23.95.222.237:1883",{clientId:"ViteVueTest"}),e.on("connect",()=>{console.log("已连接到 MQTT 代理"),e.subscribe("Flowerpot")}),e.on("message",(i,s)=>{const a=s.toString(),p=a.indexOf("#"),y=a.indexOf("#",p+1);if(p!==-1&&y!==-1&&a.substring(p+3,y)===I.value){w.value="在线";const l=a.split("#");if(O.value=l[8].toString(),h=l[2].toString(),v=l[3].toString(),_=l[4].toString(),l[9].toString()!=="0"){const o=document.getElementById("autobt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),r=1}else{const o=document.getElementById("autobt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),r=0}if(l[6].toString()!=="0"){const o=document.getElementById("tempbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),b=1}else{const o=document.getElementById("tempbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),b=0}if(l[5].toString()!=="0"){const o=document.getElementById("waterbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),m=1}else{const o=document.getElementById("waterbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),m=0}if(l[7].toString()!=="0"){const o=document.getElementById("lightbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),g=1}else{const o=document.getElementById("lightbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),g=0}let E=l[8].charAt(0),S=l[8].charAt(1),$=l[8].charAt(2),k=`V${E}.${S}.${$}`;f=c(k),console.log("分割后的数值:",l),console.log("接收到符合条件的消息:",a),F.value.push(a)}})},L=()=>{if(r==0)if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&ONAUTO`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。");else if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&OFFAUTO`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。")},M=()=>{if(b==0)if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&ONHOT`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。");else if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&OFFHOT`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。")},D=()=>{if(m==0)if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&ONPUMP`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。");else if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&OFFPUMP`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。")},A=()=>{if(g==0)if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&ONLED`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。");else if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&OFFLED`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接断开。")},B=()=>{T.push({path:"/update",query:{inputValue:n.value}})},C=()=>{T.push({path:"/aichat",query:{}})};return(i,s)=>(N(),P(H,null,[t("div",z,[t("div",R,[t("div",j,[G,t("h3",null,"设备ID:"+d(n.value),1),t("h3",null,"设备状态:"+d(u(w)),1),t("h3",null,"固件版本:"+d(u(f)),1),t("div",J,[t("h3",K,"环境湿度:"+d(u(v))+"%",1),t("h3",W,"环境温度:"+d(u(h))+"°C",1),t("h3",X,"土壤湿度:"+d(u(_))+"%",1)])]),Y])]),t("div",Z,[tt,t("div",{class:"col row-cols-1 d-flex align-items-start"},[t("div",null,[t("button",{onClick:L,type:"button",id:"autobt",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},ot)])]),t("div",lt,[t("div",{class:"col d-flex align-items-start"},[t("div",null,[t("button",{onClick:C,type:"button",id:"aichat",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},ct)])]),t("div",at,[t("div",null,[t("button",{onClick:s[0]||(s[0]=(...a)=>i.aigrow&&i.aigrow(...a)),type:"button",id:"aigrow",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},rt)])])]),bt,t("div",{class:"row row-cols-2 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 py-5"},[t("div",{class:"col d-flex align-items-start"},[t("div",null,[t("button",{onClick:M,type:"button",id:"tempbt",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},pt)])]),t("div",{class:"col d-flex align-items-start"},[t("div",null,[t("button",{onClick:A,type:"button",id:"lightbt",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},vt)])]),t("div",{class:"col d-flex align-items-start"},[t("div",null,[t("button",{onClick:D,type:"button",id:"waterbt",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},yt)])]),t("div",{class:"col d-flex align-items-start"},[t("div",null,[t("button",{onClick:B,type:"button",id:"updatebt",class:"btn btn-outline-secondary btn-lg px-4 me-md-2"},It)])])])])],64))}};export{Lt as default};