# How to write a script for notifying engine speed has reached a series of successive levels?

**URL:** <https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510>\
**Category:** Automated Testing\
**Tags:** scripting\
**Created:** [October 16, 2023, 5:02am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510 "2023-10-16T05:02:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerald\_Lim](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@Gerald\_Lim](https://forum.inductiveautomation.com/u/Gerald_Lim)\
**Post date:** [October 16, 2023, 5:02am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/1 "2023-10-16T05:02:06Z")

</div>

Hi, anyone ever tried to write a script for notifying engine speed has reached a series of successive levels? Hope to get some help here, thanks in advance.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 16, 2023, 6:22am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/2 "2023-10-16T06:22:21Z")

</div>

> [@Gerald\_Lim](#):
>
> notifying

What does this mean? Popup, email, phone call?

> [@Gerald\_Lim](#):
>
> engine speed

Where does the data come from?

---

<div class="post-metadata">

**Author:** ![Gerald\_Lim](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@Gerald\_Lim](https://forum.inductiveautomation.com/u/Gerald_Lim)\
**Post date:** [October 16, 2023, 6:42am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/3 "2023-10-16T06:42:42Z")

</div>

For testing purpose for now, I'm using a mimic memory tag to update this engine speed value which is another memory tag.  
But for the actual deployment, the data comes from a live engine controller through an opc ua tag.

---

<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, 6:57am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/4 "2023-10-16T06:57:14Z")

</div>

What output do you want from this function? 0, 1, 2, 3 or "Stopped", "Lethargic", "Reasonable", "Full of beans"?

---

<div class="post-metadata">

**Author:** ![Gerald\_Lim](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@Gerald\_Lim](https://forum.inductiveautomation.com/u/Gerald_Lim)\
**Post date:** [October 16, 2023, 7:02am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/5 "2023-10-16T07:02:14Z")

</div>

I would like to see succession of ramping up engine running speed levels attained with a mimic page showing each speed level label button appearing as they are attained.

---

<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:09am UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/6 "2023-10-16T07:09:07Z")

</div>

> [@Gerald\_Lim](#):
>
> ... showing each speed level label button appearing as they are attained.

You don't want **buttons**. You want **labels**.

To set the text of a label dependent on the rate, create an expression binding on each label. For example,  
`if({value} > 5, "Speed 1 achieved", "")`

 ![Speed binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1b2998b888277d4bf56771c74cb55eb062e1b5e4.png)

To **control the labels' visibility** create a similar expression binding on their `meta.visible` properties.  
`if({value} > 5, true, false)`  
Or, even simpler,  
`{value} > 5`  
why will return a true or false.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 23, 2023, 8:41pm UTC](https://forum.inductiveautomation.com/t/how-to-write-a-script-for-notifying-engine-speed-has-reached-a-series-of-successive-levels/80510/7 "2023-10-23T20:41:44Z")

</div>

How is this being used in automated testing?
