From 4f07275a25a5dbb67fe12636a28a6db4f98e323a Mon Sep 17 00:00:00 2001 From: ypc <15051963820@163.com> Date: Wed, 15 Jul 2026 18:07:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20MX=E8=AE=BE=E7=BD=AE=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20+=20=E4=BF=A1=E5=8F=B7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=8A=A0=E5=AE=BD=20+=20Canvas=E5=AD=97=E5=8F=B7=E5=A2=9E?= =?UTF-8?q?=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - plc_debug.js: 修复_setMxIn中WsClient.send返回值检查(始终返回undefined) - plc_config.js: 信号面板230→290px, 运算符面板150→160px - plc_config.js: drawGraphContent字号全面增大2-3px, 节点尺寸+10px - plc.cpp: MX遥测输出信号F32注册(plc.mx.out.0~19) --- config/web/js/pages/plc_config.js | 6 +++--- config/web/js/pages/plc_debug.js | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config/web/js/pages/plc_config.js b/config/web/js/pages/plc_config.js index da61f04..f771e75 100644 --- a/config/web/js/pages/plc_config.js +++ b/config/web/js/pages/plc_config.js @@ -130,7 +130,7 @@ var PlcConfigPage = (function() { * 信号面板 * ================================================================ */ function renderSigPanel() { - return '
' + return '
' + '
📋 信号 ('+dcOutSignals.length+')' + '
' + '' @@ -140,7 +140,7 @@ var PlcConfigPage = (function() { function renderOpPanel() { var ops=[{t:NT_AND,n:'与门',i:'🔷',c:'#9C27B0'},{t:NT_OR,n:'或门',i:'🔶',c:'#FF9800'},{t:NT_NOT,n:'非门',i:'🔺',c:'#f44336'},{t:NT_62P,n:'62P',i:'⏱️',c:'#00BCD4'},{t:NT_62D,n:'62D',i:'⏱️',c:'#009688'},{t:NT_RISING,n:'上升沿',i:'⬆️',c:'#E91E63'},{t:NT_FALLING,n:'下降沿',i:'⬇️',c:'#FF5722'},{t:NT_TOGGLE,n:'翻转',i:'🔄',c:'#CDDC39'},{t:NT_SR,n:'SR',i:'🔒',c:'#795548'},{t:NT_RS,n:'RS',i:'🔒',c:'#607D8B'},{t:NT_MX_ADD,n:'加法',i:'➕',c:'#E040FB'},{t:NT_MX_SUB,n:'减法',i:'➖',c:'#00E5FF'},{t:NT_MX_MAX,n:'最大值',i:'⬆️',c:'#FFD600'},{t:NT_MX_MIN,n:'最小值',i:'⬇️',c:'#76FF03'},{t:NT_MX_MUL,n:'乘法',i:'✖️',c:'#FF6D00'},{t:NT_MX_DIV,n:'除法',i:'➗',c:'#D50000'},{t:NT_MX_ABS,n:'绝对值',i:'📏',c:'#00C853'},{t:NT_MX_CMP,n:'比较',i:'⚖️',c:'#FF1744'}]; - var h='
🧮 运算符
'; + var h='
🧮 运算符
'; for(var oi=0;oi'+op.i+''+op.n+'
';} h+='
'; return h; @@ -320,7 +320,7 @@ function showGateCfgModal(idx){var nd=editNodes[idx],cur=getNodeInPins(nd),info= /* ================================================================ * 共用 Canvas 绘制 * ================================================================ */ - function drawGraphContent(ctx,nodes,links,selectedIdx,selectedLinkIdx,wiring){var IW=250,IH=80,GW=170,GH=66,CR=12,SO=3,LBW=8;for(var i=0;i=nodes.length||l.dstIdx>=nodes.length)continue;var sn=nodes[l.srcIdx],dn=nodes[l.dstIdx];var sIO=(sn.type===NT_OUTPUT||sn.type===NT_INPUT),dIO=(dn.type===NT_OUTPUT||dn.type===NT_INPUT);var dSR=(dn.type===NT_SR||dn.type===NT_RS);var sW=sIO?IW:GW,dW=dIO?IW:GW,dH=dIO?IH:(dSR?86:GH);var x1=sn._lx+sW/2,y1=sn._ly;var dIP=getNodeInPins(dn),epi=(l.dstPin!==undefined)?l.dstPin:0;var y2=dn._ly-dH/2+dH*(epi+1)/(dSR?3:(dIP+1)),x2=dn._lx-dW/2;var isAct=wiring&&wiring.fromIdx===l.srcIdx,isSel=(selectedLinkIdx===i);var mid=(x1+x2)/2,la=isAct||isSel?1:0.6,lw=isAct||isSel?3:2;var lc=isSel?'#FF5722':(isAct?'#FFC107':'rgba(180,200,220,'+la+')');ctx.beginPath();ctx.strokeStyle=isSel?'rgba(255,87,34,0.3)':'rgba(255,200,0,'+(la*0.2)+')';ctx.lineWidth=lw+4;ctx.moveTo(x1,y1);ctx.bezierCurveTo(mid,y1,mid,y2,x2,y2);ctx.stroke();ctx.beginPath();ctx.strokeStyle=lc;ctx.lineWidth=lw;ctx.moveTo(x1,y1);ctx.bezierCurveTo(mid,y1,mid,y2,x2,y2);ctx.stroke();ctx.fillStyle=lc;ctx.beginPath();ctx.moveTo(x2,y2);ctx.lineTo(x2-7,y2-3.5);ctx.lineTo(x2-7,y2+3.5);ctx.closePath();ctx.fill();if(isSel){var lx2=(x1+x2)/2,ly2=(y1+y2)/2-18;ctx.fillStyle='#FF5722';ctx.font='bold 14px sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('✕ 右键删除',lx2,ly2);}}if(wiring&&wiring.fromIdx18?dt2.substring(0,16)+'…':dt2,x,y+14);}}else{var gi=n.id&0xFF,ri=0,ro=0;for(var li=0;li0){var isSR=(n.type===NT_SR||n.type===NT_RS),rp=isSR?2:(isIO?inP:inP);for(var p=0;p=50&&n.type<=57);if(isMX){ctx.fillStyle='#fff';ctx.font='bold 10px monospace';ctx.textAlign='right';ctx.textBaseline='middle';ctx.fillText(p===0?'A':'B',x-hw-12,py);}}}if(info.outPins>0){ctx.fillStyle='#2e2e4a';ctx.beginPath();ctx.arc(x+hw,y,7,0,Math.PI*2);ctx.fill();ctx.strokeStyle='#FF9800';ctx.lineWidth=2;ctx.stroke();ctx.fillStyle='#FF9800';ctx.beginPath();ctx.arc(x+hw,y,3.5,0,Math.PI*2);ctx.fill();}}} + function drawGraphContent(ctx,nodes,links,selectedIdx,selectedLinkIdx,wiring){var IW=260,IH=90,GW=180,GH=72,CR=12,SO=3,LBW=8;for(var i=0;i=nodes.length||l.dstIdx>=nodes.length)continue;var sn=nodes[l.srcIdx],dn=nodes[l.dstIdx];var sIO=(sn.type===NT_OUTPUT||sn.type===NT_INPUT),dIO=(dn.type===NT_OUTPUT||dn.type===NT_INPUT);var dSR=(dn.type===NT_SR||dn.type===NT_RS);var sW=sIO?IW:GW,dW=dIO?IW:GW,dH=dIO?IH:(dSR?86:GH);var x1=sn._lx+sW/2,y1=sn._ly;var dIP=getNodeInPins(dn),epi=(l.dstPin!==undefined)?l.dstPin:0;var y2=dn._ly-dH/2+dH*(epi+1)/(dSR?3:(dIP+1)),x2=dn._lx-dW/2;var isAct=wiring&&wiring.fromIdx===l.srcIdx,isSel=(selectedLinkIdx===i);var mid=(x1+x2)/2,la=isAct||isSel?1:0.6,lw=isAct||isSel?3:2;var lc=isSel?'#FF5722':(isAct?'#FFC107':'rgba(180,200,220,'+la+')');ctx.beginPath();ctx.strokeStyle=isSel?'rgba(255,87,34,0.3)':'rgba(255,200,0,'+(la*0.2)+')';ctx.lineWidth=lw+4;ctx.moveTo(x1,y1);ctx.bezierCurveTo(mid,y1,mid,y2,x2,y2);ctx.stroke();ctx.beginPath();ctx.strokeStyle=lc;ctx.lineWidth=lw;ctx.moveTo(x1,y1);ctx.bezierCurveTo(mid,y1,mid,y2,x2,y2);ctx.stroke();ctx.fillStyle=lc;ctx.beginPath();ctx.moveTo(x2,y2);ctx.lineTo(x2-7,y2-3.5);ctx.lineTo(x2-7,y2+3.5);ctx.closePath();ctx.fill();if(isSel){var lx2=(x1+x2)/2,ly2=(y1+y2)/2-18;ctx.fillStyle='#FF5722';ctx.font='bold 14px sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText('✕ 右键删除',lx2,ly2);}}if(wiring&&wiring.fromIdx18?dt2.substring(0,16)+'…':dt2,x,y+14);}}else{var gi=n.id&0xFF,ri=0,ro=0;for(var li=0;li0){var isSR=(n.type===NT_SR||n.type===NT_RS),rp=isSR?2:(isIO?inP:inP);for(var p=0;p=50&&n.type<=57);if(isMX){ctx.fillStyle='#fff';ctx.font='bold 12px monospace';ctx.textAlign='right';ctx.textBaseline='middle';ctx.fillText(p===0?'A':'B',x-hw-12,py);}}}if(info.outPins>0){ctx.fillStyle='#2e2e4a';ctx.beginPath();ctx.arc(x+hw,y,7,0,Math.PI*2);ctx.fill();ctx.strokeStyle='#FF9800';ctx.lineWidth=2;ctx.stroke();ctx.fillStyle='#FF9800';ctx.beginPath();ctx.arc(x+hw,y,3.5,0,Math.PI*2);ctx.fill();}}} /* ================================================================ * XML 解析 (与原工程完全一致) diff --git a/config/web/js/pages/plc_debug.js b/config/web/js/pages/plc_debug.js index f79ea7c..e3ec620 100644 --- a/config/web/js/pages/plc_debug.js +++ b/config/web/js/pages/plc_debug.js @@ -276,8 +276,7 @@ var PlcDebugPage = (function() { if (!inp) { toast('找不到输入框', 'error'); return; } var nv = inp.value.trim(); if (nv === '') { toast('请输入值', 'error'); return; } - var sent = WsClient.send({ curd: 'set', signal_type: 'out', saddr: m.saddr, signal_data: nv, setting_zone: '0' }); - if (!sent) { toast('发送失败', 'error'); return; } + WsClient.send({ curd: 'set', signal_type: 'out', saddr: m.saddr, signal_data: nv, setting_zone: '0' }); m.val = parseFloat(nv) || 0; m.inputVal = ''; var outs = SignalStore.get('out');