This TechTip is about automatically changing the HMI window when logout, or Auto logout occurs. This could be useful if you want to ensure that if a user with elevated privileges leaves the HMI without logging out then the HMI will return to a normal operating or information window. Auto logout enabled is set in the System tab of System Parameters Setting in EasyBuilder Pro. To achieve window change on logout or Auto logout, we’ll use a macro to check the value of LW 9222 – this is the system register holding the value of operable security classes. If a user with “Class A” privileges is logged in then LW 9222 will have a value of “1”, if a user with “Class B” privileges is logged in then the LW 9222 will have a value of “2”, if the user has “Class A” and “Class B” privileges, LW 9222 will have a value of “3” and so on. For the purposes of this demo, we’ll monitor the value of LW 9222 and when it is = to “0” then there is no user logged in. We’ll also monitor the window that the user is on to determine whether to drive the user to a different window. For the purposes of this demo there is a main window, “10” and 6 “protected” windows, “20, 21 & 22” with “Class A” restriction and “30, 31 & 32” with “Class B” restriction. The Macro code: macro_command main() // short currentclass // current class - anything other than 0 means a user is logged in short currentwindownumber // this is the current window number short newwindownumber // this is the new window we want to direct the user to if they logout or are autologged out GetData(currentclass, "Local HMI", LW, 9222, 1) // get the current class value GetData(currentwindownumber, "Local HMI", LW, 9050,1) // get current window number if currentclass==0 and ((currentwindownumber >= 20 and currentwindownumber <= 24) or (currentwindownumber >= 30 and currentwindownumber <= 34)) then // if the user is logged out and the currentwindow is 20 then... newwindownumber=10 // set newwindow to "10" SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 10 else end if // end macro_command The macro will run periodically, every 5 seconds since it is not that critical The “Window Change” is a PLC control object; we’re using local HMI word LW 100 here as the trigger address as referenced in the macro. As usual, we have a demo project for you to download.
For more information on TechTip: Window Change on Auto-Logout Weintek HMI talk to Lamonde Automation Ltd