Mingcedar

Product: Mingcedar Studio DESIGNER

Shared behavior options and script scope | Mingcedar Studio

Understand data-quality indicators, the behavior-specific meaning of Condition, and visibility options. Available controls depend on the behavior editor.

Published Updated

<section id="post-ops" class="docs-block docs-block-intro docs-block-current"> <span class="section-kicker">Feature</span> <h2>Shared behavior options and script scope</h2> <p>Understand data-quality indicators, the behavior-specific meaning of Condition, and visibility options. Available controls depend on the behavior editor.</p> <div class="docs-detail-list"> <article id="post-ops-item-1" class="docs-detail-row"> <strong>Data quality and display state</strong> <p>Data quality indicates whether Tag data is valid; process states such as running, stopped and alarmed are separate. In Script Text, select Use quality outline colors under Quality Override and set Good and Bad colors. State Color provides Follow data quality (border / hide), with an option to hide on bad quality.</p> </article><article id="post-ops-item-2" class="docs-detail-row"> <strong>What Condition means</strong> <p>Condition has a different role in each behavior. Use the table and the corresponding editor to configure it.</p> </article><article id="post-ops-item-3" class="docs-detail-row"> <strong>Three visibility options</strong> <p></p> </article><article id="post-ops-item-4" class="docs-detail-row"> <strong>Expressions and verification</strong> <p>For example, enter the expression below in Script Text Condition to evaluate its text only when the specified Tag has good quality. Replace the example name with your project Tag and verify both good and bad quality. Configure the corresponding Quality Override when a persistent quality indication is required.</p> <ul> <li>Condition must return a Boolean immediately; do not use fetch, promises or timers.</li><li>Condition does not replace Mingcedar write permissions or equipment interlocks.</li><li>Move / Rotate / Scale currently have no separate Post Operations input.</li> </ul> <pre class="docs-code-block"><code>ReadTagQualityGood(&quot;PLC_LINE01.PUMP01.SPEED&quot;)</code></pre> </article><article id="post-ops-item-5" class="docs-detail-row"> <strong>Start with the five script locations</strong> <p>Code location determines scope, execution timing, and async/write permissions. Mingcedar Studio has no global script document spanning all pages.</p> <ul> <li>Page Script: belongs to the current page. Top-level var, let, const, class, and function declarations are available to animations and expressions on that page.</li><li>hqVisuDesignerPageReady(ctx): runs once after the page runtime is ready and suits component initialization; constants and helpers needed by the first animation evaluation still belong at Page Script top level.</li><li>Setup Script: prepares variables and intermediate results for one behavior only; it is not a page-global area.</li><li>Condition / Value / Display Text / Fill / Border / Visibility / Source value: synchronous expression slots that must immediately return one result.</li><li>Click / Hover / Press-Release Script: full event-driven script bodies. WriteTag is allowed only for a genuine Click, Press, or Release; Hover cannot write device data.</li> </ul> </article><article id="post-ops-item-6" class="docs-detail-row"> <strong>Recommended animation-script split</strong> <p>Keep shared Tag prefixes, ranges, and conversion functions in Page Script. Color and text behaviors that provide Setup Script can prepare local results there. Move, Rotate, and Scale have no Setup Script or Post Operations field. Put reads and conversions directly in Source value or Rotation input and reusable helpers in Page Script.</p> <pre class="docs-code-block"><code>// Current Page Script

const tankTagPrefix = &quot;PLC_LINE01.TANK01&quot;;

function percent(value, min, max) {

return Math.max(0, Math.min(100, (value - min) * 100 / (max - min)));

}

// Scale: Source value

percent(ReadTagDouble(tankTagPrefix + &quot;.LEVEL&quot;, 0), 0, 10)

// Source minimum / maximum: 0 / 100

// Limit minimum / maximum: 0 / 100

// At limit minimum / maximum: 0 / 1

