# How do tags work in Tatsoft scripting?

**URL:** <https://forum.tatsoft.com/t/how-do-tags-work-in-tatsoft-scripting/542>\
**Category:** Devices Communication\
**Created:** [December 12, 2024, 8:00pm UTC](https://forum.tatsoft.com/t/how-do-tags-work-in-tatsoft-scripting/542 "2024-12-12T20:00:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyM](https://forum.tatsoft.com/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@JeremyM](https://forum.tatsoft.com/u/JeremyM)\
**Post date:** [December 12, 2024, 8:00pm UTC](https://forum.tatsoft.com/t/how-do-tags-work-in-tatsoft-scripting/542/1 "2024-12-12T20:00:35Z")

</div>

Hi,

I’m observing high comms usage on our 5580 processors (33.12) used by Tatsoft (9.2.29) and am studying how the provided OEM C# scripting behaves to determine whether and how it should be changed.

(1) Read example is MES\_TransferPct\_SP (double) with access type:

- ReadOnStartup: No
- ReadEnable: Always
- ReadPollingRate: 00:00:03.500
- ReadTrigger: None
- WriteEventEnabled: Yes
- WriteEvent: Changed
- WriteTrigger: None
- AcceptUnsolicited: Yes
- UseStaticBlocks: No
- BlockCommand: None

Snippet:  
`PctDeadband = (float)(@Tag.MES_TransferPct_SP / 100.0);`

**Does Tatsoft treat this as a blocking line of code that reads the PLC on-demand or is the expression just the most recent value of the tag provided at the ReadPollingRate?**

* * *

(2) Write example is MES\_RequestedIngredient (IngredientInfo) with the same access type above.

Tatsoft type:

- LicensePlate: Text
- Max: Double
- Min: Double
- SP: Double
- Lot: Text
- Desc: Text
- ID: Text

Logix UDT (364 bytes):

- LicensePlate: STRING
- ID: STRING
- Desc: STRING
- Lot: STRING
- Max: REAL
- Min: REAL
- SP: REAL

Snippet:  
`@Tag.MES_RequestedIngredient.LicensePlate = "-1"; @Tag.MES_RequestedIngredient.Desc = "-1"; @Tag.MES_RequestedIngredient.ID = "-1"; @Tag.MES_RequestedIngredient.Lot = "-1"; `

**Does Tatsoft write to the PLC with each statement (4x writes) in this body of code?**

Thanks!

---

<div class="post-metadata">

**Author:** ![Gabriel\_support](https://forum.tatsoft.com/letter_avatar_proxy/v4/letter/g/ccd318/32.png) [@Gabriel\_support](https://forum.tatsoft.com/u/Gabriel_support)\
**Post date:** [December 13, 2024, 8:08pm UTC](https://forum.tatsoft.com/t/how-do-tags-work-in-tatsoft-scripting/542/2 "2024-12-13T20:08:28Z")

</div>

Hi Jeremy,

**Does Tatsoft treat this as a blocking line of code that reads the PLC on-demand or is the expression just the most recent value of the tag provided at the ReadPollingRate?**

FactoryStudio supports both methods for handling tag values from a PLC: **polling** and **exception-based updates**.

1. **Polling:**

- The system reads the tag value from the PLC at regular intervals defined by the `ReadPollingRate`.
- For example, if the `ReadPollingRate` is set to 5 seconds, the system will query the PLC for the most recent tag value every 5 seconds.

1. **Exception-Based Updates:**

- The system updates the tag value only when a change or event occurs in the PLC (just when the driver supports unsolicited messages).
- This approach reduces communication overhead as the PLC pushes updates only when there is a new value.
- It is more efficient when dealing with tags that do not require constant monitoring.

**Does Tatsoft write to the PLC with each statement (4x writes) in this body of code?**

Tatsoft writes to the PLC for each tag, but only if the tag’s value changes. This applies to tags configured with the **Changed** access type.

For tags with the **WriteTrigger** access type, all tags in the group are sent together when triggered. However, each tag group is sent in a separate packet.

Best Regards,  
Gabriel Caetano.
