Mingcedar

Product: Mingcedar CONTROL

Read and use data from another Site | Mingcedar

Prerequisites: B has a valid collected Tag and A has joined B. On A, select B’s IO, save PLC scope and reference the Tag. IO selection does not copy Devices, Tags or values.

Published Updated

<div class="manual-doc-article manual-doc-article-section"><h2 id="io-sharing">Operating tutorial: Read and use data from another Site</h2>

On A, select B’s IO and PLC scope, obtain a source reference and read it with Python, then configure alarms and trends.

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

<article class="doc-card">

<h3 id="remote-data-path">1. Prepare source and consumer</h3>

<p>Prerequisites: B has a valid collected Tag and A has joined B. On A, select B’s IO, save PLC scope and reference the Tag. IO selection does not copy Devices, Tags or values.</p>

<ul class="doc-related-links">

<li><a href="/en/hqserver/manual/distributed-deployment/">Two-server deployment</a></li>

<li><a href="/en/hqserver/manual/sites/#sites-capabilities">Select capability sources</a></li>

</ul>

</article>

<article class="doc-card">

<h3 id="io-sharing-item-1">2. Open B’s Device catalog</h3>

<ol>

<li>Add B’s node under Sites → Local Capabilities → IO and verify that it is selected and available.</li>

<li>Select Browse Devices beside the node, or select B directly in Sites and Devices.</li>

<li>In Devices, search by name, code or protocol. Search covers loaded Devices; use Load More Devices to read additional pages.</li>

<li>Check the source Site and Device enablement before editing the PLC usage scope.</li>

</ol>

<p class="doc-step-result"><strong>Expected result</strong> The source maintains this catalog; A creates no PLC connection. Saved scope survives an outage, and the catalog reloads after recovery.</p>

</article>

<article class="doc-card">

<h3 id="io-sharing-item-2">3. Preview and save the PLC usage scope</h3>

<ol>

<li>Check Use in the target Device’s Usage Scope column. Review Saved PLCs and Current Selection counts.</li>

<li>Review Selected Outside Loaded Pages. Those Devices remain selected even if the current page does not show them.</li>

<li>Select Preview PLC Scope Changes and review additions, removals and existing business dependencies.</li>

<li>Check the confirmation that you reviewed additions, removals and dependencies, then select Confirm and Save PLC Usage Scope.</li>

<li>Wait for the saved-and-effective result. Check that neither Scope Not Effective nor Catalog Update Required remains.</li>

</ol>

<p class="doc-step-result"><strong>Expected result</strong> After the save is effective, this Site can use source Tags within the scope. Checking Devices changes only the draft; preview does not submit the change.</p>

<div class="doc-step-troubleshooting"><p><strong>If the result differs</strong></p><ul>

<li>If removal would break existing references, preview lists dependencies and blocks saving. Update those references and preview again.</li>

<li>If source catalog or configuration versions change, refresh and preview again. A catalog update may be required even when the Device set is unchanged.</li>

<li>Changing the browsed Site prompts before discarding unsaved PLC selections. Switching workspace views retains the draft.</li>

</ul></div>

</article>

<article class="doc-card">

<h3 id="remote-tagref">4. Obtain a source reference from Site Tags</h3>

<p>A TagRef is a stable source reference: <code>hq://io/&lt;io-domain-uuid&gt;/&lt;device-uuid&gt;/&lt;tag-uuid&gt;</code>. Expand Source Reference in synchronized Site Tags and copy it. If you already have the target Tag’s complete reference, continue to the next step.</p>

<ol>

<li>Open Tag Management → Site Tags and confirm that Target Site and Target Database belong to A. Catalog access requires <code>admin:view</code>, Site view or management permission, and IO or Tag view permission. Synchronization also requires <code>io:manage</code>.</li>

<li>Choose B as Source Site and the admitted PLC as Source Device. Use Load More Devices when another page is available.</li>

<li>Select Preview Device Tag Synchronization. Review this batch’s new, updated, unchanged or conflicting definitions. This operates on pages of the Device catalog, rather than a single checked Tag.</li>

<li>Review the batch target and changes, check confirmation and select Confirm and Save Batch. Use Preview Next Batch and confirm each remaining batch.</li>

<li>Find the desired Tag by code or name in Synchronized Tags. Expand its Source Reference, then select and copy the complete <code>hq://io/...</code> text.</li>

</ol>

<p class="doc-step-result"><strong>Expected result</strong> Synchronization saves only local Tag definitions and source bindings. It creates no acquisition Devices, copies no live values, rules or history, and enables no writes. Copy references from the catalog, not Site names or IPs.</p>

<div class="doc-step-troubleshooting"><p><strong>If the result differs</strong></p><ul>

<li>A conflicting batch cannot be saved. Review source/local differences and preview again; earlier confirmed batches remain.</li>

<li>If the save outcome is unconfirmed, select Check This Batch. Confirm whether it was saved before continuing to the next batch.</li>

</ul></div>

<ul class="doc-related-links">

<li><a href="/en/hqserver/manual/master-data/">Device and Tag management</a></li>

