Scripts - Page Navigation

Discuss issues and ideas you have to configuring displays with PowerVision
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Scripts - Page Navigation

Post by Ocelot » Thu Sep 10, 2015 5:07 pm

Hello,

Windows 10
PowerVision 2.7.10475
Color Displays Only (PV450/780)

Question concerning AngelScripting

I would like to navigate from one page to another page, based on a users current position within a list (i.e. a lookup table). Test_Page_1 through Test_Page_4 are page views on the same page, located on the Menu Layer in Page Designer.

i.e.

When they are done with the "scroll up" and "scroll down" buttons, and press the "select" button the following script is called

void $PageSelected$ ()
{
string route = "null";
CustomListData data;

ListManagerGetItem(ListDataType.PageList, ListManagerGetPosition(ListDataType.PageList), data);
data.ReadString(CustomListColumn.PageList_Page_Routing, route);

if (route == "page1")
{
smWrite(VariableIDs.db1, 1);
sendEvent(PageViewIDs.Menu_Test_Page_1);
}
else if (route == "page2")
{
smWrite(VariableIDs.db2, 1);
sendEvent(PageViewIDs.Menu_Test_Page_2);
}
else if (route == "page3")
{
smWrite(VariableIDs.db3, 1);
sendEvent(PageViewIDs.Menu_Test_Page_3);
}
else if (route == "page4")
{
smWrite(VariableIDs.db4, 1);
sendEvent(PageViewIDs.Menu_Test_Page_4);
}
}

I strongly believe that I am incorrectly trying to navigate to a page using the sendEvent(PageViewIDs.Menu_Test_Page_X); and that is not the right way to try to do this. Any help or suggestions would be appreciated.

P.S. I know that I am pulling the correct string value out of the table/list as my db1-4 variables do increment on the screen (db = debug1-4) based on the if statements. I chose to use the smWrite method, as opposed to Print/PrintNumber, as I do not have to be linked to the display and have the debug console open to see my "trace".

I went back and looked at some Murphy Standard configs in PowerVision 2.3 and was unsuccessful in piecing out how the page navigation "action" was actually being called. I only performed a cursory look through in previous forum postings.

Thank you.
Kyle Bruneau
Applications Engineer - MurCal Inc
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Scripts - Page Navigation

Post by stalley » Thu Sep 10, 2015 5:40 pm

Hello ocelot,

You are on the right track, but use the SendAction() instead.

Code: Select all

SendAction(ApplicationIDs.UIApp, ActionIDs.UIApp_Show_View, PageViewIDs.Menu_Test_Page_4 );
This should get you where you want to go.
Sara Talley
Software Engineer
Enovation Controls
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Re: Scripts - Page Navigation

Post by Ocelot » Fri Sep 11, 2015 10:16 am

That works.

Thank you.
Kyle Bruneau
Applications Engineer - MurCal Inc
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Re: Scripts - Page Navigation

Post by Ocelot » Mon Sep 14, 2015 4:01 pm

Hello All,

Another scripting question,

Is there any way to indirectly reference VariablIDs. based on a index? VariableIDs."Insert variable name of your choice"

As something that is constructed, like a string etc.?

I am looking for a way to index based on something like the following

Code: Select all

string indexer = "index_";
string temp;

for(i = 0, i < 10, i++)
{
temp = indexer + formatInt(number, 'l', 3);
smWrite(VariableIDs.temp, i);
}
Basically just want to loop through some variable names with a "name" pattern of

index_1
index_2
index_3...

under the programming tab. These variables are not declared in a script anywhere, but as variables in a folder.

I noticed that the definition of smRead and smWrite requires arguments of (uint, double) and was wondering if I should be instead using,

smWrite(StringToInt("VariableIDs.index_1"), i); and constructing the string separately instead?

Let me know what your thoughts are.
Kyle Bruneau
Applications Engineer - MurCal Inc
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Scripts - Page Navigation

Post by stalley » Tue Sep 15, 2015 9:13 am

Hi Ocelot,

Do you remember back when we would have a uint handle variable, assign it the VariableIDs.variableName? This way we had a local variable to use. It seems you could do something similar. I am attaching a script from the Murphy standard in the 2.3 PowerVision Configuration Studio. It has an array of EventIDs, gsEventHandles, which may be similar to how you could do your VariableIDs, and using the pattern as the index to the array of "addresses".

This isn't quite how you described your approach, but somehow your "pattern" will need to resolve to the uint VariableIDs.variableName which is an address or the "pattern" could resolve to an index to an array of uint VariableIDs.variableName.

I probably haven't explained this very well. Maybe the script will give you some ideas. :)
Attachments
Variable handle example.zip
(1.16 KiB) Downloaded 15 times
Sara Talley
Software Engineer
Enovation Controls