index_html.h 188 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866
  1. /* 自动生成的文本数据头文件 */
  2. /* 源文件: index.html */
  3. /* 文件大小: 168443 字节 */
  4. /* 生成时间: 2026-06-07 19:06:58 */
  5. /* 编码: utf-8 */
  6. #ifndef P_INDEX_HTML_H
  7. #define P_INDEX_HTML_H
  8. #include <stddef.h>
  9. // 文本数据(UTF-8编码)
  10. const char *p_index_html =
  11. "<!DOCTYPE html>\n"
  12. "<html lang=\"zh-CN\">\n"
  13. " <head>\n"
  14. " <meta charset=\"UTF-8\">\n"
  15. " <meta name=\"viewport\"\n"
  16. " content=\"width=device-width, initial-scale=1.0, user-scalable=yes\">\n"
  17. " <title>电力监测系统</title>\n"
  18. " <style>\n"
  19. " * {\n"
  20. " box-sizing: border-box;\n"
  21. " font-family: 'Inter', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;\n"
  22. " }\n"
  23. " body {\n"
  24. " background: #eef2f8;\n"
  25. " margin: 0;\n"
  26. " padding: 24px 20px;\n"
  27. " min-height: 100vh;\n"
  28. " }\n"
  29. " .dashboard { max-width: 1600px; width: 100%; margin: 0 auto; }\n"
  30. " .ws-status-bar {\n"
  31. " background: white; border-radius: 60px; padding: 8px 20px; margin-bottom: 20px;\n"
  32. " display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;\n"
  33. " box-shadow: 0 2px 8px rgba(0,0,0,0.05); border: 1px solid #e2edf7;\n"
  34. " }\n"
  35. " .ws-indicator { display: flex; align-items: center; gap: 8px; }\n"
  36. " .ws-led { width: 12px; height: 12px; border-radius: 50%; background-color: #aaa; transition: background-color 0.3s; }\n"
  37. " .ws-led.connected { background-color: #2ecc71; box-shadow: 0 0 6px #2ecc71; }\n"
  38. " .ws-led.disconnected { background-color: #e74c3c; }\n"
  39. " .ws-led.connecting { background-color: #f39c12; animation: pulse 1s infinite; }\n"
  40. " @keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }\n"
  41. " .ws-url { font-family: monospace; font-size: 0.8rem; color: #4a627a; }\n"
  42. " .reconnect-btn { background: #eef2f8; border: none; border-radius: 40px; padding: 4px 16px; font-size: 0.7rem; cursor: pointer; color: #1f6392; }\n"
  43. " .reconnect-btn:hover { background: #dfe7f0; }\n"
  44. " .tabs { display: flex; gap: 12px; margin-bottom: 24px; border-bottom: 2px solid #dfe8f0; padding-bottom: 8px; flex-wrap: wrap; }\n"
  45. " .tab-btn { background: none; border: none; padding: 10px 24px; font-size: 1rem; font-weight: 600; color: #6c8eae; cursor: pointer; border-radius: 40px; transition: all 0.2s; }\n"
  46. " .tab-btn.active { background: #1f6392; color: white; box-shadow: 0 4px 12px rgba(31,99,146,0.3); }\n"
  47. " .tab-btn:hover:not(.active) { background: #e2eaf1; color: #2c5a7a; }\n"
  48. " .tab-key-btn { background: none; border: none; padding: 10px 24px; font-size: 1rem; font-weight: 600; color: #6c8eae; cursor: pointer; border-radius: 10px;transition: all 0.2s; }\n"
  49. " .tab-key-btn.active { background: #a85b1b; color: white; box-shadow: 0 4px 12px rgba(241, 241, 240, 0.3); }\n"
  50. " .tab-key-btn:hover:not(.active) { background: #799143; color: #5a7e20; }\n"
  51. " .page { display: none; }\n"
  52. " .page.active-page { display: block; }\n"
  53. " .header { text-align: center; margin-bottom: 28px; }\n"
  54. " .header h1 { font-size: 1.7rem; font-weight: 600; background: linear-gradient(135deg, #1e2a3a, #0f2b3d); background-clip: text; -webkit-background-clip: text; color: transparent; margin: 0 0 6px 0; }\n"
  55. " .header p { color: #4a627a; font-size: 0.9rem; }\n"
  56. " .summary-panel {\n"
  57. " background: white; border-radius: 28px; padding: 16px 24px; margin-bottom: 20px;\n"
  58. " box-shadow: 0 4px 12px rgba(0,0,0,0.05); border: 1px solid #e2edf7;\n"
  59. " }\n"
  60. " .summary-title { text-align: center; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: #7c9ab8; margin-bottom: 16px; }\n"
  61. " .summary-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; row-gap: 16px; }\n"
  62. " .summary-item { text-align: center; min-width: 120px; }\n"
  63. " .summary-label { font-size: 0.7rem; color: #7c9ab8; margin-bottom: 6px; }\n"
  64. " .summary-value { font-size: 1.4rem; font-weight: 700; color: #1e2f3c; }\n"
  65. " .summary-unit { font-size: 0.7rem; font-weight: 400; color: #7c9ab8; margin-left: 3px; }\n"
  66. " .table-wrapper {\n"
  67. " background: white; border-radius: 28px; box-shadow: 0 12px 30px rgba(0,0,0,0.08);\n"
  68. " overflow-x: auto; border: 1px solid #e2edf7; margin-bottom: 24px;\n"
  69. " }\n"
  70. " .power-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1300px; font-size: 0.85rem; }\n"
  71. " .power-table th { padding: 14px 10px; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px; color: #2c5a7a; text-align: center; background: #f9fbfe; border-bottom: 2px solid #dfe8f0; }\n"
  72. " .power-table td { padding: 12px 10px; text-align: center; border-bottom: 1px solid #edf2f7; color: #1e2f3c; font-weight: 500; }\n"
  73. " .numeric-value { font-weight: 600; }\n"
  74. " .unit-sub { font-size: 0.65rem; font-weight: 400; color: #7c9ab8; margin-left: 2px; }\n"
  75. " .energy-cell { background: #f4faf7; font-weight: 700; color: #1a6e55; }\n"
  76. " .power-bg { background: #fef9e6; }\n"
  77. " .reactive-bg { background: #f0f0fe; }\n"
  78. " .pf-cell { background: #f5f0fc; font-weight: 700; color: #5e3a8c; }\n"
  79. " .channel-badge { display: inline-flex; align-items: center; gap: 6px; }\n"
  80. " .ch-icon { background: #eef2fa; border-radius: 30px; padding: 3px 8px; font-size: 0.65rem; font-weight: 600; color: #1f6392; }\n"
  81. " .ph-icon { color: #070707; font-weight: 700; background: #85ddb1; display: inline-block; padding: 3px 12px; border-radius: 10px; font-size: 0.75rem;}\n"
  82. " .action-btn { background: #eef2f8; border: none; padding: 5px 14px; border-radius: 40px; font-size: 0.7rem; font-weight: 600; cursor: pointer; color: #2c6282; min-width: 64px; }\n"
  83. " .action-btn:hover { background: #dfe7f0; }\n"
  84. " .delay-badge { background: #eef2fa; border-radius: 20px; padding: 3px 8px; font-size: 0.65rem; font-weight: 600; display: inline-block; min-width: 70px; text-align: center; }\n"
  85. " .delay-idle { background: #e8f0fe; color: #4f7ea0; }\n"
  86. " .channel-off td:not(.energy-cell) { opacity: 0.7; background-color: #fefcf5; }\n"
  87. " .status-on { color: #2c8f6e; font-weight: 700; background: #e0f2e9; display: inline-block; padding: 3px 12px; border-radius: 30px; font-size: 0.75rem; }\n"
  88. " .status-off { color: #b33; font-weight: 700; background: #ffe6e5; display: inline-block; padding: 3px 12px; border-radius: 30px; font-size: 0.75rem; }\n"
  89. " .action-bar { display: flex; justify-content: flex-end; gap: 12px; margin-bottom: 16px; padding: 8px 0; flex-wrap: wrap; }\n"
  90. " .action-bar .btn-config, .action-bar .btn-threshold, .action-bar .btn-reset, \n"
  91. " .action-bar .btn-on, .action-bar .btn-off, .action-bar .btn-alarm {\n"
  92. " background: #ffffffcc; backdrop-filter: blur(4px); border: 1px solid #cbdde9;\n"
  93. " border-radius: 40px; padding: 6px 18px; font-size: 0.75rem; font-weight: 600;\n"
  94. " cursor: pointer; position: relative;\n"
  95. " }\n"
  96. " .threshold-alarm { background-color: #ffe0e0 !important; color: #c00 !important; font-weight: 700; border-radius: 8px; }\n"
  97. " .threshold-low-alarm { background-color: #d4de94 !important; color: #c00 !important; font-weight: 700; border-radius: 8px; }\n"
  98. " .switch-btn { background: #eef2f8; border: none; padding: 5px 14px; border-radius: 40px; font-size: 0.7rem; font-weight: 600; cursor: pointer; color: #2c6282; min-width: 64px; }\n"
  99. " .switch-btn:hover { background: #dfe7f0; }\n"
  100. " .action-bar .btn-config, .action-bar .btn-threshold, .action-bar .btn-reset, .action-bar .btn-alarm { color: #1f6392; }\n"
  101. " .action-bar .btn-on { color: #2c8f6e; border-color: #2c8f6e; }\n"
  102. " .action-bar .btn-off { color: #b33; border-color: #b33; }\n"
  103. " .action-bar .btn-alarm { background: #fff3e0; border-color: #e6b800; color: #b8860b; }\n"
  104. " .action-bar .btn-alarm:hover { background: #ffe0b3; }\n"
  105. " .action-bar .btn-config:hover, .action-bar .btn-threshold:hover, .action-bar .btn-reset:hover, \n"
  106. " .action-bar .btn-on:hover, .action-bar .btn-off:hover { background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }\n"
  107. " .alarm-badge { position: absolute; top: -8px; right: -8px; background-color: #e74c3c; color: white; border-radius: 20px; padding: 2px 8px; font-size: 0.65rem; font-weight: 600; min-width: 22px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }\n"
  108. " .env-cards { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 24px; justify-content: space-between; }\n"
  109. " .env-card { background: white; border-radius: 24px; padding: 16px 20px; flex: 1; min-width: 140px; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.05); border: 1px solid #e2edf7; transition: transform 0.2s; }\n"
  110. " .env-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }\n"
  111. " .env-card .env-label { font-size: 0.8rem; text-transform: uppercase; color: #358ade; letter-spacing: 1px; margin-bottom: 8px; }\n"
  112. " .env-card .env-value { font-size: 1.8rem; font-weight: 700; color: #1e2f3c; }\n"
  113. " .env-card .env-unit { font-size: 0.8rem; font-weight: 400; color: #7c9ab8; margin-left: 4px; }\n"
  114. " .env-card.alarm-warning .env-value { color: #e67e22; }\n"
  115. " .env-card.alarm-danger .env-value { color: #e74c3c; }\n"
  116. " .live-footer { margin-top: 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; background: rgba(255,255,245,0.7); backdrop-filter: blur(4px); padding: 8px 20px; border-radius: 60px; }\n"
  117. " .footer-status { display: flex; align-items: center; gap: 12px; font-size: 0.75rem; color: #4f6f8f; }\n"
  118. " .channel-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; justify-content: center; }\n"
  119. " .jump-chip { background: #eef2f8; border-radius: 40px; padding: 4px 12px; font-size: 0.7rem; font-weight: 500; cursor: pointer; }\n"
  120. " .alarm-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }\n"
  121. " .alarm-table th, .alarm-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #e2edf7; }\n"
  122. " .alarm-table th { background: #f8fafd; font-weight: 600; color: #2c5a7a; }\n"
  123. " .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 2000; visibility: hidden; opacity: 0; transition: visibility 0.2s, opacity 0.2s; }\n"
  124. " .modal-overlay.active { visibility: visible; opacity: 1; }\n"
  125. " .modal-container { background: white; border-radius: 32px; width: 90%; max-width: 950px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }\n"
  126. " .modal-header { padding: 18px 24px; border-bottom: 1px solid #e9edf2; display: flex; justify-content: space-between; align-items: center; background: #fafcff; }\n"
  127. " .modal-header h3 { margin: 0; font-size: 1.3rem; font-weight: 700; color: #1e2a3a; }\n"
  128. " .modal-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: #8ba3bc; }\n"
  129. " .modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }\n"
  130. " .modal-footer { padding: 16px 24px; border-top: 1px solid #e9edf2; display: flex; justify-content: flex-end; gap: 12px; background: #fafcff; }\n"
  131. " .modal-card-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 2000; visibility: hidden; opacity: 0; transition: visibility 0.2s, opacity 0.2s; }\n"
  132. " .modal-card-overlay.active { visibility: visible; opacity: 1; }\n"
  133. " .modal-card-container { background: white; border-radius: 32px; width: 90%; max-width: 400px; max-height: 65vh; display: flex; flex-direction: column; overflow: hidden; }\n"
  134. " .modal-card-header { padding: 18px 24px; border-bottom: 1px solid #e9edf2; display: flex; justify-content: space-between; align-items: center; background: #fafcff; }\n"
  135. " .modal-card-header h3 { margin: 0; font-size: 1.3rem; font-weight: 300; color: #1e2a3a; }\n"
  136. " .modal-card-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: #8ba3bc; }\n"
  137. " .modal-card-body { padding: 20px 24px; overflow-y: auto; flex: 1; }\n"
  138. " .modal-card-footer { padding: 16px 24px; border-top: 1px solid #e9edf2; display: flex; justify-content: flex-end; gap: 12px; background: #fafcff; }\n"
  139. " .btn-cancel-modal { background: #eef2f8; border: none; border-radius: 40px; padding: 8px 22px; font-weight: 600; cursor: pointer; color: #2c6282; }\n"
  140. " .btn-confirm { background: #1f6392; color: white; border: none; border-radius: 40px; padding: 8px 22px; font-weight: 600; cursor: pointer; }\n"
  141. " .config-card { background: white; border-radius: 28px; box-shadow: 0 12px 30px rgba(0,0,0,0.08); padding: 28px 32px; max-width: 650px; margin: 0 auto; }\n"
  142. " .config-group { margin-bottom: 20px; }\n"
  143. " .config-group label { display: block; font-weight: 600; color: #2c5a7a; margin-bottom: 8px; font-size: 0.85rem; }\n"
  144. " .config-group input, .config-group select { width: 100%; padding: 12px 16px; border: 1px solid #cbdde9; border-radius: 28px; font-size: 0.9rem; background: #f9fbfe; }\n"
  145. " .save-config-btn { background: #1f6392; color: white; border: none; border-radius: 40px; padding: 12px 28px; font-size: 0.9rem; font-weight: 600; cursor: pointer; width: 100%; margin-top: 16px; }\n"
  146. " .save-config-btn:hover { background: #0e4b70; }\n"
  147. " .config-status { margin-top: 20px; padding: 12px; background: #e8f0fe; border-radius: 20px; font-size: 0.8rem; color: #2c5a7a; text-align: center; }\n"
  148. " .sub-hint { font-size: 0.7rem; color: #7c9ab8; margin-top: 4px; }\n"
  149. " .info-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #e2edf7; }\n"
  150. " .info-label { font-weight: 600; color: #2c5a7a; }\n"
  151. " .info-value { font-weight: 500; color: #111111;}\n"
  152. " .datetime-set-group { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }\n"
  153. " .datetime-set-group input { flex: 1; padding: 10px 14px; border: 1px solid #cbdde9; border-radius: 28px; }\n"
  154. " .btn-small { background: #eef2f8; border: none; border-radius: 40px; padding: 6px 18px; font-size: 0.75rem; font-weight: 600; cursor: pointer; color: #2c6282; }\n"
  155. " .btn-small:hover { background: #dfe7f0; }\n"
  156. " .btn-reboot { background: #eef2f8; border: none; border-radius: 40px; padding: 6px 18px; font-size: 0.75rem; font-weight: 700; cursor: pointer; color: #2c6282; }\n"
  157. " .btn-reboot:hover { background: #dfe7f0; }\n"
  158. " .config-row { background: #f9fbfe; border-radius: 20px; padding: 14px 18px; border: 1px solid #eef2f8; margin-bottom: 16px; }\n"
  159. " .config-row-title { font-weight: 700; font-size: 0.9rem; color: #2c5a7a; margin-bottom: 12px; }\n"
  160. " .config-inputs { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }\n"
  161. " .config-item { display: flex; flex-direction: column; gap: 4px; min-width: 100px; }\n"
  162. " .config-item label { font-size: 0.75rem; font-weight: 600; color: #5f7e9c; }\n"
  163. " .config-item input { background: white; border: 1px solid #cbdde9; border-radius: 28px; padding: 8px 12px; width: 120px; font-size: 0.8rem; }\n"
  164. " .config-batch-row { background: #e7f0fd; border-radius: 20px; padding: 14px 18px; border: 1px solid #7386a3; margin-bottom: 16px; }\n"
  165. " .config-batch-item { display: flex; flex-direction: column; gap: 4px; min-width: 100px; }\n"
  166. " .config-batch-item label { font-size: 0.85rem; font-weight: 600; color: #114579; }\n"
  167. " .config-batch-item input { background: white; border: 1px solid #677883; border-radius: 28px; padding: 8px 12px; width: 120px; font-size: 0.8rem; }\n"
  168. " .save-channel-config-btn { background: #1f6392; color: white; border: none; border-radius: 32px; padding: 6px 20px; font-size: 0.7rem; font-weight: 600; cursor: pointer; margin-left: auto; }\n"
  169. " .channel-select-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }\n"
  170. " .channel-checkbox { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: #f9fbfe; border-radius: 40px; }\n"
  171. " .channel-checkbox input { width: 18px; height: 18px; cursor: pointer; }\n"
  172. " .channel-checkbox label { font-weight: 600; color: #1e2f3c; cursor: pointer; flex: 1; }\n"
  173. " .select-all-row { display: flex; gap: 16px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e2edf7; }\n"
  174. " .select-all-btn { background: #eef2f8; border: none; border-radius: 30px; padding: 6px 16px; font-size: 0.7rem; font-weight: 600; cursor: pointer; color: #2c6282; }\n"
  175. " .logout-btn { background: #eef2f8; border: 1px solid #cbdde9; border-radius: 40px; padding: 6px 18px; font-size: 0.7rem; font-weight: 600; cursor: pointer; color: #2c6282; margin-left: 12px; }\n"
  176. " .login-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #1e2f3c 0%, #0f2b3d 100%); display: flex; align-items: center; justify-content: center; z-index: 3000; transition: all 0.3s; }\n"
  177. " .login-card { background: white; border-radius: 48px; padding: 40px 36px; width: 90%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.3); text-align: center; }\n"
  178. " .login-card h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; background: linear-gradient(135deg, #1e2a3a, #1f6392); background-clip: text; -webkit-background-clip: text; color: transparent; }\n"
  179. " .login-input-group { margin-bottom: 24px; text-align: left; }\n"
  180. " .login-input-group label { display: block; font-weight: 600; color: #2c5a7a; margin-bottom: 8px; font-size: 0.8rem; }\n"
  181. " .login-input-group input { width: 100%; padding: 14px 18px; border: 1px solid #cbdde9; border-radius: 40px; font-size: 0.9rem; background: #f9fbfe; }\n"
  182. " .login-btn { background: #1f6392; color: white; border: none; border-radius: 40px; padding: 14px 28px; font-size: 1rem; font-weight: 700; cursor: pointer; width: 100%; transition: background 0.2s; }\n"
  183. " .login-btn:disabled { background: #9ab3c7; cursor: not-allowed; }\n"
  184. " .login-error { color: #e74c3c; font-size: 0.8rem; margin-top: 16px; min-height: 40px; }\n"
  185. " .hidden { display: none; }\n"
  186. " .add-user-btn { background: #1f6392; color: white; border: none; border-radius: 40px; padding: 8px 20px; margin-bottom: 16px; cursor: pointer; float: right; }\n"
  187. " .table-wrapper { background: white; border-radius: 28px; box-shadow: 0 12px 30px rgba(0,0,0,0.08); overflow-x: auto; border: 1px solid #e2edf7; margin-bottom: 24px; } \n"
  188. " \n"
  189. " .btn-icon { background: #eef2f8; border: none; padding: 4px 12px; border-radius: 30px; font-size: 0.7rem; margin: 0 4px; cursor: pointer; }\n"
  190. " .btn-icon.danger { color: #e74c3c; }\n"
  191. " .btn-icon.success { color: #2c8f6e; }\n"
  192. " .user-table { width: 100%; border-collapse: collapse; background: white; border-radius: 24px; overflow: hidden; }\n"
  193. " .user-table th, .user-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #e2edf7; }\n"
  194. " .user-table th { background: #f8fafd; color: #2c5a7a; }\n"
  195. " \n"
  196. " </style>\n"
  197. " </head>\n"
  198. " <body>\n"
  199. " <!-- 登录页面 -->\n"
  200. " <div id=\"loginContainer\" class=\"login-container\">\n"
  201. " <div class=\"login-card\">\n"
  202. " <h2>⚡ 电力监测系统</h2>\n"
  203. " <p>请输入凭证进行身份验证</p>\n"
  204. " <div class=\"login-input-group\"><label>👤 用户名</label><input type=\"text\" id=\"loginUsername\" placeholder=\"admin\" autocomplete=\"off\"></div>\n"
  205. " <div class=\"login-input-group\"><label>🔒 密码</label><input type=\"password\" id=\"loginPassword\" placeholder=\"******\"></div>\n"
  206. " <button class=\"login-btn\" id=\"loginBtn\">登 录</button>\n"
  207. " <div id=\"loginErrorMsg\" class=\"login-error\"></div>\n"
  208. " </div>\n"
  209. " </div>\n"
  210. " <div id=\"dashboardApp\" class=\"dashboard\" style=\"display: none;\">\n"
  211. " \n"
  212. " <div class=\"ws-status-bar\">\n"
  213. " <div class=\"ws-indicator\">\n"
  214. " <div class=\"ws-led\" id=\"wsLed\"></div>\n"
  215. " <span id=\"wsStatusText\">未连接</span>\n"
  216. " </div>\n"
  217. " <div>\n"
  218. " <button class=\"logout-btn\" id=\"logoutBtn\">🚪 登出</button>\n"
  219. " <button class=\"reconnect-btn\" id=\"reconnectBtn\">🔌 重新连接</button>\n"
  220. " </div>\n"
  221. " </div>\n"
  222. " \n"
  223. " <div class=\"tabs\">\n"
  224. " <button class=\"tab-btn active\" data-page=\"monitor\">📊 电力监测</button>\n"
  225. " <button class=\"tab-btn\" data-page=\"network\">🌐 网络配置</button>\n"
  226. " <button class=\"tab-btn\" data-page=\"rs485\">🔌 RS485配置</button>\n"
  227. " <button class=\"tab-btn\" data-page=\"snmp\">📡 SNMP配置</button>\n"
  228. " <button class=\"tab-btn\" data-page=\"device\">📟 设备信息</button>\n"
  229. " <button class=\"tab-btn\" data-page=\"user\">👥 用户管理</button>\n"
  230. " </div>\n"
  231. " <!-- 电力监测页面 -->\n"
  232. " <div id=\"monitorPage\" class=\"page active-page\">\n"
  233. " <div class=\"summary-panel\">\n"
  234. " <div class=\"summary-title\">📊 系统总览</div>\n"
  235. " <div class=\"summary-grid\">\n"
  236. " <button class=\"tab-key-btn active\" id=\"L1\">L1</button>\n"
  237. " <button class=\"tab-key-btn\" id=\"L2\">L2</button>\n"
  238. " <button class=\"tab-key-btn\" id=\"L3\">L3</button> \n"
  239. " </div>\n"
  240. " <div class=\"summary-grid\">\n"
  241. " <div class=\"summary-item\"><div class=\"summary-label\" id=\"All-V\">总电压 (V)</div><div class=\"summary-value\" id=\"totalVoltage\">0.0<span class=\"summary-unit\">V</span></div></div>\n"
  242. " <div class=\"summary-item\"><div class=\"summary-label\" id=\"All-I\">总电流 (A)</div><div class=\"summary-value\" id=\"totalCurrent\">0.0<span class=\"summary-unit\">A</span></div></div>\n"
  243. " <div class=\"summary-item\"><div class=\"summary-label\">总有功功率 (kW)</div><div class=\"summary-value\" id=\"totalActivePower\">0<span class=\"summary-unit\">W</span></div></div>\n"
  244. " <div class=\"summary-item\"><div class=\"summary-label\">总无功功率 (kvar)</div><div class=\"summary-value\" id=\"totalReactivePower\">0<span class=\"summary-unit\">var</span></div></div>\n"
  245. " <div class=\"summary-item\"><div class=\"summary-label\">总视在功率 (kVA)</div><div class=\"summary-value\" id=\"totalApparentPower\">0<span class=\"summary-unit\">VA</span></div></div>\n"
  246. " <div class=\"summary-item\"><div class=\"summary-label\">总功率因数</div><div class=\"summary-value\" id=\"totalPowerFactor\">0.00<span class=\"summary-unit\"></span></div></div>\n"
  247. " <div class=\"summary-item\"><div class=\"summary-label\">总耗电量(kWh)</div><div class=\"summary-value\" id=\"totalConsumer\">0.00<span class=\"summary-unit\">kWh</span></div></div>\n"
  248. " </div>\n"
  249. " </div>\n"
  250. " <div class=\"action-bar\">\n"
  251. " <button class=\"btn-config\" id=\"openDelayConfigBtn\">⚙️ 延时配置</button>\n"
  252. " <button class=\"btn-threshold\" id=\"openThresholdConfigBtn\">⚠️ 阈值配置</button>\n"
  253. " <button class=\"btn-reset\" id=\"openResetEnergyModalBtn\">↻ 重置耗电量(可选通道)</button>\n"
  254. " <button class=\"btn-on\" id=\"allOnBtn\">🔛 全部开启</button>\n"
  255. " <button class=\"btn-off\" id=\"allOffBtn\">⛔ 全部关闭</button>\n"
  256. " <button class=\"btn-on\" id=\"cleanSoundLight\">✏️ 清除声光报警</button>\n"
  257. " <button class=\"btn-alarm\" id=\"openAlarmModalBtn\">🔔 报警记录<span id=\"alarmCountBadge\" class=\"alarm-badge\" style=\"display:none;\">0</span></button>\n"
  258. " </div>\n"
  259. " <div class=\"channel-jump\" id=\"channelJumpContainer\"></div>\n"
  260. " <div class=\"table-wrapper\">\n"
  261. " <table class=\"power-table\" id=\"powerTable\">\n"
  262. " <thead>\n"
  263. " <tr><th>通道</th><th>相序</th><th>电压 (V)</th><th>电流 (A)</th><th>有功 (kW)</th><th>无功 (kvar)</th><th>视在 (kVA)</th><th>功率因数</th><th>频率 (Hz)</th><th>累计耗电 (kWh)</th><th>开关延时</th><th>开关状态</th><th>操作</th></tr>\n"
  264. " </thead>\n"
  265. " <tbody id=\"tableBody\"><tr><td colspan=\"12\">等待WebSocket数据...</td></tr></tbody>\n"
  266. " </table>\n"
  267. " </div>\n"
  268. " <div class=\"env-cards\">\n"
  269. " <div class=\"env-card\" id=\"tempCard\"><div class=\"env-label\">🌡️ 温度</div><div class=\"env-label\" id=\"tempStatus\">--</div><div class=\"env-value\" id=\"tempValue\">--<span class=\"env-unit\">°C</span></div></div>\n"
  270. " <div class=\"env-card\" id=\"humiCard\"><div class=\"env-label\">💧 湿度</div><div class=\"env-label\" id=\"humiStatus\">--</div><div class=\"env-value\" id=\"humiValue\">--<span class=\"env-unit\">%RH</span></div></div>\n"
  271. " <div class=\"env-card\" id=\"smokeCard\"><div class=\"env-label\">🔥 烟雾</div><div class=\"env-label\" id=\"smokeStatus\">--</div><div class=\"env-value\" id=\"smokeValue\">--<span class=\"env-unit\">ppm</span></div></div>\n"
  272. " <div class=\"env-card\" id=\"co2Card\"><div class=\"env-label\">🌫️ CO₂浓度</div><div class=\"env-label\" id=\"co2Status\">--</div><div class=\"env-value\" id=\"co2Value\">--<span class=\"env-unit\">ppm</span></div></div>\n"
  273. " </div>\n"
  274. " </div>\n"
  275. " <!-- 网络配置页面 -->\n"
  276. " <div id=\"networkPage\" class=\"page\">\n"
  277. " <div class=\"header\"><h1>🌐 网络配置</h1><p>配置设备网络参数 (IP/掩码/网关/DNS)</p></div>\n"
  278. " <div class=\"config-card\">\n"
  279. " <div class=\"config-group\"><label>📡 IP获取模式</label><select id=\"ipMode\"><option value=\"auto\">自动 (DHCP)</option><option value=\"manual\">手动 (静态IP)</option></select></div>\n"
  280. " <div id=\"staticIpGroup\">\n"
  281. " <div class=\"config-group\"><label id=\"ip_lable\">📌 IP地址</label><input type=\"text\" id=\"ipAddress\" placeholder=\"192.168.1.100\"></div>\n"
  282. " <div class=\"config-group\"><label id=\"mask_lable\">🔗 子网掩码</label><input type=\"text\" id=\"subnetMask\" placeholder=\"255.255.255.0\"></div>\n"
  283. " <div class=\"config-group\"><label id=\"gate_lable\">🚪 默认网关</label><input type=\"text\" id=\"gateway\" placeholder=\"192.168.1.1\"></div>\n"
  284. " </div>\n"
  285. " <div class=\"config-group\"><label>🌍 首选DNS服务器</label><input type=\"text\" id=\"dns1\" placeholder=\"114.114.114.114\"></div>\n"
  286. " <div class=\"config-group\"><label>🌍 备用DNS服务器</label><input type=\"text\" id=\"dns2\" placeholder=\"8.8.8.8\"></div>\n"
  287. " <button class=\"save-config-btn\" id=\"saveNetConfigBtn\">💾 保存网络配置</button>\n"
  288. " <div class=\"config-status\" id=\"netStatusMsg\">当前配置: 未加载</div>\n"
  289. " </div>\n"
  290. " </div>\n"
  291. " <!-- RS485配置页面 -->\n"
  292. " <div id=\"rs485Page\" class=\"page\">\n"
  293. " <div class=\"header\"><h1>🔌 RS485 通讯配置</h1><p>配置串口通讯参数 (主从机模式/地址/波特率)</p></div>\n"
  294. " <div class=\"config-card\">\n"
  295. " <div class=\"config-group\"><label>🎛️ 主从机模式</label><select id=\"rs485Mode\"><option value=\"master\">主机 (Master)</option><option value=\"slave\">从机 (Slave)</option></select></div>\n"
  296. " <div class=\"config-group\"><label>📍 设备地址 (1-247)</label><input type=\"number\" id=\"rs485Addr\" min=\"1\" max=\"247\" value=\"1\" step=\"1\"></div>\n"
  297. " <div class=\"config-group\"><label>⚡ 波特率 (bps)</label>\n"
  298. " <select id=\"rs485Baudrate\">\n"
  299. " <option value=\"9600\">9600</option>\n"
  300. " <option value=\"19200\">19200</option>\n"
  301. " <option value=\"38400\">38400</option>\n"
  302. " <option value=\"57600\">57600</option>\n"
  303. " <option value=\"115200\">115200</option>\n"
  304. " </select>\n"
  305. " </div>\n"
  306. " <button class=\"save-config-btn\" id=\"saveRs485ConfigBtn\">💾 保存485配置</button>\n"
  307. " <div class=\"config-status\" id=\"rs485StatusMsg\">当前配置: 未加载</div>\n"
  308. " </div>\n"
  309. " </div>\n"
  310. " <!-- SNMP配置页面 -->\n"
  311. " <div id=\"snmpPage\" class=\"page\">\n"
  312. " <div class=\"header\"><h1>📡 SNMP 配置</h1><p>配置简单网络管理协议参数 (社团名称/TRAP目标)</p></div>\n"
  313. " <div class=\"config-card\">\n"
  314. " <div class=\"config-group\"><label>🔐 只读社团名称 (Read-Only)</label><input type=\"text\" id=\"snmpReadCommunity\" placeholder=\"public\" value=\"public\"></div>\n"
  315. " <div class=\"config-group\"><label>✏️ 读写社团名称 (Read-Write)</label><input type=\"text\" id=\"snmpWriteCommunity\" placeholder=\"private\" value=\"private\"></div>\n"
  316. " <div class=\"config-group\"><label>🔌 TRAP状态</label><select id=\"snmpTrapStatus\"><option value=\"open\">开启 (Open)</option><option value=\"close\">关闭 (Close)</option></select></div>\n"
  317. " <div class=\"config-group\"><label id=\"trapAddr\">📡 TRAP目标IP地址</label><input type=\"text\" id=\"snmpTrapIp\" placeholder=\"192.168.1.100\"></div>\n"
  318. " <div class=\"sub-hint\">TRAP将用于发送告警信息(如阈值超限、开关状态变化等)</div>\n"
  319. " <button class=\"save-config-btn\" id=\"saveSnmpConfigBtn\">💾 保存SNMP配置</button>\n"
  320. " <div class=\"config-status\" id=\"snmpStatusMsg\">当前配置: 未加载</div>\n"
  321. " </div>\n"
  322. " </div> \n"
  323. " <!-- 设备信息页面 -->\n"
  324. " <div id=\"devicePage\" class=\"page\">\n"
  325. " <div class=\"header\"><h1>📟 设备信息</h1><p>查看和设置系统时间、固件版本等信息</p></div>\n"
  326. " <div class=\"config-card\">\n"
  327. " <div class=\"info-row\"><span class=\"info-label\">设备型号:</span><span class=\"info-value\">SmartPDU</span></div>\n"
  328. " <div class=\"info-row\"><span class=\"info-label\">通道数:</span><span class=\"info-value\" id=\"deviceChannel\"></span></div>\n"
  329. " <div class=\"info-row\"><span class=\"info-label\">供电类型:</span><span class=\"info-value\" id=\"powerType\"></span></div>\n"
  330. " <div class=\"info-row\"><span class=\"info-label\">控制板数:</span><span class=\"info-value\" id=\"controlBoard\"></span></div>\n"
  331. " <div class=\"info-row\"><span class=\"info-label\">序列号:</span><span class=\"info-value\" id=\"serivalNumber\">SN20241206001</span></div>\n"
  332. " <div class=\"info-row\"><span class=\"info-label\">软件版本:</span><span class=\"info-value\" id=\"softVersion\"></span></div>\n"
  333. " <div class=\"info-row\"><span class=\"info-label\">时区:</span><span class=\"info-value\" id=\"zone\"></span></div>\n"
  334. " <div class=\"info-row\"><span class=\"info-label\">当前系统时间:</span><span class=\"info-value\" id=\"systemTimeDisplay\">--:--:--</span></div>\n"
  335. " <div class=\"config-group\" style=\"margin-top: 20px;\">\n"
  336. " <label>⏰ 设置系统时间</label>\n"
  337. " <div class=\"config-card\">\n"
  338. " <div class=\"config-group\"><label>⚡ 时区</label>\n"
  339. " <select id=\"ntpZone\">\n"
  340. " <option value=\"0\">0</option>\n"
  341. " <option value=\"1\">+1</option><option value=\"2\">+2</option><option value=\"3\">+3</option><option value=\"4\">+4</option><option value=\"5\">+5</option><option value=\"6\">+6</option><option value=\"7\">+7</option><option value=\"8\">+8</option><option value=\"9\">+9</option><option value=\"10\">+10</option><option value=\"11\">+11</option><option value=\"12\">+12</option> \n"
  342. " <option value=\"-1\">-1</option><option value=\"-2\">-2</option><option value=\"-3\">-3</option><option value=\"-4\">-4</option><option value=\"-5\">-5</option><option value=\"-6\">-6</option><option value=\"-7\">-7</option><option value=\"-8\">-8</option><option value=\"-9\">-9</option><option value=\"-10\">-10</option><option value=\"-11\">-11</option><option value=\"-12\">-12</option>\n"
  343. " </select>\n"
  344. " </div>\n"
  345. " <div class=\"datetime-set-group\">\n"
  346. " <input type=\"datetime-local\" step=\"1\" id=\"newSystemTime\">\n"
  347. " <button class=\"btn-small\" id=\"setSystemTimeBtn\">同步时间</button>\n"
  348. " <button class=\"btn-reboot\" id=\"setSystemRebootBtn\">重启设备</button>\n"
  349. " </div>\n"
  350. " </div>\n"
  351. " </div>\n"
  352. " </div>\n"
  353. " </div>\n"
  354. " <!-- 用户管理界面 (新增) -->\n"
  355. " <div id=\"userPage\" class=\"page\">\n"
  356. " <div class=\"header\"><h1>👥 用户管理</h1></div>\n"
  357. " <div style=\"display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;\">\n"
  358. " <h3 style=\"margin:0;\">用户列表</h3>\n"
  359. " <button class=\"add-user-btn\" id=\"addUserBtn\">➕ 新增用户</button>\n"
  360. " </div>\n"
  361. " <div class=\"table-wrapper\" style=\"overflow-x: auto;\">\n"
  362. " <table class=\"user-table\" id=\"userTable\">\n"
  363. " <thead><tr><th style=\"text-align:center;\">用户名</th><th style=\"text-align:center;\">角色</th><th style=\"text-align:center;\">创建时间</th><th style=\"text-align:center;\">操作</th></tr></thead>\n"
  364. " <tbody id=\"userTableBody\"><tr><td colspan=\"3\" style=\"text-align:center;\">暂无用户数据</td></tr></tbody>\n"
  365. " </table>\n"
  366. " </div>\n"
  367. " </div>\n"
  368. " </div>\n"
  369. " <!-- 模态框 -->\n"
  370. " <div id=\"alarmModal\" class=\"modal-overlay\">\n"
  371. " <div class=\"modal-container\">\n"
  372. " <div class=\"modal-header\"><h3>🔔 报警记录</h3><button class=\"modal-close\" id=\"closeAlarmModalBtn\">&times;</button></div>\n"
  373. " <div class=\"modal-body\"><div id=\"alarmListContainer\"><div style=\"text-align:center;color:#888;padding:20px;\">暂无报警记录</div></div></div>\n"
  374. " <div class=\"modal-footer\"><button class=\"btn-cancel-modal\" id=\"clearAlarmBtn\">清空记录</button><button class=\"btn-cancel-modal\" id=\"cancelAlarmModalBtn\">关闭</button></div>\n"
  375. " </div>\n"
  376. " </div> \n"
  377. " <div id=\"delayModal\" class=\"modal-overlay\">\n"
  378. " <div class=\"modal-container\">\n"
  379. " <div class=\"modal-header\"><h3>⏱️ 通道延时设置</h3><button class=\"modal-close\" id=\"closeDelayModalBtn\">&times;</button></div>\n"
  380. " <div class=\"modal-body\"><div id=\"delayGrid\"></div></div>\n"
  381. " <div class=\"modal-footer\"><button class=\"btn-cancel-modal\" id=\"cancelDelayModalBtn\">关闭</button></div>\n"
  382. " </div>\n"
  383. " </div>\n"
  384. " <div id=\"thresholdModal\" class=\"modal-overlay\">\n"
  385. " <div class=\"modal-container\">\n"
  386. " <div class=\"modal-header\"><h3>⚠️ 阈值配置</h3><button class=\"modal-close\" id=\"closeThresholdModalBtn\">&times;</button></div>\n"
  387. " <div class=\"modal-body\"><div id=\"pathchGrid\"></div><div id=\"thresholdGrid\"></div></div>\n"
  388. " <div class=\"modal-footer\"><button class=\"btn-cancel-modal\" id=\"cancelThresholdModalBtn\">关闭</button></div>\n"
  389. " </div>\n"
  390. " </div>\n"
  391. " \n"
  392. " <div id=\"resetEnergyModal\" class=\"modal-overlay\">\n"
  393. " <div class=\"modal-container\">\n"
  394. " <div class=\"modal-header\"><h3>↻ 选择要重置耗电量的通道</h3><button class=\"modal-close\" id=\"closeResetModalBtn\">&times;</button></div>\n"
  395. " <div class=\"modal-body\">\n"
  396. " <div class=\"select-all-row\"><button class=\"select-all-btn\" id=\"selectAllChannels\">全选</button><button class=\"select-all-btn\" id=\"deselectAllChannels\">全不选</button></div>\n"
  397. " <div class=\"channel-select-list\" id=\"channelSelectList\"></div>\n"
  398. " </div>\n"
  399. " <div class=\"modal-footer\"><button class=\"btn-cancel-modal\" id=\"cancelResetModalBtn\">取消</button><button class=\"btn-confirm\" id=\"confirmResetEnergyBtn\">确认重置</button></div>\n"
  400. " </div>\n"
  401. " </div> \n"
  402. " <!-- Temp 模态框 -->\n"
  403. " <div id=\"tempCardModal\" class=\"modal-card-overlay\">\n"
  404. " <div class=\"modal-card-container\">\n"
  405. " <div class=\"modal-card-header\"><h3>🌡️ 温度配置</h3><button class=\"modal-card-close\" id=\"closeTempModalBtn\">&times;</button></div>\n"
  406. " <div class=\"modal-card-body\">\n"
  407. " <div class=\"config-group\"><label>🔺最大值</label><input type=\"text\" id=\"tempMax\" placeholder=\"25.5\"></div>\n"
  408. " <div class=\"config-group\"><label>🔻最小值</label><input type=\"text\" id=\"tempMin\" placeholder=\"12.6\"></div>\n"
  409. " </div>\n"
  410. " <div class=\"modal-card-footer\"><button class=\"btn-confirm\" id=\"confirmTempThrBtn\">提交</button></div>\n"
  411. " </div>\n"
  412. " </div>\n"
  413. " <div id=\"humiCardModal\" class=\"modal-card-overlay\">\n"
  414. " <div class=\"modal-card-container\">\n"
  415. " <div class=\"modal-card-header\"><h3>💧 湿度配置</h3><button class=\"modal-card-close\" id=\"closeHumiModalBtn\">&times;</button></div>\n"
  416. " <div class=\"modal-card-body\">\n"
  417. " <div class=\"config-group\"><label>🔺最大值</label><input type=\"text\" id=\"humiMax\" placeholder=\"80.5\"></div>\n"
  418. " <div class=\"config-group\"><label>🔻最小值</label><input type=\"text\" id=\"humiMin\" placeholder=\"50.6\"></div>\n"
  419. " </div>\n"
  420. " <div class=\"modal-card-footer\"><button class=\"btn-confirm\" id=\"confirmHumiThrBtn\">提交</button></div>\n"
  421. " </div>\n"
  422. " </div>\n"
  423. " <div id=\"smokeCardModal\" class=\"modal-card-overlay\">\n"
  424. " <div class=\"modal-card-container\">\n"
  425. " <div class=\"modal-card-header\"><h3>🔥 烟雾配置</h3><button class=\"modal-card-close\" id=\"closeSmokeModalBtn\">&times;</button></div>\n"
  426. " <div class=\"modal-card-body\">\n"
  427. " <div class=\"config-group\"><label>🔺最大值</label><input type=\"text\" id=\"smokeMax\" placeholder=\"25.5\"></div>\n"
  428. " <div class=\"config-group\"><label>🔻最小值</label><input type=\"text\" id=\"smokeMin\" placeholder=\"12.6\"></div>\n"
  429. " </div>\n"
  430. " <div class=\"modal-card-footer\"><button class=\"btn-confirm\" id=\"confirmSmokeThrBtn\">提交</button></div>\n"
  431. " </div>\n"
  432. " </div>\n"
  433. " <div id=\"co2CardModal\" class=\"modal-card-overlay\">\n"
  434. " <div class=\"modal-card-container\">\n"
  435. " <div class=\"modal-card-header\"><h3>🌫️ CO₂配置</h3><button class=\"modal-card-close\" id=\"closeCo2ModalBtn\">&times;</button></div>\n"
  436. " <div class=\"modal-card-body\">\n"
  437. " <div class=\"config-group\"><label>🔺最大值</label><input type=\"text\" id=\"Co2Max\" placeholder=\"25.5\"></div>\n"
  438. " <div class=\"config-group\"><label>🔻最小值</label><input type=\"text\" id=\"Co2Min\" placeholder=\"12.6\"></div>\n"
  439. " </div>\n"
  440. " <div class=\"modal-card-footer\"><button class=\"btn-confirm\" id=\"confirmCo2ThrBtn\">提交</button></div>\n"
  441. " </div>\n"
  442. " </div>\n"
  443. " <!-- 用户编辑模态框 -->\n"
  444. " <div id=\"userModal\" class=\"modal-card-overlay\">\n"
  445. " <div class=\"modal-card-container\">\n"
  446. " <div class=\"modal-card-header\"><h3 id=\"userModalTitle\">编辑用户</h3><button class=\"modal-card-close\" id=\"closeUserModalBtn\">&times;</button></div>\n"
  447. " <div class=\"modal-body\">\n"
  448. " <div class=\"config-group\"><label>用户名</label><input type=\"text\" id=\"userName\" placeholder=\"请输入用户名\" autocomplete=\"off\"></div>\n"
  449. " <div class=\"config-group\"><label>旧密码</label><input type=\"password\" id=\"userOldPassword\" placeholder=\"留空则不修改密码(编辑时)\"></div>\n"
  450. " <div class=\"config-group\"><label>新密码</label><input type=\"password\" id=\"userNewPassword\" placeholder=\"留空则不修改密码(编辑时)\"></div>\n"
  451. " <div class=\"config-group\"><label>角色</label><select id=\"userRole\"><option value=\"superadmin\">超级管理员</option><option value=\"admin\">管理员</option><option value=\"user\">普通用户</option></select></div>\n"
  452. " <div id=\"loginUpdateErrorMsg\" class=\"login-error\"></div>\n"
  453. " </div>\n"
  454. " <div class=\"modal-card-footer\"><button class=\"btn-cancel-modal\" id=\"cancelUserModalBtn\">取消</button><button class=\"btn-confirm\" id=\"confirmUserBtn\">确认</button></div>\n"
  455. " </div>\n"
  456. " </div>\n"
  457. " <!-- 用户新增 -->\n"
  458. " <div id=\"userAddModal\" class=\"modal-card-overlay\">\n"
  459. " <div class=\"modal-card-container\">\n"
  460. " <div class=\"modal-card-header\"><h3 id=\"userAddModalTitle\">新增用户</h3><button class=\"modal-card-close\" id=\"closeUserAddModalBtn\">&times;</button></div>\n"
  461. " <div class=\"modal-body\">\n"
  462. " <div class=\"config-group\"><label>用户名</label><input type=\"text\" id=\"userAddName\" placeholder=\"请输入用户名\" autocomplete=\"off\"></div>\n"
  463. " <div class=\"config-group\"><label>密码</label><input type=\"password\" id=\"userAddPassword\" placeholder=\"留空则不修改密码(编辑时)\"></div>\n"
  464. " <div class=\"config-group\"><label>角色</label><select id=\"userAddRole\"><option value=\"superadmin\">超级管理员</option><option value=\"admin\">管理员</option><option value=\"user\">普通用户</option></select></div>\n"
  465. " <div id=\"loginAddErrorMsg\" class=\"login-error\"></div>\n"
  466. " </div>\n"
  467. " <div class=\"modal-card-footer\"><button class=\"btn-cancel-modal\" id=\"cancelUserAddModalBtn\">取消</button><button class=\"btn-confirm\" id=\"confirmUserAddBtn\">确认</button></div>\n"
  468. " </div>\n"
  469. " </div>\n"
  470. " \n"
  471. " <script>\n"
  472. " const PKT_TYPE = function() {\n"
  473. " var len = 0;\n"
  474. " return {\n"
  475. " NEW_PKT_TYPE_DEVICE_INFO: len++,\n"
  476. " NEW_PKT_TYPE_ELE_INFO: len++,\n"
  477. " NEW_PKT_TYPE_SENSOR: len++,\n"
  478. " NEW_PKT_TYPE_NETWORK: len++,\n"
  479. " NEW_PKT_TYPE_RS485: len++,\n"
  480. " NEW_PKT_TYPE_SNMP: len++,\n"
  481. " NEW_PKT_TYPE_WANNING: len++,\n"
  482. " NEW_PKT_TYPE_NTP :len++,\n"
  483. " MEW_PKT_TYPE_LOGIN :len++,\n"
  484. " NEW_PKT_TYPE_USER :len++,\n"
  485. " }\n"
  486. " }();\n"
  487. " const SUB_POWER_TYPE = function() {\n"
  488. " var len = 0;\n"
  489. " return {\n"
  490. " NEW_SUB_PKT_TYPE_ELE_DATA_L1: len++,\n"
  491. " NEW_SUB_PKT_TYPE_ELE_DATA_L2: len++,\n"
  492. " NEW_SUB_PKT_TYPE_ELE_DATA_L3: len++,\n"
  493. " NEW_SUB_PKT_TYPE_ELE_DATA_INFO: len++,\n"
  494. " NEW_SUB_PKT_TYPE_ELE_DATA_ALL: len++,\n"
  495. " NEW_SUB_PKT_TYPE_ELE_DATA_THR: len++,\n"
  496. " NEW_SUB_PKT_TYPE_ELE_DELAY: len++,\n"
  497. " NEW_SUB_PKT_TYPE_ELE_CLEAR_CONSUMER: len++,\n"
  498. " NEW_SUB_PKT_TYPE_ELE_CTRL: len++,\n"
  499. " NEW_SUB_PKT_TYPE_ELE_ALL_CTRL: len++,\n"
  500. " NEW_SUB_PKT_TYPE_ELE_BATCH: len++,\n"
  501. " }\n"
  502. " }();\n"
  503. " const SUB_SENSOR_TYPE = function() {\n"
  504. " var len = 0;\n"
  505. " return {\n"
  506. " NEW_SUB_PKT_TYPE_HUMI: len++,\n"
  507. " NEW_SUB_PKT_TYPE_TEMP: len++,\n"
  508. " NEW_SUB_PKT_TYPE_SMOKE: len++,\n"
  509. " NEW_SUB_PKT_TYPE_CO2: len++,\n"
  510. " }\n"
  511. " }();\n"
  512. " const SUB_WANNING_TYPE = function(){\n"
  513. " var len = 0;\n"
  514. " return{\n"
  515. " NEW_SUB_PKT_TYPE_WANNING_CLEAN:len++,\n"
  516. " NEW_SUB_PKT_TYPE_WANNING_SOUND_LIGHT_CLEAN:len++,\n"
  517. " }\n"
  518. " }();\n"
  519. " const SUB_USER_TYPE = function(){\n"
  520. " var len = 0;\n"
  521. " return{\n"
  522. " NEW_SUB_PKT_TYPE_USER_INFO:len++,\n"
  523. " NEW_SUB_PKT_TYPE_USER_ADD:len++,\n"
  524. " NEW_SUB_PKT_TYPE_USER_UPDATE:len++,\n"
  525. " NEW_SUB_PKT_TYPE_USER_DELETE:len++,\n"
  526. " }\n"
  527. " }();\n"
  528. " \n"
  529. " function array_set(array, str, offset) {\n"
  530. " const encoder = new TextEncoder(); \n"
  531. " const buffer = encoder.encode(str);\n"
  532. " array.set(buffer, offset); \n"
  533. " }\n"
  534. " function array_to_string(data) {\n"
  535. " const decoder = new TextDecoder('utf-8');\n"
  536. " const decoded = decoder.decode(data);\n"
  537. " const cleaned = decoded.replace(/\\0/g, '');\n"
  538. " return cleaned;\n"
  539. " }\n"
  540. " function array_cat(a1, a2) {\n"
  541. " var tlen = a1.byteLength + a2.byteLength;\n"
  542. " var buffer = new ArrayBuffer(tlen);\n"
  543. " var vw = new Uint8Array(buffer);\n"
  544. " var vw1 = new Uint8Array(a1);\n"
  545. " for (var i = 0; i < a1.byteLength; i++) {\n"
  546. " vw[i] = vw1[i];\n"
  547. " }\n"
  548. " var vw2 = new Uint8Array(a2);\n"
  549. " for (var i = 0; i < a2.byteLength; i++) {\n"
  550. " vw[i + a1.byteLength] = vw2[i];\n"
  551. " }\n"
  552. " return buffer;\n"
  553. " }\n"
  554. " \n"
  555. " function bin_to_hdr(bin) {\n"
  556. " var tmp, length = 0;\n"
  557. " tmp = new DataView(bin, length); this.magic = tmp.getUint16(0, true); length += 2;\n"
  558. " tmp = new DataView(bin, length); this.addr = tmp.getUint8(0, true); length += 1;\n"
  559. " tmp = new DataView(bin, length); this.type = tmp.getUint8(0, true); length += 1;\n"
  560. " tmp = new DataView(bin, length); this.subtype = tmp.getUint8(0, true); length += 1;\n"
  561. " tmp = new DataView(bin, length); this.nack = tmp.getUint8(0, true); length += 1;\n"
  562. " tmp = new DataView(bin, length); this.flag = tmp.getUint32(0, true); length += 4;\n"
  563. " tmp = new DataView(bin, length); this.dlen = tmp.getUint32(0, true); length += 4;\n"
  564. " this.len = length;\n"
  565. " }\n"
  566. " \n"
  567. " function mk_hdr_bin(addr, type, subtype, nack, flag, dlen) {\n"
  568. " var tmp, length = 0;\n"
  569. " var t = MAGIC;\n"
  570. " var buffer = new ArrayBuffer(14);\n"
  571. " tmp = new DataView(buffer, length); tmp.setUint16(0, t, true); length += 2; //MAGIC\n"
  572. " tmp = new DataView(buffer, length); tmp.setUint8(0, addr, true); length += 1; //addr\n"
  573. " tmp = new DataView(buffer, length); tmp.setUint8(0, type, true); length += 1; //type\n"
  574. " tmp = new DataView(buffer, length); tmp.setUint8(0, subtype, true); length += 1; //subtype\n"
  575. " tmp = new DataView(buffer, length); tmp.setUint8(0, nack, true); length += 1; //nack\n"
  576. " tmp = new DataView(buffer, length); tmp.setUint32(0, flag, true); length += 4; //flag\n"
  577. " tmp = new DataView(buffer, length); tmp.setUint32(0, dlen, true); length += 4; //dlen\n"
  578. " return buffer;\n"
  579. " }\n"
  580. " function bin_to_device_info(bin) {\n"
  581. " var tmp, bin2, length = 0;\n"
  582. " tmp = new DataView(bin, length); this.chs = tmp.getUint8(0, true); length += 1;\n"
  583. " tmp = new DataView(bin, length); this.power_type = tmp.getInt8(0, true); length += 1;\n"
  584. " tmp = new DataView(bin, length); this.zone = tmp.getUint8(0, true); length += 1;\n"
  585. " tmp = new DataView(bin, length); this.board_cnt = tmp.getUint8(0, true); length += 1;\n"
  586. " this.soft_version = array_to_string(bin.slice(length, 32)); length += 32;\n"
  587. " this.hard_version = array_to_string(bin.slice(length, length + 32)); length += 32;\n"
  588. " this.date = array_to_string(bin.slice(length, length + 16)); length += 16;\n"
  589. " this.time = array_to_string(bin.slice(length, length + 16)); length += 16;\n"
  590. " \n"
  591. " this.len = length;\n"
  592. " }\n"
  593. " function bin_to_power_th(bin) {\n"
  594. " var tmp, length = 2;\n"
  595. " tmp = new DataView(bin, length); this.v_upper = tmp.getFloat32(0, true); length += 4;\n"
  596. " tmp = new DataView(bin, length); this.v_lower = tmp.getFloat32(0, true); length += 4;\n"
  597. " tmp = new DataView(bin, length); this.c_upper = tmp.getFloat32(0, true); length += 4;\n"
  598. " tmp = new DataView(bin, length); this.p_upper = tmp.getFloat32(0, true); length += 4;\n"
  599. " tmp = new DataView(bin, length); this.w_upper = tmp.getFloat32(0, true); length += 4;\n"
  600. " this.len = length;\n"
  601. " }\n"
  602. " function bin_to_sensor(bin){\n"
  603. " var tmp, length = 0;\n"
  604. " this.name = array_to_string(bin.slice(length, 32)); length += 32;\n"
  605. " tmp = new DataView(bin, length); this.status = tmp.getUint8(0, true); length += 1;\n"
  606. " tmp = new DataView(bin, length); this.v_max_wrn = tmp.getUint8(0, true); length += 1;\n"
  607. " tmp = new DataView(bin, length); this.v_min_wrn = tmp.getUint8(0, true); length += 1;\n"
  608. " tmp = new DataView(bin, length); this.value = tmp.getFloat32(0, true); length += 4;\n"
  609. " tmp = new DataView(bin, length); this.v_max = tmp.getFloat32(0, true); length += 4;\n"
  610. " tmp = new DataView(bin, length); this.v_min = tmp.getFloat32(0, true); length += 4;\n"
  611. " this.len = length; \n"
  612. " }\n"
  613. " function bin_to_network(bin)\n"
  614. " {\n"
  615. " var tmp, length = 0;\n"
  616. " tmp = new DataView(bin, length); this.mode = tmp.getUint8(0, true); length += 1;\n"
  617. " this.ipaddr = array_to_string(bin.slice(length, length+48)); length += 48;\n"
  618. " this.mask = array_to_string(bin.slice(length, length+48)); length += 48;\n"
  619. " this.gateway = array_to_string(bin.slice(length, length+48)); length += 48;\n"
  620. " this.dns1 = array_to_string(bin.slice(length, length+48)); length += 48;\n"
  621. " this.dns2 = array_to_string(bin.slice(length, length+48)); length += 48;\n"
  622. " this.len = length; \n"
  623. " }\n"
  624. " function bin_to_rs485(bin)\n"
  625. " {\n"
  626. " var tmp, length = 0;\n"
  627. " tmp = new DataView(bin, length); this.mode = tmp.getUint8(0, true); length += 1;\n"
  628. " tmp = new DataView(bin, length); this.addr = tmp.getUint8(0, true); length += 1;\n"
  629. " tmp = new DataView(bin, length); this.baud = tmp.getUint32(0, true); length += 4;\n"
  630. " this.len = length;\n"
  631. " }\n"
  632. " \n"
  633. " function bin_to_snmp(bin)\n"
  634. " {\n"
  635. " var tmp, length = 0;\n"
  636. " tmp = new DataView(bin, length); this.mode = tmp.getUint8(0, true); length += 1;\n"
  637. " tmp = new DataView(bin, length); this.version = tmp.getUint8(0, true); length += 1;\n"
  638. " this.publics = array_to_string(bin.slice(length, length+10)); length += 10;\n"
  639. " this.privates = array_to_string(bin.slice(length, length+10)); length += 10;\n"
  640. " tmp = new DataView(bin, length); this.trapmode = tmp.getUint8(0, true); length += 1;\n"
  641. " this.nms_ip = array_to_string(bin.slice(length, length+32)); length += 32;\n"
  642. " this.len = length;\n"
  643. " }\n"
  644. " function bin_to_login(bin)\n"
  645. " {\n"
  646. " var tmp, length = 0;\n"
  647. " tmp = new DataView(bin, length); this.flag = tmp.getUint8(0, true); length += 1;\n"
  648. " this.len = length;\n"
  649. " }\n"
  650. " function bin_to_user(bin)\n"
  651. " {\n"
  652. " var tmp, length = 0;\n"
  653. " tmp = new DataView(bin, length); this.flag = tmp.getUint8(0, true); length += 1;\n"
  654. " this.len = length;\n"
  655. " }\n"
  656. " function bin_to_user_cnt(bin)\n"
  657. " {\n"
  658. " var tmp,length = 0;\n"
  659. " tmp = new DataView(bin, length); this.cnt = tmp.getUint32(0, true); length += 4;\n"
  660. " this.len = length;\n"
  661. " }\n"
  662. " function bin_to_users(bin)\n"
  663. " {\n"
  664. " var tmp, length = 0;\n"
  665. " tmp = new DataView(bin, length); this.role = tmp.getUint32(0, true); length += 4;\n"
  666. " this.user = array_to_string(bin.slice(length, length+32)); length += 32;\n"
  667. " this.date = array_to_string(bin.slice(length, length+16)); length += 16;\n"
  668. " this.time = array_to_string(bin.slice(length, length+16)); length += 16;\n"
  669. " this.len = length;\n"
  670. " }\n"
  671. " \n"
  672. " function bin_to_wanning_count(bin)\n"
  673. " {\n"
  674. " var tmp, length = 0;\n"
  675. " tmp = new DataView(bin, length); this.count = tmp.getUint16(0, true); length += 2;\n"
  676. " this.len = length;\n"
  677. " } \n"
  678. " function bin_to_wanning(bin)\n"
  679. " {\n"
  680. " var tmp, length = 0;\n"
  681. " tmp = new DataView(bin, length); this.type = tmp.getUint8(0, true); length += 1;\n"
  682. " this.date = array_to_string(bin.slice(length, length+32)); length += 32;\n"
  683. " this.context = array_to_string(bin.slice(length, length+64)); length += 64;\n"
  684. " this.len = length;\n"
  685. " }\n"
  686. " function bin_to_power(bin) {\n"
  687. " var tmp, length = 0;\n"
  688. " tmp = new DataView(bin, length); this.voltage = tmp.getFloat32(0, true); length += 4;\n"
  689. " tmp = new DataView(bin, length); this.current = tmp.getFloat32(0, true); length += 4;\n"
  690. " tmp = new DataView(bin, length); this.power = tmp.getFloat32(0, true); length += 4;\n"
  691. " tmp = new DataView(bin, length); this.reactive_power = tmp.getFloat32(0, true); length += 4;\n"
  692. " tmp = new DataView(bin, length); this.app_power = tmp.getFloat32(0, true); length += 4;\n"
  693. " tmp = new DataView(bin, length); this.freq = tmp.getFloat32(0, true); length += 4;\n"
  694. " tmp = new DataView(bin, length); this.factor = tmp.getFloat32(0, true); length += 4;\n"
  695. " tmp = new DataView(bin, length); this.consump = tmp.getFloat32(0, true); length += 4;\n"
  696. " this.len = length;\n"
  697. " }\n"
  698. " \n"
  699. " function bin_to_power_info(bin) {\n"
  700. " var tmp, length = 0;\n"
  701. " this.name = array_to_string(bin.slice(length, 16)); length += 16;\n"
  702. " tmp = new DataView(bin, length); this.addr = tmp.getUint8(0, true); length += 1;\n"
  703. " tmp = new DataView(bin, length); this.sch = tmp.getUint8(0, true); length += 1;\n"
  704. " tmp = new DataView(bin, length); this.phse = tmp.getUint8(0, true); length += 1;\n"
  705. " tmp = new DataView(bin, length); this.phse1 = tmp.getUint8(0, true); length += 1;\n"
  706. " tmp = new DataView(bin, length); this.open = tmp.getUint8(0, true); length += 1;\n"
  707. " tmp = new DataView(bin, length); this.close = tmp.getUint8(0, true); length += 1;\n"
  708. " tmp = new DataView(bin, length); this.status = tmp.getUint8(0, true); length += 1;\n"
  709. " tmp = new DataView(bin, length); let val = tmp.getUint32(0, true); length += 4;\n"
  710. " this.l1_v_upper = (val & 0x1); this.l1_v_lower = (val & 0x2); this.l1_c_upper = (val & 0x4); this.l1_p_upper = (val & 0x8); this.l1_w_upper = (val & 0x10);\n"
  711. " this.l2_v_upper = (val & (1 << 8)); this.l2_v_lower = (val & (1 << 9)); this.l2_c_upper = (val & (1 << 10)); this.l2_p_upper = (val & (1 << 11)); this.l2_w_upper = (val & (1 << 12));\n"
  712. " this.l3_v_upper = (val & (1 << 16)); this.l3_v_lower = (val & (1 << 17)); this.l3_c_upper = (val & (1 << 18)); this.l3_p_upper = (val & (1 << 19)); this.l3_w_upper = (val & (1 << 20));\n"
  713. " this.ph_loss1 = (val & (1 << 24)); this.ph_loss2 = (val & (1 << 25)); this.ph_loss3 = (val & (1 << 26));\n"
  714. " this.len = length;\n"
  715. " }\n"
  716. " function ctrl_to_bin(data)\n"
  717. " {\n"
  718. " var bin, tmp, length = 0;\n"
  719. " bin = new ArrayBuffer(data.len);\n"
  720. " tmp = new DataView(bin, length); tmp.setUint8(0, data.sch, true); length +=1;\n"
  721. " tmp = new DataView(bin, length); tmp.setUint8(0, data.status, true); length +=1;\n"
  722. " return bin;\n"
  723. " }\n"
  724. " function reboot_to_bin(data)\n"
  725. " {\n"
  726. " var bin, tmp, length = 0;\n"
  727. " bin = new ArrayBuffer(data.len);\n"
  728. " tmp = new DataView(bin, length); tmp.setUint8(0, data.flag, true); length +=1;\n"
  729. " return bin;\n"
  730. " }\n"
  731. " function delay_to_bin(data)\n"
  732. " {\n"
  733. " var bin, tmp, length = 0;\n"
  734. " bin = new ArrayBuffer(data.len);\n"
  735. " tmp = new DataView(bin, length); tmp.setUint8(0, data.channel, true); length +=1;\n"
  736. " tmp = new DataView(bin, length); tmp.setUint8(0, data.open, true); length +=1;\n"
  737. " tmp = new DataView(bin, length); tmp.setUint8(0, data.close, true); length +=1;\n"
  738. " return bin;\n"
  739. " }\n"
  740. " function thr_to_bin(data)\n"
  741. " {\n"
  742. " var bin, tmp, length = 0;\n"
  743. " bin = new ArrayBuffer(data.len);\n"
  744. " tmp = new DataView(bin, length); tmp.setUint8(0, data.channel, true); length +=1;\n"
  745. " tmp = new DataView(bin, length); tmp.setUint16(0, data.en, true); length +=2;\n"
  746. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.vmax, true); length +=4;\n"
  747. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.vmin, true); length +=4;\n"
  748. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.cmax, true); length +=4;\n"
  749. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.pmax, true); length +=4;\n"
  750. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.wmax, true); length +=4;\n"
  751. " return bin;\n"
  752. " } \n"
  753. " function clear_consumer_bin(data)\n"
  754. " {\n"
  755. " var bin, tmp, length = 0;\n"
  756. " bin = new ArrayBuffer(data.len);\n"
  757. " tmp = new DataView(bin, length); tmp.setUint8(0, data.channel, true); length +=1; \n"
  758. " return bin; \n"
  759. " } \n"
  760. " \n"
  761. " function all_contol_to_bin(data)\n"
  762. " {\n"
  763. " var bin, tmp, length = 0;\n"
  764. " bin = new ArrayBuffer(data.len);\n"
  765. " tmp = new DataView(bin, length); tmp.setUint8(0, data.status, true); length +=1; \n"
  766. " return bin; \n"
  767. " } \n"
  768. " function sensor_thr_to_bin(data)\n"
  769. " {\n"
  770. " var bin, tmp, length = 0;\n"
  771. " bin = new ArrayBuffer(data.len);\n"
  772. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.vmax, true); length +=4;\n"
  773. " tmp = new DataView(bin, length); tmp.setFloat32(0, data.vmin, true); length +=4;\n"
  774. " return bin; \n"
  775. " } \n"
  776. " function network_to_bin(data)\n"
  777. " {\n"
  778. " var bin, tmp, length = 0;\n"
  779. " bin = new ArrayBuffer(data.len);\n"
  780. " tmp = new DataView(bin, length); tmp.setUint8(0, data.ipMode,true); length += 1;\n"
  781. " array_set(new Uint8Array(bin), data.ipAddress, length); length += 48;\n"
  782. " array_set(new Uint8Array(bin), data.subnetMask, length); length += 48;\n"
  783. " array_set(new Uint8Array(bin), data.gateway, length); length += 48;\n"
  784. " array_set(new Uint8Array(bin), data.dns1, length); length += 48;\n"
  785. " array_set(new Uint8Array(bin), data.dns2, length); length += 48;\n"
  786. " return bin;\n"
  787. " }\n"
  788. " function rs485_to_bin(data)\n"
  789. " {\n"
  790. " var bin, tmp, length = 0;\n"
  791. " bin = new ArrayBuffer(data.len);\n"
  792. " tmp = new DataView(bin, length); tmp.setUint8(0, data.rs485Mode,true); length += 1;\n"
  793. " tmp = new DataView(bin, length); tmp.setUint8(0, data.rs485Addr,true); length += 1;\n"
  794. " tmp = new DataView(bin, length); tmp.setUint32(0, data.rs485Baudrate,true); length += 4;\n"
  795. " return bin;\n"
  796. " }\n"
  797. " function snmp_to_bin(data)\n"
  798. " {\n"
  799. " var bin, tmp, length = 0;\n"
  800. " bin = new ArrayBuffer(data.len);\n"
  801. " tmp = new DataView(bin, length); tmp.setUint8(0, data.mode,true); length += 1;\n"
  802. " tmp = new DataView(bin, length); tmp.setUint8(0, data.version,true); length += 1;\n"
  803. " array_set(new Uint8Array(bin), data.snmpReadCommunity, length); length += 10;\n"
  804. " array_set(new Uint8Array(bin), data.snmpWriteCommunity, length); length += 10;\n"
  805. " tmp = new DataView(bin, length); tmp.setUint8(0, data.snmpTrapStatus,true); length += 1;\n"
  806. " array_set(new Uint8Array(bin), data.snmpTrapIp, length); length += 32;\n"
  807. " return bin;\n"
  808. " }\n"
  809. " function ntp_to_bin(data)\n"
  810. " {\n"
  811. " var bin, tmp, length = 0;\n"
  812. " bin = new ArrayBuffer(data.len);\n"
  813. " tmp = new DataView(bin, length); tmp.setInt8(0, data.ntpZone,true); length += 1;\n"
  814. " array_set(new Uint8Array(bin), data.ntpDateTime, length); length += 32;\n"
  815. " return bin; \n"
  816. " }\n"
  817. " function wanning_to_bin(data)\n"
  818. " {\n"
  819. " var bin, tmp, length = 0;\n"
  820. " bin = new ArrayBuffer(data.len);\n"
  821. " tmp = new DataView(bin, length); tmp.setUint8(0, data.value,true); length += 1;\n"
  822. " return bin; \n"
  823. " }\n"
  824. " function user_add_to_bin(data)\n"
  825. " {\n"
  826. " var bin, tmp, length = 0;\n"
  827. " bin = new ArrayBuffer(data.len);\n"
  828. " tmp = new DataView(bin, length); tmp.setUint8(0, data.role,true); length += 1;\n"
  829. " array_set(new Uint8Array(bin), data.user, length); length += 32;\n"
  830. " array_set(new Uint8Array(bin), data.password, length); length += 32;\n"
  831. " return bin;\n"
  832. " }\n"
  833. " function user_delete_to_bin(data)\n"
  834. " {\n"
  835. " var bin, tmp, length = 0;\n"
  836. " bin = new ArrayBuffer(data.len);\n"
  837. " array_set(new Uint8Array(bin), data.user, length); length += 32;\n"
  838. " return bin;\n"
  839. " }\n"
  840. " \n"
  841. " function user_update_to_bin(data)\n"
  842. " {\n"
  843. " var bin, tmp, length = 0;\n"
  844. " bin = new ArrayBuffer(data.len);\n"
  845. " tmp = new DataView(bin, length); tmp.setUint8(0, data.role,true); length += 1;\n"
  846. " array_set(new Uint8Array(bin), data.user, length); length += 32;\n"
  847. " array_set(new Uint8Array(bin), data.old_password, length); length += 32;\n"
  848. " array_set(new Uint8Array(bin), data.new_password, length); length += 32;\n"
  849. " return bin;\n"
  850. " }\n"
  851. " function pkt_to_bin(addr, type, subtype, nack, flag, js) {\n"
  852. " var tmp;\n"
  853. " var buffer = new mk_hdr_bin(addr, type, subtype, nack, flag, js.len);\n"
  854. " switch(type)\n"
  855. " {\n"
  856. " case PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO:\n"
  857. " {\n"
  858. " tmp = new reboot_to_bin(js);\n"
  859. " }\n"
  860. " break;\n"
  861. " case PKT_TYPE.NEW_PKT_TYPE_ELE_INFO:\n"
  862. " {\n"
  863. " switch(subtype)\n"
  864. " {\n"
  865. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_CTRL:\n"
  866. " {\n"
  867. " tmp = new ctrl_to_bin(js);\n"
  868. " }\n"
  869. " break;\n"
  870. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DELAY:\n"
  871. " {\n"
  872. " tmp = new delay_to_bin(js);\n"
  873. " }\n"
  874. " break;\n"
  875. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_THR:\n"
  876. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_BATCH:\n"
  877. " {\n"
  878. " tmp = new thr_to_bin(js);\n"
  879. " }\n"
  880. " break;\n"
  881. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_CLEAR_CONSUMER:\n"
  882. " {\n"
  883. " tmp = new clear_consumer_bin(js);\n"
  884. " }\n"
  885. " break;\n"
  886. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_ALL_CTRL:\n"
  887. " {\n"
  888. " tmp = new all_contol_to_bin(js);\n"
  889. " }\n"
  890. " break;\n"
  891. " default:\n"
  892. " break;\n"
  893. " }\n"
  894. " }\n"
  895. " break;\n"
  896. " case PKT_TYPE.NEW_PKT_TYPE_SENSOR:\n"
  897. " {\n"
  898. " tmp = new sensor_thr_to_bin(js);\n"
  899. " }\n"
  900. " break;\n"
  901. " case PKT_TYPE.NEW_PKT_TYPE_NETWORK:\n"
  902. " {\n"
  903. " tmp = new network_to_bin(js);\n"
  904. " }\n"
  905. " break;\n"
  906. " case PKT_TYPE.NEW_PKT_TYPE_RS485:\n"
  907. " {\n"
  908. " tmp = new rs485_to_bin(js);\n"
  909. " }\n"
  910. " break;\n"
  911. " case PKT_TYPE.NEW_PKT_TYPE_SNMP:\n"
  912. " {\n"
  913. " tmp = new snmp_to_bin(js);\n"
  914. " }\n"
  915. " break;\n"
  916. " case PKT_TYPE.NEW_PKT_TYPE_NTP:\n"
  917. " {\n"
  918. " tmp = new ntp_to_bin(js);\n"
  919. " }\n"
  920. " break;\n"
  921. " case PKT_TYPE.NEW_PKT_TYPE_WANNING:\n"
  922. " {\n"
  923. " switch(subtype)\n"
  924. " {\n"
  925. " case SUB_WANNING_TYPE.NEW_SUB_PKT_TYPE_WANNING_CLEAN:\n"
  926. " {\n"
  927. " tmp = new wanning_to_bin(js);\n"
  928. " }\n"
  929. " break;\n"
  930. " case SUB_WANNING_TYPE.NEW_SUB_PKT_TYPE_WANNING_SOUND_LIGHT_CLEAN:\n"
  931. " {\n"
  932. " tmp = new wanning_to_bin(js);\n"
  933. " }\n"
  934. " break;\n"
  935. " default:\n"
  936. " break;\n"
  937. " }\n"
  938. " }\n"
  939. " break;\n"
  940. " case PKT_TYPE.NEW_PKT_TYPE_USER:\n"
  941. " {\n"
  942. " switch(subtype)\n"
  943. " {\n"
  944. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_ADD:\n"
  945. " {\n"
  946. " tmp = new user_add_to_bin(js);\n"
  947. " }\n"
  948. " break;\n"
  949. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_UPDATE:\n"
  950. " {\n"
  951. " tmp = new user_update_to_bin(js);\n"
  952. " }\n"
  953. " break;\n"
  954. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_DELETE:\n"
  955. " {\n"
  956. " tmp = new user_delete_to_bin(js);\n"
  957. " \n"
  958. " }\n"
  959. " break;\n"
  960. " }\n"
  961. " }\n"
  962. " break;\n"
  963. " default:\n"
  964. " break;\n"
  965. " }\n"
  966. " return array_cat(buffer, tmp);\n"
  967. " }\n"
  968. " function single_ctrl(channel,status)\n"
  969. " {\n"
  970. " data = {sch:0,status:0,len:2};\n"
  971. " data.sch = channel;\n"
  972. " data.status = status;\n"
  973. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_CTRL, 0, 0, data);\n"
  974. " ws.send(a);\n"
  975. " }\n"
  976. " \n"
  977. " \n"
  978. " function channel_set_delay(channel,open,close)\n"
  979. " {\n"
  980. " data = [];\n"
  981. " data.channel = channel;\n"
  982. " data.open = open;\n"
  983. " data.close = close;\n"
  984. " data.len = 3;\n"
  985. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DELAY, 0, 0, data);\n"
  986. " ws.send(a);\n"
  987. " }\n"
  988. " function channel_set_thr(channel,vmax,vmin,cmax,pmax,wmax)\n"
  989. " {\n"
  990. " data = [];\n"
  991. " data.channel = channel;\n"
  992. " data.en=0x1F;\n"
  993. " data.vmax = vmax;\n"
  994. " data.vmin = vmin;\n"
  995. " data.cmax = cmax;\n"
  996. " data.pmax = pmax;\n"
  997. " data.wmax = wmax;\n"
  998. " data.len = 23;\n"
  999. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_THR, 0, 0, data);\n"
  1000. " ws.send(a);\n"
  1001. " }\n"
  1002. " function batch_set_thr(channel,vmax,vmin,cmax,pmax,wmax)\n"
  1003. " {\n"
  1004. " data = [];\n"
  1005. " data.channel = 0;\n"
  1006. " data.en=0x1F;\n"
  1007. " data.vmax = vmax;\n"
  1008. " data.vmin = vmin;\n"
  1009. " data.cmax = cmax;\n"
  1010. " data.pmax = pmax;\n"
  1011. " data.wmax = wmax;\n"
  1012. " data.len = 23;\n"
  1013. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_BATCH, 0, 0, data);\n"
  1014. " ws.send(a); \n"
  1015. " }\n"
  1016. " function channel_clear_consumer(channel)\n"
  1017. " {\n"
  1018. " data = [];\n"
  1019. " data.channel = channel;\n"
  1020. " data.len = 1;\n"
  1021. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_CLEAR_CONSUMER, 0, 0, data);\n"
  1022. " ws.send(a);\n"
  1023. " }\n"
  1024. " \n"
  1025. " \n"
  1026. " function all_contrl(status)\n"
  1027. " {\n"
  1028. " data = [];\n"
  1029. " data.status = status;\n"
  1030. " data.len = 1;\n"
  1031. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_ALL_CTRL, 0, 0, data);\n"
  1032. " ws.send(a); \n"
  1033. " }\n"
  1034. " function set_sensor_thr(vmax,vmin,type)\n"
  1035. " {\n"
  1036. " data = [];\n"
  1037. " data.vmax = vmax;\n"
  1038. " data.vmin = vmin;\n"
  1039. " data.len = 8;\n"
  1040. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_SENSOR,type, 0, 0, data);\n"
  1041. " console.log(data.vmax,data.vmin);\n"
  1042. " ws.send(a); \n"
  1043. " }\n"
  1044. " \n"
  1045. " function clean_alarm()\n"
  1046. " {\n"
  1047. " data = [];\n"
  1048. " data.value = 0;\n"
  1049. " data.len = 1;\n"
  1050. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_WANNING,SUB_WANNING_TYPE.NEW_SUB_PKT_TYPE_WANNING_CLEAN, 0, 0, data);\n"
  1051. " ws.send(a); \n"
  1052. " }\n"
  1053. " function clean_sound_light()\n"
  1054. " {\n"
  1055. " data = [];\n"
  1056. " data.value = 0;\n"
  1057. " data.len = 1;\n"
  1058. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_WANNING,SUB_WANNING_TYPE.NEW_SUB_PKT_TYPE_WANNING_SOUND_LIGHT_CLEAN, 0, 0, data);\n"
  1059. " ws.send(a); \n"
  1060. " showToast(\"清除声光报警\", 1000); \n"
  1061. " }\n"
  1062. " \n"
  1063. " var temp = [];\n"
  1064. " function bin_parse(bin) {\n"
  1065. " var tmp, h = new bin_to_hdr(bin);\n"
  1066. " if (h.nack == 1) {}\n"
  1067. " var data = bin.slice(h.len);\n"
  1068. " if (data.byteLength > 0 && h.dlen == data.byteLength) {\n"
  1069. " switch (h.type) {\n"
  1070. " case PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO:\n"
  1071. " {\n"
  1072. " h.device_info = new bin_to_device_info(data.slice(length));\n"
  1073. " }\n"
  1074. " break;\n"
  1075. " case PKT_TYPE.NEW_PKT_TYPE_ELE_INFO:\n"
  1076. " {\n"
  1077. " var length = 0;\n"
  1078. " switch(h.subtype)\n"
  1079. " {\n"
  1080. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_ALL:\n"
  1081. " {\n"
  1082. " h.power_all = new bin_to_power(data.slice(length));\n"
  1083. " length += h.power_all.len;\n"
  1084. " for(var i = 0; i < 3;i++)\n"
  1085. " {\n"
  1086. " temp[i] = new bin_to_power(data.slice(length));\n"
  1087. " length += temp[i].len;\n"
  1088. " }\n"
  1089. " h.power_all_l = temp;\n"
  1090. " }\n"
  1091. " break;\n"
  1092. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_INFO:\n"
  1093. " {\n"
  1094. " for(let i = 0;i < device_info.chs;i++)\n"
  1095. " {\n"
  1096. " temp[i] = new bin_to_power_info(data.slice(length));\n"
  1097. " length += temp[i].len;\n"
  1098. " }\n"
  1099. " h.power_info = temp;\n"
  1100. " }\n"
  1101. " break;\n"
  1102. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L1:\n"
  1103. " {\n"
  1104. " for(var i = 0; i < device_info.chs;i++)\n"
  1105. " {\n"
  1106. " temp[i] = new bin_to_power(data.slice(length));\n"
  1107. " length += temp[i].len;\n"
  1108. " }\n"
  1109. " h.power_data = temp;\n"
  1110. " }\n"
  1111. " break;\n"
  1112. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L2:\n"
  1113. " {\n"
  1114. " for(var i = 0; i < device_info.chs;i++)\n"
  1115. " {\n"
  1116. " temp[i] = new bin_to_power(data.slice(length));\n"
  1117. " length += temp[i].len;\n"
  1118. " }\n"
  1119. " h.power_data1 = temp;\n"
  1120. " }\n"
  1121. " break;\n"
  1122. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L3:\n"
  1123. " {\n"
  1124. " for(var i = 0; i < device_info.chs;i++)\n"
  1125. " {\n"
  1126. " temp[i] = new bin_to_power(data.slice(length));\n"
  1127. " length += temp[i].len;\n"
  1128. " }\n"
  1129. " h.power_data2 = temp;\n"
  1130. " }\n"
  1131. " break;\n"
  1132. " case SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_THR:\n"
  1133. " {\n"
  1134. " for(var i = 0; i < device_info.chs;i++)\n"
  1135. " {\n"
  1136. " temp[i] = new bin_to_power_th(data.slice(length));\n"
  1137. " length += temp[i].len;\n"
  1138. " } \n"
  1139. " h.power_thr = temp;\n"
  1140. " }\n"
  1141. " break;\n"
  1142. " default:\n"
  1143. " break;\n"
  1144. " }\n"
  1145. " }\n"
  1146. " break;\n"
  1147. " case PKT_TYPE.NEW_PKT_TYPE_SENSOR:\n"
  1148. " {\n"
  1149. " var length = 0;\n"
  1150. " for(let i =0;i < 4; i++)\n"
  1151. " {\n"
  1152. " temp[i] = new bin_to_sensor(data.slice(length));\n"
  1153. " length += temp[i].len;\n"
  1154. " }\n"
  1155. " h.sensor_info = temp;\n"
  1156. " }\n"
  1157. " break;\n"
  1158. " case PKT_TYPE.NEW_PKT_TYPE_NETWORK:\n"
  1159. " {\n"
  1160. " h.network = new bin_to_network(data.slice(length));\n"
  1161. " }\n"
  1162. " break;\n"
  1163. " case PKT_TYPE.NEW_PKT_TYPE_RS485:\n"
  1164. " {\n"
  1165. " h.rs485 = new bin_to_rs485(data.slice(length));\n"
  1166. " }\n"
  1167. " break;\n"
  1168. " case PKT_TYPE.NEW_PKT_TYPE_SNMP:\n"
  1169. " {\n"
  1170. " h.snmp = new bin_to_snmp(data.slice(length));\n"
  1171. " }\n"
  1172. " break;\n"
  1173. " case PKT_TYPE.NEW_PKT_TYPE_WANNING:\n"
  1174. " {\n"
  1175. " var length = 0;\n"
  1176. " h.wanni_count = new bin_to_wanning_count(data.slice(length));\n"
  1177. " length += h.wanni_count.len;\n"
  1178. " for(let i = 0; i < h.wanni_count.count;i++)\n"
  1179. " {\n"
  1180. " temp[i] = new bin_to_wanning(data.slice(length));\n"
  1181. " length += temp[i].len;\n"
  1182. " }\n"
  1183. " h.wanning = temp;\n"
  1184. " }\n"
  1185. " break; \n"
  1186. " case PKT_TYPE.NEW_PKT_TYPE_USER:\n"
  1187. " {\n"
  1188. " switch(h.subtype)\n"
  1189. " {\n"
  1190. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_INFO:\n"
  1191. " {\n"
  1192. " var length = 0;\n"
  1193. " var tmp = [];\n"
  1194. " h.user_count = new bin_to_user_cnt(data.slice(length));\n"
  1195. " length += h.user_count.len;\n"
  1196. " for(let i = 0; i < h.user_count.cnt;i++)\n"
  1197. " {\n"
  1198. " tmp[i] = new bin_to_users(data.slice(length));\n"
  1199. " length += tmp[i].len;\n"
  1200. " }\n"
  1201. " h.users = tmp;\n"
  1202. " }\n"
  1203. " break;\n"
  1204. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_ADD:\n"
  1205. " {\n"
  1206. " h.user_add = new bin_to_user(data.slice(length));\n"
  1207. " }\n"
  1208. " break;\n"
  1209. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_DELETE:\n"
  1210. " {\n"
  1211. " h.user_delete = new bin_to_user(data.slice(length));\n"
  1212. " }\n"
  1213. " break;\n"
  1214. " case SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_UPDATE:\n"
  1215. " {\n"
  1216. " h.user_update = new bin_to_user(data.slice(length));\n"
  1217. " }\n"
  1218. " break;\n"
  1219. " }\n"
  1220. " }\n"
  1221. " break;\n"
  1222. " case PKT_TYPE.MEW_PKT_TYPE_LOGIN:\n"
  1223. " {\n"
  1224. " h.login = new bin_to_login(data.slice(length));\n"
  1225. " } \n"
  1226. " break; \n"
  1227. " default:\n"
  1228. " console.log(\"wrong hdr type: \" + h.type);\n"
  1229. " break;\n"
  1230. " }\n"
  1231. " }\n"
  1232. " return h;\n"
  1233. " };\n"
  1234. " function openTempModal()\n"
  1235. " {\n"
  1236. " let vmax = tempValue.v_max;\n"
  1237. " let vmin = tempValue.v_min;\n"
  1238. " document.getElementById('tempMax').value=vmax.toFixed(2);\n"
  1239. " document.getElementById('tempMin').value=vmin.toFixed(2);\n"
  1240. " document.getElementById('tempCardModal').classList.add('active');\n"
  1241. " } \n"
  1242. " \n"
  1243. " function openHumiModal()\n"
  1244. " {\n"
  1245. " let vmax = humiValue.v_max;\n"
  1246. " let vmin = humiValue.v_min;\n"
  1247. " document.getElementById('humiMax').value=vmax.toFixed(2);\n"
  1248. " document.getElementById('humiMin').value=vmin.toFixed(2);\n"
  1249. " document.getElementById('humiCardModal').classList.add('active');\n"
  1250. " }\n"
  1251. " function openSmokeModal()\n"
  1252. " {\n"
  1253. " let vmax = smokeValue.v_max;\n"
  1254. " let vmin = smokeValue.v_min;\n"
  1255. " document.getElementById('smokeMax').value=vmax.toFixed(2);\n"
  1256. " document.getElementById('smokeMin').value=vmin.toFixed(2);\n"
  1257. " document.getElementById('smokeCardModal').classList.add('active');\n"
  1258. " }\n"
  1259. " function openCo2Modal()\n"
  1260. " {\n"
  1261. " let vmax = co2Value.v_max;\n"
  1262. " let vmin = co2Value.v_min;\n"
  1263. " document.getElementById('Co2Max').value=vmax.toFixed(2);\n"
  1264. " document.getElementById('Co2Min').value=vmin.toFixed(2);\n"
  1265. " document.getElementById('co2CardModal').classList.add('active');\n"
  1266. " }\n"
  1267. " function openDelayModal() {\n"
  1268. " const grid = document.getElementById('delayGrid');\n"
  1269. " if (!grid) return;\n"
  1270. " grid.innerHTML = '';\n"
  1271. " for (let i = 0; i < device_info.chs; i++) {\n"
  1272. " const delays = channelDelays[i];\n"
  1273. " const rowDiv = document.createElement('div');\n"
  1274. " rowDiv.className = 'config-row';\n"
  1275. " rowDiv.innerHTML = '<div class=\"config-row-title\">CH' + (i+1) + ' · ' + delays.name + '</div>' +\n"
  1276. " '<div class=\"config-inputs\">' +\n"
  1277. " '<div class=\"config-item\"><label>⏫ 开延时 (秒)</label><input type=\"number\" step=\"0.1\" min=\"0.3\" max=\"10\" id=\"onDelay_' + i + '\" value=\"' + delays.onSec + '\"></div>' +\n"
  1278. " '<div class=\"config-item\"><label>⏬ 关延时 (秒)</label><input type=\"number\" step=\"0.1\" min=\"0.3\" max=\"10\" id=\"offDelay_' + i + '\" value=\"' + delays.offSec + '\"></div>' +\n"
  1279. " '<button class=\"save-channel-config-btn\" data-channel=\"' + i + '\">💾 保存本通道</button>' +\n"
  1280. " '</div>';\n"
  1281. " const saveBtn = rowDiv.querySelector('.save-channel-config-btn');\n"
  1282. " saveBtn.addEventListener('click', (function(idx) {\n"
  1283. " return function() {\n"
  1284. " const onVal = parseFloat(document.getElementById('onDelay_' + idx).value);\n"
  1285. " const offVal = parseFloat(document.getElementById('offDelay_' + idx).value);\n"
  1286. " channel_set_delay(idx,onVal,offVal);\n"
  1287. " showToast('通道 ' + (idx+1) + ' 延时已保存: 开' + onVal.toFixed(1) + 's / 关' + offVal.toFixed(1) + 's', 1200);\n"
  1288. " };\n"
  1289. " })(i));\n"
  1290. " grid.appendChild(rowDiv);\n"
  1291. " }\n"
  1292. " document.getElementById('delayModal').classList.add('active');\n"
  1293. " }\n"
  1294. " function openThresholdModal() {\n"
  1295. " const grid = document.getElementById('thresholdGrid');\n"
  1296. " const patch_grid = document.getElementById('pathchGrid');\n"
  1297. " if (!grid || !patch_grid) return;\n"
  1298. " grid.innerHTML = '';\n"
  1299. " patch_grid.innerHTML = '';\n"
  1300. " if(device_info.chs > 0)\n"
  1301. " {\n"
  1302. " const rowDiv = document.createElement('div');\n"
  1303. " rowDiv.className = 'config-batch-row';\n"
  1304. " rowDiv.innerHTML = '<div class=\"config-row-title\">批量设置'+'</div>' +\n"
  1305. " '<div class=\"config-inputs\">' +\n"
  1306. " '<div class=\"config-batch-item\"><label>🔻 电压最小值 (V)</label><input type=\"number\" step=\"1\" min=\"0\" max=\"300\" id=\"vMin_batch' + '\" value=\"' + 0.00 + '\"></div>' +\n"
  1307. " '<div class=\"config-batch-item\"><label>🔺 电压最大值 (V)</label><input type=\"number\" step=\"1\" min=\"0\" max=\"300\" id=\"vMax_batch' + '\" value=\"' + 0.00 + '\"></div>' +\n"
  1308. " '<div class=\"config-batch-item\"><label>⚡ 电流最大值 (A)</label><input type=\"number\" step=\"5\" min=\"0\" max=\"200\" id=\"iMax_batch' + '\" value=\"' + 0.00 + '\"></div>' +\n"
  1309. " '<div class=\"config-batch-item\"><label>🔋 功率最大值 (W)</label><input type=\"number\" step=\"500\" min=\"0\" max=\"50000\" id=\"pMax_batch' + '\" value=\"' + 0.00 + '\"></div>' +\n"
  1310. " '<div class=\"config-batch-item\"><label>📊 耗电量最大值 (kWh)</label><input type=\"number\" step=\"50\" min=\"0\" max=\"10000\" id=\"eMax_batch' + '\" value=\"' + 0.00 + '\"></div>' +\n"
  1311. " '<button class=\"save-channel-config-btn\" data-channel=\"'+ '\">💾 保存</button>' +\n"
  1312. " '</div>';\n"
  1313. " const saveBtn = rowDiv.querySelector('.save-channel-config-btn');\n"
  1314. " saveBtn.addEventListener('click',function() {\n"
  1315. " const vMin = parseFloat(document.getElementById('vMin_batch').value);\n"
  1316. " const vMax = parseFloat(document.getElementById('vMax_batch').value);\n"
  1317. " const iMax = parseFloat(document.getElementById('iMax_batch').value);\n"
  1318. " const pMax = parseFloat(document.getElementById('pMax_batch').value);\n"
  1319. " const eMax = parseFloat(document.getElementById('eMax_batch').value);\n"
  1320. " if (!isNaN(vMin) && !isNaN(vMax) && !isNaN(iMax) && !isNaN(pMax) && !isNaN(eMax)) {\n"
  1321. " batch_set_thr(0,vMax,vMin,iMax,pMax,eMax);\n"
  1322. " showToast('批量阈值' + '已配置', 1000);\n"
  1323. " closeModal('thresholdModal');\n"
  1324. " } else {\n"
  1325. " showToast('请输入有效数值', 1000);\n"
  1326. " }\n"
  1327. " });\n"
  1328. " patch_grid.appendChild(rowDiv);\n"
  1329. " }\n"
  1330. " \n"
  1331. " \n"
  1332. " for (let i = 0; i < device_info.chs; i++) {\n"
  1333. " const thr = channelThresholds[i];\n"
  1334. " const rowDiv = document.createElement('div');\n"
  1335. " rowDiv.className = 'config-row';\n"
  1336. " rowDiv.innerHTML = '<div class=\"config-row-title\">CH' + (i+1) + ' · '+ (thr.name) + '</div>' +\n"
  1337. " '<div class=\"config-inputs\">' +\n"
  1338. " '<div class=\"config-item\"><label>🔻 电压最小值 (V)</label><input type=\"number\" step=\"1\" min=\"0\" max=\"300\" id=\"vMin_' + i + '\" value=\"' + thr.vMin.toFixed(2) + '\"></div>' +\n"
  1339. " '<div class=\"config-item\"><label>🔺 电压最大值 (V)</label><input type=\"number\" step=\"1\" min=\"0\" max=\"300\" id=\"vMax_' + i + '\" value=\"' + thr.vMax.toFixed(2) + '\"></div>' +\n"
  1340. " '<div class=\"config-item\"><label>⚡ 电流最大值 (A)</label><input type=\"number\" step=\"5\" min=\"0\" max=\"200\" id=\"iMax_' + i + '\" value=\"' + thr.iMax.toFixed(2) + '\"></div>' +\n"
  1341. " '<div class=\"config-item\"><label>🔋 功率最大值 (W)</label><input type=\"number\" step=\"500\" min=\"0\" max=\"50000\" id=\"pMax_' + i + '\" value=\"' + thr.pMax.toFixed(2) + '\"></div>' +\n"
  1342. " '<div class=\"config-item\"><label>📊 耗电量最大值 (kWh)</label><input type=\"number\" step=\"50\" min=\"0\" max=\"10000\" id=\"eMax_' + i + '\" value=\"' + thr.eMax.toFixed(2) + '\"></div>' +\n"
  1343. " '<button class=\"save-channel-config-btn\" data-channel=\"' + i + '\">💾 保存本通道</button>' +\n"
  1344. " '</div>';\n"
  1345. " const saveBtn = rowDiv.querySelector('.save-channel-config-btn');\n"
  1346. " saveBtn.addEventListener('click', (function(idx) {\n"
  1347. " return function() {\n"
  1348. " const vMin = parseFloat(document.getElementById('vMin_' + idx).value);\n"
  1349. " const vMax = parseFloat(document.getElementById('vMax_' + idx).value);\n"
  1350. " const iMax = parseFloat(document.getElementById('iMax_' + idx).value);\n"
  1351. " const pMax = parseFloat(document.getElementById('pMax_' + idx).value);\n"
  1352. " const eMax = parseFloat(document.getElementById('eMax_' + idx).value);\n"
  1353. " if (!isNaN(vMin) && !isNaN(vMax) && !isNaN(iMax) && !isNaN(pMax) && !isNaN(eMax)) {\n"
  1354. " channel_set_thr(idx,vMax,vMin,iMax,pMax,eMax)\n"
  1355. " showToast('通道 ' + (idx+1) + ' 阈值已保存', 1000);\n"
  1356. " } else {\n"
  1357. " showToast('请输入有效数值', 1000);\n"
  1358. " }\n"
  1359. " };\n"
  1360. " })(i));\n"
  1361. " grid.appendChild(rowDiv);\n"
  1362. " }\n"
  1363. " document.getElementById('thresholdModal').classList.add('active');\n"
  1364. " }\n"
  1365. " function updateResetModalUI() {\n"
  1366. " const container = document.getElementById('channelSelectList');\n"
  1367. " if (!container) return;\n"
  1368. " container.innerHTML = '';\n"
  1369. " for (let i = 0; i < device_info.chs; i++) {\n"
  1370. " const div = document.createElement('div');\n"
  1371. " div.className = 'channel-checkbox';\n"
  1372. " div.innerHTML = '<input type=\"checkbox\" id=\"resetChk_' + i + '\" ' + (currentSelectedChannels[i] ? 'checked' : '') + '>' +\n"
  1373. " '<label for=\"resetChk_' + i + '\">CH' + (i+1) + ' · '+(channelTelemetry[i].name) + ' (当前耗电: ' + ((channelTelemetry[i]?.energyKwh || 0).toFixed(2)) + ' kWh)</label>';\n"
  1374. " const chk = div.querySelector('input');\n"
  1375. " chk.addEventListener('change', (function(idx) {\n"
  1376. " return function(e) { currentSelectedChannels[idx] = e.target.checked; };\n"
  1377. " })(i));\n"
  1378. " container.appendChild(div);\n"
  1379. " }\n"
  1380. " }\n"
  1381. " function openResetEnergyModal() {\n"
  1382. " for (let i = 0; i < device_info.chs; i++) currentSelectedChannels[i] = true;\n"
  1383. " updateResetModalUI();\n"
  1384. " document.getElementById('resetEnergyModal').classList.add('active');\n"
  1385. " }\n"
  1386. " function confirmResetEnergy() {\n"
  1387. " const toReset = [];\n"
  1388. " for (let i = 0; i < device_info.chs; i++) {\n"
  1389. " if (currentSelectedChannels[i]) toReset.push(i);\n"
  1390. " }\n"
  1391. " if (toReset.length === 0) {\n"
  1392. " showToast(\"未选择任何通道\", 1000);\n"
  1393. " return;\n"
  1394. " }\n"
  1395. " for (let idx of toReset) {\n"
  1396. " channel_clear_consumer(idx);\n"
  1397. " }\n"
  1398. " //renderTable();\n"
  1399. " const names = toReset.map(i => 'CH' + (i + 1)).join(', ');\n"
  1400. " showToast('已重置 ' + names + ' 的耗电量', 1500);\n"
  1401. " closeModal('resetEnergyModal');\n"
  1402. " }\n"
  1403. " function confirmTempThr() {\n"
  1404. " valmax = document.getElementById('tempMax').value;\n"
  1405. " valmin = document.getElementById('tempMin').value;\n"
  1406. " set_sensor_thr(valmax,valmin,SUB_SENSOR_TYPE.NEW_SUB_PKT_TYPE_TEMP);\n"
  1407. " showToast('设置温度阈值', 1500);\n"
  1408. " closeModal('tempCardModal');\n"
  1409. " }\n"
  1410. " function confirmHumiThr() {\n"
  1411. " valmax = document.getElementById('humiMax').value;\n"
  1412. " valmin = document.getElementById('humiMin').value;\n"
  1413. " set_sensor_thr(valmax,valmin,SUB_SENSOR_TYPE.NEW_SUB_PKT_TYPE_HUMI); \n"
  1414. " showToast('设置湿度阈值', 1500);\n"
  1415. " closeModal('humiCardModal');\n"
  1416. " }\n"
  1417. " \n"
  1418. " function confirmSmokeThr() {\n"
  1419. " valmax = document.getElementById('smokeMax').value;\n"
  1420. " valmin = document.getElementById('smokeMin').value;\n"
  1421. " set_sensor_thr(valmax,valmin,SUB_SENSOR_TYPE.NEW_SUB_PKT_TYPE_SMOKE); \n"
  1422. " showToast('设置烟雾阈值', 1500);\n"
  1423. " closeModal('smokeCardModal');\n"
  1424. " }\n"
  1425. " function confirmCo2Thr() {\n"
  1426. " valmax = document.getElementById('Co2Max').value;\n"
  1427. " valmin = document.getElementById('Co2Min').value;\n"
  1428. " set_sensor_thr(valmax,valmin,SUB_SENSOR_TYPE.NEW_SUB_PKT_TYPE_CO2); \n"
  1429. " showToast('设置Co2阈值', 1500);\n"
  1430. " closeModal('co2CardModal');\n"
  1431. " }\n"
  1432. " function confirmNetwork()\n"
  1433. " {\n"
  1434. " ip_data=[];\n"
  1435. " ip_data.ipMode = (document.getElementById('ipMode').value == \"auto\") ? 0 : 1;\n"
  1436. " ip_data.ipAddress = document.getElementById('ipAddress').value;\n"
  1437. " ip_data.subnetMask = document.getElementById('subnetMask').value;\n"
  1438. " ip_data.gateway = document.getElementById('gateway').value;\n"
  1439. " ip_data.dns1 = document.getElementById('dns1').value;\n"
  1440. " ip_data.dns2 = document.getElementById('dns2').value;\n"
  1441. " ip_data.len = 241;\n"
  1442. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_NETWORK,0, 0, 0, ip_data);\n"
  1443. " ws.send(a); \n"
  1444. " }\n"
  1445. " function confirmNtp()\n"
  1446. " {\n"
  1447. " ntp_data = [];\n"
  1448. " ntp_data.ntpZone = document.getElementById('ntpZone').value;\n"
  1449. " datetimeStr = document.getElementById('newSystemTime').value;\n"
  1450. " ntp_data.len = 33;\n"
  1451. " if (datetimeStr) {\n"
  1452. " const newDate = new Date(datetimeStr);\n"
  1453. " if (!isNaN(newDate.getTime())) \n"
  1454. " {\n"
  1455. " ntp_data.ntpDateTime = newDate.toLocaleString();\n"
  1456. " \n"
  1457. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_NTP,0, 0, 0, ntp_data);\n"
  1458. " ws.send(a); \n"
  1459. " showToast(newDate.toLocaleString(), 1000);\n"
  1460. " }\n"
  1461. " else \n"
  1462. " showToast(\"无效的时间格式\", 1000);\n"
  1463. " } else showToast(\"请选择日期时间\", 1000);\n"
  1464. " }\n"
  1465. " function rebootSystem()\n"
  1466. " {\n"
  1467. " data = [];\n"
  1468. " data.flag = 1;\n"
  1469. " data.len = 1;\n"
  1470. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO,0, 0, 0, data); \n"
  1471. " ws.send(a);\n"
  1472. " showToast(\"重启设备\", 1000);\n"
  1473. " }\n"
  1474. " function selectAllChannels() {\n"
  1475. " for (let i = 0; i < device_info.chs; i++) currentSelectedChannels[i] = true;\n"
  1476. " updateResetModalUI();\n"
  1477. " }\n"
  1478. " function deselectAllChannels() {\n"
  1479. " for (let i = 0; i < device_info.chs; i++) currentSelectedChannels[i] = false;\n"
  1480. " updateResetModalUI();\n"
  1481. " }\n"
  1482. " function updateSummary() {\n"
  1483. " let totalVoltage = 0.00, totalCurrent = 0.00, totalActivePower = 0.00, totalReactivePower = 0.00, totalApparentPower = 0.00, totalWeightedPf = 0.000,totalPf=0.00,totalConsumer= 0.00;\n"
  1484. " if(device_info.chs > 0)\n"
  1485. " {\n"
  1486. " if(show_l_info == 0)\n"
  1487. " {\n"
  1488. " //总电压 (V)\n"
  1489. " // document.getElementById('All-V').innerHTML = '<div class=\"summary-label\" id=\"All-V\">线电压 (V)</div>'\n"
  1490. " // // document.getElementById('All-I').style.display = 'none';\n"
  1491. " // // document.getElementById('totalCurrent').style.display ='none';\n"
  1492. " // totalVoltage = all_channel.voltage;\n"
  1493. " // totalCurrent = all_channel.current;\n"
  1494. " // totalActivePower = all_channel.power;\n"
  1495. " // totalReactivePower = all_channel.reactive_power;\n"
  1496. " // totalApparentPower = all_channel.app_power;\n"
  1497. " // totalPf = all_channel.factor;\n"
  1498. " // totalConsumer = all_channel.consump;\n"
  1499. " }else \n"
  1500. " {\n"
  1501. " document.getElementById('All-V').innerHTML = '<div class=\"summary-label\" id=\"All-V\">相电压 (V)</div>'\n"
  1502. " totalVoltage = all_l_channel[show_l_info-1].voltage;\n"
  1503. " totalCurrent = all_l_channel[show_l_info-1].current;\n"
  1504. " totalActivePower = all_l_channel[show_l_info-1].power;\n"
  1505. " totalReactivePower = all_l_channel[show_l_info-1].reactive_power;\n"
  1506. " totalApparentPower = all_l_channel[show_l_info-1].app_power;\n"
  1507. " totalPf = all_l_channel[show_l_info-1].factor;\n"
  1508. " totalConsumer = all_l_channel[show_l_info-1].consump; \n"
  1509. " }\n"
  1510. " }\n"
  1511. " document.getElementById('totalVoltage').innerHTML = totalVoltage.toFixed(2) + '<span class=\"summary-unit\">V</span>';\n"
  1512. " document.getElementById('totalCurrent').innerHTML = totalCurrent.toFixed(2) + '<span class=\"summary-unit\">A</span>';\n"
  1513. " document.getElementById('totalActivePower').innerHTML = totalActivePower.toLocaleString() + '<span class=\"summary-unit\">kW</span>';\n"
  1514. " document.getElementById('totalReactivePower').innerHTML = totalReactivePower.toLocaleString() + '<span class=\"summary-unit\">kvar</span>';\n"
  1515. " document.getElementById('totalApparentPower').innerHTML = totalApparentPower.toLocaleString() + '<span class=\"summary-unit\">kVA</span>';\n"
  1516. " document.getElementById('totalPowerFactor').innerHTML = totalPf.toFixed(3);\n"
  1517. " document.getElementById('totalConsumer').innerHTML = totalConsumer.toFixed(2) + '<span class=\"summary-unit\">kWh</span>'; \n"
  1518. " }\n"
  1519. " function updateWsStatus(connected, message) {\n"
  1520. " const led = document.getElementById('wsLed');\n"
  1521. " const statusText = document.getElementById('wsStatusText');\n"
  1522. " if (connected) {\n"
  1523. " led.className = 'ws-led connected';\n"
  1524. " statusText.innerHTML = '已连接';\n"
  1525. " } else {\n"
  1526. " led.className = 'ws-led disconnected';\n"
  1527. " statusText.innerHTML = message || '未连接';\n"
  1528. " }\n"
  1529. " }\n"
  1530. " function onWsMessage(event) {\n"
  1531. " try {\n"
  1532. " if (event.data instanceof ArrayBuffer) {\n"
  1533. " var obj = bin_parse(event.data);\n"
  1534. " if (obj.device_info != undefined) {\n"
  1535. " if(device_info.chs != obj.device_info.chs)\n"
  1536. " {\n"
  1537. " device_info.chs = obj.device_info.chs;\n"
  1538. " currentSelectedChannels = null;\n"
  1539. " currentSelectedChannels = new Array(device_info.chs).fill(true);\n"
  1540. " for (let i = 0; i < device_info.chs; i++) {\n"
  1541. " channelThresholds[i] = {name:\"smartPDU\",vMin: 198, vMax: 242, iMax: 100, pMax: 15000, eMax: 500 };\n"
  1542. " channelDelays[i] = {name:\"smartPDU\", onSec: 1.8, offSec: 1.5 };\n"
  1543. " channelTelemetry[i] = {name:\"smartPDU\", voltage: 220, current: 30, activePower: 6600, reactivePower: 2500, apparentPower: 7000, powerFactor: 0.85, frequency: 50.00, energyKwh: 100 };\n"
  1544. " channelTelemetry1[i] = {name:\"smartPDU\", voltage: 220, current: 30, activePower: 6600, reactivePower: 2500, apparentPower: 7000, powerFactor: 0.85, frequency: 50.00, energyKwh: 100 };\n"
  1545. " channelTelemetry2[i] = {name:\"smartPDU\", voltage: 220, current: 30, activePower: 6600, reactivePower: 2500, apparentPower: 7000, powerFactor: 0.85, frequency: 50.00, energyKwh: 100 };\n"
  1546. " channelSwitchStates[i] = true;\n"
  1547. " channel_info[i] ={name:\"SmartPDU\",addr:0,sch:0,phse:0,phse1:1,open:1,close:1,status:1,\n"
  1548. " l1_v_upper:0,l1_v_lower:0,l1_c_upper:0,l1_p_upper:0,l1_w_upper:0,\n"
  1549. " l2_v_upper:0,l2_v_lower:0,l2_c_upper:0,l2_p_upper:0,l2_w_upper:0,\n"
  1550. " l3_v_upper:0,l3_v_lower:0,l3_c_upper:0,l3_p_upper:0,l3_w_upper:0\n"
  1551. " };\n"
  1552. " }\n"
  1553. " all_channel.voltage = 0;\n"
  1554. " all_channel.current = 0;\n"
  1555. " all_channel.power = 0;\n"
  1556. " all_channel.reactive_power = 0;\n"
  1557. " all_channel.app_power = 0;\n"
  1558. " all_channel.factor = 0; \n"
  1559. " renderTable();\n"
  1560. " \n"
  1561. " }\n"
  1562. " device_info.chs = obj.device_info.chs;\n"
  1563. " device_info.power_type = obj.device_info.power_type;\n"
  1564. " device_info.zone = obj.device_info.zone;\n"
  1565. " device_info.board_cnt = obj.device_info.board_cnt;\n"
  1566. " device_info.soft_version = obj.device_info.soft_version;\n"
  1567. " device_info.hard_version = obj.device_info.hard_version;\n"
  1568. " device_info.date = obj.device_info.date;\n"
  1569. " device_info.time = obj.device_info.time;\n"
  1570. " updateDeviceStatusMsg();\n"
  1571. " updateTimeDisplay();\n"
  1572. " console.log('WebSocket收到: ', device_info.chs,device_info.date,device_info.time);\n"
  1573. " }\n"
  1574. " if (obj.power_data != undefined) {\n"
  1575. " for (let i = 0; i < device_info.chs; i++) {\n"
  1576. " \n"
  1577. " channelTelemetry[i].voltage = obj.power_data[i].voltage;\n"
  1578. " channelTelemetry[i].current = obj.power_data[i].current;\n"
  1579. " channelTelemetry[i].activePower = obj.power_data[i].power;\n"
  1580. " channelTelemetry[i].reactivePower = obj.power_data[i].reactive_power;\n"
  1581. " channelTelemetry[i].apparentPower = obj.power_data[i].app_power;\n"
  1582. " channelTelemetry[i].powerFactor = obj.power_data[i].factor;\n"
  1583. " channelTelemetry[i].frequency = obj.power_data[i].freq;\n"
  1584. " channelTelemetry[i].energyKwh = obj.power_data[i].consump;\n"
  1585. " obj.power_data[i] = null;\n"
  1586. " }\n"
  1587. " //updateTableData();\n"
  1588. " }\n"
  1589. " if (obj.power_data1 != undefined) {\n"
  1590. " for (let i = 0; i < device_info.chs; i++) {\n"
  1591. " \n"
  1592. " channelTelemetry1[i].voltage = obj.power_data1[i].voltage;\n"
  1593. " channelTelemetry1[i].current = obj.power_data1[i].current;\n"
  1594. " channelTelemetry1[i].activePower = obj.power_data1[i].power;\n"
  1595. " channelTelemetry1[i].reactivePower = obj.power_data1[i].reactive_power;\n"
  1596. " channelTelemetry1[i].apparentPower = obj.power_data1[i].app_power;\n"
  1597. " channelTelemetry1[i].powerFactor = obj.power_data1[i].factor;\n"
  1598. " channelTelemetry1[i].frequency = obj.power_data1[i].freq;\n"
  1599. " channelTelemetry1[i].energyKwh = obj.power_data1[i].consump;\n"
  1600. " obj.power_data1[i] = null;\n"
  1601. " }\n"
  1602. " //updateTableData();\n"
  1603. " }\n"
  1604. " if (obj.power_data2 != undefined) {\n"
  1605. " for (let i = 0; i < device_info.chs; i++) {\n"
  1606. " \n"
  1607. " channelTelemetry2[i].voltage = obj.power_data2[i].voltage;\n"
  1608. " channelTelemetry2[i].current = obj.power_data2[i].current;\n"
  1609. " channelTelemetry2[i].activePower = obj.power_data2[i].power;\n"
  1610. " channelTelemetry2[i].reactivePower = obj.power_data2[i].reactive_power;\n"
  1611. " channelTelemetry2[i].apparentPower = obj.power_data2[i].app_power;\n"
  1612. " channelTelemetry2[i].powerFactor = obj.power_data2[i].factor;\n"
  1613. " channelTelemetry2[i].frequency = obj.power_data2[i].freq;\n"
  1614. " channelTelemetry2[i].energyKwh = obj.power_data2[i].consump;\n"
  1615. " obj.power_data2[i] = null;\n"
  1616. " }\n"
  1617. " //updateTableData();\n"
  1618. " } \n"
  1619. " if (obj.power_all != undefined) {\n"
  1620. " all_channel = obj.power_all;\n"
  1621. " obj.power_all = null;\n"
  1622. " updateSummary();\n"
  1623. " }\n"
  1624. " if (obj.power_all_l != undefined) {\n"
  1625. " all_l_channel = obj.power_all_l;\n"
  1626. " obj.power_all_l = null;\n"
  1627. " }\n"
  1628. " if (obj.power_info != undefined) {\n"
  1629. " channel_info = obj.power_info;\n"
  1630. " for(let i =0;i < device_info.chs;i++)\n"
  1631. " {\n"
  1632. " channelDelays[i].onSec =channel_info[i].open;\n"
  1633. " channelDelays[i].offSec = channel_info[i].close;\n"
  1634. " channelDelays[i].name = channel_info[i].name;\n"
  1635. " channelThresholds[i].name = channel_info[i].name;\n"
  1636. " channelTelemetry[i].name = channel_info[i].name;\n"
  1637. " }\n"
  1638. " obj.power_info = null;\n"
  1639. " updateTableData();\n"
  1640. " }\n"
  1641. " if (obj.power_thr != undefined) {\n"
  1642. " for (let i = 0; i < device_info.chs; i++) {\n"
  1643. " channelThresholds[i].vMax = obj.power_thr[i].v_upper;\n"
  1644. " channelThresholds[i].vMin = obj.power_thr[i].v_lower;\n"
  1645. " channelThresholds[i].iMax = obj.power_thr[i].c_upper;\n"
  1646. " channelThresholds[i].pMax = obj.power_thr[i].p_upper;\n"
  1647. " channelThresholds[i].eMax = obj.power_thr[i].w_upper;\n"
  1648. " obj.power_thr[i] = null;\n"
  1649. " }\n"
  1650. " }\n"
  1651. " if(obj.sensor_info != undefined)\n"
  1652. " {\n"
  1653. " humiValue = obj.sensor_info[0];\n"
  1654. " tempValue = obj.sensor_info[1];\n"
  1655. " smokeValue = obj.sensor_info[2];\n"
  1656. " co2Value = obj.sensor_info[3];\n"
  1657. " updateEnvDisplay();\n"
  1658. " }\n"
  1659. " if(obj.network != undefined)\n"
  1660. " {\n"
  1661. " netConfig.ipMode = (obj.network.mode == 0) ? \"auto\" : \"manual\"; \n"
  1662. " netConfig.ipAddress = obj.network.ipaddr;\n"
  1663. " netConfig.subnetMask = obj.network.mask;\n"
  1664. " netConfig.gateway = obj.network.gateway;\n"
  1665. " netConfig.dns1 = obj.network.dns1;\n"
  1666. " netConfig.dns2 = obj.network.dns2;\n"
  1667. " loadNetConfig();\n"
  1668. " }\n"
  1669. " if(obj.rs485 != undefined)\n"
  1670. " {\n"
  1671. " rs485Config.mode = obj.rs485.mode == 0? \"master\" : \"slave\";\n"
  1672. " rs485Config.address = obj.rs485.addr;\n"
  1673. " rs485Config.baudrate = obj.rs485.baud;\n"
  1674. " loadRs485Config();\n"
  1675. " }\n"
  1676. " if(obj.snmp != undefined)\n"
  1677. " {\n"
  1678. " snmpConfig.status = (obj.snmp.mode == 0)? \"close\" :\"open\";\n"
  1679. " snmpConfig.readCommunity = obj.snmp.publics;\n"
  1680. " snmpConfig.writeCommunity = obj.snmp.privates;\n"
  1681. " snmpConfig.trapStatus = (obj.snmp.trapmode == 0)? \"close\" :\"open\";;\n"
  1682. " snmpConfig.trapIp =obj.snmp.nms_ip;\n"
  1683. " loadSnmpConfig();\n"
  1684. " }\n"
  1685. " if(obj.wanni_count != undefined)\n"
  1686. " {\n"
  1687. " //clearAlarm();\n"
  1688. " alarmList = [];\n"
  1689. " for(let i = 0; i < obj.wanni_count.count;i++)\n"
  1690. " {\n"
  1691. " addAlarm(obj.wanning[i],i);\n"
  1692. " }\n"
  1693. " updateAlarmBadge();\n"
  1694. " updateAlarmUI();\n"
  1695. " }\n"
  1696. " if(obj.user_count != undefined )\n"
  1697. " {\n"
  1698. " user_count = obj.user_count;\n"
  1699. " users = obj.users;\n"
  1700. " renderUserTable();\n"
  1701. " }\n"
  1702. " if(obj.user_add != undefined )\n"
  1703. " {\n"
  1704. " const errorDiv = document.getElementById('loginAddErrorMsg'); \n"
  1705. " if(obj.user_add.flag == 1)\n"
  1706. " {\n"
  1707. " \n"
  1708. " errorDiv.innerText = '用户已存在'; \n"
  1709. " }else if(obj.user_add.flag == 2)\n"
  1710. " {\n"
  1711. " errorDiv.innerText = '用户超过10'; \n"
  1712. " }else\n"
  1713. " {\n"
  1714. " errorDiv.innerTex='';\n"
  1715. " closeModal('userAddModal'); \n"
  1716. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,0, 0, 0)); \n"
  1717. " }\n"
  1718. " \n"
  1719. " }\n"
  1720. " if(obj.user_update != undefined)\n"
  1721. " {\n"
  1722. " const errorDiv = document.getElementById('loginUpdateErrorMsg'); \n"
  1723. " if(obj.user_update.flag == 1)\n"
  1724. " {\n"
  1725. " errorDiv.innerText = '密码错误'; \n"
  1726. " }else\n"
  1727. " {\n"
  1728. " errorDiv.innerTex='';\n"
  1729. " closeModal('userModal'); \n"
  1730. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,0, 0, 0)); \n"
  1731. " }\n"
  1732. " \n"
  1733. " }\n"
  1734. " if(obj.user_delete != undefined)\n"
  1735. " {\n"
  1736. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,0, 0, 0)); \n"
  1737. " }\n"
  1738. " }\n"
  1739. " } catch (e) {\n"
  1740. " console.error('解析WebSocket消息失败:', e);\n"
  1741. " }\n"
  1742. " }\n"
  1743. " function sendSwitchCommand(channel, state) {\n"
  1744. " if (ws && ws.readyState === WebSocket.OPEN) {\n"
  1745. " showToast(\"发送指令: 通道\" + (channel + 1) + \" \" + (state ? \"开启\" : \"关闭\"), 1000);\n"
  1746. " } else {\n"
  1747. " showToast(\"WebSocket未连接,无法发送指令\", 1500);\n"
  1748. " }\n"
  1749. " }\n"
  1750. " function sendAllSwitchCommand(state) {\n"
  1751. " if (ws && ws.readyState === WebSocket.OPEN) {\n"
  1752. " all_contrl(state);\n"
  1753. " showToast(\"发送全部\" + (state ? \"开启\" : \"关闭\") + \"指令\", 1000);\n"
  1754. " } else {\n"
  1755. " showToast(\"WebSocket未连接,无法发送指令\", 1500);\n"
  1756. " }\n"
  1757. " }\n"
  1758. " function deleteUserApi(userId) {\n"
  1759. " let user = users[userId].user;\n"
  1760. " userDeleteConfig(user);\n"
  1761. " }\n"
  1762. " function escapeHtml(str) { return str.replace(/[&<>]/g, function(m){ if(m==='&') return '&amp;'; if(m==='<') return '&lt;'; if(m==='>') return '&gt;'; return m;}); }\n"
  1763. " function openUserEditModal(userId) {\n"
  1764. " // let user = usersList.find(u => u.id === userId);\n"
  1765. " // if (!user) return;\n"
  1766. " let i = userId;\n"
  1767. " document.getElementById('userModalTitle').innerText = '编辑用户';\n"
  1768. " document.getElementById('userName').value = users[userId].user;\n"
  1769. " document.getElementById('userName').setAttribute('disabled','disabled');\n"
  1770. " document.getElementById('userOldPassword').value = '';\n"
  1771. " document.getElementById('userNewPassword').value = '';\n"
  1772. " document.getElementById('userRole').value = (users[userId].role === 1 )? \"superadmin\" : (users[userId].role === 2 ) ? \"admin\" : \"user\";\n"
  1773. " document.getElementById('userModal').classList.add('active');\n"
  1774. " }\n"
  1775. " function renderUserTable() {\n"
  1776. " let tbody = document.getElementById('userTableBody');\n"
  1777. " if (!tbody) return;\n"
  1778. " if (!user_count.cnt) { tbody.innerHTML = '<tr><td colspan=\"3\" style=\"text-align:center;\">暂无用户数据</td></tr>'; return; }\n"
  1779. " let html = '';\n"
  1780. " for (let i = 0;i < user_count.cnt;i++) {\n"
  1781. " let roleText = (users[i].role === 1) ? '超级管理员' : (users[i].role === 2 ? '管理员' : '普通用户');\n"
  1782. " html += `<tr>\n"
  1783. " <td style=\"text-align:center;\">${escapeHtml(users[i].user)}</td>\n"
  1784. " <td style=\"text-align:center;\">${roleText}</td>\n"
  1785. " <td style=\"text-align:center;\">${users[i].date} ${users[i].time}</td>\n"
  1786. " <td style=\"text-align:center;\"><button class=\"btn-icon success\" data-id=\"${i}\" data-action=\"edit\">编辑</button>\n"
  1787. " <button class=\"btn-icon danger\" data-id=\"${i}\" data-action=\"delete\">删除</button></td>\n"
  1788. " </tr>`;\n"
  1789. " }\n"
  1790. " tbody.innerHTML = html;\n"
  1791. " // 绑定编辑删除事件\n"
  1792. " tbody.querySelectorAll('[data-action=\"edit\"]').forEach(btn => {\n"
  1793. " btn.addEventListener('click', (e) => { let id = parseInt(btn.getAttribute('data-id')); openUserEditModal(id); });\n"
  1794. " });\n"
  1795. " tbody.querySelectorAll('[data-action=\"delete\"]').forEach(btn => {\n"
  1796. " btn.addEventListener('click', (e) => { let id = parseInt(btn.getAttribute('data-id')); if(confirm('确定删除该用户吗?')) deleteUserApi(id); });\n"
  1797. " });\n"
  1798. " }\n"
  1799. " function updateEnvDisplay() {\n"
  1800. " document.getElementById('tempStatus').innerHTML= `<div class=\"${tempValue.status ? 'status-on' : 'status-off'}\">${tempValue.status ? \"在线\" : \"离线\"}<div>`;\n"
  1801. " document.getElementById('humiStatus').innerHTML= `<div class=\"${humiValue.status ? 'status-on' : 'status-off'}\">${humiValue.status ? \"在线\" : \"离线\"}<div>`;\n"
  1802. " document.getElementById('smokeStatus').innerHTML= `<div class=\"${smokeValue.status ? 'status-on' : 'status-off'}\">${smokeValue.status ? \"在线\" : \"离线\"}<div>`\n"
  1803. " document.getElementById('co2Status').innerHTML= `<div class=\"${co2Value.status ? 'status-on' : 'status-off'}\">${co2Value.status ? \"在线\" : \"离线\"}<div>`\n"
  1804. " document.getElementById('tempValue').innerHTML = tempValue.value.toFixed(2) + '<span class=\"env-unit\">°C</span>';\n"
  1805. " document.getElementById('humiValue').innerHTML = humiValue.value.toFixed(2) + '<span class=\"env-unit\">%RH</span>';\n"
  1806. " document.getElementById('smokeValue').innerHTML = Math.floor(smokeValue.value) + '<span class=\"env-unit\">ppm</span>';\n"
  1807. " document.getElementById('co2Value').innerHTML = Math.floor(co2Value.value) + '<span class=\"env-unit\">ppm</span>';\n"
  1808. " const tempCard = document.getElementById('tempCard');\n"
  1809. " const humiCard = document.getElementById('humiCard');\n"
  1810. " const smokeCard = document.getElementById('smokeCard');\n"
  1811. " const co2Card = document.getElementById('co2Card');\n"
  1812. " tempCard.classList.remove('alarm-warning', 'alarm-danger');\n"
  1813. " humiCard.classList.remove('alarm-warning', 'alarm-danger');\n"
  1814. " smokeCard.classList.remove('alarm-warning', 'alarm-danger');\n"
  1815. " co2Card.classList.remove('alarm-warning', 'alarm-danger');\n"
  1816. " if (tempValue.v_max_wrn) tempCard.classList.add('alarm-danger');\n"
  1817. " else if(tempValue.v_min_wrn) tempCard.classList.add('alarm-warning');\n"
  1818. " if (humiValue.v_max_wrn) humiCard.classList.add('alarm-danger');\n"
  1819. " if (smokeValue.v_max_wrn) smokeCard.classList.add('alarm-danger');\n"
  1820. " if (co2Value.v_max_wrn) co2Card.classList.add('alarm-danger');\n"
  1821. " }\n"
  1822. " function updateAlarmBadge() {\n"
  1823. " const badge = document.getElementById('alarmCountBadge');\n"
  1824. " if (badge) {\n"
  1825. " const count = alarmList.length;\n"
  1826. " if (count > 0) {\n"
  1827. " badge.textContent = count > 10 ? '10' : count;\n"
  1828. " badge.style.display = 'inline-flex';\n"
  1829. " } else {\n"
  1830. " badge.style.display = 'none';\n"
  1831. " }\n"
  1832. " }\n"
  1833. " }\n"
  1834. " function updateAlarmUI() {\n"
  1835. " const container = document.getElementById('alarmListContainer');\n"
  1836. " if (!container) return;\n"
  1837. " if (alarmList.length === 0) {\n"
  1838. " container.innerHTML = '<div style=\"text-align:center;color:#888;padding:20px;\">暂无报警记录</div>';\n"
  1839. " return;\n"
  1840. " }\n"
  1841. " let html = '<table class=\"alarm-table\"><thead><tr><th>报警ID</th><th>时间</th><th>报警类型</th><th>详细信息</th></tr></thead><tbody>';\n"
  1842. " for (let i = 0; i < alarmList.length; i++) {\n"
  1843. " const a = alarmList[i];\n"
  1844. " html += '<tr><td class=\"alarm-id\">' + a.id + '</td><td>' + a.time + '</td><td><span style=\"background:#ffe0e0;padding:2px 8px;border-radius:20px;font-size:0.7rem;\">' + a.type + '</span></td><td>' + a.message + '</td></tr>';\n"
  1845. " }\n"
  1846. " html += '</tbody></table>';\n"
  1847. " container.innerHTML = html;\n"
  1848. " }\n"
  1849. " function clearAlarm() {\n"
  1850. " clean_alarm();\n"
  1851. " alarmList = [];\n"
  1852. " showToast(\"报警记录已清空\", 1000);\n"
  1853. " }\n"
  1854. " function showToast(msg, dur) {\n"
  1855. " if (!dur) dur = 1500;\n"
  1856. " const t = document.createElement('div');\n"
  1857. " t.innerText = msg;\n"
  1858. " t.style.cssText = 'position:fixed; bottom:70px; right:24px; background:#1e2f3ce6; color:#fff; padding:8px 20px; border-radius:40px; font-size:0.8rem; z-index:2100;';\n"
  1859. " document.body.appendChild(t);\n"
  1860. " setTimeout(function() {\n"
  1861. " t.style.opacity = '0';\n"
  1862. " setTimeout(function() {\n"
  1863. " t.remove();\n"
  1864. " }, 300);\n"
  1865. " }, dur);\n"
  1866. " }\n"
  1867. " \n"
  1868. " function updateTableData() {\n"
  1869. " for (let i = 0; i < device_info.chs; i++) {\n"
  1870. " //if (!tableRows[i]) continue;\n"
  1871. " const row = tableRows[i];\n"
  1872. " if (!row) continue;\n"
  1873. " let tele= channelTelemetry[i]|| {};\n"
  1874. " let target = channelSwitchStates[i];\n"
  1875. " let delays = channelDelays[i];\n"
  1876. " let thr = channelThresholds[i];\n"
  1877. " let info = channel_info[i];\n"
  1878. " if(device_info.power_type == 4 || device_info.power_type == 5)\n"
  1879. " {\n"
  1880. " if(info.phse == 1)\n"
  1881. " {\n"
  1882. " //tele = channelTelemetry[i];\n"
  1883. " }else if(info.phse == 2)\n"
  1884. " {\n"
  1885. " tele = channelTelemetry1[i];\n"
  1886. " }else if(info.phse == 3)\n"
  1887. " {\n"
  1888. " tele = channelTelemetry2[i];\n"
  1889. " }\n"
  1890. " }\n"
  1891. " \n"
  1892. " // 检查阈值告警\n"
  1893. " const alarms = [];\n"
  1894. " alarmClass = '';\n"
  1895. " const cells = row.cells;\n"
  1896. " if (cells[0]) {\n"
  1897. " cells[0].innerHTML = '<div class=\"channel-badge\"><span class=\"ch-icon\">CH' + (i + 1) + '</span> <strong>' + (info.name) + '</strong></div>';\n"
  1898. " //cells[0].className = 'channel-badge ';\n"
  1899. " }\n"
  1900. " if(cells[1])\n"
  1901. " {\n"
  1902. " cells[1].innerHTML = '<span class=\"ph-icon\"><strong>'+'L'+info.phse+'</strong></span>' \n"
  1903. " }\n"
  1904. " if (cells[2]) {\n"
  1905. " cells[2].innerHTML = (tele.voltage || 0).toFixed(2) + '<span class=\"unit-sub\">V</span>' + (info.l1_v_lower || info.l2_v_lower || info.l3_v_lower ? '🔻' : (info.l1_v_upper || info.l2_v_upper || info.l3_v_upper ? '🔺' : ''));\n"
  1906. " if(info.l1_v_lower || info.l2_v_lower || info.l3_v_lower) {\n"
  1907. " alarmClass = 'threshold-low-alarm';\n"
  1908. " }else if(info.l1_v_upper || info.l2_v_upper || info.l3_v_upper) {\n"
  1909. " alarmClass = 'threshold-alarm';\n"
  1910. " } \n"
  1911. " cells[2].className = 'numeric-value ' + alarmClass;\n"
  1912. " }\n"
  1913. " // 电流 (第3列,索引2)\n"
  1914. " if (cells[3]) {\n"
  1915. " cells[3].innerHTML = (tele.current || 0).toFixed(2) + '<span class=\"unit-sub\">A</span>';\n"
  1916. " cells[3].className = 'numeric-value ' + ((info.l1_c_upper ||info.l2_c_upper || info.l3_c_upper) ? 'threshold-alarm' : '');\n"
  1917. " }\n"
  1918. " // 有功功率 (第4列,索引3)\n"
  1919. " if (cells[4]) {\n"
  1920. " cells[4].innerHTML = ((tele.activePower || 0).toLocaleString()) + '<span class=\"unit-sub\">kW</span>';\n"
  1921. " cells[4].className = 'numeric-value power-bg ' + (info.l1_p_upper || info.l2_p_upper || info.l3_p_upper? 'threshold-alarm' : '');\n"
  1922. " }\n"
  1923. " // 无功功率 (第5列,索引4)\n"
  1924. " if (cells[5]) {\n"
  1925. " cells[5].innerHTML = ((tele.reactivePower || 0).toLocaleString()) + '<span class=\"unit-sub\">kvar</span>';\n"
  1926. " cells[5].className = 'numeric-value reactive-bg';\n"
  1927. " }\n"
  1928. " // 视在功率 (第6列,索引5)\n"
  1929. " if (cells[6]) {\n"
  1930. " cells[6].innerHTML = ((tele.apparentPower || 0).toLocaleString()) + '<span class=\"unit-sub\">kVA</span>';\n"
  1931. " }\n"
  1932. " // 功率因数 (第7列,索引6)\n"
  1933. " if (cells[7]) {\n"
  1934. " cells[7].innerHTML = (tele.powerFactor || 0).toFixed(3);\n"
  1935. " }\n"
  1936. " // 频率 (第8列,索引7)\n"
  1937. " if (cells[8]) {\n"
  1938. " cells[8].innerHTML = tele.frequency.toFixed(2) + '<span class=\"unit-sub\">Hz</span>';\n"
  1939. " }\n"
  1940. " // 耗电量 (第9列,索引8)\n"
  1941. " if (cells[9]) {\n"
  1942. " cells[9].innerHTML = '<span class=\"energy-value\">' + ((tele.energyKwh || 0).toFixed(2)) + '</span><span class=\"unit-sub\">kWh</span>';\n"
  1943. " cells[9].className = 'energy-cell numeric-value ' + (info.l1_w_upper || info.l2_w_upper || info.l3_w_upper ? 'threshold-alarm' : '');\n"
  1944. " }\n"
  1945. " // 开关延时 (第10列,索引9)\n"
  1946. " if (cells[10]) {\n"
  1947. " cells[10].innerHTML = '<div class=\"delay-badge delay-idle\">开:' + (info.open) + 's/关:' + (info.close) + 's</div>';\n"
  1948. " }\n"
  1949. " // 开关状态 (第11列,索引10)\n"
  1950. " if (cells[11]) {\n"
  1951. " cells[11].innerHTML = '<span class=\"' + (info.status ? 'status-on' : 'status-off') + ' status-span\">' + (info.status ? '开' : '关') + '</span>';\n"
  1952. " }\n"
  1953. " // 操作按钮 (第12列,索引11)\n"
  1954. " if (cells[12]) {\n"
  1955. " if (channelSwitchStates[i] != channel_info[i].status) {\n"
  1956. " cells[12].innerHTML = '<div class=\"switch-control\"><button class=\"switch-btn ' + (info.status ? 'switch-on' : 'switch-off') + '\" data-idx=\"' + i + '\">' + (info.status ? '关闭' : '打开') + '</button></div>';\n"
  1957. " channelSwitchStates[i] = channel_info[i].status\n"
  1958. " }\n"
  1959. " }\n"
  1960. " // 行样式\n"
  1961. " if (target) {\n"
  1962. " row.classList.remove('channel-off');\n"
  1963. " row.classList.add('channel-on');\n"
  1964. " } else {\n"
  1965. " row.classList.remove('channel-on');\n"
  1966. " row.classList.add('channel-off');\n"
  1967. " }\n"
  1968. " }\n"
  1969. " }\n"
  1970. " function renderTable() {\n"
  1971. " const tbody = document.getElementById('tableBody');\n"
  1972. " if (!tbody) return;\n"
  1973. " tbody.innerHTML = '';\n"
  1974. " tableRows = [];\n"
  1975. " for (let i = 0; i < device_info.chs; i++) {\n"
  1976. " const tele = channelTelemetry[i] || {};\n"
  1977. " const target = channelSwitchStates[i];\n"
  1978. " const delays = channelDelays[i];\n"
  1979. " const thr = channelThresholds[i];\n"
  1980. " const info = channel_info[i];\n"
  1981. " const alarms = [];\n"
  1982. " if (channel_info.l1_v_lower) alarms.push('欠压');\n"
  1983. " if (channel_info.l1_v_upper) alarms.push('过压');\n"
  1984. " if (channel_info.l1_c_upper) alarms.push('过流');\n"
  1985. " if (channel_info.l1_p_upper) alarms.push('过功率');\n"
  1986. " if (channel_info.l1_w_upper) alarms.push('能耗超限');\n"
  1987. " const alarmClass = alarms.length > 0 ? 'threshold-alarm' : '';\n"
  1988. " const row = document.createElement('tr');\n"
  1989. " if (!info.status) row.classList.add('channel-off');\n"
  1990. " channelSwitchStates[i] = channel_info[i].status;\n"
  1991. " row.innerHTML = `\n"
  1992. " <td><div class=\"channel-badge\"><span class=\"ch-icon\">CH${i+1}</span> <strong>${info.name} ${i+1}</strong></div></td>\n"
  1993. " <td><span class=\"ph-icon\"><strong>L${info.phse}</strong></span></td>\n"
  1994. " <td class=\"numeric-value ${alarmClass}\">${(tele.voltage || 0).toFixed(1)}<span class=\"unit-sub\">V</span>${alarms.includes('欠压') ? '🔻' : (alarms.includes('过压') ? '🔺' : '')}</td>\n"
  1995. " <td class=\"numeric-value ${alarms.includes('过流') ? 'threshold-alarm' : ''}\">${(tele.current || 0).toFixed(2)}<span class=\"unit-sub\">A</span></td>\n"
  1996. " <td class=\"numeric-value power-bg ${alarms.includes('过功率') ? 'threshold-alarm' : ''}\">${(tele.activePower || 0).toLocaleString()}<span class=\"unit-sub\">W</span></td>\n"
  1997. " <td class=\"numeric-value reactive-bg\">${(tele.reactivePower || 0).toLocaleString()}<span class=\"unit-sub\">kvar</span></td>\n"
  1998. " <td class=\"numeric-value\">${(tele.apparentPower || 0).toLocaleString()}<span class=\"unit-sub\">kVA</span></td>\n"
  1999. " <td class=\"pf-cell numeric-value\">${(tele.powerFactor || 0).toFixed(3)}</td>\n"
  2000. " <td class=\"numeric-value\">${(tele.frequency || 50).toFixed(2)}<span class=\"unit-sub\">Hz</span></td>\n"
  2001. " <td class=\"energy-cell numeric-value ${alarms.includes('能耗超限') ? 'threshold-alarm' : ''}\"><span class=\"energy-value\">${(tele.energyKwh || 0).toFixed(2)}</span><span class=\"unit-sub\">kWh</span></td>\n"
  2002. " <td><div class=\"delay-badge delay-idle\">开:${info.close.toFixed(1)}s/关:${info.open.toFixed(1)}s</div></td>\n"
  2003. " <td><span class=\"${target ? 'status-on' : 'status-off'}\">${info.status ? '开' : '关'}</span></td>\n"
  2004. " <td><div class=\"switch-control\"><button class=\"switch-btn ${info.status ? 'switch-on' : 'switch-off'}\" data-idx=\"${i}\">${info.status ? '关闭' : '打开'}</button></div></td>\n"
  2005. " `;\n"
  2006. " tbody.appendChild(row);\n"
  2007. " tableRows.push(row)\n"
  2008. " }\n"
  2009. " tbody.removeEventListener('click', handleSwitchClick);\n"
  2010. " tbody.addEventListener('click', handleSwitchClick);\n"
  2011. " }\n"
  2012. " function handleSwitchClick(e) {\n"
  2013. " const btn = e.target.closest('.switch-btn');\n"
  2014. " if (!btn) return;\n"
  2015. " e.stopPropagation();\n"
  2016. " const idx = parseInt(btn.getAttribute('data-idx'));\n"
  2017. " if (!isNaN(idx) && idx >= 0 && idx < device_info.chs) {\n"
  2018. " sendSwitchCommand(idx, !channelSwitchStates[idx]);\n"
  2019. " }\n"
  2020. " }\n"
  2021. " function sendSwitchCommand(channel, state) {\n"
  2022. " if (ws && ws.readyState === WebSocket.OPEN) {\n"
  2023. " single_ctrl(channel,state);\n"
  2024. " showToast(\"通道\" + (channel + 1) + \" \" + (state ? \"开启\" : \"关闭\"), 1000);\n"
  2025. " } else {\n"
  2026. " showToast(\"WebSocket未连接,无法发送指令\", 1500);\n"
  2027. " }\n"
  2028. " }\n"
  2029. " function allOn() { sendAllSwitchCommand(true);}\n"
  2030. " function allOff() { sendAllSwitchCommand(false);}\n"
  2031. " function openAlarmModal() {\n"
  2032. " updateAlarmUI();\n"
  2033. " document.getElementById('alarmModal').classList.add('active');\n"
  2034. " }\n"
  2035. " function closeModal(modalId) {document.getElementById(modalId).classList.remove('active');}\n"
  2036. " function loadNetConfig() {\n"
  2037. " document.getElementById(\"ipMode\").value = netConfig.ipMode;\n"
  2038. " document.getElementById(\"ipAddress\").value = netConfig.ipAddress;\n"
  2039. " document.getElementById(\"subnetMask\").value = netConfig.subnetMask;\n"
  2040. " document.getElementById(\"gateway\").value = netConfig.gateway;\n"
  2041. " document.getElementById(\"dns1\").value = netConfig.dns1;\n"
  2042. " document.getElementById(\"dns2\").value = netConfig.dns2;\n"
  2043. " updateStaticIpFieldsEnable();\n"
  2044. " updateNetStatusMsg();\n"
  2045. " }\n"
  2046. " function loadNtpConfig()\n"
  2047. " {\n"
  2048. " document.getElementById(\"ntpZone\").value = ntpConfig.ntpZone;\n"
  2049. " }\n"
  2050. " function updateStaticIpFieldsEnable() {\n"
  2051. " const isManual = document.getElementById(\"ipMode\").value === \"manual\";\n"
  2052. " console.log(document.getElementById(\"ipMode\").value);\n"
  2053. " [\"ipAddress\", \"subnetMask\", \"gateway\"].forEach(function(id) {\n"
  2054. " const el = document.getElementById(id);\n"
  2055. " if (el){\n"
  2056. " //el.hidden = !isManual;\n"
  2057. " isManual ? el.removeAttribute('disabled') : el.setAttribute('disabled','disabled');\n"
  2058. " // if(isManual)\n"
  2059. " // {\n"
  2060. " // el.removeAttribute('disabled');\n"
  2061. " // }else\n"
  2062. " // {\n"
  2063. " // el.setAttribute('disabled','disabled');\n"
  2064. " // }\n"
  2065. " } \n"
  2066. " });\n"
  2067. " // [\"ip_lable\",\"mask_lable\",\"gate_lable\"].forEach(function(id) {\n"
  2068. " // const el = document.getElementById(id);\n"
  2069. " // if (el){\n"
  2070. " // el.style.display = (!isManual) ? 'none' : 'inline';\n"
  2071. " // } \n"
  2072. " // });\n"
  2073. " }\n"
  2074. " function saveNetConfig() {\n"
  2075. " confirmNetwork();\n"
  2076. " showToast(\"网络配置已保存\", 1200);\n"
  2077. " }\n"
  2078. " function updateNetStatusMsg() {\n"
  2079. " const msgDiv = document.getElementById(\"netStatusMsg\");\n"
  2080. " if (msgDiv) {\n"
  2081. " const modeText = netConfig.ipMode === \"auto\" ? \"自动(DHCP)\" : \"静态IP: \" + netConfig.ipAddress;\n"
  2082. " msgDiv.innerHTML = \"📡 IP模式: \" + modeText + \"<br>🌐 DNS: \" + netConfig.dns1 + \" / \" + netConfig.dns2;\n"
  2083. " }\n"
  2084. " }\n"
  2085. " function loadRs485Config() {\n"
  2086. " const saved = sessionStorage.getItem(\"powerMonitorRs485Config\");\n"
  2087. " document.getElementById(\"rs485Mode\").value = rs485Config.mode;\n"
  2088. " document.getElementById(\"rs485Addr\").value = rs485Config.address;\n"
  2089. " document.getElementById(\"rs485Baudrate\").value = rs485Config.baudrate;\n"
  2090. " updateRs485StatusMsg();\n"
  2091. " }\n"
  2092. " function saveRs485Config() {\n"
  2093. " rs_data = [];\n"
  2094. " rs_data.rs485Mode = (document.getElementById('rs485Mode').value == \"master\") ? 0 : 1;\n"
  2095. " rs_data.rs485Addr = document.getElementById('rs485Addr').value || 1;\n"
  2096. " rs_data.rs485Baudrate = document.getElementById('rs485Baudrate').value;\n"
  2097. " rs_data.len = 6;\n"
  2098. " if (rs_data.rs485Addr < 1) rs_data.rs485Addr = 1;\n"
  2099. " if (rs_data.rs485Addr > 247) rs_data.rs485Addr = 247;\n"
  2100. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_RS485,0, 0, 0, rs_data);\n"
  2101. " ws.send(a);\n"
  2102. " showToast(\"RS485配置已保存\", 1200);\n"
  2103. " }\n"
  2104. " function updateRs485StatusMsg() {\n"
  2105. " const msgDiv = document.getElementById(\"rs485StatusMsg\");\n"
  2106. " if (msgDiv) {\n"
  2107. " const modeText = rs485Config.mode === \"master\" ? \"主机模式\" : \"从机模式\";\n"
  2108. " msgDiv.innerHTML = \"🔧 模式: \" + modeText + \" | 地址: \" + rs485Config.address + \" | 波特率: \" + rs485Config.baudrate + \" bps\";\n"
  2109. " }\n"
  2110. " }\n"
  2111. " function loadSnmpConfig() {\n"
  2112. " document.getElementById(\"snmpReadCommunity\").value = snmpConfig.readCommunity;\n"
  2113. " document.getElementById(\"snmpWriteCommunity\").value = snmpConfig.writeCommunity;\n"
  2114. " document.getElementById(\"snmpTrapIp\").value = snmpConfig.trapIp;\n"
  2115. " document.getElementById(\"snmpTrapStatus\").value = snmpConfig.trapStatus;\n"
  2116. " updateSnmpEnable();\n"
  2117. " updateSnmpStatusMsg();\n"
  2118. " }\n"
  2119. " \n"
  2120. " function updateSnmpEnable()\n"
  2121. " {\n"
  2122. " const isManual = document.getElementById(\"snmpTrapStatus\").value === \"open\";\n"
  2123. " const el = document.getElementById(\"snmpTrapIp\");\n"
  2124. " if(el) el.hidden = !isManual;\n"
  2125. " document.getElementById(\"trapAddr\").style.display = !isManual ? 'none' :'inline';\n"
  2126. " }\n"
  2127. " function saveSnmpConfig() {\n"
  2128. " snmp_data = [];\n"
  2129. " snmp_data.mode = 1;\n"
  2130. " snmp_data.version = 0;\n"
  2131. " snmp_data.snmpReadCommunity = document.getElementById(\"snmpReadCommunity\").value;\n"
  2132. " snmp_data.snmpWriteCommunity = document.getElementById(\"snmpWriteCommunity\").value;\n"
  2133. " snmp_data.snmpTrapIp = document.getElementById(\"snmpTrapIp\").value;\n"
  2134. " snmp_data.snmpTrapStatus = document.getElementById(\"snmpTrapStatus\").value == \"open\" ? 1 : 0;\n"
  2135. " snmp_data.len = 55;\n"
  2136. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_SNMP,0, 0, 0, snmp_data);\n"
  2137. " ws.send(a);\n"
  2138. " showToast(\"SNMP配置已保存\", 1200);\n"
  2139. " }\n"
  2140. " function userAddConfig(user,password,role)\n"
  2141. " {\n"
  2142. " user_data = [];\n"
  2143. " user_data.role = role;\n"
  2144. " user_data.user = user;\n"
  2145. " user_data.password = password;\n"
  2146. " user_data.len = 65;\n"
  2147. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_ADD, 0, 0, user_data);\n"
  2148. " ws.send(a);\n"
  2149. " showToast(\"增加用户\",user, 1200);\n"
  2150. " }\n"
  2151. " function userDeleteConfig(user)\n"
  2152. " {\n"
  2153. " user_data=[];\n"
  2154. " user_data.user = user;\n"
  2155. " user_data.len = 32;\n"
  2156. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_DELETE, 0, 0, user_data);\n"
  2157. " ws.send(a);\n"
  2158. " showToast(\"删除用户\",user, 1200);\n"
  2159. " }\n"
  2160. " function userUpdateConfig(user,old_pass,new_pass,role)\n"
  2161. " {\n"
  2162. " user_data = [];\n"
  2163. " user_data.role = role\n"
  2164. " user_data.user = user;\n"
  2165. " user_data.old_password = old_pass;\n"
  2166. " user_data.new_password = new_pass;\n"
  2167. " user_data.len = 97;\n"
  2168. " a = pkt_to_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,SUB_USER_TYPE.NEW_SUB_PKT_TYPE_USER_UPDATE, 0, 0, user_data);\n"
  2169. " ws.send(a);\n"
  2170. " showToast(\"修改用户\",user, 1200);\n"
  2171. " }\n"
  2172. " function updateSnmpStatusMsg() {\n"
  2173. " const msgDiv = document.getElementById(\"snmpStatusMsg\");\n"
  2174. " if (msgDiv) {\n"
  2175. " const trapInfo = snmpConfig.trapIp ? (snmpConfig.trapIp) : \"未配置\";\n"
  2176. " msgDiv.innerHTML = \"🔐 只读社团: \" + snmpConfig.readCommunity + \" | ✏️ 读写社团: \" + snmpConfig.writeCommunity + \"<br>📡 TRAP目标: \" + trapInfo;\n"
  2177. " }\n"
  2178. " }\n"
  2179. " function updateDeviceStatusMsg()\n"
  2180. " {\n"
  2181. " document.getElementById('deviceChannel').textContent = device_info.chs;\n"
  2182. " document.getElementById(\"powerType\").textContent = (device_info.power_type == 0)? 'AC-AC' : (device_info.power_type == 1) \n"
  2183. " ? 'DC-DC' : (device_info.power_type == 3) \n"
  2184. " ? 'AC3-AC3': (device_info.power_type == 4 || device_info.power_type == 5) \n"
  2185. " ? 'AC3-AC1': (device_info.power_type == 6)\n"
  2186. " ? 'AC3-AC2':'Other';\n"
  2187. " document.getElementById(\"controlBoard\").textContent = device_info.board_cnt;\n"
  2188. " document.getElementById(\"softVersion\").textContent = device_info.soft_version;\n"
  2189. " document.getElementById(\"zone\").textContent = device_info.zone;\n"
  2190. " }\n"
  2191. " function updateTimeDisplay() {\n"
  2192. " const display = document.getElementById(\"systemTimeDisplay\");\n"
  2193. " if (display) {\n"
  2194. " display.innerHTML = device_info.date + ' ' + device_info.time;\n"
  2195. " }\n"
  2196. " }\n"
  2197. " function startTimeUpdater() {\n"
  2198. " clearInterval(device_info_id);\n"
  2199. " power_all_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_ALL, 0, 0));}, 600);\n"
  2200. " power_data_id = setInterval(function() { \n"
  2201. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L1, 0, 0));\n"
  2202. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L2, 0, 0));},40);\n"
  2203. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L3, 0, 0));},40);\n"
  2204. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_INFO, 0, 0));},40);\n"
  2205. " }, 300);\n"
  2206. " power_thr_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_THR, 0, 0));}, 500);\n"
  2207. " sensor_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_SENSOR,0, 0, 0));}, 1000); \n"
  2208. " wanning_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_WANNING,0, 0, 0));}, 3000);\n"
  2209. " }\n"
  2210. " function setSystemTime(newDate) {\n"
  2211. " systemTime = newDate;\n"
  2212. " updateTimeDisplay();\n"
  2213. " showToast(\"系统时间已更新为: \" + systemTime.toLocaleString(), 1500);\n"
  2214. " }\n"
  2215. " function switchPage(pageId) { \n"
  2216. " document.querySelectorAll('.page').forEach(function(p){ p.classList.remove('active-page'); }); \n"
  2217. " document.getElementById(pageId + 'Page').classList.add('active-page'); \n"
  2218. " document.querySelectorAll('.tab-btn').forEach(function(btn){ btn.classList.remove('active'); }); \n"
  2219. " document.querySelector('.tab-btn[data-page=\"' + pageId + '\"]').classList.add('active'); \n"
  2220. " if(pageId == 'network')\n"
  2221. " {\n"
  2222. " clearInterval(power_all_id);\n"
  2223. " clearInterval(power_thr_id);\n"
  2224. " clearInterval(power_data_id);\n"
  2225. " clearInterval(device_info_id);\n"
  2226. " clearInterval(sensor_id);\n"
  2227. " clearInterval(wanning_id);\n"
  2228. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_NETWORK,0, 0, 0));\n"
  2229. " }else if(pageId == 'rs485')\n"
  2230. " {\n"
  2231. " clearInterval(power_all_id);\n"
  2232. " clearInterval(power_thr_id);\n"
  2233. " clearInterval(power_data_id);\n"
  2234. " clearInterval(device_info_id);\n"
  2235. " clearInterval(sensor_id); \n"
  2236. " clearInterval(wanning_id);\n"
  2237. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_RS485,0, 0, 0)); \n"
  2238. " }else if(pageId == 'user')\n"
  2239. " {\n"
  2240. " clearInterval(power_all_id);\n"
  2241. " clearInterval(power_thr_id);\n"
  2242. " clearInterval(power_data_id);\n"
  2243. " clearInterval(device_info_id);\n"
  2244. " clearInterval(sensor_id); \n"
  2245. " clearInterval(wanning_id);\n"
  2246. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_USER,0, 0, 0)); \n"
  2247. " } \n"
  2248. " else if(pageId =='monitor')\n"
  2249. " {\n"
  2250. " clearInterval(device_info_id);\n"
  2251. " power_all_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_ALL, 0, 0));}, 600);\n"
  2252. " power_data_id = setInterval(function() { \n"
  2253. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L1, 0, 0));\n"
  2254. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L2, 0, 0));},40);\n"
  2255. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_L3, 0, 0));},40);\n"
  2256. " setTimeout(() => {ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_INFO, 0, 0));},40);\n"
  2257. " }, 300);\n"
  2258. " power_thr_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_ELE_INFO, SUB_POWER_TYPE.NEW_SUB_PKT_TYPE_ELE_DATA_THR, 0, 0));}, 500);\n"
  2259. " sensor_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_SENSOR,0, 0, 0));}, 1000);\n"
  2260. " wanning_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_WANNING,0, 0, 0));}, 3000);\n"
  2261. " }else if(pageId =='snmp')\n"
  2262. " {\n"
  2263. " clearInterval(power_all_id);\n"
  2264. " clearInterval(power_thr_id);\n"
  2265. " clearInterval(power_data_id);\n"
  2266. " clearInterval(device_info_id);\n"
  2267. " clearInterval(sensor_id);\n"
  2268. " clearInterval(wanning_id);\n"
  2269. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_SNMP, 0, 0, 0));\n"
  2270. " }\n"
  2271. " else if(pageId == 'device')\n"
  2272. " {\n"
  2273. " clearInterval(power_all_id);\n"
  2274. " clearInterval(power_thr_id);\n"
  2275. " clearInterval(power_data_id);\n"
  2276. " clearInterval(sensor_id);\n"
  2277. " clearInterval(wanning_id);\n"
  2278. " ntpConfig.ntpZone = device_info.zone;\n"
  2279. " loadNtpConfig();\n"
  2280. " device_info_id = setInterval(function() { ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO,0, 0, 0));}, 1000);\n"
  2281. " }\n"
  2282. " }\n"
  2283. " function connectWebSocket() {\n"
  2284. " const wsUrl = 'ws://' + window.location.host + '/ws';\n"
  2285. " //const wsUrl = 'ws://' + '192.168.9.110' + '/ws';\n"
  2286. " updateWsStatus(false, '正在连接...');\n"
  2287. " const led = document.getElementById('wsLed');\n"
  2288. " led.className = 'ws-led connecting';\n"
  2289. " try {\n"
  2290. " ws = new WebSocket(wsUrl);\n"
  2291. " ws.onopen = function() {\n"
  2292. " console.log('WebSocket连接成功'); \n"
  2293. " wsConnected = true;\n"
  2294. " reconnectAttempts = 0;\n"
  2295. " updateWsStatus(true, '已连接'); \n"
  2296. " ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO, 0, 0, 0)); \n"
  2297. " };\n"
  2298. " ws.binaryType = 'arraybuffer';\n"
  2299. " ws.onmessage = onWsMessage;\n"
  2300. " ws.onerror = function(error) { console.error('WebSocket错误:', error); updateWsStatus(false, '连接错误'); };\n"
  2301. " ws.onclose = function() { \n"
  2302. " console.log('WebSocket连接关闭'); \n"
  2303. " wsConnected = false; \n"
  2304. " updateWsStatus(false, '连接已断开'); \n"
  2305. " if (reconnectTimer) \n"
  2306. " clearTimeout(reconnectTimer); \n"
  2307. " if (reconnectAttempts < maxReconnectAttempts) { \n"
  2308. " reconnectAttempts++; \n"
  2309. " reconnectTimer = setTimeout(function() { \n"
  2310. " connectWebSocket(); \n"
  2311. " }, 3000); \n"
  2312. " } else { \n"
  2313. " updateWsStatus(false, '连接失败,请刷新页面重试'); \n"
  2314. " } \n"
  2315. " };\n"
  2316. " } catch(e) { console.error('创建WebSocket失败:', e); updateWsStatus(false, '创建连接失败'); }\n"
  2317. " }\n"
  2318. " function openAddUserModal() {\n"
  2319. " currentEditUserId = null;\n"
  2320. " document.getElementById('userModalTitle').innerText = '新增用户';\n"
  2321. " document.getElementById('userName').value = '';\n"
  2322. " document.getElementById('userAddPassword').value = '';\n"
  2323. " document.getElementById('userAddModal').classList.add('active');\n"
  2324. " }\n"
  2325. " function confirmUserAddAction()\n"
  2326. " {\n"
  2327. " let username = document.getElementById('userAddName').value.trim();\n"
  2328. " let password = document.getElementById('userAddPassword').value;\n"
  2329. " let role_s = document.getElementById('userRole').value;\n"
  2330. " let role = (role_s == \"superadmin\") ? 1 : (role_s == \"admin\") ? 2 : 3; \n"
  2331. " if (!username || !password) { showToast(\"用户名或密码不能为空\", 1000); return; }\n"
  2332. " userAddConfig(username,password,role)\n"
  2333. " // let editId = document.getElementById('editUserId').value;\n"
  2334. " // if (editId) {\n"
  2335. " // updateUserApi(parseInt(editId), username, password, role);\n"
  2336. " // } else {\n"
  2337. " // if (!password) { showToast(\"新增用户必须填写密码\", 1000); return; }\n"
  2338. " // addUserApi(username, password, role);\n"
  2339. " // }\n"
  2340. " //closeModal('userAddModal'); \n"
  2341. " }\n"
  2342. " function confirmUserAction() {\n"
  2343. " let username = document.getElementById('userName').value.trim();\n"
  2344. " let old_password = document.getElementById('userOldPassword').value;\n"
  2345. " let new_password = document.getElementById('userNewPassword').value;\n"
  2346. " let role_s = document.getElementById('userRole').value;\n"
  2347. " let role = (role_s == \"superadmin\") ? 1 : (role_s == \"admin\") ? 2 : 3; \n"
  2348. " if(!old_password || !new_password)\n"
  2349. " {\n"
  2350. " showToast(\"编辑用户必须填写密码\", 1000); return;\n"
  2351. " }\n"
  2352. " userUpdateConfig(username,old_password,new_password,role);\n"
  2353. " // if (!username) { showToast(\"用户名不能为空\", 1000); return; }\n"
  2354. " // let editId = document.getElementById('editUserId').value;\n"
  2355. " // if (editId) {\n"
  2356. " // updateUserApi(parseInt(editId), username, password, role);\n"
  2357. " // } else {\n"
  2358. " // if (!password) { showToast(\"新增用户必须填写密码\", 1000); return; }\n"
  2359. " // addUserApi(username, password, role);\n"
  2360. " // }\n"
  2361. " // closeModal('userModal');\n"
  2362. " }\n"
  2363. " function initApp() {\n"
  2364. " connectWebSocket();\n"
  2365. " //ws.send(mk_hdr_bin(0, PKT_TYPE.NEW_PKT_TYPE_DEVICE_INFO, 0, 0, 0)); \n"
  2366. " startTimeUpdater();\n"
  2367. " document.getElementById('openDelayConfigBtn').addEventListener('click', openDelayModal);\n"
  2368. " document.getElementById('openThresholdConfigBtn').addEventListener('click', openThresholdModal);\n"
  2369. " document.getElementById('openResetEnergyModalBtn').addEventListener('click', openResetEnergyModal);\n"
  2370. " document.getElementById('allOnBtn').addEventListener('click', allOn);\n"
  2371. " document.getElementById('allOffBtn').addEventListener('click', allOff);\n"
  2372. " document.getElementById('openAlarmModalBtn').addEventListener('click', openAlarmModal);\n"
  2373. " document.getElementById('cleanSoundLight').addEventListener('click', clean_sound_light);\n"
  2374. " document.getElementById('tempCard').addEventListener('click',openTempModal);\n"
  2375. " document.getElementById('humiCard').addEventListener('click',openHumiModal);\n"
  2376. " document.getElementById('smokeCard').addEventListener('click',openSmokeModal);\n"
  2377. " document.getElementById('co2Card').addEventListener('click',openCo2Modal);\n"
  2378. " document.getElementById('setSystemRebootBtn').addEventListener('click',rebootSystem);\n"
  2379. " document.getElementById('addUserBtn')?.addEventListener('click', openAddUserModal);\n"
  2380. " document.getElementById('closeUserModalBtn')?.addEventListener('click',()=>closeModal('userModal'));\n"
  2381. " document.getElementById('cancelUserModalBtn')?.addEventListener('click',()=>closeModal('userModal'));\n"
  2382. " document.getElementById('closeUserAddModalBtn')?.addEventListener('click',()=>closeModal('userAddModal'));\n"
  2383. " document.getElementById('cancelUserAddModalBtn')?.addEventListener('click',()=>closeModal('userAddModal'));\n"
  2384. " document.getElementById('confirmUserAddBtn')?.addEventListener('click', confirmUserAddAction);\n"
  2385. " document.getElementById('confirmUserBtn')?.addEventListener('click', confirmUserAction);\n"
  2386. " \n"
  2387. " // document.getElementById('ALL').addEventListener('click',function(){\n"
  2388. " // show_l_info = 0;\n"
  2389. " // document.getElementById('ALL').classList.add('active');\n"
  2390. " // document.getElementById('L1').classList.remove('active');\n"
  2391. " // document.getElementById('L2').classList.remove('active');\n"
  2392. " // document.getElementById('L3').classList.remove('active');\n"
  2393. " // });\n"
  2394. " document.getElementById('L1').addEventListener('click',function(){\n"
  2395. " show_l_info =1;\n"
  2396. " //document.getElementById('ALL').classList.remove('active');\n"
  2397. " document.getElementById('L1').classList.add('active');\n"
  2398. " document.getElementById('L2').classList.remove('active');\n"
  2399. " document.getElementById('L3').classList.remove('active');\n"
  2400. " });\n"
  2401. " document.getElementById('L2').addEventListener('click',function(){\n"
  2402. " show_l_info = 2;\n"
  2403. " //document.getElementById('ALL').classList.remove('active');\n"
  2404. " document.getElementById('L1').classList.remove('active');\n"
  2405. " document.getElementById('L2').classList.add('active');\n"
  2406. " document.getElementById('L3').classList.remove('active');\n"
  2407. " });\n"
  2408. " document.getElementById('L3').addEventListener('click',function(){\n"
  2409. " show_l_info = 3\n"
  2410. " // document.getElementById('ALL').classList.remove('active');\n"
  2411. " document.getElementById('L1').classList.remove('active');\n"
  2412. " document.getElementById('L2').classList.remove('active');\n"
  2413. " document.getElementById('L3').classList.add('active');\n"
  2414. " });\n"
  2415. " document.getElementById('closeAlarmModalBtn').addEventListener('click', function() {\n"
  2416. " closeModal('alarmModal');\n"
  2417. " });\n"
  2418. " document.getElementById('cancelAlarmModalBtn').addEventListener('click', function() {\n"
  2419. " closeModal('alarmModal');\n"
  2420. " });\n"
  2421. " document.getElementById('clearAlarmBtn').addEventListener('click', clearAlarm);\n"
  2422. " document.getElementById('saveNetConfigBtn').addEventListener('click', saveNetConfig);\n"
  2423. " document.getElementById('saveRs485ConfigBtn').addEventListener('click', saveRs485Config);\n"
  2424. " document.getElementById('saveSnmpConfigBtn').addEventListener('click', saveSnmpConfig);\n"
  2425. " document.getElementById('ipMode').addEventListener('change', updateStaticIpFieldsEnable);\n"
  2426. " document.getElementById('snmpTrapStatus').addEventListener('change', updateSnmpEnable);\n"
  2427. " document.getElementById('reconnectBtn').addEventListener('click', function() {\n"
  2428. " if (ws) ws.close();\n"
  2429. " connectWebSocket();\n"
  2430. " });\n"
  2431. " document.getElementById('setSystemTimeBtn').addEventListener('click', function() {\n"
  2432. " confirmNtp();\n"
  2433. " });\n"
  2434. " const tabs = document.querySelectorAll('.tab-btn');\n"
  2435. " for (let j = 0; j < tabs.length; j++) tabs[j].addEventListener('click', function() {\n"
  2436. " switchPage(this.dataset.page);\n"
  2437. " });\n"
  2438. " document.getElementById('closeTempModalBtn').addEventListener('click', function() {\n"
  2439. " closeModal('tempCardModal');\n"
  2440. " });\n"
  2441. " document.getElementById('closeHumiModalBtn').addEventListener('click', function() {\n"
  2442. " closeModal('humiCardModal');\n"
  2443. " });\n"
  2444. " document.getElementById('closeSmokeModalBtn').addEventListener('click', function() {\n"
  2445. " closeModal('smokeCardModal');\n"
  2446. " });\n"
  2447. " document.getElementById('closeCo2ModalBtn').addEventListener('click', function() {\n"
  2448. " closeModal('co2CardModal');\n"
  2449. " });\n"
  2450. " document.getElementById('closeDelayModalBtn').addEventListener('click', function() {\n"
  2451. " closeModal('delayModal');\n"
  2452. " });\n"
  2453. " document.getElementById('cancelDelayModalBtn').addEventListener('click', function() {\n"
  2454. " closeModal('delayModal');\n"
  2455. " });\n"
  2456. " document.getElementById('closeThresholdModalBtn').addEventListener('click', function() {\n"
  2457. " closeModal('thresholdModal');\n"
  2458. " });\n"
  2459. " document.getElementById('cancelThresholdModalBtn').addEventListener('click', function() {\n"
  2460. " closeModal('thresholdModal');\n"
  2461. " });\n"
  2462. " document.getElementById('closeResetModalBtn').addEventListener('click', function() {\n"
  2463. " closeModal('resetEnergyModal');\n"
  2464. " });\n"
  2465. " document.getElementById('cancelResetModalBtn').addEventListener('click', function() {\n"
  2466. " closeModal('resetEnergyModal');\n"
  2467. " });\n"
  2468. " document.getElementById('confirmTempThrBtn').addEventListener('click', confirmTempThr);\n"
  2469. " document.getElementById('confirmHumiThrBtn').addEventListener('click', confirmHumiThr);\n"
  2470. " document.getElementById('confirmSmokeThrBtn').addEventListener('click', confirmSmokeThr);\n"
  2471. " document.getElementById('confirmCo2ThrBtn').addEventListener('click', confirmCo2Thr);\n"
  2472. " document.getElementById('confirmResetEnergyBtn').addEventListener('click', confirmResetEnergy);\n"
  2473. " document.getElementById('selectAllChannels').addEventListener('click', selectAllChannels);\n"
  2474. " document.getElementById('deselectAllChannels').addEventListener('click', deselectAllChannels);\n"
  2475. " const modals = ['delayModal', 'thresholdModal', 'resetEnergyModal', 'alarmModal'];\n"
  2476. " for (let k = 0; k < modals.length; k++)(function(id) {\n"
  2477. " const el = document.getElementById(id);\n"
  2478. " if (el) el.addEventListener('click', function(e) {\n"
  2479. " if (e.target === document.getElementById(id)) closeModal(id);\n"
  2480. " });\n"
  2481. " })(modals[k]);\n"
  2482. " document.getElementById('reconnectBtn').addEventListener('click',()=>{ if(ws)ws.close(); connectWebSocket(); }); \n"
  2483. " document.getElementById('logoutBtn').addEventListener('click',()=>{ sessionStorage.removeItem(STORAGE_KEY); \n"
  2484. " if(ws && ws.readyState===WebSocket.OPEN) \n"
  2485. " ws.close(); \n"
  2486. " if(power_all_id) clearInterval(power_all_id); \n"
  2487. " if(power_data_id) clearInterval(power_data_id); \n"
  2488. " if(power_thr_id) clearInterval(power_thr_id); \n"
  2489. " if(sensor_id) clearInterval(sensor_id); \n"
  2490. " if(wanning_id) clearInterval(wanning_id); \n"
  2491. " if(device_info_id) clearInterval(device_info_id); \n"
  2492. " document.getElementById('loginContainer').style.display='flex'; \n"
  2493. " document.getElementById('dashboardApp').style.display='none'; \n"
  2494. " document.getElementById('loginUsername').value=''; \n"
  2495. " document.getElementById('loginPassword').value=''; \n"
  2496. " document.getElementById('loginErrorMsg').innerText=''; }); \n"
  2497. " \n"
  2498. " const pwdInput = document.getElementById('loginPassword');\n"
  2499. " if (pwdInput) {\n"
  2500. " pwdInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') document.getElementById('loginBtn').click(); });\n"
  2501. " }\n"
  2502. " }\n"
  2503. " function performLogin(username, password) { \n"
  2504. " const errorDiv = document.getElementById('loginErrorMsg'); \n"
  2505. " if (!username || !password) { errorDiv.innerText = '请输入用户名和密码'; return; } \n"
  2506. " errorDiv.innerText = '正在验证...'; \n"
  2507. " //const wsUrl = 'ws://192.168.9.110/ws'; \n"
  2508. " const wsUrl = 'ws://' + window.location.host + '/ws';\n"
  2509. " tempws = new WebSocket(wsUrl); \n"
  2510. " tempws.binaryType = 'arraybuffer'; \n"
  2511. " let responded = false; \n"
  2512. " tempws.onopen = function() { \n"
  2513. " const encoder = new TextEncoder(); \n"
  2514. " const unameBuf = new Uint8Array(32); \n"
  2515. " const pwdBuf = new Uint8Array(32); \n"
  2516. " unameBuf.set(encoder.encode(username).slice(0,32)); \n"
  2517. " pwdBuf.set(encoder.encode(password).slice(0,32)); \n"
  2518. " const payload = new ArrayBuffer(64); \n"
  2519. " const view = new Uint8Array(payload); \n"
  2520. " view.set(unameBuf,0); view.set(pwdBuf,32); \n"
  2521. " const header = mk_hdr_bin(0,0x08,0,0,0,64); \n"
  2522. " const fullMsg = array_cat(header,payload); \n"
  2523. " tempws.send(fullMsg); \n"
  2524. " }; \n"
  2525. " tempws.onmessage = function(event) { \n"
  2526. " if(responded) return; \n"
  2527. " try {\n"
  2528. " if (event.data instanceof ArrayBuffer) {\n"
  2529. " var obj = bin_parse(event.data);\n"
  2530. " if (obj.login != undefined) {\n"
  2531. " if(obj.login.flag === 1)\n"
  2532. " {\n"
  2533. " responded=true;\n"
  2534. " tempws.close(); \n"
  2535. " errorDiv.innerText=''; \n"
  2536. " document.getElementById('loginContainer').style.display='none'; \n"
  2537. " document.getElementById('dashboardApp').style.display='block'; \n"
  2538. " sessionStorage.setItem(STORAGE_KEY,'true'); \n"
  2539. " initApp(); \n"
  2540. " }else if(obj.login.flag === 2)\n"
  2541. " {\n"
  2542. " responded=true; \n"
  2543. " tempws.close(); \n"
  2544. " errorDiv.innerText='密码错误'; \n"
  2545. " }else if(obj.login.flag === 0)\n"
  2546. " {\n"
  2547. " responded=true; \n"
  2548. " tempws.close(); \n"
  2549. " errorDiv.innerText='用户名错误'; \n"
  2550. " }\n"
  2551. " \n"
  2552. " }\n"
  2553. " }\n"
  2554. " }catch (e) {\n"
  2555. " console.error('解析WebSocket消息失败:', e);\n"
  2556. " }\n"
  2557. " }; \n"
  2558. " tempws.onerror = function() { \n"
  2559. " if(!responded){ \n"
  2560. " responded=true; \n"
  2561. " errorDiv.innerText='连接服务器失败'; \n"
  2562. " } \n"
  2563. " }; \n"
  2564. " tempws.onclose = function() { if(!responded) errorDiv.innerText='连接已断开'; }; \n"
  2565. " }\n"
  2566. " const STORAGE_KEY = 'power_monitor_auth';\n"
  2567. " const MAGIC = 0xdead;\n"
  2568. " let power_all_id = 0;\n"
  2569. " let power_thr_id = 0;\n"
  2570. " let power_data_id = 0;\n"
  2571. " let device_info_id = 0;\n"
  2572. " let sensor_id = 0;\n"
  2573. " let wanning_id = 0;\n"
  2574. " let device_info = [];\n"
  2575. " let channelDelays = [];\n"
  2576. " let channelThresholds = [];\n"
  2577. " let tempValue = [];\n"
  2578. " let humiValue = [];\n"
  2579. " let smokeValue = [];\n"
  2580. " let co2Value = [];\n"
  2581. " let currentSelectedChannels = [];\n"
  2582. " let channelTelemetry = [];\n"
  2583. " let channelTelemetry1 = [];\n"
  2584. " let channelTelemetry2 = [];\n"
  2585. " let channelSwitchStates = [];\n"
  2586. " let envData = {temp: 25,humi: 50,smoke: 100,co2: 400};\n"
  2587. " let alarmList = [];\n"
  2588. " let nextAlarmId = 1;\n"
  2589. " let all_channel = [];\n"
  2590. " let all_l_channel = [];\n"
  2591. " let channel_info = [];\n"
  2592. " let update_flag = 0;\n"
  2593. " let show_l_info = 0;\n"
  2594. " let tableRows = [];\n"
  2595. " let netConfig = {\n"
  2596. " ipMode: \"auto\",\n"
  2597. " ipAddress: \"192.168.1.100\",\n"
  2598. " subnetMask: \"255.255.255.0\",\n"
  2599. " gateway: \"192.168.1.1\",\n"
  2600. " dns1: \"114.114.114.114\",\n"
  2601. " dns2: \"8.8.8.8\"\n"
  2602. " };\n"
  2603. " let ntpConfig = {\n"
  2604. " ntpZone:\"8\",\n"
  2605. " };\n"
  2606. " let rs485Config = {\n"
  2607. " mode: \"master\",\n"
  2608. " address: 1,\n"
  2609. " baudrate: \"9600\"\n"
  2610. " };\n"
  2611. " let snmpConfig = {\n"
  2612. " status : \"open\",\n"
  2613. " readCommunity: \"public\",\n"
  2614. " writeCommunity: \"private\",\n"
  2615. " trapStatus: \"open\",\n"
  2616. " trapIp: \"\",\n"
  2617. " };\n"
  2618. " let users = [];\n"
  2619. " let user_cnt = [];\n"
  2620. " let systemTime = new Date();\n"
  2621. " // WebSocket 连接\n"
  2622. " let ws = null;\n"
  2623. " let wsConnected = false;\n"
  2624. " let reconnectAttempts = 0;\n"
  2625. " const maxReconnectAttempts = 10;\n"
  2626. " let reconnectTimer = null; \n"
  2627. " document.getElementById('loginBtn').addEventListener('click',()=>{ \n"
  2628. " let user=document.getElementById('loginUsername').value.trim(); \n"
  2629. " let pwd=document.getElementById('loginPassword').value; \n"
  2630. " performLogin(user,pwd); \n"
  2631. " });\n"
  2632. " if(sessionStorage.getItem(STORAGE_KEY)==='true'){ \n"
  2633. " document.getElementById('loginContainer').style.display='none'; \n"
  2634. " document.getElementById('dashboardApp').style.display='block'; \n"
  2635. " initApp(); \n"
  2636. " } else { \n"
  2637. " document.getElementById('loginContainer').style.display='flex'; \n"
  2638. " document.getElementById('dashboardApp').style.display='none';\n"
  2639. " }\n"
  2640. " </script>\n"
  2641. " </body>\n"
  2642. "</html>"
  2643. ;
  2644. // 文本数据大小(包括null终止符)
  2645. const size_t p_index_html_size = 168444;
  2646. // 文本长度(字符数)
  2647. const size_t p_index_html_length = 165341;
  2648. #endif /* P_INDEX_HTML_H */