Mingcedar

Product: Mingcedar Studio DESIGNER

Expression and template field syntax | Mingcedar Studio

Identify whether a field expects a Tag name, a variable name, a number, or text. The leading = marks an expression in selected configuration fields. It is not general script syntax and does not grant Tag access.

Published Updated

<section id="animation-syntax" class="docs-block docs-block-intro docs-block-current"> <span class="section-kicker">Data binding</span> <h2>Expression and template field syntax</h2> <p>Identify whether a field expects a Tag name, a variable name, a number, or text. The leading = marks an expression in selected configuration fields. It is not general script syntax and does not grant Tag access.</p> <div class="docs-detail-list"> <article id="animation-syntax-item-1" class="docs-detail-row"> <strong>1. Distinguish Tag names, runtime variables, and template parameters</strong> <p>Mingcedar supplies Tag data. Runtime variables hold state on the current page. Template parameters replace placeholders when configuring an instance. A variable containing a Tag name is still a string; a read method retrieves its value. Examples use PLC_LINE01, PUMP01, and TANK01. Replace them with names configured in your project.</p> <ul> <li>Full Tag name: `PLC_LINE01.PUMP01.SPEED`.</li><li>Calculated Tag name: `Line01TotalFlow`, exactly as saved in the host.</li><li>Runtime variables: `selectedSpeedTag` holds a name; `speedValue` holds a number.</li><li>Template placeholders: `&lt;PLC&gt;` and `&lt;PUMP_CODE&gt;`, replaced with instance values.</li> </ul> <pre class="docs-code-block"><code>// Page Script: store the target name

var selectedSpeedTag = &quot;PLC_LINE01.PUMP01.SPEED&quot;;

// Behavior Setup Script: read the current value during evaluation

var speedValue = ReadTagDouble(selectedSpeedTag, 0);</code></pre> </article><article id="animation-syntax-item-2" class="docs-detail-row"> <strong>2. Target fields in Tag Text and write behaviors</strong> <p>Target tag in Tag Text and Target Tag in Write Tag or Write Tag Bit identify the read or write target. Enter a full fixed name directly, or a variable that holds the name. Use = for object properties or computed names to distinguish them from literal Tag paths. The control performs the read or write; do not call ReadTag or WriteTag inside the target field.</p> <ul> <li>Fixed target: `PLC_LINE01.PUMP01.SPEED`.</li><li>Name variable: `selectedSpeedTag`; define it first and ensure it returns a string.</li><li>Object property: `=bindingConfig.speedTag`.</li><li>Write Tag Bit takes the parent Tag name and a separate Bit Index from 0 to 31.</li> </ul> </article><article id="animation-syntax-item-3" class="docs-detail-row"> <strong>3. = expressions in Input and charts</strong> <p>The Input PLC Tag field, chart series Tag fields, Gauge Tag, and JSON Tag treat a fixed entry as a name. To obtain the name from a page variable, enter =selectedSpeedTag. The expression must return a Tag name string, not the current Tag value or a JSON object.</p> <ul> <li>Fixed Input target: `PLC_LINE01.PUMP01.SPEED_SETPOINT`.</li><li>Dynamic Input target: `=selectedSetpointTag`.</li><li>Dynamic chart target: `=selectedSpeedTag`.</li><li>JSON Tag: `PLC_LINE01.REPORT01.CHART_DATA`; use `=selectedJsonTag` for a dynamic name.</li> </ul> </article><article id="animation-syntax-item-4" class="docs-detail-row"> <strong>4. Variable-name fields and value fields</strong> <p>In Input Runtime Variable mode, enter the destination name, such as speedSetpointDraft. A dynamic name can use =selectedVariableName, which must return a valid variable-name string. The Variable field in Set Variable on Click identifies the assignment target; Value supplies the content to assign.</p> <ul> <li>Fixed variable name without quotes: `speedSetpointDraft`.</li><li>Dynamic Input variable: define `var selectedVariableName = &quot;speedSetpointDraft&quot;;` in Page Script and enter `=selectedVariableName` in the field.</li><li>Value and Condition are expression fields: enter `speedValue` or `speedValue &gt; 1200` directly.</li><li>In JavaScript, use `ReadTagDouble(selectedSpeedTag, 0)`. Do not pass `&quot;=selectedSpeedTag&quot;` as an API name argument.</li> </ul> </article><article id="animation-syntax-item-5" class="docs-detail-row"> <strong>5. Literal text and table data</strong> <p>Table Rows and Headers accept arrays, page array variables, or functions returning arrays. Use = to request evaluation explicitly. Quote a literal title when it could be confused with a variable. Table array data and the Tag name required by JSON Chart are different input types.</p> <ul> <li>Headers: `[&quot;Equipment&quot;, &quot;Status&quot;]`.</li><li>Rows: `[[&quot;PUMP01&quot;, &quot;Running&quot;], [&quot;PUMP02&quot;, &quot;Stopped&quot;]]`.</li><li>Dynamic rows: `pumpRows` or `=buildPumpRows()`, returning an array.</li><li>Literal title: `&quot;Pump station operating record&quot;`.</li> </ul> </article><article id="animation-syntax-item-6" class="docs-detail-row"> <strong>6. Combine template parameters and page variables</strong> <p>Set template parameter PLC to PLC_LINE01 and define the equipment code in Page Script. The template replaces &lt;PLC&gt; during authoring. At runtime, the page variable supplies the remaining name. Built-in template expressions use Page Script variables and cannot access another behavior&#39;s Setup Script locals. Enter each part below in the location identified by its comment. Lines beginning with = belong in configuration fields, not in a JavaScript script body.</p> <pre class="docs-code-block"><code>// Page Script

