# Link State of Pump

**URL:** <https://forum.inductiveautomation.com/t/link-state-of-pump/48930>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 18, 2021, 8:40am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930 "2021-07-18T08:40:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![len](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@len](https://forum.inductiveautomation.com/u/len)\
**Post date:** [July 18, 2021, 8:40am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/1 "2021-07-18T08:40:28Z")

</div>

Hi All,

I’m new to Perspective.  
I’m trying to link running, stopped and faulted of a pump to my tags (running, stopped and tripped).  
Can someone please advise.  
Thanks  
 ![pump](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/09a73e4f8fbaf8a406314fb728a729cbbf2d5b26.png)

---

<div class="post-metadata">

**Author:** ![rourksb](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@rourksb](https://forum.inductiveautomation.com/u/rourksb)\
**Post date:** [July 18, 2021, 10:07am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/2 "2021-07-18T10:07:51Z")

</div>

Have you tried linking it to a tag and using a map transform?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 19, 2021, 6:15pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/3 "2021-07-19T18:15:23Z")

</div>

I’m assuming you have those 3 tags as booleans, and there will always be one and only one `true`.  
You could bind the `state` property to an expression structure, and add a little script:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f19a9a8a1184ba3a8e8d485bc68c05ed78130df.png)

This is probably doable with expressions, but I don’t like them.  
I can explain how this works in more details if you’re not familiar with all of this, just let me know.

Another way you could consider if you need the same logic in other places of your project, would be to create a new tag containing the current state, then use a tag binding on the `state` property of the pump and add a map transform.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 19, 2021, 7:02pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/4 "2021-07-19T19:02:47Z")

</div>

There are _many_ ways to skin this cat. If it's a single tag, I'd echo @rourksb's recommendation of a map transform - it's simple to set up and easy to change later. If you have multiple tags, you could use @pascal.fragnoud's suggestion, though I'd simplify to two elements:

1. A single expression bringing in the value of the tags and (assuming they're mutually exclusive) use [`binEnum`](https://docs.inductiveautomation.com/display/DOC81/binEnum) to translate it to a single numeric value
2. A map transform, just like the first suggestion. (You _could_ do the entire thing using a single expression, but IMO a pair of transforms is the most readable and maintainable in the future).

> [@pascal.fragnoud](#):
>
> This is probably doable with expressions, but I don’t like them.

Sidebar: This is perfectly reasonable if you're more comfortable with scripting, just be aware you're leaving performance on the table. Jython compilation can be a significant bottleneck; the more script transforms you're using the more that can pile up. For a simple task like this I'd strongly recommend an expression based solution.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 20, 2021, 7:10am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/5 "2021-07-20T07:10:56Z")

</div>

Yes, I try to use expressions where I can figure out quickly how to do what I want. But if it doesn’t work after a few tries, I’ll just switch to scripting.  
To be perfectly honest, it’s not the expressions I don’t like, it’s the doc. More often than not, I find myself confused after reading the doc, or not sure where to go next to find the information I need.  
On the other hand, python, even if it’s Jython is quite well documented.  
For example, I gave expressions a shot for this case. BinEnum is exactly what I would have wanted to find, but… It’s not like the name speaks for itself, and there’s not much pointing in its direction for the case at hands.

---

<div class="post-metadata">

**Author:** ![len](https://avatars.discourse-cdn.com/v4/letter/l/58f4c7/32.png) [@len](https://forum.inductiveautomation.com/u/len)\
**Post date:** [July 22, 2021, 10:25am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/6 "2021-07-22T10:25:12Z")

</div>

Thanks for all the help gents.  
I came right using the map transform but will try the other methods as well.

---

<div class="post-metadata">

**Author:** ![Joshua\_Myers](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Joshua\_Myers](https://forum.inductiveautomation.com/u/Joshua_Myers)\
**Post date:** [October 16, 2023, 7:18pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/7 "2023-10-16T19:18:37Z")

</div>

Could you use expressions here to map multiple tags to the same prop?

i.e. I have one tag that checks if the pump is running but another tag that indicates if it is faulted

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 16, 2023, 7:27pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/8 "2023-10-16T19:27:04Z")

</div>

Follow what @paul-griffith described above using `binEnum`.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 16, 2023, 7:36pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/9 "2023-10-16T19:36:15Z")

</div>

Yes. If the tags aren't mutually exclusive then use `binEnc`.

- Create an expression structure binding on the symbol. Add in the paths to the two tags.
- Add an expression transform.

 ![binEnc](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/6067fac46e9a5412249b1a25e12ed30b19b37c45.png)

Code:

```auto
//pumpRunning pumpFaulted Result
// 0 0 00 = 0
// 1 0 01 = 1
// 0 1 10 = 2
// 1 1 11 = 3
binEnc({value}['pumpRunning'], {value}['pumpFaulted'])

```

[https://docs.inductiveautomation.com/display/DOC81/binEnc](https://docs.inductiveautomation.com/display/DOC81/binEnc)

---

<div class="post-metadata">

**Author:** ![Joshua\_Myers](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Joshua\_Myers](https://forum.inductiveautomation.com/u/Joshua_Myers)\
**Post date:** [October 16, 2023, 8:00pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/10 "2023-10-16T20:00:14Z")

</div>

This worked, thank you!

---

<div class="post-metadata">

**Author:** ![Joshua\_Myers](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Joshua\_Myers](https://forum.inductiveautomation.com/u/Joshua_Myers)\
**Post date:** [October 16, 2023, 8:01pm UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/11 "2023-10-16T20:01:25Z")

</div>

Thanks for the reply. I ended up having to use `binEnc` because I have 1 tag for 'running' and 'stopped' and another tag for 'faulted' so the 3 values are not mutually exclusive.

---

<div class="post-metadata">

**Author:** ![Sujanaka\_Dilsara](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Sujanaka\_Dilsara](https://forum.inductiveautomation.com/u/Sujanaka_Dilsara)\
**Post date:** [January 20, 2025, 10:25am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/12 "2025-01-20T10:25:57Z")

</div>

You can easily accomplish this by using the map transform.

 ![Capture1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/524748aff1e4106bc5397148bb00d99198376cf5.png)

If you use boolean type data tag, simply use true & false instead of numeric input range.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 20, 2025, 11:26am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/13 "2025-01-20T11:26:06Z")

</div>

The OP has 3 distinct tags for each state, not a single tag, which is why binEnc was suggested to combine them together before using a map

---

<div class="post-metadata">

**Author:** ![Sujanaka\_Dilsara](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Sujanaka\_Dilsara](https://forum.inductiveautomation.com/u/Sujanaka_Dilsara)\
**Post date:** [January 21, 2025, 3:39am UTC](https://forum.inductiveautomation.com/t/link-state-of-pump/48930/14 "2025-01-21T03:39:00Z")

</div>

Yes, If the OP has multiple tags for each state, then using `binEnc` to combine them into a single representation before mapping is a practical approach. This ensures that the tags are treated as a unified entity, allowing for efficient mapping and retrieval.