// Moving edge: Top</code></pre> </article><article id="post-ops-item-7" class="docs-detail-row"> <strong>Synchronous, asynchronous, and write boundaries</strong> <p>Do not put fetch, Promise, setTimeout, or setInterval directly in an expression slot because animation evaluation needs an immediate result. Prepare asynchronous data in an async function in Page Script, hqVisuDesignerPageReady, Click Script, or Hover Script, then expose a page variable or host data source for the animation to read. await is valid only inside an async function; top-level await and import/export module syntax are unsupported. Device writes require a genuine user click, press, or release and remain subject to host permission, confirmation, reason, and audit controls.</p> </article><article id="post-ops-item-8" class="docs-detail-row"> <strong>Navigation parameters: supported content</strong> <p>In Open Link, select Internal page to enter values under Parameters (optional). For other Destinations, fill the fields for that target type. Scripted navigation passes parameters in the second hqVisuDesigner.openPage argument. Values may be strings, numbers, booleans, or null; the destination reads strings and reads null as an empty string.</p> <ul> <li>parameters must be an array whose entries have { key, value }.</li><li>The array preserves order and repeated keys. A plain object is not the formal openPage parameter shape.</li><li>frameTarget supports frame, fullscreen, and _blank; openInNewWindow: true is equivalent to _blank.</li><li>Use openPage within one package. Use openScreen(screenCode) across packages, but generic Jump Parameters are not guaranteed across a screen-package boundary.</li><li>Website / File URL parameters become URL query values and are read according to the destination system&#39;s query rules.</li> </ul> <pre class="docs-code-block"><code>hqVisuDesigner.openPage(&quot;device_details&quot;, {

frameTarget: &quot;frame&quot;,

parameters: [

{ key: &quot;PLC&quot;, value: &quot;PLC_LINE01&quot; },

{ key: &quot;Device&quot;, value: &quot;PUMP_01&quot; },

{ key: &quot;Mode&quot;, value: 1 },

{ key: &quot;Enabled&quot;, value: true }

]

});</code></pre> </article><article id="post-ops-item-9" class="docs-detail-row"> <strong>Destination reads and type conversion</strong> <p>Read parameters in the destination Page Script and validate before use. GetPageParameter returns the first matching value; GetPageParameterValues returns every value for a repeated key; GetPageParameters returns every { key, value } in original order. All three also have hqVisuDesigner namespace forms. Every read value is a string, so explicitly convert numbers and booleans and constrain allowed characters before building a Tag name.</p> <pre class="docs-code-block"><code>var plc = GetPageParameter(&quot;PLC&quot;, &quot;&quot;);

var device = GetPageParameter(&quot;Device&quot;, &quot;&quot;);

var modeText = GetPageParameter(&quot;Mode&quot;, &quot;0&quot;);

var enabledText = GetPageParameter(&quot;Enabled&quot;, &quot;false&quot;);

if (!/^[A-Za-z0-9_-]{1,64}$/.test(plc) ||

!/^[A-Za-z0-9_-]{1,64}$/.test(device)) {

throw new Error(&quot;Invalid page parameter&quot;);

}

var mode = Number.parseInt(modeText, 10);

var enabled = enabledText === &quot;true&quot;;

var statusTag = plc + &quot;.&quot; + device + &quot;.STATUS&quot;;</code></pre> </article><article id="post-ops-item-10" class="docs-detail-row"> <strong>Popup parameters and close results</strong> <p>The static Open Page as Popup input accepts a JSON object, not a top-level array. With Build page parameters with an expression enabled, the runtime accepts an object or an ordered array of { key, value } entries; use an array for repeated keys. The popup destination still reads values through GetPageParameter*. Close Current Popup&#39;s Result expression is a reverse result channel from the popup to its opener and may return a boolean, number, string, or object; it is separate from the query parameters used to open the popup.</p> </article><article id="post-ops-item-11" class="docs-detail-row"> <strong>Count, length, and security limits</strong> <p>The Runtime keeps at most 64 navigation parameters. A key is limited to 256 characters and a value to 2048 characters; invalid entries are ignored. Parameters enter the URL query and must not carry passwords, tokens, authorization proof, sensitive personal data, or large JSON payloads. Cookie, localStorage, and sessionStorage depend on origin, iframe, and host loading details and are not a formal cross-page parameter protocol. Page parameters cannot expand host-granted Tag, page, or user permissions.</p> </article><article id="post-ops-item-12" class="docs-detail-row"> <strong>Separate four value mechanisms and troubleshoot in order</strong> <p>Template variables, Runtime Variables, PLC Tags, and page parameters solve different problems. Template variables are substituted on an instance and before export; Runtime Variables link state on the current page; PLC Tags belong to the host data layer; page parameters carry context only when a destination is opened. If a read is empty, check whether the target type supports parameters, key spelling and case, whether parameters is an array, count/length limits, whether the host took over navigation, whether the destination URL contains the query, and whether a cross-package relative path was used by mistake.</p> </article> </div> </section>