Mingcedar

所属产品: Mingcedar Studio DESIGNER

页面与项目配置方法:优先从配置读取数据 | Mingcedar Studio

当前页的数据优先来自 Page Script 变量、函数、内部 JSON Tag 和默认 alarm.js。它们适合保存页面参数、表格数据、显示规则和报警范围。

首次发布 最近更新

<section id="config-methods" class="docs-block docs-block-intro docs-block-current"> <span class="section-kicker">配置</span> <h2>页面与项目配置方法:优先从配置读取数据</h2> <p>当前页的数据优先来自 Page Script 变量、函数、内部 JSON Tag 和默认 alarm.js。它们适合保存页面参数、表格数据、显示规则和报警范围。</p> <div class="docs-detail-list"> <article id="config-methods-item-1" class="docs-detail-row"> <strong>Page Script 变量和函数</strong> <p>当前页的表格行、筛选条件、显示开关、标题和阈值放在 Page Script。Table 的 Rows 可引用数组变量或函数,无需单独建立 JSON 文档。</p> <ul> <li>适合当前页独有配置</li><li>常用于表格数据和局部规则</li><li>Rows 可填变量名或函数名</li> </ul> <pre class="docs-code-block"><code>var tableRows = [

[&quot;Pump 1&quot;, &quot;Running&quot;],

[&quot;Pump 2&quot;, &quot;Stop&quot;]

];

var panelTitle = &quot;泵站运行概览&quot;;</code></pre> </article><article id="config-methods-item-2" class="docs-detail-row"> <strong>内部 JSON Tag</strong> <p>Python 或宿主脚本将报表、分页等结构化结果写入内部 JSON Tag,页面通过 ReadTagJson(...) 读取,沿用 Tag 通道。</p> <ul> <li>适合报表行、分页结果和结构化状态</li><li>由 Python 写内部 Tag</li><li>PPT 页面只负责 ReadTagJson 读取</li> </ul> <pre class="docs-code-block"><code>var rows = ReadTagJson(&quot;PLC_LINE01.REPORT01.ROWS&quot;, []);

var updatedAt = ReadTagDateTime(&quot;PLC_LINE01.REPORT01.UPDATED_AT&quot;, null);</code></pre> </article><article id="config-methods-item-3" class="docs-detail-row"> <strong>默认 alarm.js</strong> <p>每页默认有一个受保护的 alarm.js,用来维护当前页报警窗口开关和范围。编辑核心对象 `HQVISU_PAGE_ALARM` 即可。</p> <ul> <li>适合当前页报警窗口开关</li><li>适合当前页报警范围</li><li>每页独立,跟随页面导出</li> </ul> <pre class="docs-code-block"><code>HQVISU_PAGE_ALARM = {

showWindow: true,

tags: [],

deviceCodes: [],

objectIdentifiers: [],

groupCodes: [],

areaCodes: []

};</code></pre> </article><article id="config-methods-item-4" class="docs-detail-row"> <strong>getPageAlarm(fallbackValue)</strong> <p>读取当前页的 PPT 报警设置。它不是运行端报警规则本身,而是当前页面随导出包携带的报警窗口开关和报警范围配置。当前页没有 alarm 配置时,会返回传入的回退值或默认结构。</p> <ul> <li>适合读取当前页是否允许显示报警窗口</li><li>适合读取页面携带的报警范围</li><li>导出后来自 HQVISU_PAGE_ALARM</li><li>没有配置时要给回退值,避免空对象报错</li> </ul> <pre class="docs-code-block"><code>var alarmConfig = getPageAlarm({

showWindow: true,

tags: [],

deviceCodes: [],

objectIdentifiers: [],

groupCodes: [],

areaCodes: []

});

if (alarmConfig.showWindow) {

hqVisuDesigner.setComponentVisible(&quot;PageAlarmPanel&quot;, true);

}</code></pre> </article><article id="config-methods-item-5" class="docs-detail-row"> <strong>PPT 报警设置字段说明</strong> <p>showWindow 控制报警窗口;tags 为完整点名,deviceCodes 为设备或 PLC 编码,objectIdentifiers 为对象标识,groupCodes 为信号组,areaCodes 为区域范围。空数组表示该维度不附加条件,不表示自动选择全部点位。</p> <ul> <li>只指定几个点位时,优先填 tags</li><li>按设备限定范围时,填 deviceCodes</li><li>按对象或设备单元限定范围时,填 objectIdentifiers</li><li>按信号类别限定范围时,填 groupCodes</li><li>按区域或产线限定范围时,填 areaCodes</li> </ul> <pre class="docs-code-block"><code>{

&quot;showWindow&quot;: true,

&quot;tags&quot;: [],

&quot;deviceCodes&quot;: [],

&quot;objectIdentifiers&quot;: [],

&quot;groupCodes&quot;: [],

&quot;areaCodes&quot;: []

}</code></pre> </article><article id="config-methods-item-6" class="docs-detail-row"> <strong>GetCurrentUsername()</strong> <p>读取当前宿主用户。它适合做轻量级个性化显示,例如页面欢迎语、当前操作人展示和当前用户标记。它不是权限系统本身,权限判断应以宿主机规则为准。</p> <ul> <li>适合欢迎语和当前用户显示</li><li>适合轻量日志标记</li><li>权限校验仍然应以宿主机规则为准</li> </ul> <pre class="docs-code-block"><code>var username = GetCurrentUsername();

hqVisuDesigner.setComponentText(&quot;CurrentUser&quot;, username || &quot;Guest&quot;);</code></pre> </article> </div> <div class="docs-note-grid"> <figure id="config-methods-image-1" class="docs-note-card manual-doc-image-card"> <img src="/WEB_img/HQPPT/TextEditorForm.png" alt="页面脚本代码面板" loading="lazy" decoding="async"> <figcaption> <strong>页面脚本代码面板</strong> <p>页面配置读取、报警读取和局部逻辑通常会集中出现在这里。</p> </figcaption> </figure> </div> </section>