How Can We Help?

Print

Users, user groups and user logs

What you will build

The finished project has two groups, four users, group-protected controls, a login area and an operation log that shows who changed what.

Group Users Allowed to (example)
Operators Operator1, Operator2 Run the machine: start and stop, setpoints, recipe selection
Maintenance Tech1, Tech2 Everything Operators can do, plus settings screens, log export and log clearing

Names and rights are examples; replace them with your own. Give each user a unique password and do not keep any default password.

 

Before you start

Use User Permission for everything in this tutorial; it is the current user management of CommandHMI

  • User Permission (Project Manager > Setting > User Permission): named users and user groups. Use this one.
  • Set user password (HMI Parameter Settings): 8 fixed users with levels 1 to 8. This is the previous user management, kept for compatibility with older projects. Do not use it in new projects, and do not mix the two.

Create the two groups

Create the groups first, so they exist when you add the users.

  1. In the Project Manager, open Setting and double-click User Permission.
  2. Use Add user group and enter the name Operators
  3. Repeat for Maintenance
  4. Leave the default users and groups in place. The software does not allow deleting them.

Keep group names short: the HMI displays the current group through LW63200, which holds 32 characters.

 

Create the 4 users

Add each user in the same dialog and assign it to exactly one group.

  1. In User Permission, use Add user.
  2. Enter the user name and a password, then select the group.
  3. Repeat for the four users below.
  4. Confirm with OK and save the project.
  • LW60838~60853 displays the current login user name (ASCII length 32)
  • LW63200~63215

 

 

Restrict controls by group

Access is set per control (Bit switch, Word switch,..). The Advanced tab decides who can touch it, the Visibility tab decides who can see it.

  1. Add a control like Bit switch and open the Advanced tab.
  2. Enable the user-based control option and select the allowed groups.
    • Operator-level control: allow Operators and Maintenance
    • Maintenance-only control: allow Maintenance
  3. To hide a control instead of locking it, set the same option on the Visibility tab.

 

Only input controls have this option: bit button, word button, screen button, function button, multi-function button, multi-state button, numeric input, ASCII input, combo box, radio button, stepping button, slider and recipe selector. Display controls can only be hidden through the Visibility tab.

Login, logout and current user display

  • Login button : See “Function Button” Log on
  • Logout button: See “Function Button” Cancel user login
  • View of who is logged in
    • Current user name, ASCII Display, Monitor address LW60838, Total 32
    • Current group name, ASCII Display, Monitor address LW63200, Total 32

Place these four controls in a header that is visible on every screen; a public screen works well for this.

To log out from a script or from the PLC, set LB60133 to 1. The bit resets automatically once the logout is done.

Configure the operation log with historical log

We are going to use:

  • LW1000~1015 : user name to bewrite in log (32 ASCII characters, free-form field, to be adapted)
  • LW39900~39915 : copy of the previous user name (free-form field, to be adapted)
  • LW60838~60853 : user name of the logged-in user (32 ASCII characters, read-only)
  • LB1000 : Trigger for recording events
  1. Create a historical data log
  2. Specify the maximum number of logs you want (in this case, 50)
  3. Add the LB1000 as the recording trigger, with Auto-Reset

The script that will monitor changes to users or log-outs

#include "MacroInit.h"
//#include "subFun1.c" //Example
#define USER_NAME_ADDR 60838 // LW60838~60853 : user name of the logged-in user (32 ASCII characters, read-only)
#define PREV_NAME_ADDR 39900 // copy of the previous user name (free-form field, to be adapted)
#define LOG_TEXT_ADDR 1000 // LW1000~1015 : user name to bewrite in log (32 ASCII characters, free-form field, to be adapted)
#define USER_NAME_WORDS 16 // 32 char = 16 words
void Macro_main(IN *p)
{
MarcoInit
int i;
int changed = 0;
char logoutText[] = "User logout";
// Check if logged user changed
for (i = 0; i < USER_NAME_WORDS; i++) { if (LocalWord[USER_NAME_ADDR + i] != LocalWord[PREV_NAME_ADDR + i]) { changed = 1; LocalWord[PREV_NAME_ADDR + i] = LocalWord[USER_NAME_ADDR + i]; } } if (changed) { if (LocalWord[USER_NAME_ADDR] == 0) { // Logout : empty name -> fixed text
for (i = 0; i < USER_NAME_WORDS; i++)
{
LocalWord[LOG_TEXT_ADDR + i] = 0;
}
for (i = 0; logoutText[i] != 0; i++)
{
LocalWord[LOG_TEXT_ADDR + i / 2] |= (unsigned short)logoutText[i] << (8 * (i % 2));
}
}
else
{
// Login : copy of the user’s name
for (i = 0; i < USER_NAME_WORDS; i++)
{
LocalWord[LOG_TEXT_ADDR + i] = LocalWord[USER_NAME_ADDR + i];
}
}
// Trigger for recording events
LocalBit[1000] = 1;
}
}

 

Paste it in New script of the Script Editor, compil it, then call it every 500 ms.

and Add the Historical data display

To obtain this:

You can add switch user and log out buttons with bit buttons to test

You can dowload the project here