wincc 常用脚本

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

DeactivateRTProject ();//退出系统
#pragma code("useadmin.dll")
#include"PWRT_api.h"
#pragma code()
char* CUser=NULL;
CUser=GetTagChar("@CurrentUser");
if (strlen(CUser)==0)
{
PWRTSilentLogin("operator","123456");//用户“operator",密码"123456”登录}
OpenPicture("@MAIN.pdl");
}
在画面中结合不同按钮来组态下面 C 操作
Login
Action for login (for example, "mouse click" event):
#pragma code ("useadmin.dll")
#include "PWRT_api.h"
#pragma code()
PWRTLogin('c');
Logout
Action for logout (for example, "mouse click" event):
#pragma code ("useadmin.dll")
#include "PWRT_api.h"
#pragma code()
PWRTLogout();
PWRTLogin 参数必须是CHAR 字符。

它指定了显示对话框的监视器。

如果只使用一个监视器,那么保留默认参数“c”或者指定“1”。

注意
可以使用PASSLoginDialog 函数来代替PWRTLogin 或者PWRTLogout 函数。

这个函数需要和函数PWRTLogin 相同的参数。

PWRTLogin 和PASSLoginDialog 函数可以调用登录界面,在上面可以登录或者注销。

函数PWRTLogout 被正确执行并且不调用登录界面。

正确执行后这两个函数都返回“1”。

然而,登录不会等到显示对话框之后。

注意
如果使用多个显示器,为了能使登录对话框显示在合适的显示器上,需要WinCC Basic Process Control (OS项目编辑器)。

不使用WinCC Basic Process Control 时,可以指定显示器编号,但登录对话框始终显示在第一个显示器上。

#include"apdefap.h"//调用函数代码
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetVisible(lpszPictureName,"@ERROR",FALSE); //当前画面上有一个名称为"@ERROR"对象,将其隐藏。

FALSE或者0都可以
SetOperation(lpszPictureName,"@LoginIn",TRUE); //函数SetOperation是控制画面对象的可操作性
SetOperation(lpszPictureName,"@PasswordIn",TRUE);
SetOperation(lpszPictureName,"@OK",TRUE);
Set_Focus(lpszPictureName,"@LoginIn"); //次函数表示将光标重新聚焦到当前画面中,名称为“@Loginin”对象中SetVisible(lpszPictureName,lpszObjectName,FALSE);
SetVisible函数是用来执行是否显示的函数
在利用画面窗口实现画面切换中使用了SetPictureName函数
实现画面属性的更改使用了SetPropChar函数
SetPictureName("@MAIN.pdl", "Alarm", "AlarmList.pdl"); //调用MAIN中Alarm画面中的AlarmList画面
SetProp是一种函数,功能是增加一个新项,修改一个现有项。

