I am using Perspective to build my views. I have one view (Overview) that has several buttons to select a station i.e. 1, 2, ...20. I have written a script to write an integer value to a memory tag that writes the specific integer based on which button is pressed. I want to use this value in the memory tag to select the specific station view which is another view separate from the Overview. I also have an embedded version of the station view to see if that would work. My issue is that in the Perspective designer I can test the function of the script in the preview mode and everything works as desired. The selected button writes the appropriate integer value to the memory tag and this tag selects the appropriate station view relevant to the value in the memory tag. Both the main station view and the embedded station view show exactly the same results. I have configured an event binding on the Overview buttons to 1. run the Script that sets the value of the memory tag, then 2. Navigation to the appropriate station view based on the value in the memory tag written in step 1. As I mentioned before this all works in preview mode, at least the scripting part works as intended. Once I launch a Perspective session the Overview buttons do not seem to write to the memory tag and the station screen that is navigated to is the screen set to the last value in the memory tag prior to initiating the Perspective session.
If possible could you post both your script code (properly formatted, see Wiki - how to post code on this forum. ) and some screenshots showing how your bindings and views are configured. (redacting any sensitive information as needed)
In general, anything that is controlling what screen your session is on, navigation in a session, or selection of items in a session should NOT be a gateway memory tag. They are server wide¹ so if multiple sessions are running they will all use the same tag, and you will have one session navigating/interfering with the others.
For your use case, the value should likely be kept in a view custom property.
1 - Vision has per session tags but that's not what you are using
Thanks for your quick response, below is the script on the button in the overview screen. My intention is to write an integer to the memory tag in order to select the correct station for the detail view.
def runAction(self, event):
system.tag.writeBlocking(["[RioOso_Tag_Provider]ColdBrew/brewStationM"],[1])
From what I can gleam from the pictures you provided, you can do all of what you want without using tags.
I'm assuming that the 'Brew Station' view is being used in an embedded view component on the 'Overview' view, correct? If that's the case you should be able to pass the selected station number to the embedded view using that component, no tags required.
When you say navigate, you are navigating via an action on a button or calling system.perspective.navigate
from a script, correct?
If so, either modify your existing page configuration for 'Brew Station' or create a new one that can take the selected station number as a URL param. ie. /plant/station/:brewStation
. From there, your button script would only be system.perspective.navigate('/plant/station/1')
or similar.
Remove the tag binding on the brewStation
view parameter, otherwise it will interfere with the value being passed to the view by the embedding component or URL param.
Hi,
I didn't realize I could embed the 'Brew Station' view in the 'Overview' view? At the moment they are in two separate views.
Maybe I'm missing the point, when I try to embed the 'Brew Station' view on the 'Overview' view, the brew station view now shows up on the bottom of the overview view, I want them to act like separate pages, if that's possible?
For you second point I was using the 'onActionPerformed' on the button to navigate to the 'Brew Station' screen.
If this is your aim then don't worry about the embedding. Just start here:
and do everything from there onward. It should behave the way you like.
When you get some time later, I recommend looking into embedding views in perspective. Helps a lot with making modular parts to interfaces and reducing repetitive work.
As Ryan has pointed out, using a memory tag for display control would affect all sessions running that Perspective application. This is generally a bad thing.
If you select Perspective in the Project Browser pane, then go to the Perspective Property Browser pane and scroll down to SESSION CUSTOM, you can add custom properties there and these act like global variables for your application. You can bind other components to them and you can read from and write to them in scripts.
I got it to work! Thanks both to Ryan and Transistor as I used a combination of both ideas. I created the SESSION CUSTOM property "brewStationMP" and used one script to both write to the custom property and navigate to the 'brewStation' view.
def runAction(self, event):
self.session.custom.brewStationMP = 1
system.perspective.navigate('/Brew Station/brewStation')