Finding and Updating a Trigger

When a trigger already exists in your project, you can locate it and change its configuration from PowerShell using the IcoTrgPowershell module—without searching for it in the Workbench tree. This is a common maintenance routine: read the current configuration, change one or more settings, and confirm the result. This topic uses a data trigger as the example, but the same read-modify-verify pattern applies to every trigger type and, indeed, to every provider.

Before you begin, review the entity and key model so the way commands identify items is familiar.

The example finds a data trigger and changes the condition that causes it to fire. Substitute the trigger name and the settings that apply to your project.

To find a trigger and update its configuration:

  1. List the data triggers in the project to find the one you want:

    Get-TrgDataItems | Select-Object Name, Key

    Get-TrgDataItems (plural) returns every data trigger. The other trigger types have matching commands, such as Get-TrgTimeItems and Get-TrgAlarmItems.

  2. Narrow the list with a filter when there are many triggers:

    Get-TrgDataItems | Where-Object { $_.Name -like 'Line A*' }
  3. Read the specific trigger and inspect the settings you intend to change:

    Get-TrgDataItem 'HighTemperatureTrigger' | Select-Object Name, ExecuteCondition, Severity, UseDelay, Delay

    Get-TrgDataItem (singular) returns the one trigger you name. Reading it first confirms you have the right item and shows the current values before you change anything.

  4. Update the trigger with the new settings:

    Set-TrgDataItem 'HighTemperatureTrigger' -ExecuteCondition IsTrue -UseDelay $true -Delay 5000 -Severity 500
    • -ExecuteCondition—when the trigger fires. Accepted values are AnyChange, ChangeToTrue, ChangeToFalse, IsTrue, IsFalse, and AnyValueChange.
    • -UseDelay / -Delay—enable a firing delay and set its length in milliseconds. -Delay has no effect unless -UseDelay is $true.
    • -Severity—the severity assigned to the trigger.

    Set commands change only the parameters you supply; any setting you do not name keeps its current value. To rename the trigger, use -NewName.

  5. Confirm the change took effect by reading the trigger again:

    Get-TrgDataItem 'HighTemperatureTrigger' | Select-Object Name, ExecuteCondition, Severity, UseDelay, Delay

    The values should now reflect your update. The change is committed to the configuration immediately; see How Configuration Changes Synchronize for how the running system applies it.