Angelscript and GUIDs

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

Angelscript and GUIDs

Post by Ocelot » Thu Aug 17, 2017 4:24 pm

Hello,

Powervision 2.9, the latest beta.

Using some guid values in angelscript and ran into some behavior I am having a hard time figuring out.

I am Packing a List table with variable GUID's, and then pulling them out in a smRead loop to update the List table.

The table has GUID defined as int32, and is the GUID column is packed with something like,

Code: Select all

VariableIDs.MB1_Low_SysVar_1_Alarm;
When I then go to check each row of the list to see if I need to update the variable value in the list,

Code: Select all

	//get the length of the list for indexing purposes
   	int length = ListManagerGetCount(ListDataType.Menu_List);
   	int index = 0;
   	
	//Temporary holding variables for performing lookups and updates
	int32 variable_guid = 0;
	float variable_value = 0;
	float list_value = 0;
	
	//declare a class to hold the retrieved information
	CustomListData data;
	
	//Loop through the list and update a row when the current list value does not match the variable values in PowerVision folders etc.
	while (index < length)
	{
		//Get the list row
		ListManagerGetItem(ListDataType.Menu_List, index, data);
		
		//Get the list row's Variable GUID value
		variable_guid = data.ReadInt32(CustomListColumn.Menu_List_Guid);
			
		//Get the list row's variable value
		list_value = data.ReadFloat(CustomListColumn.Menu_List_variable);
			
		//Lookup current variable GUID value
		smRead(variable_guid, variable_value);
			
		//Compare current variable value to the value in the list, if different update list
		if(variable_value != list_value)
		{
			data.WriteFloat(CustomListColumn.Menu_List_variable, variable_value);
			ListManagerSetItem(ListDataType.Menu_List, index, data);
		}
		
		index = index + 1;
	}
What I am seeing is if I perform the following,

Code: Select all

PrintNumber(variable_guid);
PrintNumber(VariableIDs.MB1_Low_SysVar_1_Alarm);
I end up with,

1145143296
1052

and if I do,

Code: Select all

smRead(variable_guid, variable_value); // Returns 0
smRead(1145143296, variable_value);   // Returns 0
smRead(variableIDs.MB1_Low_SysVar_1_Alarm, variable_value); // Returns a true value
smRead(1052, variable_value); // Returns a true value
What am I doing wrong?
Kyle Bruneau
Applications Engineer - MurCal Inc
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: Angelscript and GUIDs

Post by boyce » Fri Aug 18, 2017 10:53 am

The code in your script looks like it is working okay. I think the problem might be in the list definition. I was told that the list should have the first 2 columns as RowID and Guid and then you can add your 2 columns of Id and Value. If you look at the system tables they all have the same first 2 columns, RowID and Guid. So don't use the first 2 columns and just add your columns below them.
Boyce Schrack
Enovation Controls
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Re: Angelscript and GUIDs

Post by Ocelot » Fri Aug 18, 2017 11:23 am

Hi Boyce,

Here is a snapshot of my current list definition.

For RowID I have been packing that with int32, 0 - 1 - 2 -3 .... etc.

For Guid should I do nothing with it, no assignment of anything? Same question about RowID, should I not be packing it with numbers and do nothing with it?

My understanding of your comment is that I should add another row and, for example, call it var_guid that's my variableIDs.xxx that I am using.
List.png
List.png (17.63 KiB) Viewed 120 times
Thanks for the prompt response
Kyle Bruneau
Applications Engineer - MurCal Inc
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: Angelscript and GUIDs

Post by boyce » Fri Aug 18, 2017 12:45 pm

Yes, that's right. You do not have to do anything with RowID and Guid, and add your own column var_guid.
Boyce Schrack
Enovation Controls
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: Angelscript and GUIDs

Post by cconner_aie » Mon Sep 18, 2017 11:02 am

I had a question related this I've been meaning to ask.

If you click 'Refresh Columns' it adds these four rows. Based on your comment above about the RowID and Guid, should the Size and DataBuffer be left there as well? Or is it just RowID and Guid that is required?

Image
Coleby Conner
Controls Engineer, Anderson Industrial Engines
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Re: Angelscript and GUIDs

Post by Ocelot » Mon Sep 18, 2017 11:41 am

Hi cconner,

I ended up discovering that it doesn't seem to matter if the rowIDs etc. are present, the issue I was having was actually in my routine.

I am currently not using the table with RowID and Guid left alone, I have my own columns.
Kyle Bruneau
Applications Engineer - MurCal Inc
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: Angelscript and GUIDs

Post by boyce » Fri Sep 22, 2017 11:05 am

Shouldn't have to keep the Size and DataBuffer columns. I have seen lists that used the RowID and didn't keep the Guid column and they worked okay. The developer here that I asked said to leave the RowID and Guid columns but you will see that it is not always done.
Boyce Schrack
Enovation Controls