</ul>

</article>

<article class="doc-card">

<h3 id="remote-python-read">5. Run read-only Python from a remote Tag event</h3>

<p>The built-in <code>hqcontrol</code> reads collected state without another package. Run Test supports local Tags only; use a Point Change event to include a remote TagRef in the action scope.</p>

<ol>

<li>On A, prepare the project and permissions using the Python tutorial. Create scripts/read_value.py in Configuration Center → script → Code and paste the example.</li>

<li>Replace the complete source reference inside the quotes in <code>tags.read(...)</code> with the URI copied above and save the source. Then set this script’s entrypoint and runtime limits in Settings → Python → Python Packages → Advanced Project Settings → Project Runtime Configuration and check the application state. The script must read the same Tag selected by the event below.</li>

<li>Open Run → New Event and choose Point Change. Under Choose a Trigger Tag, select B, the target Device and the same Tag. Set the required condition and minimum interval.</li>

<li>Add a Script Action, select the entrypoint under Script, check Action Enabled and save the action binding. Enable the event, select Save Event and check the save and application results.</li>

<li>Wait for a valid change meeting the condition. In Records, compare script Value and Quality with B. The first valid value after reconnection may only establish a baseline.</li>

<li>When continued reads are no longer needed, disable and save the event.</li>

</ol>

<div class="manual-code" data-code-language="python"><div class="manual-code-toolbar"><span>scripts/read_value.py · Complete read-only entry</span><span class="manual-code-tools"><small>Python</small><button type="button" data-copy-code data-copied="Copied" data-failed="Select and copy the code" aria-label="Copy code: scripts/read_value.py · Complete read-only entry">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"># scripts/read_value.py</span></span>

<span class="line"><span style="color:#D73A49">from</span><span style="color:#24292E"> hqcontrol </span><span style="color:#D73A49">import</span><span style="color:#24292E"> tags</span></span>

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

<span class="line"><span style="color:#D73A49">def</span><span style="color:#6F42C1"> main</span><span style="color:#24292E">(ctx):</span></span>

<span class="line"><span style="color:#24292E"> response </span><span style="color:#D73A49">=</span><span style="color:#24292E"> tags.read(</span><span style="color:#032F62">"hq://io/&#x3C;io-domain-id>/&#x3C;device-uid>/&#x3C;tag-uid>"</span><span style="color:#24292E">)</span></span>

<span class="line"><span style="color:#D73A49"> if</span><span style="color:#D73A49"> not</span><span style="color:#24292E"> response </span><span style="color:#D73A49">or</span><span style="color:#24292E"> response.get(</span><span style="color:#032F62">"ok"</span><span style="color:#24292E">) </span><span style="color:#D73A49">is</span><span style="color:#D73A49"> not</span><span style="color:#005CC5"> True</span><span style="color:#24292E">:</span></span>

<span class="line"><span style="color:#D73A49"> raise</span><span style="color:#005CC5"> RuntimeError</span><span style="color:#24292E">(</span><span style="color:#032F62">"Tag read failed"</span><span style="color:#24292E">)</span></span>

<span class="line"><span style="color:#24292E"> snapshot </span><span style="color:#D73A49">=</span><span style="color:#24292E"> response[</span><span style="color:#032F62">"value"</span><span style="color:#24292E">]</span></span>

<span class="line"><span style="color:#D73A49"> if</span><span style="color:#D73A49"> not</span><span style="color:#24292E"> tags.is_good_quality(snapshot):</span></span>

<span class="line"><span style="color:#D73A49"> raise</span><span style="color:#005CC5"> RuntimeError</span><span style="color:#24292E">(</span><span style="color:#032F62">"Tag quality is not good"</span><span style="color:#24292E">)</span></span>

<span class="line"><span style="color:#005CC5"> print</span><span style="color:#24292E">(</span><span style="color:#032F62">"Value:"</span><span style="color:#24292E">, snapshot.get(</span><span style="color:#032F62">"value"</span><span style="color:#24292E">), </span><span style="color:#032F62">"Quality:"</span><span style="color:#24292E">, snapshot.get(</span><span style="color:#032F62">"quality"</span><span style="color:#24292E">))</span></span>

<span class="line"><span style="color:#D73A49"> return</span><span style="color:#24292E"> {</span><span style="color:#032F62">"value"</span><span style="color:#24292E">: snapshot.get(</span><span style="color:#032F62">"value"</span><span style="color:#24292E">)}</span></span>

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

<span class="line"><span style="color:#D73A49">if</span><span style="color:#005CC5"> __name__</span><span style="color:#D73A49"> ==</span><span style="color:#032F62"> "__main__"</span><span style="color:#24292E">:</span></span>

<span class="line"><span style="color:#24292E"> main({})</span></span>

<span class="line"></span></code></pre></div>

<p class="doc-step-result"><strong>Expected result</strong> After triggering, the script reads the event-scoped remote value on A. If nothing fires, check enablement, conditions and source changes; for execution failures, check quality and permissions. The example does not write PLC values or archive trends.</p>

