Password Protected Screens

This forum contains common answers to questions and tutorials produced for the community.
jbilleter
Posts: 87
Joined: Fri Oct 15, 2010 6:49 pm

Password Protected Screens

Post by jbilleter » Fri Feb 11, 2011 11:32 am

Is there a really good way to password protect screens? I know there is the method of using different views with key combinations (like the hidden menu access), but I am interested in setting up the main screen so that when you press one of the buttons, it would show a popup that would allow the user to enter a code. If the code is correct when the enter button is pressed, the PV750 would show the password protected screen. Thanks for any help that can be offered.
Jacob Billeter
Staff Engineer - MurCal, Inc.
jdgallaher
Enovation Controls Development
Enovation Controls Development
Posts: 9
Joined: Tue Sep 14, 2010 11:30 am

Re: Password Protected Screens

Post by jdgallaher » Fri Feb 11, 2011 8:21 pm

We just implemented a password protected screen using a four digit code. Here’s a short synoposis:

Create 4 “User Defined Variables”, one for each digit (i.e. UserDefinedVariable.Password1000sDigit). For each one create a calculation for increment, decrement, and reset.

Make a password entry menu on the Popup Layer, before you show this menu make sure you reset each of the password digits, otherwise the last password entered will show up. Create some views that show each digit, allow you to increment and decrement each password digit, move to the next digit, and an OK or Validate button.

To validate the password and jump to the next screen we wrote a script as follows:

Code: Select all

void $EventName ()
{
	uint digit = smGetHandle("UserDefinedVariable.Password1000sDigit");
	double temp;
	
	// get 1000s digit
	smRead(digit, temp);
	double password = temp * 1000;
	
	// get 100s digit and add to password
	digit = smGetHandle("UserDefinedVariable.Password100sDigit");
	smRead(digit, temp);
	password += temp * 100;
	
	// get 10s digit and add to password
	digit = smGetHandle("UserDefinedVariable.Password10sDigit");
	smRead(digit, temp);
	password += temp * 10;
	
	// get 1s digit and add to password
	digit = smGetHandle("UserDefinedVariable.Password1sDigit");
	smRead(digit, temp);
	password += temp;

	// get password stored in memory and compare
	digit = smGetHandle("UserDefinedVariable.Password");
	smRead(digit, temp);
	
	if( temp == password)	// success
		sendEvent(EventID("GoToProtectedScreen"));
	else	// failure
		sendEvent(EventID("GoToInvalidPasswordScreen"));
}