Setting the User Level
The LUX.Machine maintains the user level. This user level can be changed, cleared, and overwritten by the application.
Get User Level
/**
* getUserLevel - get the active user's level
* @return {number} the active user's level
* */
// example
var userLevel = machine.getUserLevel();
PLC-Based User Level
Set User Level Variable
/**
* setUserLevelPV - set which PLC process variable to read the user level from
* @param {string} PV string to read the user level from
* */
// example
machine.setUserLevelPV('task:userLevelPV');
Clear User Level Variable
/**
* clearUserLevelPV - set the PLC process variable to read the user level from back to undefined
* this functionally reverts to App-based user level control
* */
// example
machine.clearUserLevelPV();
App-Based User Level
/**
* setUserLevel - set the active user's level
* @param {number} the active user's level
* */
// example
const USER_LEVEL_X = 10;
machine.setUserLevel(USER_LEVEL_X);
-or-
<!-- include Loupe UX -->
<script src="libraries/loupe-ux/lux.js"></script>
<script src="libraries/loupe-ux/lux-data-bind.js"></script>
<!-- include app code where Loupe UX machine is instantiated -->
<script src="js/app.js"></script>
<!-- Set user level PV from html script -->
<script>window['machine'].setUserLevelPV('task:userLevelPV')</script>