# Case expression with Binary encoder and timer

**URL:** <https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863>\
**Category:** Ignition\
**Created:** [November 9, 2021, 11:08am UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863 "2021-11-09T11:08:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![IA\_old\_forum](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@IA\_old\_forum](https://forum.inductiveautomation.com/u/IA_old_forum)\
**Post date:** [November 9, 2021, 11:08am UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/1 "2021-11-09T11:08:03Z")

</div>

Hello everyone. As this is my second question in the forum, I am still very new to the Ignition software, and I wanted to ask:  
Is it possible to use some sort of timer within an expression tag? I have 2 OPC tags that return a boolean value each depending on the respective machine part working or not.

I have the following expression (as example):

switch (binEnc( tag path mode, tag path status)  
1,  
2,  
3,  
10,  
14,  
19,  
0)

but I want an extra output state, i.e. 25, when the tag: Mode, is on/true for longer than 1 minute and tag status = x. Since I am using this expression tag as my machine state tag, would this be possible? is there some sort of expression or logic I could use?

thanks in advance and sorry if the question is not 100% clear

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 9, 2021, 11:30am UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/2 "2021-11-09T11:30:00Z")

</div>

You can use a tag’s timestamp in your expression.

```auto
SWITCH (binEnc( {[~]mode, [~]status, ([~]mode && secondsBetween({[~]mode.Timestamp}, now()) >= 60) )
        0, 1, 2, 3,
        0, 10, 14, 19,
        25
	   )

```

---

<div class="post-metadata">

**Author:** ![IA\_old\_forum](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@IA\_old\_forum](https://forum.inductiveautomation.com/u/IA_old_forum)\
**Post date:** [November 9, 2021, 12:55pm UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/3 "2021-11-09T12:55:18Z")

</div>

Thanks! again to my rescue haha  
do you know about some sort of manual where I can learn a bit more (specially examples/exercises) for Ignition's scripting language? the user and function manual does not dive too deep into more complex or compound uses.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 9, 2021, 1:40pm UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/4 "2021-11-09T13:40:19Z")

</div>

There really isn’t one. Trial and error are my best friends. That said, you can trial portions in another custom property or expression tag and mix/match however you want in your overall expression.

---

<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:** [November 9, 2021, 1:44pm UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/5 "2021-11-09T13:44:31Z")

</div>

Look at [documentation for Python 2.7](https://docs.python.org/2.7/index.html). Ignore the big banner that it is unsupported. Ignition 8+ uses Jython 2.7, which is the same language with the same built-ins and most of the same standard library. Jython adds the treatment of java packages/classes as importable like python modules/classes.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 9, 2021, 2:01pm UTC](https://forum.inductiveautomation.com/t/case-expression-with-binary-encoder-and-timer/52863/6 "2021-11-09T14:01:04Z")

</div>

To contrast what I was saying to Phil’s post, I was talking more on the expression language than Jython’s scripting language. They are two separate things, and it’s sometime easy to accidentally mix the two.
