import{p as v,v as B,aj as I,y as r,a9 as O,an as f,z as F,ao as L,f as k,o as h,c as g,a as s,h as d,t as w,w as x,Y as V,K as S,F as N,am as P}from"./index-fLiXr-6R.js";const U={class:"flex flex-col"},W={class:"card"},R={class:"flex flex-co items-center flex-col md:flex-row justify-between gap-3"},M={class:"font-bold"},q={class:"flex gap-3"},j={class:"card"},$={class:"flex gap-3 w-auto h-svh border-primary dark:border-primary-800 border-2"},z=v({__name:"SensorDetails",setup(H){const o=B(),c=I(),n=r(!1),_=r(!1),p=O(()=>document.documentElement.classList.contains("dark")),A=r({automaticLayout:!0,formatOnType:!0,formatOnPaste:!0,cursorSmoothCaretAnimation:!0,renderWhitespace:"boundary",fontSize:14,wordWrap:"on",theme:p.value?"vs-dark":"vs"}),l=r(`[[inputs.modbus]]

  name = "PM3133"

  ## Slave ID - addresses a MODBUS device on the bus
  ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved]
  slave_id = 1

  ## Timeout for each request
  timeout = "1s"

  # TCP - connect via Modbus/TCP
  controller = "tcp://IP-ADDRESS:502"

  input_registers = [
    { name = "wiring_type",   byte_order = "AB",   data_type = "UINT16",   scale=1.0,     address = [512]},
    { name = "phase_seq",   byte_order = "AB",   data_type = "UINT16",   scale=1.0,     address = [513]},
    { name = "model_name",   byte_order = "AB",   data_type = "UINT16",   scale=1.0,     address = [514]},
    { name = "mode_type",   byte_order = "AB",   data_type = "UINT16",   scale=1.0,     address = [515]},
    { name = "Volt_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4353,4354]},
    { name = "Amp_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4355,4356]},
    { name = "kW_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4357,4358]},
    { name = "kvar_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4359,4360]},
    { name = "kVA_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4361,4362]},
    { name = "PF_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4363,4364]},
    { name = "kWh_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4365,4366]},
    { name = "kvarh_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4367,4368]},
    { name = "kVah_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4369,4370]},
    { name = "Freq_a",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4425,4426]},
    { name = "Volt_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4371,4372]},
    { name = "Amp_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4373,4374]},
    { name = "kW_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4375,4376]},
    { name = "kvar_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4377,4378]},
    { name = "kVA_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4379,4380]},
    { name = "PF_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4381,4382]},
    { name = "kWh_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4383,4384]},
    { name = "kvarh_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4385,4386]},
    { name = "kVah_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4387,4388]},
    { name = "Freq_b",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4427,4428]},
    { name = "Volt_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4389,4390]},
    { name = "Amp_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4391,4392]},
    { name = "kW_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4393,4394]},
    { name = "kvar_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4395,4396]},
    { name = "kVA_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4397,4398]},
    { name = "PF_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4399,4400]},
    { name = "kWh_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4401,4402]},
    { name = "kvarh_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4403,4404]},
    { name = "kVah_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4405,4406]},
    { name = "Freq_c",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4429,4430]},
    { name = "V_avg",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4407,4408]},
    { name = "I_avg",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4409,4410]},
    { name = "kW_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4411,4412]},
    { name = "kvar_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4413,4414]},
    { name = "kVA_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4415,4416]},
    { name = "PF_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4417,4418]},
    { name = "kWh_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4419,4420]},
    { name = "kvarh_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4421,4422]},
    { name = "kVAh_tot",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4423,4424]},
    { name = "Freq_max",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4431,4432]},
    { name = "VTHD",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4459,4460]},
    { name = "ITHD",   byte_order = "ABCD",   data_type = "FLOAT32-IEEE",   scale=1.0,     address = [4461,4462]},
  ]
 `),u=f(),b=e=>u.value=e;function E(){return new Promise(e=>{setTimeout(()=>{c.add({severity:"success",summary:o.params.sensorName,detail:"Config applied successfully",life:3e3}),e()},1e3)})}function y(){return new Promise(e=>{n.value=!0,setTimeout(()=>{c.add({severity:"success",summary:o.params.sensorName,detail:"Config tested successfully",life:3e3}),n.value=!1,e()},4e3)})}function T(){_.value=!0,setTimeout(()=>{const e=new Blob([l.value],{type:"text/plain"}),a=URL.createObjectURL(e),t=document.createElement("a");t.href=a,t.download=`${o.params.sensorName}.conf`,t.click(),URL.revokeObjectURL(a),_.value=!1},1e3)}const i=async e=>{(e.metaKey&&e.key==="s"||e.ctrlKey&&e.key==="s")&&(e.preventDefault(),await E(),await y())};return F(()=>{document.addEventListener("keydown",i)}),L(()=>{document.removeEventListener("keydown",i)}),(e,a)=>{const t=S,C=k("vue-monaco-editor"),D=P;return h(),g("div",U,[s("div",W,[s("div",R,[d(t,{label:"List",icon:"pi pi-fw pi-chevron-left",onClick:a[0]||(a[0]=m=>e.$router.push({name:"Sensors"}))}),s("span",M,w(e.$route.params.sensorName),1),s("div",q,[d(t,{severity:"success",raised:"",onClick:E},{default:x(()=>a[2]||(a[2]=[N(" Apply config "),s("span",{class:"ml-auto bg-green-600 dark:bg-green-500 rounded dark:text-surface-700 text-xs p-1"},"⌘+S",-1)])),_:1}),d(t,{label:"Test config",severity:"warn",icon:"pi pi-fw pi-exclamation-triangle",loading:n.value,raised:"",onClick:y},null,8,["loading"]),V(d(t,{icon:"pi pi-fw pi-download",loading:_.value,raised:"",onClick:T},null,8,["loading"]),[[D,"Download config",void 0,{bottom:!0}]])])])]),s("div",null,[s("div",j,[s("div",$,[d(C,{value:l.value,"onUpdate:value":a[1]||(a[1]=m=>l.value=m),options:A.value,language:"ini",onMount:b},null,8,["value","options"])])])])])}}});export{z as default};
