I am needing to have a timer that will switch to the next tab every 60 seconds, and then continue to loop through the tabs. I am attempting to setup the timer as a Gateway Event, but I feel I am incorrectly calling the tab.
Thanks for any help!
I am needing to have a timer that will switch to the next tab every 60 seconds, and then continue to loop through the tabs. I am attempting to setup the timer as a Gateway Event, but I feel I am incorrectly calling the tab.
Thanks for any help!
I might be misunderstanding the question. Are you attempting to control a userâs browser to switch between tabs or do you have a Tab Container that you would like to switch on a timer?
A tab container. For context, the URL will be opened on a TV monitor without any other interactions. Just need the tab container to switch to the next tab every 60 seconds.
I would recommend using system.util.sendMessage()
(docs) to âbroadcastâ every 60 seconds. Make sure youâre specifying the session scope. You would then configure a Message Handler on the Tab Container (make sure in the handler that youâre specifying the session scope), and whenever it hears the message, just set TabContainer.props.activeTab to the next available tab. Youâll also want a custom property which defines the maximum known number of tabs so that you can loop back to the first.
Something like this in the handler:
self.props.activeTab = (self.props.activeTab + 1) % self.custom.total_tabs
Update:
Thinking about this some more, the system.util.sendMessage will only be heard at the SESSION level, so you will need to have three pieces.
system.util.sendMessage('MyProjectName', 'GATEWAYNEXTTAB',scope='S')
Really appreciate the followup! I feel am very close, but still missing or incorrectly doing something.
Gateway Timer Script
project = 'MyProjectName'
messageHandler = 'GatewayNextTab'
scope = 'S'
system.util.sendMessage(project, messageHandler, scope)
Gateway Message Handler (I also added a Session Event Message Handler with below to try it out)
GatewayNextTab
messageType = 'SessionNextTab'
scope = 'session'
system.perspective.sendMessage(messageType, scope)
Script Config on Tab Container Root
Message Type = SessionNextTab
self.props.activeTab = (self.props.activeTab + 1) % self.custom.total_tabs
Ah, okay. Two mistakes on my part, and sort of one mistake on your part (you didnât double-check my work, so you get some of the blame ).
Iâve updated my post because you do want SESSION Event - not GATEWAY Event (Iâm sorry, Iâm only halfway through my morning coffee).
In your code you removed the keyword designations, so your arguments are being interpreted incorrectly; your use of system.perspective.sendMessage()
will interpret your arguments as the messageHandler
arg and the payload
arg. You need to specify the args in this manner, because you are NOT supplying a payload:
# we need to supply an empty payload arg AND we need to use the "scope" keyword
messageType = 'SessionNextTab'
scope = 'session'
system.perspective.sendMessage(messageType, payload={}, scope=scope)
Not sure why I am unable to get it to work. I feel as if the Gateway Timer isnât reaching the messages arenât reaching the tab container message handler.
What I would recommend is using a line of logging as the first piece of each so that you can see where the messages are being heard. Iâll set up an actual working example and screenshot the settings.
Okay, this works for me:
Gateway Timer Event/Script:
Session Message Event/Script:
Component Message Handler:
Gateway logging:
My Tab Container is successfully flipping to the next tab every five seconds, and goes from the last to the first when after the last has been displayed for five seconds.
I'm getting the confirmations in the Gateway Logger!
I'm also getting an error:
Error running TabTest@C/root/TabContainer.onMessageReceived(self, payload): Traceback (most recent call last): File "function:onMessageReceived", line 3, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'tab_count'
Tried the total_tabs mentioned earlier as well.
Error running TabTest@C/root/TabContainer.onMessageReceived(self, payload): Traceback (most recent call last): File "function:onMessageReceived", line 3, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'total_tabs'
You need to set your own custom property on the Tab Container.
Hi, i'm new to ignition Perspective so i am currently working on a similar project that involves a main view configured as a tab container, in this view i added in total 4 tabs (0,1,2,3) and in each tab i added a coordinate container for working in it, i am having trouble with the scripting in general, i know how to add all the scripting except the gateway logging, but apart from that, it is not working, so i dont know what to do with the tab timer project.
hoping for the support, looking forward for the help.
Welcome to the forum.
It's going to be hard to debug your problem with the information given. Please confirm with screengrabs that you have done all the steps in cmallonee's post #9.
sure!
the main information described is this:
First pic is the perspective menu
Second pic is the arrange of the proyect, with the main view as a tab container and in each tab there is a coordinate container
continuation:
Gateway timer script third pic
Hi @Saul_Garcia, I want to make you aware of the Carousel component (which wasn't out when OP posted) that can essentially automatically play through preconfigured panes on a schedule. Check it out to see if it meets your needs - its much easier to set up as you can do most of this configuration right from the Property editor in the designer.