增加高压空闲调节
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
+2018
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+6
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
.cm-s-monokai.CodeMirror{background:#272822;color:#f8f8f2}.cm-s-monokai div.CodeMirror-selected{background:#49483e}.cm-s-monokai .CodeMirror-line::selection,.cm-s-monokai .CodeMirror-line>span::selection,.cm-s-monokai .CodeMirror-line>span>span::selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-line::-moz-selection,.cm-s-monokai .CodeMirror-line>span::-moz-selection,.cm-s-monokai .CodeMirror-line>span>span::-moz-selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-gutters{background:#272822;border-right:0}.cm-s-monokai .CodeMirror-guttermarker{color:#fff}.cm-s-monokai .CodeMirror-guttermarker-subtle{color:#d0d0d0}.cm-s-monokai .CodeMirror-linenumber{color:#d0d0d0}.cm-s-monokai .CodeMirror-cursor{border-left:1px solid #f8f8f0}.cm-s-monokai span.cm-comment{color:#75715e}.cm-s-monokai span.cm-atom{color:#ae81ff}.cm-s-monokai span.cm-number{color:#ae81ff}.cm-s-monokai span.cm-comment.cm-attribute{color:#97b757}.cm-s-monokai span.cm-comment.cm-def{color:#bc9262}.cm-s-monokai span.cm-comment.cm-tag{color:#bc6283}.cm-s-monokai span.cm-comment.cm-type{color:#5998a6}.cm-s-monokai span.cm-attribute,.cm-s-monokai span.cm-property{color:#a6e22e}.cm-s-monokai span.cm-keyword{color:#f92672}.cm-s-monokai span.cm-builtin{color:#66d9ef}.cm-s-monokai span.cm-string{color:#e6db74}.cm-s-monokai span.cm-variable{color:#f8f8f2}.cm-s-monokai span.cm-variable-2{color:#9effff}.cm-s-monokai span.cm-type,.cm-s-monokai span.cm-variable-3{color:#66d9ef}.cm-s-monokai span.cm-def{color:#fd971f}.cm-s-monokai span.cm-bracket{color:#f8f8f2}.cm-s-monokai span.cm-tag{color:#f92672}.cm-s-monokai span.cm-header{color:#ae81ff}.cm-s-monokai span.cm-link{color:#ae81ff}.cm-s-monokai span.cm-error{background:#f92672;color:#f8f8f0}.cm-s-monokai .CodeMirror-activeline-background{background:#373831}.cm-s-monokai .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}
|
||||
@@ -0,0 +1,85 @@
|
||||
.card {
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
#feedbackVoltage,
|
||||
#feedbackCurrent,
|
||||
#filamentVoltage,
|
||||
#filamentCurrent {
|
||||
background-color: #f8f9fa;
|
||||
font-weight: bold;
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* 导航栏样式 */
|
||||
.navbar {
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.nav-link i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* 编辑器相关样式 */
|
||||
.CodeMirror {
|
||||
height: calc(100vh - 200px);
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#fileTree {
|
||||
height: calc(100vh - 200px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.jstree-default .jstree-icon {
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
.jstree-default .jstree-themeicon {
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.jstree-default .jstree-themeicon-custom {
|
||||
color: #0d6efd;
|
||||
}
|
||||
|
||||
/* 文件类型图标颜色 */
|
||||
.bi-filetype-py {
|
||||
color: #306998;
|
||||
}
|
||||
|
||||
.bi-filetype-json {
|
||||
color: #f7df1e;
|
||||
}
|
||||
|
||||
.bi-filetype-sh {
|
||||
color: #4eaa25;
|
||||
}
|
||||
|
||||
.bi-folder {
|
||||
color: #ffc107;
|
||||
}
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,244 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>高压电源管理系统1</title>
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/bootstrap-icons.css" rel="stylesheet">
|
||||
<link href="css/style.min.css" rel="stylesheet">
|
||||
<link href="css/codemirror.min.css" rel="stylesheet">
|
||||
<link href="css/monokai.min.css" rel="stylesheet">
|
||||
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- 导航栏 -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/">高压电源管理系统</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Toast提示组件 -->
|
||||
<div class="position-fixed top-0 start-50 translate-middle-x p-3" style="z-index: 11">
|
||||
<div id="toast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">系统提示</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选项卡 -->
|
||||
<ul class="nav nav-tabs mb-3" id="mainTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="panel-tab" data-bs-toggle="tab" data-bs-target="#panel"
|
||||
type="button" role="tab" aria-controls="panel" aria-selected="true">控制面板</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="script-tab" data-bs-toggle="tab" data-bs-target="#script" type="button"
|
||||
role="tab" aria-controls="script" aria-selected="false"><i class="bi bi-code-square"></i>
|
||||
脚本编辑器</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="var-tab" data-bs-toggle="tab" data-bs-target="#var" type="button"
|
||||
role="tab" aria-controls="var" aria-selected="false"><i class="bi bi-gear"></i>
|
||||
变量设置</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="mainTabContent">
|
||||
<!-- 控制面板 -->
|
||||
<div class="tab-pane fade show active" id="panel" role="tabpanel" aria-labelledby="panel-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">设备控制</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="reboot">重启设备</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_start">启动程序</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_stop">停止程序</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_restart">重启程序</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-danger" id="hvEnable">开启高压</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-success" id="hvDisable">关闭高压</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-danger" id="rayEnable">开启射线</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-success" id="rayDisable">关闭射线</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">设定参数</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="setVoltage" class="form-label">设定电压 (kV)</label>
|
||||
<input type="number" class="form-control" id="setVoltage" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="setCurrent" class="form-label">设定电流 (mA)</label>
|
||||
<input type="number" class="form-control" id="setCurrent" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="filaPreheatCurrent" class="form-label">灯丝预热电流 (A)</label>
|
||||
<input type="number" class="form-control" id="filaPreheatCurrent" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="filaLimitCurrent" class="form-label">灯丝限制电流 (A)</label>
|
||||
<input type="number" class="form-control" id="filaLimitCurrent" value="0">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-primary" id="getParams">读取参数</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-primary" id="setParams">设置参数</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">实时状态</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">电源状态</label>
|
||||
<div class="form-control" id="vinState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">高压状态</label>
|
||||
<div class="form-control" id="hvState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">射线状态</label>
|
||||
<div class="form-control" id="rayState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">反馈电压 (kV)</label>
|
||||
<div class="form-control" id="feedbackVoltage">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">反馈电流 (mA)</label>
|
||||
<div class="form-control" id="feedbackCurrent">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">灯丝电压 (V)</label>
|
||||
<div class="form-control" id="filamentVoltage">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">灯丝电流 (A)</label>
|
||||
<div class="form-control" id="filamentCurrent">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 脚本编辑器 -->
|
||||
<div class="tab-pane fade" id="script" role="tabpanel" aria-labelledby="script-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span>文件目录</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-primary" id="refreshTree">
|
||||
<i class="bi bi-arrow-clockwise"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="fileTree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span id="currentFile">未选择文件</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-success" id="saveFile" disabled>
|
||||
<i class="bi bi-save"></i> 保存
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger" id="deleteFile" disabled>
|
||||
<i class="bi bi-trash"></i> 删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<textarea id="editor"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 变量设置 -->
|
||||
<div class="tab-pane fade" id="var" role="tabpanel" aria-labelledby="var-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span>变量配置</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-primary" id="getVar">
|
||||
<i class="bi bi-download"></i> 读取变量
|
||||
</button>
|
||||
<button class="btn btn-sm btn-success" id="setVar">
|
||||
<i class="bi bi-upload"></i> 保存变量
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="varEditor" class="form-label">变量配置 (JSON格式)</label>
|
||||
<textarea class="form-control" id="varEditor" rows="20" placeholder="变量配置将以JSON格式显示在这里..."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/bootstrap.bundle.min.js"></script>
|
||||
<script src="js/jstree.min.js"></script>
|
||||
<script src="js/codemirror.min.js"></script>
|
||||
<script src="js/python.min.js"></script>
|
||||
<script src="js/javascript.min.js"></script>
|
||||
<script src="js/shell.min.js"></script>
|
||||
<script src="js/htmlmixed.min.js"></script>
|
||||
<script src="js/xml.min.js"></script>
|
||||
<script src="js/css.min.js"></script>
|
||||
<script src="js/base64.min.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Minified by jsDelivr using Terser v5.15.1.
|
||||
* Original file: /npm/js-base64@3.7.5/base64.js
|
||||
*
|
||||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||
*/
|
||||
!function(t,n){var r,e;"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=t.Base64,(e=n()).noConflict=function(){return t.Base64=r,e},t.Meteor&&(Base64=e),t.Base64=e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this,(function(){"use strict";var t,n="3.7.5",r="function"==typeof atob,e="function"==typeof btoa,o="function"==typeof Buffer,u="function"==typeof TextDecoder?new TextDecoder:void 0,i="function"==typeof TextEncoder?new TextEncoder:void 0,f=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(t={},f.forEach((function(n,r){return t[n]=r})),t),a=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,d=String.fromCharCode.bind(String),s="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},l=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},h=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},p=function(t){for(var n,r,e,o,u="",i=t.length%3,c=0;c<t.length;){if((r=t.charCodeAt(c++))>255||(e=t.charCodeAt(c++))>255||(o=t.charCodeAt(c++))>255)throw new TypeError("invalid character found");u+=f[(n=r<<16|e<<8|o)>>18&63]+f[n>>12&63]+f[n>>6&63]+f[63&n]}return i?u.slice(0,i-3)+"===".substring(i):u},y=e?function(t){return btoa(t)}:o?function(t){return Buffer.from(t,"binary").toString("base64")}:p,A=o?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var n=[],r=0,e=t.length;r<e;r+=4096)n.push(d.apply(null,t.subarray(r,r+4096)));return y(n.join(""))},b=function(t,n){return void 0===n&&(n=!1),n?l(A(t)):A(t)},g=function(t){if(t.length<2)return(n=t.charCodeAt(0))<128?t:n<2048?d(192|n>>>6)+d(128|63&n):d(224|n>>>12&15)+d(128|n>>>6&63)+d(128|63&n);var n=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return d(240|n>>>18&7)+d(128|n>>>12&63)+d(128|n>>>6&63)+d(128|63&n)},B=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,x=function(t){return t.replace(B,g)},C=o?function(t){return Buffer.from(t,"utf8").toString("base64")}:i?function(t){return A(i.encode(t))}:function(t){return y(x(t))},m=function(t,n){return void 0===n&&(n=!1),n?l(C(t)):C(t)},v=function(t){return m(t,!0)},U=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,F=function(t){switch(t.length){case 4:var n=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return d(55296+(n>>>10))+d(56320+(1023&n));case 3:return d((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return d((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},w=function(t){return t.replace(U,F)},S=function(t){if(t=t.replace(/\s+/g,""),!a.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var n,r,e,o="",u=0;u<t.length;)n=c[t.charAt(u++)]<<18|c[t.charAt(u++)]<<12|(r=c[t.charAt(u++)])<<6|(e=c[t.charAt(u++)]),o+=64===r?d(n>>16&255):64===e?d(n>>16&255,n>>8&255):d(n>>16&255,n>>8&255,255&n);return o},E=r?function(t){return atob(h(t))}:o?function(t){return Buffer.from(t,"base64").toString("binary")}:S,D=o?function(t){return s(Buffer.from(t,"base64"))}:function(t){return s(E(t).split("").map((function(t){return t.charCodeAt(0)})))},R=function(t){return D(T(t))},z=o?function(t){return Buffer.from(t,"base64").toString("utf8")}:u?function(t){return u.decode(D(t))}:function(t){return w(E(t))},T=function(t){return h(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},Z=function(t){return z(T(t))},j=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},I=function(){var t=function(t,n){return Object.defineProperty(String.prototype,t,j(n))};t("fromBase64",(function(){return Z(this)})),t("toBase64",(function(t){return m(this,t)})),t("toBase64URI",(function(){return m(this,!0)})),t("toBase64URL",(function(){return m(this,!0)})),t("toUint8Array",(function(){return R(this)}))},O=function(){var t=function(t,n){return Object.defineProperty(Uint8Array.prototype,t,j(n))};t("toBase64",(function(t){return b(this,t)})),t("toBase64URI",(function(){return b(this,!0)})),t("toBase64URL",(function(){return b(this,!0)}))},P={version:n,VERSION:"3.7.5",atob:E,atobPolyfill:S,btoa:y,btoaPolyfill:p,fromBase64:Z,toBase64:m,encode:m,encodeURI:v,encodeURL:v,utob:x,btou:w,decode:Z,isValid:function(t){if("string"!=typeof t)return!1;var n=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(n)||!/[^\s0-9a-zA-Z\-_]/.test(n)},fromUint8Array:b,toUint8Array:R,extendString:I,extendUint8Array:O,extendBuiltins:function(){I(),O()},Base64:{}};return Object.keys(P).forEach((function(t){return P.Base64[t]=P[t]})),P}));
|
||||
//# sourceMappingURL=/sm/555281732ed54ee1693a772f485329378d8ea5052ffa4370e9c2e9947eb42d22.map
|
||||
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],t):t(CodeMirror)}(function(m){"use strict";var l={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]};var a={};function d(t,e){e=t.match(a[e=e]||(a[e]=new RegExp("\\s+"+e+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")));return e?/^\s*(.*?)\s*$/.exec(e[2])[1]:""}function g(t,e){return new RegExp((e?"^":"")+"</\\s*"+t+"\\s*>","i")}function o(t,e){for(var a in t)for(var n=e[a]||(e[a]=[]),l=t[a],o=l.length-1;0<=o;o--)n.unshift(l[o])}m.defineMode("htmlmixed",function(i,t){var c=m.getMode(i,{name:"xml",htmlMode:!0,multilineTagIndentFactor:t.multilineTagIndentFactor,multilineTagIndentPastTag:t.multilineTagIndentPastTag,allowMissingTagName:t.allowMissingTagName}),s={},e=t&&t.tags,a=t&&t.scriptTypes;if(o(l,s),e&&o(e,s),a)for(var n=a.length-1;0<=n;n--)s.script.unshift(["type",a[n].matches,a[n].mode]);function u(t,e){var a,o,r,n=c.token(t,e.htmlState),l=/\btag\b/.test(n);return l&&!/[<>\s\/]/.test(t.current())&&(a=e.htmlState.tagName&&e.htmlState.tagName.toLowerCase())&&s.hasOwnProperty(a)?e.inTag=a+" ":e.inTag&&l&&/>$/.test(t.current())?(a=/^([\S]+) (.*)/.exec(e.inTag),e.inTag=null,l=">"==t.current()&&function(t,e){for(var a=0;a<t.length;a++){var n=t[a];if(!n[0]||n[1].test(d(e,n[0])))return n[2]}}(s[a[1]],a[2]),l=m.getMode(i,l),o=g(a[1],!0),r=g(a[1],!1),e.token=function(t,e){return t.match(o,!1)?(e.token=u,e.localState=e.localMode=null):(a=t,n=r,l=e.localMode.token(t,e.localState),t=a.current(),-1<(e=t.search(n))?a.backUp(t.length-e):t.match(/<\/?$/)&&(a.backUp(t.length),a.match(n,!1)||a.match(t)),l);var a,n,l},e.localMode=l,e.localState=m.startState(l,c.indent(e.htmlState,"",""))):e.inTag&&(e.inTag+=t.current(),t.eol()&&(e.inTag+=" ")),n}return{startState:function(){return{token:u,inTag:null,localMode:null,localState:null,htmlState:m.startState(c)}},copyState:function(t){var e;return t.localState&&(e=m.copyState(t.localMode,t.localState)),{token:t.token,inTag:t.inTag,localMode:t.localMode,localState:e,htmlState:m.copyState(c,t.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(t,e,a){return!t.localMode||/^\s*<\//.test(e)?c.indent(t.htmlState,e,a):t.localMode.indent?t.localMode.indent(t.localState,e,a):m.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||c}}}},"xml","javascript","css"),m.defineMIME("text/html","htmlmixed")});
|
||||
+1
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+6
File diff suppressed because one or more lines are too long
@@ -0,0 +1,505 @@
|
||||
$(document).ready(function() {
|
||||
const topic_control = '/dev/control/hsv';
|
||||
const topic_status = '/dev/status/hsv';
|
||||
const topic_response = '/dev/response/hsv';
|
||||
|
||||
// ================== 控制面板相关 ==================
|
||||
// WebSocket客户端配置
|
||||
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsHost = location.hostname + (location.port ? ':' + location.port : '');
|
||||
const wsuri = wsProtocol + '//' + wsHost + '/ws';
|
||||
console.log('WebSocket URI:', wsuri);
|
||||
// 创建WebSocket连接
|
||||
let ws;
|
||||
let reconnectTimer;
|
||||
|
||||
function connectWebSocket() {
|
||||
ws = new WebSocket(wsuri);
|
||||
|
||||
ws.onopen = function() {
|
||||
showToast('已连接到WebSocket服务器');
|
||||
ws.send(JSON.stringify({ action: 'subscribe', topic: topic_status }));
|
||||
// 清除重连定时器
|
||||
if (reconnectTimer) {
|
||||
clearTimeout(reconnectTimer);
|
||||
reconnectTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
let data;
|
||||
|
||||
try {
|
||||
data = JSON.parse(event.data);
|
||||
} catch (e) {
|
||||
showToast('解析消息失败: ' + e.message);
|
||||
return;
|
||||
}
|
||||
const topic = data.topic;
|
||||
const message = data.message;
|
||||
|
||||
if (topic && message) {
|
||||
if (topic.startsWith(topic_status)) {
|
||||
try {
|
||||
const value = typeof message === 'string' ? JSON.parse(message) : message;
|
||||
var iin = parseFloat(value.value.Iin);
|
||||
if (iin > 65) {
|
||||
iin = 0;
|
||||
}
|
||||
var vinState = parseFloat(value.value.Vin).toFixed(1) + 'V ' + parseFloat(iin).toFixed(2) + 'A';
|
||||
$('#vinState').text(vinState)
|
||||
$('#hvState').text(value.value.hv == 'on' ? '高压已打开' : '高压已关闭');
|
||||
$('#rayState').text(value.value.xray == 'on' ? '射线已打开' : '射线已关闭');
|
||||
$('#feedbackVoltage').text(parseFloat(value.value.kV).toFixed(2));
|
||||
$('#feedbackCurrent').text(parseFloat(value.value.mA).toFixed(2));
|
||||
$('#filamentVoltage').text(parseFloat(value.value.fV).toFixed(3));
|
||||
$('#filamentCurrent').text(parseFloat(value.value.fI).toFixed(3));
|
||||
} catch (e) {
|
||||
showToast('解析消息失败: ' + e.message);
|
||||
}
|
||||
} else if (topic.startsWith(topic_response)) {
|
||||
try {
|
||||
const value = typeof message === 'string' ? JSON.parse(message) : message;
|
||||
if (value.command == 'get_params') {
|
||||
$('#setVoltage').val(parseFloat(value.value.kV).toFixed(2));
|
||||
$('#setCurrent').val(parseFloat(value.value.mA).toFixed(2));
|
||||
$('#filaPreheatCurrent').val(parseFloat(value.value.filament.preheat / 1000).toFixed(2));
|
||||
$('#filaLimitCurrent').val(parseFloat(value.value.filament.limit / 1000).toFixed(2));
|
||||
showToast('参数已更新');
|
||||
} else if (value.command == 'get_var') {
|
||||
// 处理变量配置响应
|
||||
if (varEditor) {
|
||||
try {
|
||||
const varData = JSON.stringify(value.value, null, 2);
|
||||
varEditor.value = varData;
|
||||
showToast('变量配置已加载');
|
||||
} catch (e) {
|
||||
showToast('解析变量配置失败:' + e.message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showToast('请求已发送');
|
||||
}
|
||||
} catch (e) {
|
||||
showToast('解析消息失败: ' + e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = function() {
|
||||
showToast('WebSocket连接错误');
|
||||
};
|
||||
|
||||
ws.onclose = function() {
|
||||
showToast('WebSocket连接已关闭,正在尝试重连...');
|
||||
// 仅在没有活跃定时器时创建新的重连定时器
|
||||
if (!reconnectTimer) {
|
||||
reconnectTimer = setTimeout(connectWebSocket, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
// 初始连接
|
||||
connectWebSocket();
|
||||
|
||||
// 定期检查连接状态(每10秒)
|
||||
setInterval(function() {
|
||||
if (!ws || ws.readyState === WebSocket.CLOSED) {
|
||||
showToast('定期检查发现连接已关闭,尝试重连...');
|
||||
if (!reconnectTimer) {
|
||||
reconnectTimer = setTimeout(connectWebSocket, 5000);
|
||||
}
|
||||
}
|
||||
}, 10000);
|
||||
|
||||
// 替换 client.publish 为 ws.send
|
||||
function wsPublish(topic, msg) {
|
||||
ws.send(JSON.stringify({
|
||||
action: 'publish',
|
||||
topic: topic,
|
||||
message: msg
|
||||
}));
|
||||
}
|
||||
// Toast初始化
|
||||
const toastEl = document.getElementById('toast');
|
||||
const toast = new bootstrap.Toast(toastEl, {
|
||||
autohide: true,
|
||||
delay: 3000
|
||||
});
|
||||
function showToast(message) {
|
||||
$('.toast-body').text(message);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
$('#setParams').click(function() {
|
||||
const setVoltage = parseFloat($('#setVoltage').val());
|
||||
const setCurrent = parseFloat($('#setCurrent').val());
|
||||
const filaPreheatCurrent = parseFloat($('#filaPreheatCurrent').val()) * 1000;
|
||||
const filaLimitCurrent = parseFloat($('#filaLimitCurrent').val()) * 1000;
|
||||
var msg = {
|
||||
device_id: '2',
|
||||
device_code: '2#HVS',
|
||||
command: 'set_params',
|
||||
value: {
|
||||
kV: setVoltage,
|
||||
mA: setCurrent,
|
||||
filament : {
|
||||
preheat: filaPreheatCurrent,
|
||||
limit: filaLimitCurrent
|
||||
}
|
||||
}
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
$('#getParams').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '2#HVS',
|
||||
command: 'get_params'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
|
||||
$('#hvEnable').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'hv_control',
|
||||
value: 'on'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
|
||||
$('#hvDisable').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'hv_control',
|
||||
value: 'off'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
$('#rayEnable').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'ray_control',
|
||||
value: 'on'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
|
||||
$('#rayDisable').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'ray_control',
|
||||
value: 'off'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('请求已发送!');
|
||||
});
|
||||
|
||||
|
||||
$('#reboot').click(function() {
|
||||
$.ajax({
|
||||
url: '/api/device/reboot',
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showToast('请求已发送');
|
||||
} else {
|
||||
showToast('请求失败:' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('请求失败:服务器错误');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#hv_service_start').click(function() {
|
||||
$.ajax({
|
||||
url: '/api/hv_service/start',
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showToast('请求已发送');
|
||||
} else {
|
||||
showToast('请求失败:' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('请求失败:服务器错误');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#hv_service_stop').click(function() {
|
||||
$.ajax({
|
||||
url: '/api/hv_service/stop',
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showToast('请求已发送');
|
||||
} else {
|
||||
showToast('请求失败:' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('请求失败:服务器错误');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function() {
|
||||
ws.close();
|
||||
});
|
||||
|
||||
// ================== 脚本编辑器相关 ==================
|
||||
let scriptTabInited = false;
|
||||
let editor = null;
|
||||
|
||||
// ================== 变量设置相关 ==================
|
||||
let varTabInited = false;
|
||||
let varEditor = null;
|
||||
|
||||
$('button[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
console.log('tab shown', e);
|
||||
const target = $(e.target).attr('data-bs-target');
|
||||
if (target === '#script' && !scriptTabInited) {
|
||||
// 初始化CodeMirror
|
||||
editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
|
||||
mode: 'text/x-python',
|
||||
theme: 'monokai',
|
||||
lineNumbers: true,
|
||||
indentUnit: 4,
|
||||
lineWrapping: true,
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true
|
||||
});
|
||||
|
||||
editor.setValue("请选择一个文件");
|
||||
|
||||
// 初始化文件树
|
||||
$('#fileTree').jstree({
|
||||
'core': {
|
||||
'data': {
|
||||
'url': function(node) {
|
||||
const url = node.id === '#' ? '/api/script/list' : '/api/script/list?path=' + node.id;
|
||||
return url;
|
||||
},
|
||||
'data': function(node) {
|
||||
return { 'id': node.id };
|
||||
},
|
||||
'dataFilter': function(data) {
|
||||
var json = {};
|
||||
try {
|
||||
json = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return "[]";
|
||||
}
|
||||
if (json.success && Array.isArray(json.data)) {
|
||||
return JSON.stringify(json.data);
|
||||
}
|
||||
return "[]";
|
||||
},
|
||||
'error': function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('加载文件列表失败:' + textStatus);
|
||||
}
|
||||
},
|
||||
'themes': {
|
||||
'name': 'default',
|
||||
'responsive': true
|
||||
},
|
||||
'check_callback': true,
|
||||
'multiple': false
|
||||
},
|
||||
'types': {
|
||||
'default': {
|
||||
'icon': 'bi bi-file-text'
|
||||
},
|
||||
'folder': {
|
||||
'icon': 'bi bi-folder'
|
||||
},
|
||||
'python': {
|
||||
'icon': 'bi bi-filetype-py'
|
||||
},
|
||||
'json': {
|
||||
'icon': 'bi bi-filetype-json'
|
||||
},
|
||||
'shell': {
|
||||
'icon': 'bi bi-filetype-sh'
|
||||
}
|
||||
},
|
||||
'plugins': ['types']
|
||||
}).on('ready.jstree', function() {
|
||||
// 文件树初始化完成
|
||||
});
|
||||
|
||||
// 文件树节点点击事件
|
||||
$('#fileTree').on('select_node.jstree', function(e, data) {
|
||||
const node = data.node;
|
||||
if (node.original.type != 'folder') {
|
||||
loadFile(node.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 加载文件内容
|
||||
function loadFile(path) {
|
||||
$.get('/api/script/read?path=' + encodeURIComponent(path), function(response) {
|
||||
if (response.success) {
|
||||
// 使用js-base64库解码
|
||||
const content = Base64.decode(response.data);
|
||||
const ext = path.split('.').pop().toLowerCase();
|
||||
switch(ext) {
|
||||
case 'py':
|
||||
editor.setOption('mode', 'text/x-python');
|
||||
break;
|
||||
case 'json':
|
||||
editor.setOption('mode', 'application/json');
|
||||
break;
|
||||
case 'sh':
|
||||
editor.setOption('mode', 'text/x-sh');
|
||||
break;
|
||||
case 'html':
|
||||
editor.setOption('mode', 'text/html');
|
||||
break;
|
||||
case 'js':
|
||||
editor.setOption('mode', 'javascript');
|
||||
break;
|
||||
case 'css':
|
||||
editor.setOption('mode', 'css');
|
||||
break;
|
||||
default:
|
||||
editor.setOption('mode', 'text/plain');
|
||||
}
|
||||
editor.setValue(content);
|
||||
$('#currentFile').text(path);
|
||||
$('#saveFile, #deleteFile').prop('disabled', false);
|
||||
} else {
|
||||
showToast('加载文件失败:' + response.message);
|
||||
}
|
||||
}).fail(function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('加载文件失败:服务器错误');
|
||||
});
|
||||
}
|
||||
|
||||
// 保存文件
|
||||
$('#saveFile').click(function() {
|
||||
const path = $('#currentFile').text();
|
||||
// 使用js-base64库编码
|
||||
const content = Base64.encode(editor.getValue());
|
||||
$.ajax({
|
||||
url: '/api/script/write',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
path: path,
|
||||
content: content
|
||||
}),
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showToast('文件保存成功');
|
||||
} else {
|
||||
showToast('保存文件失败:' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('保存文件失败:服务器错误');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 删除文件
|
||||
$('#deleteFile').click(function() {
|
||||
if (confirm('确定要删除这个文件吗?')) {
|
||||
const path = $('#currentFile').text();
|
||||
$.ajax({
|
||||
url: '/api/script/delete',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
path: path
|
||||
}),
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showToast('文件删除成功');
|
||||
$('#currentFile').text('未选择文件');
|
||||
editor.setValue('');
|
||||
$('#saveFile, #deleteFile').prop('disabled', true);
|
||||
$('#fileTree').jstree('refresh');
|
||||
} else {
|
||||
showToast('删除文件失败:' + response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
showToast('删除文件失败:服务器错误');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 刷新文件树
|
||||
$('#refreshTree').click(function() {
|
||||
console.log('刷新文件树');
|
||||
$('#fileTree').jstree('refresh');
|
||||
});
|
||||
|
||||
scriptTabInited = true;
|
||||
}
|
||||
if (target === '#var' && !varTabInited) {
|
||||
// 初始化变量设置标签页
|
||||
varEditor = document.getElementById('varEditor');
|
||||
|
||||
// 设置初始提示文本
|
||||
varEditor.value = "点击'读取变量'按钮来加载当前变量配置...";
|
||||
|
||||
// 绑定读取变量按钮事件
|
||||
$('#getVar').click(function() {
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'get_var'
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('正在读取变量配置...');
|
||||
});
|
||||
|
||||
// 绑定保存变量按钮事件
|
||||
$('#setVar').click(function() {
|
||||
try {
|
||||
// 验证JSON格式
|
||||
const varContent = varEditor.value.trim();
|
||||
if (!varContent) {
|
||||
showToast('请输入变量配置内容');
|
||||
return;
|
||||
}
|
||||
|
||||
// 尝试解析JSON
|
||||
const varData = JSON.parse(varContent);
|
||||
|
||||
var msg = {
|
||||
device_id: '1',
|
||||
device_code: '1#HVS',
|
||||
command: 'set_var',
|
||||
value: varData
|
||||
}
|
||||
wsPublish(topic_control, msg);
|
||||
showToast('正在保存变量配置...');
|
||||
} catch (e) {
|
||||
showToast('JSON格式错误:' + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
varTabInited = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(s){"use strict";s.defineMode("shell",function(){var o={};function e(e,t){for(var n=0;n<t.length;n++)o[t[n]]=e}var t=["true","false"],n=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],r=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];function i(e,t){if(e.eatSpace())return null;var n,r=e.sol(),i=e.next();if("\\"===i)return e.next(),null;if("'"===i||'"'===i||"`"===i)return t.tokens.unshift(f(i,"`"===i?"quote":"string")),l(e,t);if("#"===i)return r&&e.eat("!")?(e.skipToEnd(),"meta"):(e.skipToEnd(),"comment");if("$"===i)return t.tokens.unshift(u),l(e,t);if("+"===i||"="===i)return"operator";if("-"===i)return e.eat("-"),e.eatWhile(/\w/),"attribute";if("<"==i){if(e.match("<<"))return"operator";r=e.match(/^<-?\s*['"]?([^'"]*)['"]?/);if(r)return t.tokens.unshift((n=r[1],function(e,t){return e.sol()&&e.string==n&&t.tokens.shift(),e.skipToEnd(),"string-2"})),"string-2"}if(/\d/.test(i)&&(e.eatWhile(/\d/),e.eol()||!/\w/.test(e.peek())))return"number";e.eatWhile(/[\w-]/);i=e.current();return"="===e.peek()&&/\w+/.test(i)?"def":o.hasOwnProperty(i)?o[i]:null}function f(i,o){var s="("==i?")":"{"==i?"}":i;return function(e,t){for(var n,r=!1;null!=(n=e.next());){if(n===s&&!r){t.tokens.shift();break}if("$"===n&&!r&&"'"!==i&&e.peek()!=s){r=!0,e.backUp(1),t.tokens.unshift(u);break}if(!r&&i!==s&&n===i)return t.tokens.unshift(f(i,o)),l(e,t);if(!r&&/['"]/.test(n)&&!/['"]/.test(i)){t.tokens.unshift(function(n,r){return function(e,t){return t.tokens[0]=f(n,r),e.next(),l(e,t)}}(n,"string")),e.backUp(1);break}r=!r&&"\\"===n}return o}}s.registerHelper("hintWords","shell",t.concat(n,r)),e("atom",t),e("keyword",n),e("builtin",r);var u=function(e,t){1<t.tokens.length&&e.eat("$");var n=e.next();return/['"({]/.test(n)?(t.tokens[0]=f(n,"("==n?"quote":"{"==n?"def":"string"),l(e,t)):(/\d/.test(n)||e.eatWhile(/\w/),t.tokens.shift(),"def")};function l(e,t){return(t.tokens[0]||i)(e,t)}return{startState:function(){return{tokens:[]}},token:l,closeBrackets:"()[]{}''\"\"``",lineComment:"#",fold:"brace"}}),s.defineMIME("text/x-sh","shell"),s.defineMIME("application/x-sh","shell")});
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,214 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>高压电源管理系统1</title>
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/jstree/3.3.12/themes/default/style.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/codemirror.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/theme/monokai.min.css" rel="stylesheet">
|
||||
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- 导航栏 -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/">高压电源管理系统</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Toast提示组件 -->
|
||||
<div class="position-fixed top-0 start-50 translate-middle-x p-3" style="z-index: 11">
|
||||
<div id="toast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">系统提示</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 选项卡 -->
|
||||
<ul class="nav nav-tabs mb-3" id="mainTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="panel-tab" data-bs-toggle="tab" data-bs-target="#panel"
|
||||
type="button" role="tab" aria-controls="panel" aria-selected="true">控制面板</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="script-tab" data-bs-toggle="tab" data-bs-target="#script" type="button"
|
||||
role="tab" aria-controls="script" aria-selected="false"><i class="bi bi-code-square"></i>
|
||||
脚本编辑器</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="mainTabContent">
|
||||
<!-- 控制面板 -->
|
||||
<div class="tab-pane fade show active" id="panel" role="tabpanel" aria-labelledby="panel-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">设备控制</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="reboot">重启设备</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_start">启动程序</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_stop">停止程序</button>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" id="hv_service_restart">重启程序</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-danger" id="hvEnable">开启高压</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-success" id="hvDisable">关闭高压</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-danger" id="rayEnable">开启射线</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-success" id="rayDisable">关闭射线</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">设定参数</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="setVoltage" class="form-label">设定电压 (kV)</label>
|
||||
<input type="number" class="form-control" id="setVoltage" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="setCurrent" class="form-label">设定电流 (mA)</label>
|
||||
<input type="number" class="form-control" id="setCurrent" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="filaPreheatCurrent" class="form-label">灯丝预热电流 (A)</label>
|
||||
<input type="number" class="form-control" id="filaPreheatCurrent" value="0">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="filaLimitCurrent" class="form-label">灯丝限制电流 (A)</label>
|
||||
<input type="number" class="form-control" id="filaLimitCurrent" value="0">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-primary" id="getParams">读取参数</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button class="btn btn-primary" id="setParams">设置参数</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">实时状态</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">电源状态</label>
|
||||
<div class="form-control" id="vinState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">高压状态</label>
|
||||
<div class="form-control" id="hvState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">射线状态</label>
|
||||
<div class="form-control" id="rayState">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">反馈电压 (kV)</label>
|
||||
<div class="form-control" id="feedbackVoltage">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">反馈电流 (mA)</label>
|
||||
<div class="form-control" id="feedbackCurrent">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">灯丝电压 (V)</label>
|
||||
<div class="form-control" id="filamentVoltage">--</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">灯丝电流 (A)</label>
|
||||
<div class="form-control" id="filamentCurrent">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 脚本编辑器 -->
|
||||
<div class="tab-pane fade" id="script" role="tabpanel" aria-labelledby="script-tab">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span>文件目录</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-primary" id="refreshTree">
|
||||
<i class="bi bi-arrow-clockwise"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="fileTree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<span id="currentFile">未选择文件</span>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-success" id="saveFile" disabled>
|
||||
<i class="bi bi-save"></i> 保存
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger" id="deleteFile" disabled>
|
||||
<i class="bi bi-trash"></i> 删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<textarea id="editor"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> -->
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/jstree/3.3.12/jstree.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/python/python.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/javascript/javascript.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/shell/shell.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/htmlmixed/htmlmixed.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/xml/xml.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/codemirror/5.65.2/mode/css/css.min.js"></script>
|
||||
<script src="js/base64.min.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,190 @@
|
||||
import os
|
||||
import json
|
||||
import binascii
|
||||
import sys
|
||||
sys.path.append('/script/MicroWebSrv')
|
||||
from microWebSrv import MicroWebSrv
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ========== 文件系统API ========== #
|
||||
SCRIPT_ROOT = '/'
|
||||
|
||||
@MicroWebSrv.route('/api/script/list')
|
||||
def api_script_list(httpClient, httpResponse):
|
||||
params = httpClient.GetRequestQueryParams()
|
||||
rel_path = params.get('id', '')
|
||||
if rel_path.startswith('#'):
|
||||
rel_path = rel_path[1:]
|
||||
print("Listing scripts in path: ", rel_path)
|
||||
abs_path = rel_path if rel_path else '/'
|
||||
if abs_path == '#':
|
||||
abs_path = '/'
|
||||
if not abs_path.startswith('/'):
|
||||
abs_path = '/' + abs_path
|
||||
print("abs path: ", abs_path)
|
||||
# 防止越权
|
||||
if not abs_path.startswith(SCRIPT_ROOT):
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "Invalid path"})
|
||||
return
|
||||
data = []
|
||||
try:
|
||||
for name in os.listdir(abs_path):
|
||||
# item_path = os.path.join(abs_path, name)
|
||||
if abs_path.endswith('/'):
|
||||
item_path = abs_path + name
|
||||
else:
|
||||
item_path = abs_path + '/' + name
|
||||
try:
|
||||
is_dir = os.stat(item_path)[0] & 0x4000 == 0x4000
|
||||
except:
|
||||
is_dir = False
|
||||
file_type = 'folder' if is_dir else 'file'
|
||||
if not is_dir:
|
||||
# ext = os.path.splitext(name)[1].lower()
|
||||
dotidx = name.rfind('.')
|
||||
ext = name[dotidx:].lower() if dotidx >= 0 else ''
|
||||
if ext == '.py': file_type = 'python'
|
||||
elif ext == '.json': file_type = 'json'
|
||||
elif ext == '.sh': file_type = 'shell'
|
||||
elif ext == '.js': file_type = 'js'
|
||||
elif ext == '.css': file_type = 'css'
|
||||
elif ext == '.html': file_type = 'html'
|
||||
# id_path = os.path.join(rel_path, name).replace('\\', '/')
|
||||
if rel_path.endswith('/') or rel_path == '':
|
||||
id_path = rel_path + name
|
||||
else:
|
||||
id_path = rel_path + '/' + name
|
||||
id_path = id_path.replace('\\', '/')
|
||||
data.append({
|
||||
"id": id_path,
|
||||
"text": name,
|
||||
"type": file_type,
|
||||
"children": is_dir,
|
||||
"state": {"opened": False, "disabled": False, "selected": False}
|
||||
})
|
||||
httpResponse.WriteResponseJSONOk({"success": True, "data": data})
|
||||
except Exception as e:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": str(e)})
|
||||
|
||||
@MicroWebSrv.route('/api/script/read')
|
||||
def api_script_read(httpClient, httpResponse):
|
||||
params = httpClient.GetRequestQueryParams()
|
||||
rel_path = params.get('path', '')
|
||||
# abs_path = os.path.abspath(os.path.join(SCRIPT_ROOT, rel_path.lstrip('/')))
|
||||
abs_path = '/' + rel_path
|
||||
if not abs_path.startswith(SCRIPT_ROOT):
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "Invalid path"})
|
||||
return
|
||||
# 判断文件是否存在
|
||||
try:
|
||||
st = os.stat(abs_path)
|
||||
is_file = not (st[0] & 0x4000 == 0x4000)
|
||||
except:
|
||||
is_file = False
|
||||
if not is_file:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "File not found"})
|
||||
return
|
||||
try:
|
||||
with open(abs_path, 'rb') as f:
|
||||
content = f.read()
|
||||
encoded = binascii.b2a_base64(content).decode('ascii').rstrip('\n')
|
||||
httpResponse.WriteResponseJSONOk({"success": True, "data": encoded})
|
||||
except Exception as e:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": str(e)})
|
||||
|
||||
@MicroWebSrv.route('/api/script/write', 'POST')
|
||||
def api_script_write(httpClient, httpResponse):
|
||||
try:
|
||||
data = httpClient.ReadRequestContentAsJSON()
|
||||
rel_path = data.get('path', '')
|
||||
content_b64 = data.get('content', '')
|
||||
abs_path = '/' + rel_path
|
||||
if not abs_path.startswith(SCRIPT_ROOT):
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "Invalid path"})
|
||||
return
|
||||
# 确保目录存在
|
||||
# dir_path = os.path.dirname(abs_path)
|
||||
slash_idx = abs_path.rfind('/')
|
||||
if slash_idx > 0:
|
||||
dir_path = abs_path[:slash_idx]
|
||||
try:
|
||||
os.mkdir(dir_path)
|
||||
except:
|
||||
pass
|
||||
# base64解码
|
||||
content = binascii.a2b_base64(content_b64)
|
||||
with open(abs_path, 'wb') as f:
|
||||
f.write(content)
|
||||
httpResponse.WriteResponseJSONOk({"success": True, "message": "File saved successfully"})
|
||||
except Exception as e:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": str(e)})
|
||||
|
||||
@MicroWebSrv.route('/api/script/delete', 'POST')
|
||||
def api_script_delete(httpClient, httpResponse):
|
||||
try:
|
||||
data = httpClient.ReadRequestContentAsJSON()
|
||||
rel_path = data.get('path', '')
|
||||
abs_path = '/' + rel_path
|
||||
if not abs_path.startswith(SCRIPT_ROOT):
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "Invalid path"})
|
||||
return
|
||||
# 判断文件是否存在
|
||||
try:
|
||||
st = os.stat(abs_path)
|
||||
is_file = not (st[0] & 0x4000 == 0x4000)
|
||||
except:
|
||||
is_file = False
|
||||
if is_file:
|
||||
os.remove(abs_path)
|
||||
httpResponse.WriteResponseJSONOk({"success": True, "message": "File deleted successfully"})
|
||||
else:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": "File not found"})
|
||||
except Exception as e:
|
||||
httpResponse.WriteResponseJSONOk({"success": False, "message": str(e)})
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
def _acceptWebSocketCallback(webSocket, httpClient) :
|
||||
print("WS ACCEPT")
|
||||
webSocket.RecvTextCallback = _recvTextCallback
|
||||
webSocket.RecvBinaryCallback = _recvBinaryCallback
|
||||
webSocket.ClosedCallback = _closedCallback
|
||||
|
||||
def _recvTextCallback(webSocket, msg) :
|
||||
print("WS RECV TEXT : %s" % msg)
|
||||
webSocket.SendText("Reply for %s" % msg)
|
||||
|
||||
def _recvBinaryCallback(webSocket, data) :
|
||||
print("WS RECV DATA : %s" % data)
|
||||
|
||||
def _closedCallback(webSocket) :
|
||||
print("WS CLOSED")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
#routeHandlers = [
|
||||
# ( "/test", "GET", _httpHandlerTestGet ),
|
||||
# ( "/test", "POST", _httpHandlerTestPost )
|
||||
#]
|
||||
|
||||
|
||||
def py_server():
|
||||
print('py server start')
|
||||
srv = MicroWebSrv(port=8002,webPath='./')
|
||||
srv.MaxWebSocketRecvLen = 256
|
||||
srv.WebSocketThreaded = True
|
||||
srv.AcceptWebSocketCallback = _acceptWebSocketCallback
|
||||
srv.Start()
|
||||
|
||||
import _thread
|
||||
import time
|
||||
|
||||
_thread.start_new_thread(py_server,())
|
||||
|
||||
print('main thread ')
|
||||
while True:
|
||||
print('hello')
|
||||
time.sleep_ms(1000)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user