<ul class="doc-related-links">

<li><a href="/en/hqserver/manual/python-scripting/">Python projects, shared code and dependencies</a></li>

</ul>

</article>

<article class="doc-card">

<h3 id="io-sharing-item-3">6. Check quality and collection demand</h3>

<p>The default <code>reuse-only</code> reads collected source values without another PLC connection. On-demand Tags need valid source collection demand and the required scope and subscription permissions.</p>

<p class="doc-table-hint">Scroll horizontally to view the full table</p>

<div class="doc-table-scroll" role="region" aria-label="6. Check quality and collection demand" tabindex="0"><table class="doc-reference-table">

<thead><tr><th scope="col">Result</th><th scope="col">Where to check</th></tr></thead><tbody>

<tr><th scope="row">Current value with good quality</th><td>Compare value and time with the source Tag before connecting a consumer.</td></tr>

<tr><th scope="row">No value / not collected</th><td>Source Device and Tag enablement, collection mode and actual collection demand.</td></tr>

<tr><th scope="row">Invalid quality / source unavailable</th><td>Source Device, IO service and Site connection. Wait for valid new data after recovery.</td></tr>

<tr><th scope="row">Scope or permission denied</th><td>PLC usage scope, caller permissions and capability authorization.</td></tr>

<tr><th scope="row">Reference not found</th><td>Check whether the source Tag was removed or recreated, and obtain its current stable reference from the catalog.</td></tr>

</tbody></table></div>

<p class="doc-step-result"><strong>Expected result</strong> Reading a remote value does not establish alarm evaluation or trend recording on A. Configure those consumers separately.</p>

</article>

<article class="doc-card">

<h3 id="remote-results">7. Open B’s alarms, trends or screens</h3>

<ol>

<li>In A’s Sites → Local Capabilities, add B’s node for each required capability and verify that it is selected and available.</li>

<li>Select View Alarms, View Trends or Open Screens beside the node. The current Portal opens the selected source’s runtime content. B’s screens use B’s Tag bindings.</li>

<li>In History Trends, select Tags and start/end times to query records B still retains for that period. Remote alarms over ordinary LAN connections are read-only. Sign in directly to B with an authorized account to acknowledge, shelve or unshelve.</li>

<li>If no accessible menu exists for the capability, check runtime menus and user access on B. If the source is unavailable, restore its service or connection first.</li>

</ol>

<p class="doc-step-result"><strong>Expected result</strong> Alarm and Trend have separate entry points and do not require Screens to be selected. Results still belong to B; a failure does not substitute A’s same-named menu or data.</p>

</article>

<article class="doc-card">

<h3 id="remote-consumers">8. Use remote inputs on A</h3>

<p class="doc-table-hint">Scroll horizontally to view the full table</p>

<div class="doc-table-scroll" role="region" aria-label="8. Use remote inputs on A" tabindex="0"><table class="doc-reference-table">

<thead><tr><th scope="col">Use</th><th scope="col">Current entry point</th><th scope="col">Meaning after saving</th></tr></thead><tbody>

<tr><th scope="row">Read-only Python</th><td>Configuration Center → script → Code: call <code>tags.read</code> with the complete source reference, then bind an event for the same remote Tag as described above.</td><td>The script runs on A and reads collected state from B.</td></tr>

<tr><th scope="row">Point-change script trigger</th><td>Configuration Center → script → Run → New Event. Choose Point Change, then select B, a Device and one Tag under Choose a Trigger Tag.</td><td>After the event and actions are configured and enabled, only continuous, current, valid value changes participate in triggering.</td></tr>

<tr><th scope="row">A’s own alarms and trends</th><td>Tag Management → Site Tags → Synchronized Tags → Alarm / Trend Configuration. Also choose the Devices processed by the service in Local Capabilities.</td><td>A maintains its own rules and retention. B’s alarm rules, trend policies and history are not copied.</td></tr>

<tr><th scope="row">Custom page</th><td>Declare read scope and runtime context according to the page SDK tutorial.</td><td>The page uses its authorized interfaces, with the FullCode or reference format required by each interface.</td></tr>

<tr><th scope="row">External application</th><td>Configure IO State API credentials, Profiles and read scopes.</td><td>API access is authorized separately. Site membership does not automatically expand an API Key’s permissions.</td></tr>

</tbody></table></div>

<p class="doc-step-result"><strong>Expected result</strong> Save Device scopes, Tag definitions, alarms, trends and events separately, then check services, input quality and results. Synchronizing Tag definitions does not automatically bind Tags in runtime screens.</p>

<ul class="doc-related-links">

<li><a href="/en/hqserver/manual/sites/#sites-input-devices">Local Alarm and Trend Device scopes</a></li>

<li><a href="/en/hqserver/manual/python-scripting/">Python projects and events</a></li>

<li><a href="/en/hqserver/manual/custom-page-tutorial/">Page SDK</a></li>

<li><a href="/en/hqserver/manual/io-state-api/">IO State API</a></li>

</ul>

</article>

</div>

</div>