# Perspective motor symbol animation

**URL:** <https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 29, 2022, 6:36pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364 "2022-06-29T18:36:22Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neeraj\_Sabharwal](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Neeraj\_Sabharwal](https://forum.inductiveautomation.com/u/Neeraj_Sabharwal)\
**Post date:** [June 29, 2022, 6:36pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/1 "2022-06-29T18:36:22Z")

</div>

Hi All,

I am using motor symbol from components and would like to show the animation. I am changing the state of the motor with the help of text field in the value. Now I want to change the text field from my tags. I have 3 (BOOL) tags and want to configure them to write it to the text field. The 3 Bools are as follows

1. Run/tag - should write running in the text field
2. Fault tag - should write faulted in the text field
3. Stopped - should write running in the text field

would request for any help!!!

---

<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:** [June 29, 2022, 7:04pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/2 "2022-06-29T19:04:38Z")

</div>

Why have you got three tags instead of just one with, for example,

- 1 = running
- 0 = stopped
- -1 = faulted

Then your binding becomes very simple.

---

<div class="post-metadata">

**Author:** ![Neeraj\_Sabharwal](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Neeraj\_Sabharwal](https://forum.inductiveautomation.com/u/Neeraj_Sabharwal)\
**Post date:** [June 29, 2022, 7:12pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/3 "2022-06-29T19:12:33Z")

</div>

I am working on a project and the program for PLC is already written and don’t have rights to change it.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [June 29, 2022, 7:21pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/4 "2022-06-29T19:21:08Z")

</div>

It’s kind of messy, but try this in an expression binding:

```auto
if({[default]Tag1}, "Running",
	if({[default]Tag2}, "Faulted",
		if({[default]Tag3}, "Stopped", "")))

```

---

<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:** [June 29, 2022, 8:49pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/5 "2022-06-29T20:49:19Z")

</div>

I’d create an expression tag in your UDT with (essentially @josborn 's expression, I like all ifs on the same vertical though) :

```auto
if({[.]Tag1}, "Running",
if({[.]Tag2}, "Faulted",
if({[.]Tag3}, "Stopped",
"")))

```

Then you can use this anywhere you need to show its status rather than having to write this 17 million times (probably an exaggeration). Expression tags only ever update when it’s conditions change

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [June 29, 2022, 11:40pm UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/6 "2022-06-29T23:40:28Z")

</div>

I like to indent for readability, though it doesn’t make much difference here.  
I had to recreate some rather nonsensical color animations, and ended up with this nested if:

```auto
if({Cam_Angle1.Stat},
	if({Cam_Angle1.VCR_Stat},
		1, //flashing red
		if({Cam_Angle1.Alarm},
			2, //Red
			if({Cam_Angle1.Manual_Stat},
				3, //Yellow
				4 //Tan
			)
		)
	),
	0 //No Color
)

```

if i were to remove the indentation it is not easy to tell what’s going on:

```auto
if({Cam_Angle1.Stat},
if({Cam_Angle1.VCR_Stat},1, //flashing red
if({Cam_Angle1.Alarm},2, //Red
if({Cam_Angle1.Manual_Stat},3, 
4))),0)

```

---

<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:** [June 30, 2022, 12:06am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/7 "2022-06-30T00:06:24Z")

</div>

On the contrary, I find it more readable if all conditions and results are aligned 🤷  
However I would indent separate “case statement” if statements, e.g.

```auto
if({Cam_Angle1.Stat},
   if({Cam_Angle1.VCR_Stat},1, //flashing red
   if({Cam_Angle1.Alarm},2, //Red
   if({Cam_Angle1.Manual_Stat},3,
   4))),

   0
)

```

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [June 30, 2022, 12:10am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/8 "2022-06-30T00:10:10Z")

</div>

I’ll agree that’s not too bad actually. I’ll probably still do it my way though (;

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 30, 2022, 12:17am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/9 "2022-06-30T00:17:07Z")

</div>

I prefer the case statement to nested ifs, I don’t have to figure out how many close parenthesis are required and can add another case with copy/paste:

```auto
case(True,
    {[.]Tag1}, "Running",
    {[.]Tag2}, "Faulted",
    {[.]Tag3}, "Stopped",
"")

```

---

<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:** [June 30, 2022, 2:24am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/10 "2022-06-30T02:24:11Z")

</div>

This case statement usage has always intrigued me, every time I have needed it though I haven’t remembered to use it ☹ but it is much cleaner!

---

<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:** [June 30, 2022, 7:18am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/11 "2022-06-30T07:18:51Z")

</div>

> [@mcgheeiv](#):
>
> ```auto
> case(testVariable,
> {[.]Tag1}, "Running",
> {[.]Tag2}, "Faulted",
> {[.]Tag3}, "Stopped",
> "")
> 
> ```

That's an awful lot clearer than the user manual example. Thanks!  
[https://docs.inductiveautomation.com/display/DOC81/case](https://docs.inductiveautomation.com/display/DOC81/case)

I've suggested to [docs@inductiveautomation.com](mailto:docs@inductiveautomation.com) an update to the manual.

Update: The docs have been updated.

---

<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:** [June 30, 2022, 7:43am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/12 "2022-06-30T07:43:24Z")

</div>

Yeah wow, they’re a bit hard to read, sorry @Paul.Scott 😅

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 30, 2022, 9:51am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/13 "2022-06-30T09:51:21Z")

</div>

Perhaps a better example for the user manual:

```auto
case({[.]Tag1},
     1, "Running",
    -1, "Faulted",
     0, "Stopped",
"Unknown")

```

---

<div class="post-metadata">

**Author:** ![johannes.bo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/johannes.bo/32/27628_2.png) [@johannes.bo](https://forum.inductiveautomation.com/u/johannes.bo)\
**Post date:** [June 30, 2022, 9:58am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/14 "2022-06-30T09:58:18Z")

</div>

+1 for clean code  
-But how will this be executed compared to having the actual condition tag as the first parameter?  
-Will this be executed “constantly”, and put unnecessary load the client?

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [June 30, 2022, 9:59am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/15 "2022-06-30T09:59:39Z")

</div>

I would prefer a map transform over a case statement like this in Perspective:

[Map Transform - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Map+Transform)

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [June 30, 2022, 10:07am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/16 "2022-06-30T10:07:24Z")

</div>

Recall the original question… 3 tags are used to define the 3 states. In a UDT or with expression binding on a window/view the case statement should execute exactly the same number of times as the nested if statement. In Perspective an expression structure with map transform would work as well and would only execute once per tag change per session with the view open.

---

<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:** [June 30, 2022, 10:09am UTC](https://forum.inductiveautomation.com/t/perspective-motor-symbol-animation/61364/17 "2022-06-30T10:09:15Z")

</div>

> [@johannes.bo](#):
>
> Will this be executed “constantly”, and put unnecessary load the client?

1. Expressions will be executed only when any of the inputs change.
2. The expression is calculated on the gateway, not on the client. Obviously there will be some extra traffic to refresh the data binding on the client component but it shouldn't hurt.

* * *

Tip: for bulleted lists the markdown requires a space after the hyphen. `- list item`.
