Auto-rotate through windows

Greetings All, I’m working on an existing project that will auto-rotate through several screens on a big screen TV. Below is the existing script, however it throws an “uncaught exception” error. I would appreciate any help with this script, or any thoughts on another way to accomplish this.

tagPath = "[Client]TV1_SWAP" % system.net.getHostName()
x = system.tag.getTagValue(tagpath)
windows = [MGMT/TV_PKG_BY_SHIFT, MGMT/TV_CUSTOM]

if x >= len(windows):
     x = 0

system.nav.swapto(windows[x])
system.tag.writeToTag(tagPath, x+1)

As a follow-up question, the IA demo project has a screen that uses a timer and signal generator to animate a component, effectively rotating out of view, and setting the visible/hidden property. Is it possible to do the same thing with an entire template? I don’t see X-Y positioning properties for a template but wonder if I’m missing something? Animated templates would serve my needs nicely if it’s possible.

1 Like

Well, I think I can see two problems right off the bat.

  1. Your swapto() function needs a capitol t. ie: system.nav.swapTo()
  2. Your window names should be strings.

In a semi-unrelated note, I’d rewrite you script like this:tagPath = "[Client]TV1_SWAP" windows = ["MGMT/TV_PKG_BY_SHIFT", "MGMT/TV_CUSTOM"] x = system.tag.read(tagPath).value%len(windows) # mod 2 produces a 0 or a 1 system.nav.swapTo(windows[x]) system.tag.write(tagPath, x+1)That way, all you need to do is add more screens to the windows list and it will continue to work right.

And for your second question, Templates don’t have rotation or x/y properties. You can set the component’s size and location with system.gui.reshapeComponent() though.

1 Like

Using a Client Timer Script…

This cycles through a number of screens (in this case Screen1, Screen2, etc.) Note that I check to ensure that the value is in a valid range before trying to change the display.

val = system.tag.getTagValue("[Client]Screen") maxScreens=system.tag.getTagValue("[Client]MaxScreens") val = val + 1 if (val>MaxScreens): val=1 WindowName = "Screen " + str(val) system.nav.swapTo(WindowName) system.tag.writeToTag("[Client]Screen", val)

Alternative way would be to shorten to this (without the swapTo):

val = system.tag.getTagValue("[Client]Screen") maxScreens=system.tag.getTagValue("[Client]MaxScreens") val = val + 1 if (val>MaxScreens): val=1 system.tag.writeToTag("[Client]Screen", val)

Set all your screens to open at startup. Then set the Layer property to a higher value for each display I’ve used a value of 1 for the background, and 2 for the foreground. Just because I’ve occasionally had odd things happen using layer 0. There is a longer startup time, depending on the number of screens, but swapping layers instead of swapTo is much faster once it’s loaded up.

2 Likes

Hi Robert,

You are a lifesaver, this worked beautifully!

Maybe I’m just missing it, but how do you mark a post as “solved”? Or is that something you have to do?

Thanks again,
Dana

1 Like

at the lower-right corner of each post in the thread (has to be one that you started) there’s a ‘Solved’ button…[attachment=0]10-9-2013 2-06-02 PM.png[/attachment]

Glad it’s all working for you! :smiley:

1 Like

As someone who is still learning to use Ignition, which component/where should I put this script to switch windows??

In v7, it would be found in Project -> Scripts -> Client Event Scripts.

In v8 it’s in Vision -> Client Events

1 Like

Thanks for the insanely quick reply! We are currently using 7.9.9 but are soon upgrading to 8.0.2, so thank you for the clarification!