描述
WinCC可以根据登录用户权限级别响应动作…
指导
以下脚本查询是否拥有高级过程控制的权限。根据权限确定是否显示IO域。可以由任意信号触发该功能。本例通过左键点击按钮触发查询。
功能定义
Printout: BOOL PASSCheckAreaLevelPermission (LPCTSTR areaname, DWORD level);
LPCTSTR areaname:执行查询的屏幕画面。
DWORD level:查询的权限级别。
权限级别指定为数字。分配如下:
用户管理器中权限编号 |
名称 |
---|---|
5 | Operator process control |
6 | High process controlling |
1100 | Highest process controlling |
1101 | Extended operation 1 |
1102 | Extended operation 2 |
- 在过程画面中添加IO域。
- 通过”Object Properties > Properties > Miscellaneous > Display”隐藏IO域。
图. 01 - 添加查询按钮,在”Object Properties > Events > Mouse > Mouse Click”中插入C动作。
图. 02#include “apdefap.h”
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{BOOL Permission;
DWORD PermissionLevel = 6;Permission = PASSCheckAreaLevelPermission(lpszPictureName, PermissionLevel);
// If the authorization level is available, the top input field is displayed
if (Permission == 1)
SetPropBOOL(lpszPictureName, “EA-Feld1”, “Visible”, 1);// Otherwise the bottom input field is displayed
else
SetPropBOOL(lpszPictureName, “EA-Feld2”, “Visible”, 1);}
- 当拥有权限的用户左键点击此按钮时,显示上方IO域。
图. 03当没有权限的用户左键点击此按钮时,显示下方相应的IO域。
原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc322931.html