# Ignition Edge - How to script a Tag Totalizer without Gateway Scripts or Tag Change Scripts

**URL:** <https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [April 26, 2019, 5:46pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423 "2019-04-26T17:46:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://forum.inductiveautomation.com/u/kieran)\
**Post date:** [April 26, 2019, 5:46pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/1 "2019-04-26T17:46:45Z")

</div>

I need to create a fuel totalizer in an Ignition Edge Installation.

Let’s say I have 3 tags:

1. Sequence Step Number (Int)(OPC Tag)
2. Total Fuel (Float)(Memory Tag)
3. Current Fuel Usage (Float)(OPC Tag)

When the Sequence Step Number reaches 200 I want to add the value of the Current Fuel Usage to the Total Fuel.

The place for this script would be on the Gateway so that no matter whether any clients are open or not there is still totalizing happening. This is causing the problem as Gateway Event Scripts and Tag Change Scripts are disabled in Ignition Edge.

I’ve tried to use an Expression Tag with the **runScript Function** calling a project script that does this totalizing. I haven’t been successful with this option yet. Maybe it’s a limitation on the runScript Expression or maybe I’m not using it correctly.

The other option I’ve though of would be to us a Client Event Script or a Root Container Script tied to a window that is always open. Again this runs the risk of duplicating the script if more than one client is open so it would need to be conditioned to only run on the first client that is open.

If anybody can shed any light on this it would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [April 26, 2019, 5:57pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/2 "2019-04-26T17:57:57Z")

</div>

Kieran,  
This will be easy to do in PLC than on Ignition. I have done this on PLC and getting the totalizer on HMI and can reset also from HMI.  
…  
\*If its in Ignition, cant you create an expression tag with condition \*  
\*If(Sequence Step Number =200), \*  
_Total Fuel = Total Fuel (memory tag) + Current Fuel Usage_  
This syntax may not be correct.  
Did you try that?.

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://forum.inductiveautomation.com/u/kieran)\
**Post date:** [April 26, 2019, 6:14pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/3 "2019-04-26T18:14:08Z")

</div>

Thanks shibubalaji.

I agree that the totalizing would be more ideal in the PLC, however for this application it needs to be at the Ignition level.

The reason are a few reasons:

- This is a system with 20 valves that share a single flow meter
- The total flow recorded on each 20 valve cycle is stored in the RTAC (PLC)

\*\*The client has the ability to configure 40 pieces of equipment and assign up to 20 of them to valves 1  
through 20. Then if the client wants to disconnect a piece of equipment and connect it to another  
valve, we would like the fuel total for the unit to be maintained and start using the new valves usage to  
add to the unit total. The information about which unit is configured to which valve is only available at  
the Ignition scope and the RTAC doesn’t know anything about that. All the RTAC knows is the cycle  
cycle total for each of the 20 valves.

Quote:  
[ If(Sequence Step Number =200), \*  
_Total Fuel = Total Fuel (memory tag) + Current Fuel Usage_]

What you described here would work on a scripting object however to my knowledge there isn’t a tag write function available in the Expression Language. It is more about reading in tags.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 26, 2019, 6:39pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/4 "2019-04-26T18:39:44Z")

</div>

> [@kieran](#):
>
> I’ve tried to use an Expression Tag with the **runScript Function** calling a project script that does this totalizing.

Project scripts are not available to tag scripting, and tag scripting is not available in Edge. Edge simply does not provide a compute platform that can replace your PLC. If you must use Edge, with variant totalizing requirements, you will need to totalize in your PLC. Whatever hardware variations are possible will have to be structured so that the PLC is in fact aware of everything.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 26, 2019, 6:58pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/5 "2019-04-26T18:58:10Z")

</div>

I would even go so far as to say even if it was full blown Ignition, I would do it in the PLC. Just no way to completely guarantee that you’re not going to miss an event (Gateway issues, network issues, etc…)

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://forum.inductiveautomation.com/u/kieran)\
**Post date:** [April 26, 2019, 6:59pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/6 "2019-04-26T18:59:30Z")

</div>

Thanks for your feedback. Not what I was hoping to hear but it was the same conclusion that I was arriving at. They’ve obviously taken steps to remove this type of functionality from Edge.

I would like to take the client tag change script option a bit further. Perhaps you could speak to how I could condition a Client scope script so that it only executes on on the first client if there is more than one open.

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://forum.inductiveautomation.com/u/kieran)\
**Post date:** [April 26, 2019, 7:07pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/7 "2019-04-26T19:07:13Z")

</div>

lrose I agree with you. This is being done as a last resort in order to have a _nice to have totalizing_ feature that isn’t used for billing or anything more important than general operator info.

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [April 26, 2019, 7:20pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/8 "2019-04-26T19:20:30Z")

</div>

Kieran,  
If I understood correctly, there are 20 valves and each of them may be crisscrossed to 40 different equipment. If there is no information about the valves and instruments are in PLC, there could be a human error which valve that the operator is connecting to . Isnt it.  
Anyways, Expression tag is not only ready only and it has both read and write, as far as I know.

---

<div class="post-metadata">

**Author:** ![kieran](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@kieran](https://forum.inductiveautomation.com/u/kieran)\
**Post date:** [April 26, 2019, 8:00pm UTC](https://forum.inductiveautomation.com/t/ignition-edge-how-to-script-a-tag-totalizer-without-gateway-scripts-or-tag-change-scripts/24423/9 "2019-04-26T20:00:02Z")

</div>

Shibubalaji,

Taken from the the manual “Expressions don’t do anything, other than return a value”  
There is no tagwrite “ **Expression Function** ” to allow you to write a value into a different tag, that is a “ **Scripting Function** ” which isn’t available in an Expression Tag.