实现画面属性的更改使用了SetPropChar函数
SetPropChar("@MAIN.pdl","Alarm","CaptionText","报警清单"); //更改MAIN中Alarm画面中标题属性为报警清单SetPropBOOL("@MAIN.Pdl","Alarm","Visible",1);} // MAIN画面中中Alarm对象属性被设置为1
SetVisible("@MAIN.pdl","LoginWindow",TRUE);
}
void Open_AI_Pannel(char *AI_Num,char *TagName,char *Unit) //定义变量//void *可以指向任何类型的数据//Open_AI_Pannel名称
{
char AI_TemplateName[80]; //80为最大字符长度
char str_Title[80];
char str_Unit[80];
char str_Loop_Name[80];
strcpy(AI_TemplateName,"AI_Template");//strcpy复制地址
strcat(AI_TemplateName,AI_Num); //strcat两个char类型链接
strcpy(str_Title,TagName);
strcat(str_Title," AI Loop Control Pannel");
SetPropChar("@MAIN.pdl",AI_TemplateName,"CaptionText",str_Title); //置为变量SetPropBOOL("@MAIN.pdl",AI_TemplateName,"Visible",0); //To make the Picture window NO visible //不显示
SetPropChar("@MAIN.pdl",AI_TemplateName,"TagPrefix",TagName); //Set the ObjectName as TagPrefix -???¨???¨?o
SetPropBOOL("@MAIN.pdl",AI_TemplateName,"Visible",1); //To make the Picture window visible ?-¨
strcpy(str_Unit , TagName);
strcpy(str_Loop_Name,TagName);
//SetPropChar("PID_Pannel.pdl","PidTitle","Text",TagName); //Set the title to the oject name
//SetText("PID_Pannel.pdl","Unit01",Unit);
//Unit_VL
//SetText("PID_Pannel.pdl","Unit02",Unit);
//Unit_VL
strcat(str_Unit,"._LOOP_UNIT"),
SetTagChar(str_Unit,Unit);
//SetPropWord("PID_Pannel.pdl","SetPointBarCtrl","RangeMin",PID_Zero);
//strcat(str_Zero,"._PID_ZERO");
//SetTagWord(str_Zero,PID_Zero);
//SetPropWord("PID_Pannel.pdl","SetPointBarCtrl","RangeMax",PID_Span);
//strcat(str_Span,"._PID_SPAN");
//SetTagWord(str_Span,PID_Span);
//SetPropWord("PID_Pannel.pdl","ProcessValueBarCtrl","RangeMin",PID_Zero);
//SetPropWord("PID_Pannel.pdl","ProcessValueBarCtrl","RangeMax",PID_Span);
strcat(str_Loop_Name,"._LOOP_NAME");
SetTagChar(str_Loop_Name,TagName); //str_Loop_Name=TagName
}
DOL电机脚本:
void Open_Motor_Pannel(char *Pannel_Num,char * Motor_Name)
{
//
char pannel_name[80];
char tagname[80];
char str_Title[80];
strcpy(pannel_name,"Motor_Template");
strcat(pannel_name,Pannel_Num);
//SetPropBOOL("@MAIN.Pdl",pannel_name,"Visible",0);
strcpy(tagname,Motor_Name);
strcat(tagname,"._MOTOR_NAME"); //._MOTOR_NAME模版变量名
SetTagChar(tagname,Motor_Name);
SetPropChar("@MAIN.pdl",pannel_name,"TagPrefix",Motor_Name); //TagPrefix变量前缀SetPropChar("@MAIN.pdl",pannel_name,"PictureName","Motor_Pannel.pdl");//画面名称
strcpy(str_Title,Motor_Name);
strcat(str_Title," MOTOR Control Pannel");
SetPropChar("@MAIN.Pdl", pannel_name,"CaptionText",str_Title);
SetPropBOOL("@MAIN.Pdl",pannel_name,"Visible",1); //让画面窗口可见
PID模版
void Open_PID_Pannel(char *PID_Num,char *TagName,char *Unit)
{
char PID_TemplateName[80];
char str_Title[80];
char str_Unit[80];
char str_Loop_Name[80];
strcpy(PID_TemplateName,"PID_Template");
strcat(PID_TemplateName,PID_Num);
strcpy(str_Title,TagName);
strcat(str_Title," PID Loop Control Pannel");
SetPropChar("@MAIN.pdl",PID_TemplateName,"CaptionText",str_Title); //±êìa??±? SetPropBOOL("@MAIN.pdl",PID_TemplateName,"Visible",0); //To make the Picture window NO
visible ?-??2??é??£??é2?ó?
SetPropChar("@MAIN.pdl",PID_TemplateName,"TagPrefix",TagName); //Set the ObjectName as TagPrefix -??μ?±?á??ó?°×o
SetPropBOOL("@MAIN.pdl",PID_TemplateName,"Visible",1); //To make the Picture window visible ?-é??
strcpy(str_Unit , TagName);
strcpy(str_Loop_Name,TagName);
//SetPropChar("PID_Pannel.pdl","PidTitle","Text",TagName); //Set the title to the oject name
//SetText("PID_Pannel.pdl","Unit01",Unit);
//Unit_VL
//SetText("PID_Pannel.pdl","Unit02",Unit);
//Unit_VL
strcat(str_Unit,"._LOOP_UNIT"),
SetTagChar(str_Unit,Unit);
//SetPropWord("PID_Pannel.pdl","SetPointBarCtrl","RangeMin",PID_Zero);
//strcat(str_Zero,"._PID_ZERO");
//SetTagWord(str_Zero,PID_Zero);
//SetPropWord("PID_Pannel.pdl","SetPointBarCtrl","RangeMax",PID_Span);
//strcat(str_Span,"._PID_SPAN");
//SetTagWord(str_Span,PID_Span);
//SetPropWord("PID_Pannel.pdl","ProcessValueBarCtrl","RangeMin",PID_Zero);
//SetPropWord("PID_Pannel.pdl","ProcessValueBarCtrl","RangeMax",PID_Span);
strcat(str_Loop_Name,"._LOOP_NAME");
SetTagChar(str_Loop_Name,TagName); //str_Loop_Name=TagName。

相关文档
最新文档