OPC connections and References Tag

In my project, I have two OPC connections from one pair of TwinCAT controllers (e.g. 1A and 1B). And I have approximately 250K OPC tags in one tag provider. In terms of redundancy, if i want to switch all the tags from one OPC connection to the other by changing OPC Server name using Reference tag naming 1A and 1B. Is it possible and having any impact on performance of Ignition.

Did you ever come up with a solution? I have a similar application with redundant servers. We switch based on PLC code which PLC is active, meaning we can be on secondary PLC even with the primary PLC up and running (which the native OPC server in ignition would be alive and healthy).

Right now I am reading the status tag from primary PLC and if it reports as Not Active, I have a gateway script that reads the tag status and writes the new OPC directly to the tags (as a Parameter that is typically hard coded). Still in testing phase but it does work. The script reads the tags from a hard coded directory and loops through every instance writing the secondary PLC OPC.

It does work but we haven’t deployed this on a large project yet, such as yours with 250k tags. It seems like the best solution based on the fact the OPC setting in the tags can ONLY accept the OPC as a paramaeter. If it could reference a tag instead (as a string) we could simply switch a single tag to the appropriate OPC path, but unless tag structure changes I’ve found this as the only solution.

Here is a clean example of what I have

============================================================================

# IGNITION GATEWAY TAG CHANGE SCRIPT

# Purpose: Switch OPC server for tags when redundant PLC active state changes

#

# Setup:

# 1. Create this script in Gateway Events > Tag Change Scripts

# 2. Add trigger tag: [YourProvider]Path/To/PrimaryPLC/stsIAmActive

# 3. Modify OPC server names and UDT paths below

#

# How it works:

# - Monitors the primary PLC's "I am active" status tag

# - When it changes, updates the OPCServer parameter on UDT instances

# - All child tags using {OPCServer} automatically inherit the new value

# ============================================================================

# === CONFIGURATION - Edit these for your system ===

PRIMARY_OPC = "PrimaryPLC_OPC_Server" # OPC connection name for primary PLC

BACKUP_OPC = "BackupPLC_OPC_Server" # OPC connection name for backup PLC

# List of UDT instances to switch: (parentFolderPath, udtInstanceName)

UDT_INSTANCES = [

("\[default\]Equipment/Zone1", "Motor1"),

("\[default\]Equipment/Zone1", "Motor2"),

("\[default\]Equipment/Zone2", "Conveyor1"),

\# Add more UDT instances as needed...

]

# === SCRIPT LOGIC ===

logger = system.util.getLogger("OPCRedundancySwitch")




if currentValue.quality.isGood() and previousValue.quality.isGood():

    if currentValue.value != previousValue.value:

        # Determine which OPC server to use

        if currentValue.value:

            targetOPC = PRIMARY_OPC

            activePLC = "Primary"

        else:

            targetOPC = BACKUP_OPC

            activePLC = "Backup"

        

        logger.info("Switching to %s PLC (OPC: %s)" % (activePLC, targetOPC))

        

        # Reconfigure each UDT instance's OPCServer parameter

        for basePath, tagName in UDT_INSTANCES:

            try:

                system.tag.configure(

                    basePath,

                    [{"name": tagName, "parameters": {"OPCServer": targetOPC}}],

                    "m"  # merge mode

                )

            except Exception as e:

                logger.error("Failed to reconfigure %s/%s: %s" % (basePath, tagName, str(e)))

        

        logger.info("OPC switch complete - %d UDT instances reconfigured" % len(UDT_INSTANCES))