Mingcedar

Product: Mingcedar Studio DESIGNER

Discrete Color | Mingcedar Studio

Divide a numeric value into up to eight threshold intervals, each with its own fill, border, and visibility settings. Use it for status codes or bit combinations with a limited set of values.

Published Updated

<div class="manual-doc-article manual-doc-article-section"><h2 id="discrete-color">Colors: Discrete Color</h2>

Divide a numeric value into up to eight threshold intervals, each with its own fill, border, and visibility settings. Use it for status codes or bit combinations with a limited set of values.

<div class="doc-card-list">

<article class="doc-card">

<h3 id="discrete-color-item-1">Overview</h3>

<p>Discrete Color uses seven increasing thresholds to divide State value into up to eight intervals. Each interval can set fill, border, and visibility. Use it for status codes, alarm levels, or bit combinations. To give specific values different appearances, set thresholds that separate those values.</p>

</article>

<article class="doc-card">

<h3 id="discrete-color-item-2">Field configuration</h3>

<p>Open the Discrete Color editor. Prepare data in Setup script and return a number from State value. In State actions, enter seven increasing thresholds in Value &lt; to create eight state intervals.</p>

<ul>

<li>Setup script (Setup Script): read a numeric Tag and prepare the state value.</li>

<li>State value: return a number such as stateValue. Use State Color for booleans, or convert explicitly to 0 / 1.</li>

<li>State actions / Value &lt;: default thresholds are 0, 1, 2, 4, 8, 16, 32. Comparisons use strictly less than; the last state is Final (+∞).</li>

<li>Fill: a fill color per state (8 states); can be toggled on/off as a whole.</li>

<li>Border: a border color per state (8 states); can be toggled on/off as a whole.</li>

<li>Visibility: show or hide per state (8 states); can be toggled on/off as a whole.</li>

<li>Quality override: Follow data quality (border / hide) controls quality borders and hiding on bad quality. An enabled state border takes precedence over Good.</li>

</ul>

<div class="manual-code" data-code-language="javascript"><div class="manual-code-toolbar"><span>JavaScript</span><span class="manual-code-tools"><small>JavaScript</small><button type="button" data-copy-code data-copied="Copied" data-failed="Select and copy the code" aria-label="Copy code: JavaScript">Copy code</button><span class="manual-code-status" role="status"></span></span></div><pre tabindex="0" class="docs-code-block shiki github-light" style="background-color:#fff;color:#24292e" tabindex="0"><code><span class="line"><span style="color:#6A737D">// Setup script</span></span>

<span class="line"><span style="color:#D73A49">var</span><span style="color:#24292E"> stateValue </span><span style="color:#D73A49">=</span><span style="color:#6F42C1"> ReadTagInteger</span><span style="color:#24292E">(</span><span style="color:#032F62">"PLC_LINE01.PUMP01.MODE"</span><span style="color:#24292E">, </span><span style="color:#005CC5">0</span><span style="color:#24292E">);</span></span>

<span class="line"></span>

<span class="line"><span style="color:#6A737D">// State value</span></span>

<span class="line"><span style="color:#24292E">stateValue</span></span></code></pre></div>

</article>

<article class="doc-card">

<h3 id="discrete-color-item-3">When to use it</h3>

<p>Use it when a finite set of numeric values needs different appearances based on thresholds.</p>

<ul>

<li>Device status codes: set thresholds so 0 (stopped), 1 (running), 2 (fault), and 4 (maintenance) fall into the intended color intervals.</li>

<li>Alarm level or bit combination: map an integer state into a few fixed buckets, each with its own fill/border/visibility.</li>

</ul>

</article>

<article class="doc-card">

<h3 id="discrete-color-item-4">Pitfalls</h3>

<p>Check these limits:</p>

<ul>

<li>State value must return a number; use State Color for a boolean condition.</li>

<li>8 states maximum. It can&#39;t express more than 8 states.</li>

<li>Discrete Color uses threshold intervals, not equality matching. With default thresholds, both 2 and 3 enter [2, 4). Adjust thresholds or use exact equality conditions in Multi-State Color when they must differ.</li>

<li>The seven Value &lt; thresholds must increase. By default, 0 enters [0, 1) and values at or above 32 enter the final state. There is no automatic unknown-enum branch.</li>

<li>Quality Border reflects communication quality, not the process value itself; when quality is bad the shape should not keep rendering as if the value were valid.</li>

</ul>

</article>

</div>

<div class="docs-note-grid manual-doc-image-grid">

<figure class="docs-note-card manual-doc-image-card" id="discrete-color-image-1">

<img src="/WEB_img/HQPPT/current/color/discrete.png" alt="Discrete Color behavior editor" loading="lazy" decoding="async" />

<figcaption>

<strong>Figure 1: Discrete Color editor</strong>

<p>Snap one numeric value into up to 8 fixed states by limits, each with its own fill, border, and visibility.</p>

</figcaption>

</figure>

</div>

</div>