Novice seeks help with Vision Property Change Script - *He thinks*

My issue is this....looking at an old HMI (Delphi 5 w/Pascal - what fun) they set a tag value based on what forms are open/visible by the operator. So in Ignition (vision) I have (2) pages with (5) tabs total. I created a mouse click script on each of those (2) tab strips that will manipulate the tag vale 1,2,3,4,5 etc.

This is one of those...

What I am struggling with is...

  1. how (and where) to set the tag value to 0 if none of those 5 tabs are open / visible.

  2. when the operator navigates to the (2) pages with the tab trips on them I need a script to execute immediately - and not have to wait for the operator to click in the tab strip control.

I sorta stumbled into a fix for #2 this morning with a property change script on one of the root containers....

That appears to fix #2 in limited testing. But if I remove the original mouse click script - the property change script does not update the tag value I wish when cycling through the tabs. (The tab strip is set to not navigate, and the .selectedTab property is used to set visibility on each of the (3) containers this tab strip is supposed to control).

So I expected the .visible property to handle that.

I cannot figure out how to use the .newValue that the scripting editor speaks to. And online help is proving less useful than it usually is.

image

I think the correct thing to do use a property change script but there is (obviously) something I am missing with that.

Let's clear something up first:
What's the end goal ?
I'm talking use case (what's the requirement) and not implementation (how to achieve that requirement).

And, if there are any, what are your constraints.

A few tips/considerations about what you already have (even if there might be a better solution to achieve your goal, that don't use it):

  • The tag you're using should probably be a vision client tag.
  • You should check for the property that triggered an on change event, or the script will run for ANY property change on that component.
  1. You don't need the .value on the end of the tag path you are writing to.
  2. You should use if and elif with an else on the end for situations where nothing is selected.
if event.propertyName=='selectedTab':
	print event.newValue
	writepath = '[default]TestInt'
	if event.newValue=='Tab 1':
		value = 1
	elif event.newValue=='Tab 2':
		value = 2
	elif event.newValue=='Tab 3':
		value = 3
	else:
		value = 4
	system.tag.writeBlocking(writepath,value)
else:
	pass
2 Likes

Vaguely...
To duplicate what I perceive the original HMI does.

Specifically in this case...
Write an integer to a PLC tag
0 if no operator has a linearizer page open/visible
1 if Bias RF linearizer open
2 if Antenna RF linearizer open
3 if Top magnet linearizer open
4 if Middlle magnet linearizer open
5 if Bottom magnet linearizer open

Not sure I know enough to answer your question they way you may prefer.
Ignition vision was sold to replace a WindowsNT based HMI. Along with a PLC CPUI upgrade (OMRON FINS driver in Ignition/Gateway which is working and I have the new CPU communicating)

I realize I may be going about this completely wrong. But ultimately the tag will need to write to the PLC.
So, I should broaden my approach to consider vision client scripting

Yes, that was made clear in the one Inductive university video I found. And I believe I followed the guidance therein so far as I used if statements.

# Check visibility
if event.source.getComponent('Top Container').visible:
	value = [3]									# Set Linearizer Mode Value
	system.tag.writeBlocking(writepath, value)	# Write Linearizer Mode Value

ok

is your code for the tab strip control? root container or could it be made to work on both?

No, if the value must be written to a PLC, then a client tag is not the way to go.

No, you need to check for what property has changed, like @MMaynard did in his snipper above.
Something like:

if event.propertyName == 'selectedTab':
    do_something()

The reason for this is that the property change event will trigger for ANY property that changes.
If you change the component's name, its name property changes, and it triggers the script. That's not what you usually want.
So, we filter with a line like the one above.

I was playing around with this pritn to console function earlier but not having luck. Is there some setting somewhere that enables this - or is it just that my script was not executing.

So, depending on what's visible to an operator, a value gets written to PLC.
What if 2 operators have conflicting things opened ?

3 Likes

Bingo. Your requirement indicates an assumption that there is only one client. That is a really bad assumption for Ignition. Even when using a limited license, the designer preview is also a "client".

2 Likes

That was not possible, so far as I know for Delphi 5 on WindowsNT.

I get your point - don't have an answer except at this point to educate the customer. or prohibit access.

Then at this point I'd suggest going back to the drawing board and clearly defining goals and constraints.
Figuring these things out while implementing is how you end up pulling your hair off.

4 Likes

The code he wrote is for the propertyChange event handler of the Tab Strip component.

So in the end.
@MMaynard 's property change script was put there.

Later, a colleague I reached out to, pointed out the window script option - which was hiding in (my admittedly myopic) plain sight. So I added scripting on the Window
internalFrameActivated - which took care of No.2
internalFrameDeactivated - which took care of No.1

No hair left. But, your and @pturmel 's point are taken.

Who would have thought that replacing a 23 year old HMI solution would have issues beyond just getting the data to/from the controller?

I am impressed that Omron's Cx programmer easily migrated the code from an ISA slot based controller to a new rack based CPU.