var selectedPumpCode = &quot;PUMP01&quot;;

// Input or chart Tag field

=&quot;&lt;PLC&gt;.&quot; + selectedPumpCode + &quot;.SPEED&quot;

// Script Text: Setup Script

var speedTagName = &quot;&lt;PLC&gt;.&quot; + selectedPumpCode + &quot;.SPEED&quot;;

var speedValue = ReadTagDouble(speedTagName, 0);

// Script Text: Text

speedValue.toFixed(0) + &quot; rpm&quot;</code></pre> </article><article id="animation-syntax-item-7" class="docs-detail-row"> <strong>7. Dynamic targets and page access</strong> <p>Variable-selected targets remain subject to export validation and Mingcedar read/write permissions. If export cannot determine a dynamic write target, use HQVISU_DECLARE_TAGS in Page Script to declare the finite candidate names associated with the expression. Those names must exist and be authorized in the host. Declarations do not bypass host permissions. Enter each part below in the location identified by its comment. Lines beginning with = belong in configuration fields, not in a JavaScript script body.</p> <pre class="docs-code-block"><code>var selectedSetpointTag = &quot;PLC_LINE01.PUMP01.SPEED_SETPOINT&quot;;

HQVISU_DECLARE_TAGS({

expression: &quot;selectedSetpointTag&quot;,

read: [&quot;PLC_LINE01.PUMP01.SPEED_SETPOINT&quot;, &quot;PLC_LINE01.PUMP02.SPEED_SETPOINT&quot;],

write: [&quot;PLC_LINE01.PUMP01.SPEED_SETPOINT&quot;, &quot;PLC_LINE01.PUMP02.SPEED_SETPOINT&quot;]

});

// Input PLC Tag field

=selectedSetpointTag</code></pre> </article><article id="animation-syntax-item-8" class="docs-detail-row"> <strong>8. Evaluation failures and target changes</strong> <p>An explicit expression that fails, returns a non-string, or retains an unresolved placeholder is not reinterpreted as another Tag name. Check variable scope, return type, template values, and name case.</p> <ul> <li>Changing an Input target or binding mode cancels the old unsubmitted draft. Enter a new value for the new target.</li><li>A write already sent is not recalled by a subsequent target change.</li><li>A live chart clears samples from the previous target when its dynamic target changes.</li><li>Runtime variables belong to the current page. Use page parameters to transfer context to another page.</li> </ul> </article> </div> </section>