Author Topic: Scripting question - Trying to display violated zones in a list control  (Read 2880 times)

iostream212

  • Sr. Member
  • ****
  • Posts: 459
    • View Profile
I am trying to modify the script that listed all security zones from the Festive touchscreen example. I want to add a button to filter by normal and violated zones.  Changing a few things from the original script I am left with this:
Code: [Select]
try
{
Touchscreen.lstZoneNames.BeginUpdate();

// Set 'device' to the security device name.
device = security;

// Clear the zones list
Touchscreen.lstZoneNames.Clear();

// Get the zone names array from the selected security device.
names = security.ZoneNames;

// Loop over all the zone names and add the ones that aren't blank to the zones list.
for (zoneID=1; zoneID<names.Length; zoneID++)
{
// Get the name
name = names[zoneID];

// If the zone is violated
if ( ELKM1.ZonePhysicalStatuses[zoneID] == 2 )
{
// Add the name to the list, with the zone id as the value.
Touchscreen.lstZoneNames.Add( name + " - { security.ZonePhysicalStatusTexts[" + zoneID + "] }", zoneID);
}
}
}
finally
{
Touchscreen.lstZoneNames.EndUpdate();
}

My issue is that this takes ~2-3 seconds to execute while the original script is more instant. Is there a more efficient way for me to script this?
Thanks!
I always wanted to be somebody. In retrospect, I think I should have been more specific.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Scripting question - Trying to display violated zones in a list control
« Reply #1 on: January 06, 2012, 09:52:28 pm »
Try changing the following line:

if ( ELKM1.ZonePhysicalStatuses[zoneID] == 2 )

to

if ( security.ZonePhysicalStatuses[zoneID] == 2 )

John Hughes
Codecore Technologies

iostream212

  • Sr. Member
  • ****
  • Posts: 459
    • View Profile
Re: Scripting question - Trying to display violated zones in a list control
« Reply #2 on: January 07, 2012, 01:12:39 pm »
Thanks John. That shaved off about a second. Better than what it was. :)

Sent from my SCH-I510 using Tapatalk
I always wanted to be somebody. In retrospect, I think I should have been more specific.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Scripting question - Trying to display violated zones in a list control
« Reply #3 on: January 07, 2012, 02:48:14 pm »
Is it faster after repeated refreshes?  Once the values are cached in the touch screen viewer, it should be quicker.
John Hughes
Codecore Technologies

iostream212

  • Sr. Member
  • ****
  • Posts: 459
    • View Profile
Re: Scripting question - Trying to display violated zones in a list control
« Reply #4 on: January 15, 2012, 10:43:50 pm »
Seems to be about the same even after repeated refreshes. I don't notice it too much anymore. Been in use for a few weeks and I am used to it now. Thanks!

Sent from my SCH-I510 using Tapatalk
I always wanted to be somebody. In retrospect, I think I should have been more specific.