Case expression with Binary encoder and timer

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

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

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

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.

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.

Look at documentation for Python 2.7. 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.

1 Like

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.

1 Like