wincc脚本全集

合集下载

wincc 常用脚本

wincc 常用脚本

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 操作LoginAction for login (for example, "mouse click" event):#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');LogoutAction 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 相同的参数。

WINCC常用 脚本

WINCC常用 脚本
----------------------------------------------
11、在画面中显示用户名
1.组态静态文本
2.字体属性中的文本,连接系统变量@CurrentUser
----------------------------------------------
(2)新密码设置(C)
SetOutputValueChar(lpszPictureName,lpszObjectName,GetInputValueChar(lpszPictureName,lpszObjectName));
注:字符串格式的输入输出域》事件》属性主题》输出/输入》输出值》更改》以上代码。
{
MessageBox (Handle, "新密码和旧密码不能相同 !", "请重新输入密码", MB_OK |
MB_ICONEXCLAMATION | MB_SYSTEMMODAL);
}
else
{
// this 2 lines are necessary to get the DSN-Name of the project
a=MsgBox("hello!",vbYesNo)
If vbYes=a Then
objCon2.text="ok" '如点击是,则按钮文本变为ok
Else
objCon2.text="no" '如点击否,则按钮文本变为no
End If
注:放置按钮,起名按钮1.
----------------------------------------------

wincc常用C脚本功能

wincc常用C脚本功能

wincc常用C脚本功能.用户注销:#pragma code ("")#include ""#pragma code()PWRTLogout();2.用户登录:#pragma code ("")#include ""#pragma code()PWRTLogin('c');3.关闭项目并退出wincc:ExitWinCC ();4.退出运行到wincc资源管理器:DeactivateRTProject ();按钮变三种颜色#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){#pragma option(mbcs)if(GetTagWord("TX/ZSH001")==1)return 0x0000ff00;elseif(GetTagWord("TX/ZSL001")==1)return 0x000000ff;elsereturn 0x00c0c0c0;}一个调用按钮变色#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){#pragma option(mbcs)if(GetTagWord("NewTag")==0)return 0x0000ff00;elsereturn 0x00ffffff;}5.结束监控并关闭计算机(会弹出确认对话框)HWND hWnd = NULL;击事件弹出对话框,通过点击弹出对话框的确定和取消按钮实现对变量的置位或取消:int r;r=MessageBox(NULL, "YES为开,NO为关", "确定开命令:", MB_YESNO |MB_SYSTEMMODAL);if (r==IDYES)SetTagBit("TAGNAME",TRUE);elseSetTagBit("TAGNAME",FALSE);7.开显示关显示:(要在内部变量中建立三个二进制变量COLSE_DISPLAY、DISPLAY_NO和DISPLAY_COMMENT)阀确认:BOOL a;a=GetTagBit("30T制水启动"); WinCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow(NULL,"WinCC-Runtime - "); 示或不显示(其中hiddVtext为内部的二进制变量)if(GetTagBit("hiddVtext")==0) 开编辑画面的脚本#pragma option(mbcs)#ifdef RUN_ON_WEBNAVIGATOR#elseHWND hExplorerWindow= NULL;HWND hRuntimeWindow= NULL;hExplorerWindow=FindWindow("WinCCExplorerFrameWndClass",NULL);hRuntimeWindow=FindWindow("PDLRTisAliveAndWaitsForYou",NULL);if(hExplorerWindow){ShowWindow(hExplorerWindow, SW_MINIMIZE); 何在WINCC 中制作一个保持型按钮方法1:if( GetTagBit("M10") )SetTagBit("M10",0);elseSetTagBit("M10",1);方法2:SetTagBit("",(SHORT)!GetTagBit(""));求反指令,如果为1点击变为0,如果为0点击变为1方法3:或者做两个按钮,按钮一:显示,直接连接,是--不显示,否--显示。

wincc 全套脚本总结

wincc 全套脚本总结

} -------------------------------------
——————6、时间同步——————
void SetCpuTime() { #pragma code("kernel32.dll"); void GetLocalTime(SYSTEMTIME *lpst); #pragma code(); SYSTEMTIME time BOOL ret; //printf("Start function SetCpuTime\r\n"); GetLocalTime(&time); ret= SetTagMultiWait("%d%d%d%d%d%d%d",
"data_FLAG",1
) }
-------------------------------------
——————7、对话框调用——————
BOOL A; BOOL B; HWND hwnd=NULL; int RetMsg; A=GetTagBit("TJ_ANNIU"); //Return-Type: BOOL hwnd=FindWindow(NULL,"WinCC-运行系统 - "); if (A==0)
MB_OK|MB_SYSTEMMODAL|MB_SETFOREGROUND); SetTagBit("TJ_ANNIU",0);
} else B=0; } else { } ------------------------------------------
——————8、声音报警——————
#pragma code("Winmm.dll") VOID WINAPI PlaySoundA(char* pszSound,char* hmode,DWORD dwflag); #pragma code()

wincc中常用C脚本

wincc中常用C脚本

查看文章wincc常用C动作2010-06-27 10:311.用户注销:#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogout();2.用户登录:#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');3.关闭项目并退出wincc:ExitWinCC ();4.退出运行到wincc资源管理器:DeactivateRTProject ();5.结束监控并关闭计算机(会弹出确认对话框)HWND hWnd = NULL;//Author:Smartsysint iRet;hWnd = FindWindow(NULL,"WinCC-运行系统 - ");iRet=MessageBox(hWnd,"结束监控并关闭计算机","关闭操作站",MB_YESNO|MB_ICONWARNING|MB_APPLMODAL);if(iRet==IDYES)DMExitWinCCEx (DM_SDMODE_POWEROFF);6.点击事件弹出对话框,通过点击弹出对话框的确定和取消按钮实现对变量的置位或取消:int r;r=MessageBox(NULL, "YES为开,NO为关", "确定开命令:", MB_YESNO|MB_SYSTEMMODAL);if (r==IDYES)SetTagBit("TAGNAME",TRUE);elseSetTagBit("TAGNAME",FALSE);7.开显示关显示:(要在内部变量中建立三个二进制变量COLSE_DISPLAY、DISPLAY_NO和DISPLAY_COMMENT)// Funktion: Bit in Doppelwort setzen;if (GetTagBitWait("COLSE_DISPLAY")==1 ){SetTagBit("COLSE_DISPLAY",0);SetTagBit("DISPLAY_NO",0); //Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);}else{SetTagBit("COLSE_DISPLAY",1);SetTagBit("DISPLAY_NO",1); //Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);}8.开阀确认:BOOL a;a=GetTagBit("30T制水启动"); //Return-Type :short intif (a==0){if(MessageBox(NULL,"真的要启动制水吗?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) == 6) { SetTagBit("30T制水启动",1);//Return-Type :BOOL}}else{if(MessageBox(NULL,"真的要停止制水吗?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) == 6) { SetTagBit("30T制水停止",1);}}9.将WinCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow(NULL,"WinCC-Runtime - "); //如果运行语言为英文if (WinCCHwnd==0) WinCCHwnd=FindWindow(NULL,"WinCC-运行系统 - "); //如果运行语言为中文CloseWindow(WinCCHwnd);10.显示或不显示(其中hiddVtext为内部的二进制变量)if(GetTagBit("hiddVtext")==0) //Return-Type: BOOL{SetTagBit("hiddVtext",TRUE); //Return-Type: BOOL//Return-Type: BOOL}else{SetTagBit("hiddVtext",FALSE);}10.打开编辑画面的脚本#pragma option(mbcs)#ifdef RUN_ON_WEBNAVIGATOR#elseHWND hExplorerWindow= NULL;HWND hRuntimeWindow= NULL;hExplorerWindow= FindWindow("WinCCExplorerFrameWndClass",NULL);hRuntimeWindow= FindWindow("PDLRTisAliveAndWaitsForYou",NULL);if(hExplorerWindow){ShowWindow(hExplorerWindow, SW_MINIMIZE); // This entry is only necessary for Windows 2000ShowWindow(hExplorerWindow, SW_SHOWNORMAL);SetForegroundWindow(hExplorerWindow);}elseprintf("\r\n SetForeground failed");#endif11.如何在WINCC中制作一个保持型按钮方法1:if( GetTagBit("M10") )SetTagBit("M10",0);elseSetTagBit("M10",1);方法2:SetTagBit("M1.0",(SHORT)!GetTagBit("M1.0"));求反指令,如果为1点击变为0,如果为0点击变为1方法3:或者做两个按钮,按钮一:显示,直接连接m1.0,是--不显示,否--显示。

Wincc常用C脚本及常用功能

Wincc常用C脚本及常用功能

打开用户管理器ProgramExecute("Passcs.exe");取消激活#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)HWND hwnd=NULL;int iRet;hwnd=FindWindow(NULL,"WinCC-运行系统- "); //获得句柄iRet=MessageBox(hwnd,"是否取消激活?","Deactivate",MB_OKCANCEL|MB_ICONW ARNING|MB_APPLMODAL);if(iRet==1)DeactivateRTProject (); //Return-Type: BOOL}关闭计算机#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)HWND hwnd=NULL;int iRet;hwnd=FindWindow(NULL,"WinCC-运行系统- ");iRet=MessageBox(hwnd,"是否关闭计算机?","ShutDown",MB_OKCANCEL|MB_ICONW ARNING|MB_APPLMODAL);if(iRet==1)DMExitWinCCEx(DM_SDMODE_SYSTEM);}====================================================================== 登陆代码:#pragma code(“useadmin.dll”)#include <pwrt_api.h>#pragma code()PWRTLogin (‘e’);====================================取消激活(Deactivate)DeactivateRTProject();======================================Wincc变量操作GetTagDWord(“变量名称”); 获取Wincc变量值SetTagDWord(“变量“,设定值);设置Wincc变量对文本读写操作写操作#include "apdefap.h"void OnLButtonUp(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)FILE* lpFile;char *shuzhu[6]={"tag_1","tag_2","tag_3","tag_4","tag_5","tag_6"};char* lpszStr;int i,j;lpszStr=SysMalloc(60); //Return-Type: void*lpFile = fopen("D:\\test.txt", "w+");for(i=0;i<6;i++){lpszStr=GetTagChar(shuzhu[i]);strcat(lpszStr,"\r\n");if(lpFile == NULL){ printf("can not open file\r\n"); return;}fprintf(lpFile, lpszStr);}SysFree(lpszStr);fclose(lpFile);}读操作#include "apdefap.h"void OnLButtonUp(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma option(mbcs)char* shuzhu[6]={"tag_1","tag_2","tag_3","tag_4","tag_5","tag_6"};char tmp[255];int i=0;int ChrNumLine=38;FILE *fp;fp=fopen("D:\\test.txt","r");if (fp==NULL){return;}else{rewind(fp);while(!feof(fp)){fgets(tmp,ChrNumLine,fp);SetTagChar(shuzhu[i],tmp);i++;}}fclose(fp);}画面窗口显示界面切换SetPictureName(lpszPictureName,"PicWindow_button","produce_manage_button.pdl"); SetVisible(lpszPictureName,"PicWindow_button",1);注:PicWindow_button是画面窗口名称;produce_manage_button.pdl是要显示的子画面。

WINCC动画脚本

WINCC动画脚本

WINCC动画脚本电机风扇旋转(几何---起始角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static DWORD f=20;if (GetTagBit("DI电机运行信号")) {f= f+30;if (f==360) (f=0);}return f;}电机风扇旋转(几何---结束角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static DWORD i=80;if (GetTagBit("DI电机运行信号")) {i = i+30;if (i==360) (i=0);}return i;}**物料水平右移动(几何---位置X)(停车后,物料回到原点)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}if (!GetTagBit("DI电机运行信号")) (a=350);return a;}物料水平右移动(几何---位置X)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}return a;}物料向上移动(几何---位置Y)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static int b=450;if (GetTagBit("DI电机运行信号") && (b>=290)) {b-=10;if (b<=280) (b=450);}return b;}年月日(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%04d/%02d/%02d",ptm->tm_year-100+2000,ptm->tm_mon+1,ptm->tm_mday); return(p);}时分秒(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec);return(p);}登陆到指定的用户名无须手动输入(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");}**显示登陆对话框无须热键(按钮操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code( )PWRTLogin('c');}退出WINCC运行(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){DeactivateRTProject ();}}单位递增按钮(到上限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {DWORD value;value=GetTagDWord("AI标签");if (value>90) (value=上限);else value=value+10;SetTagDWord("AI标签",value);}单位递减按钮(到下限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {DWORD value;value=GetTagDWord("AI标签");if (value<10) (value=下限);else value=value-10;SetTagDWord("AI标签",value);}**单位递增按钮(到上限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value<=90) (value=value+10);else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**单位递减按钮(到下限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value>0) (value=value-10);else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**自动登陆到指定的用户(画面属性--其它—**)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");return(0X0);}**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int 上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗?","启动!",MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);printf("\r\nExample 3\r\n");if (上位启动信号==IDNO) (printf("User selected NO button \r\n"));else (SetTagByte("上位启动信号",1));}elseMessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗?","启动!",MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPLMODAL);if (上位启动信号==IDCANCEL) (printf("User selected NO button \r\n"));else{if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));else (SetTagByte("上位启动信号",0));}}elseMessageBox(hWnd," 电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**搅拌器左侧扇页(几何—宽度)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static int h=50;static int u=0;if (GetTagBit("DI电机运行信号")) {if ((h>0)&&(h<=50)){(h-=2);return h;}if ((u>=0)&&(u<50)){(u+=2);return u;}u=0;h=50;return h;return u;}if (!GetTagBit("DI电机运行信号")){ h=50;u=0;return h;return u;}}**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {static int h=75;static int u=125;if (GetTagBit("DI电机运行信号")){if ((h>=75)&&(h<125)){(h+=2);return h;}if ((u<=125)&&(u>75)){(u-=2);return u;}u=125;h=75;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=75;u=125;return h;return u;}}**显示层按钮**SubX6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X6309X94AE2X0000X653E_OnLButtonDo wn(ByVal Item, ByVal Flags, ByVal x, ByVal y)Dim objScreenDim CountLayerSet objScreen = HMIRuntime.Screens("layer")For CountLayer=1 To 32 Step 1yers(CountLayer).Visible = vbFalseNextyers(n).Visible = vbTrueEnd Subn=层数+1初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){WinExec("PRTSCR.EXE -hardcopy",SW_SHOWNORMAL);}**一个圈代表电机两种状态**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){char* opentag="DI1电机运行信号";char* closetag="DI2电机运行信号";BOOL open,close;open = GetTagBit(opentag);close = GetTagBit(closetag);if (open)return CO_GREEN;if (close)return CO_BLUE; }。

最新WINCC脚本整理

最新WINCC脚本整理

切换按钮001 SetTagBit("TE_BOOL",!GetTagBit("TE_BOOL"));002 BOOL AA=GetTagBit("TE_BOOL");if(A) SetTagBit("TE_BOOL",0);Else SetTagBit("TE_BOOL",1);003 SetTagBit("TE_BOOL ",1-GetTagBit("TE_BOOL "));I O 域处的格式化输入输出在I/O域的输出值事件处的动作Float F_TAG;F_TAG =GetTagFloat("TE_FLOAT");return(F_TAG /100);WINCC运行画面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow("PDLRTisAliveAndWaitsForYou",NULL);CloseWindow(WinCCHwnd);WINDOWS中提供的标准对话框{ BOOL bool1;HWND Hwnd;int iRet;Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) Hwnd = FindWindow(NULL,"WinCC-运行系统- ");if (!Hwnd) printf("\r\nGetWinCC Handle Failed!");iRet=MessageBox(Hwnd,"确认合闸","确认对话框",MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);switch (iRet){case IDYES: printf("user do YES\r\n");SetTagBit("TE_QUEST",1);break;case IDNO: printf("user do NO\r\n");SetTagBit("TE_QUEST",0);break;case IDCANCEL: printf("user do CANCEL\r\n");break;}}本画框的功能是点击按钮的时候弹出windows询问对话框其中“确认合闸”为对话内容,对话框的名称为“确认对话框”用户不同显示不同的按钮你可以在用户管理器给每个用户不同的权限,使他们对按钮有不同的操作权,这是最简便的。

WINCC-C脚本大全

WINCC-C脚本大全

WINCC C脚本的标准函数 12009-08-06 17:04标准函数该系统包含标准函数。

可以按需要修改这些函数。

此外,还可以自己创建标准函数。

该系统包括一个标准函数集。

一、Alarm - 简短描述Alarm组包含控制WinCC报警控件的函数。

标准函数可用于工具栏中的每一个按钮。

这些函数可用来创建自定义工具栏,例如选择画面,或者定义控件上的设置。

1.void AcknowledgeMessage(DWORD MsgNr)函数,确认消息系统中带编号的消息,该编号被传递为参数。

使用标准函数操作WinCC报警控件的实例{//确认选择的报警记录消息AcknowledgeMessage(GetTagWord("U08i_Msg Nr"));}指定待确认的消息号。

在本例中是从变量读取的。

2.BOOL AXC_OnBtnArcLong(char* lpszPi ctureName, char* pszMsgWin)函数,在消息窗口中该函数表示消息存储在长期归档中。

使用标准函数操作WinCC报警控件的实例{// 跳转到WinCC报警控件中的第一条消息AXC_OnBtnMsgFirst("gs_alarm_00","Contro l1");}AXC_OnBtnMsgFirst函数参数:“gs_alarm_00”是在其中组态WinCC报警控件的画面的名称。

Control 1是WinCC报警控件的对象名。

3.BOOL AXC_OnBtnArcShort(char* lpszPic tureName, char* pszMsgWin)函数,在消息窗口中该函数表示消息存储在短期归档中。

使用标准函数操作WinCC报警控件的实例{// 跳转到WinCC报警控件中的第一条消息AXC_OnBtnMsgFirst("gs_alarm_00","Contro l1");}AXC_OnBtnMsgFirst函数参数:“gs_alarm_00”是在其中组态WinCC报警控件的画面的名称。

WINCC动画脚本集萃

WINCC动画脚本集萃

WINCC动画脚本集萃WINCC电机风扇旋转(几何---起始角度):#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static DWORD f=20;if (GetTagBit("DI电机运行信号")) {f= f+30;if (f==360) (f=0);}return f;}电机风扇旋转(几何---结束角度):#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static DWORD i=80;if (GetTagBit("DI电机运行信号")) {i = i+30;if (i==360) (i=0);}return i;}**物料水平右移动(几何---位置X)(停车后,物料回到原点)** #include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}if (!GetTagBit("DI电机运行信号")) (a=350);return a;}物料水平右移动(几何---位置X)(停车后,物料停在该点)#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}return a;}物料向上移动(几何---位置Y)(停车后,物料停在该点)#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int b=450;if (GetTagBit("DI电机运行信号") && (b>=290)) {b-=10;if (b<=280) (b=450);}return b;}年月日(静态文本)#include ""char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%04d/%02d/%02d",ptm->tm_year-100+2000,ptm->tm_mon+1,p tm->tm_mday);return(p);}时分秒(静态文本)#include ""char* _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min, ptm->tm_sec) ;return(p);}登陆到指定的用户名无须手动输入(按钮操作)#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code("")#include ""#pragma code()PWRTSilentLogin("用户名", "口令");}**显示登陆对话框无须热键(按钮操作)**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code ("")#include ""#pragma code( )PWRTLogin('c');}退出WINCC运行(按钮操作)#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){{DeactivateRTProject ();}}单位递增按钮(到上限不提示出错)#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value>90) (value=上限);else value=value+10;SetTagDWord("AI标签",value);}单位递减按钮(到下限不提示出错)#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value<10) (value=下限);else value=value-10;SetTagDWord("AI标签",value);}**单位递增按钮(到上限提示出错)**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value<=90) (value=value+10);else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**单位递减按钮(到下限提示出错)**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value>0) (value=value-10);else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**自动登陆到指定的用户(画面属性--其它—授权)**#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){#pragma code("")#include ""#pragma code()PWRTSilentLogin("用户名", "口令");return(0X0);}**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)** #include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int 上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗","启动!",MB_YESNO|MB_ICONQUESTION|MB_APPLM ODAL);printf("\\Example 3\\");if (上位启动信号==IDNO) (printf("User selected NO button \\"));else (SetTagByte("上位启动信号",1));}elseMessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗","启动!",MB_YESNOCANCEL|MB _ICONQUESTION|MB_APPLMODAL);if (上位启动信号==IDCANCEL) (printf("User selected NO button \\"));else{if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));else (SetTagByte("上位启动信号",0));}}elseMessageBox(hWnd," 电源未备妥,请查证后重试!","启动!", MB_OK|MB_ICONHAND|MB_APPLMODAL);}**搅拌器左侧扇页(几何—宽度)**#include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int h=50;static int u=0;if (GetTagBit("DI电机运行信号")){if ((h>0)&&(h<=50)){(h-=2);return h;}if ((u>=0)&&(u<50)){(u+=2);return u;}u=0;h=50;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=50;u=0;return h;return u;}}**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)** #include ""long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){static int h=75;static int u=125;if (GetTagBit("DI电机运行信号")) {if ((h>=75)&&(h<125)){(h+=2);return h;}if ((u<=125)&&(u>75)){(u-=2);return u;}u=125;h=75;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=75;u=125;return h;return u;}}**显示层按钮**SubX6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X630 9X94AE2X0000X653E_On LButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)Dim objScreenDim CountLayerSet objScreen = ("layer")For CountLayer=1 To 32 Step 1(CountLayer).Visible = vbFalseNext(n).Visible = vbTrueEnd Subn=层数+1初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**#include ""void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){WinExec(" -hardcopy",SW_SHOWNORMAL);}**一个圈代表电机两种状态**#include ""void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName){char* opentag="DI1电机运行信号";char* closetag="DI2电机运行信号";BOOL open,close;open = GetTagBit(opentag); close = GetTagBit(closetag); if (open)return CO_GREEN;if (close)return CO_BLUE;。

WINCC动画脚本集锦

WINCC动画脚本集锦

WINCC动画脚本电机风扇旋转(几何---起始角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static DWORD f=20;if (GetTagBit("DI电机运行信号")) {f= f+30;if (f==360) (f=0);}return f;}电机风扇旋转(几何---结束角度):#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static DWORD i=80;if (GetTagBit("DI电机运行信号")) {i = i+30;if (i==360) (i=0);}return i;}**物料水平右移动(几何---位置X)(停车后,物料回到原点)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}if (!GetTagBit("DI电机运行信号")) (a=350);return a;}物料水平右移动(几何---位置X)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int a=350;if (GetTagBit("DI电机运行信号") && (a<=730)) {a+=20;if (a>=720) (a=350);}return a;}物料向上移动(几何---位置Y)(停车后,物料停在该点)#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int b=450;if (GetTagBit("DI电机运行信号") && (b>=290)) {b-=10;if (b<=280) (b=450);}return b;}年月日(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%04d/%02d/%02d",ptm->tm_year-100+2000,ptm->tm_mon+1,ptm->tm_mday);return(p);}时分秒(静态文本)#include "apdefap.h"char* _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){time_t timer ;struct tm *ptm;char *p;time(&timer);ptm =localtime(&timer);p =SysMalloc(9);sprintf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec);return(p);}登陆到指定的用户名无须手动输入(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");}**显示登陆对话框无须热键(按钮操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code( )PWRTLogin('c');}退出WINCC运行(按钮操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){DeactivateRTProject ();}}单位递增按钮(到上限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value>90) (value=上限);else value=value+10;SetTagDWord("AI标签",value);}单位递减按钮(到下限不提示出错)#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;value=GetTagDWord("AI标签");if (value<10) (value=下限);else value=value-10;SetTagDWord("AI标签",value);}**单位递增按钮(到上限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName)DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value<=90) (value=value+10);else MessageBox(hWnd,"已到达上限值!","错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**单位递减按钮(到下限提示出错)**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){DWORD value;HWND hWnd=NULL ;hWnd=FindWindow(NULL,"Wincc-运行系统- ");value=GetTagDWord("AI标签");if (value>0) (value=value-10);else MessageBox(hWnd," 已到达下限值!"," 错误",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI标签",value);}**自动登陆到指定的用户(画面属性--其它—授权)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用户名", "口令");return(0X0);}**询问框(最好用于单机启动,组启也可,2个按钮,NO不操作)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){HWND hWnd=NULL;int 上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd,"电源已备妥,您现在确定要启动吗?","启动!",MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);printf("\r\nExample 3\r\n");if (上位启动信号==IDNO) (printf("User selected NO button \r\n"));else (SetTagByte("上位启动信号",1));}elseMessageBox(hWnd,"电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**询问框(最好用于单机启动,组启也可,3个按钮,NO复位)**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)HWND hWnd=NULL;int上位启动信号;hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI备妥")){上位启动信号=MessageBox(hWnd," 电源已备妥,您现在确定要启动吗?","启动!",MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPLMODAL);if (上位启动信号==IDCANCEL) (printf("User selected NO button\r\n"));else{if (上位启动信号==IDYES) (SetTagByte("上位启动信号",1));else (SetTagByte("上位启动信号",0));}}elseMessageBox(hWnd," 电源未备妥,请查证后重试!","启动!",MB_OK|MB_ICONHAND|MB_APPLMODAL);}**搅拌器左侧扇页(几何—宽度)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){static int h=50;static int u=0;if (GetTagBit("DI电机运行信号"))if ((h>0)&&(h<=50)){(h-=2);return h;}if ((u>=0)&&(u<50)){(u+=2);return u;}u=0;h=50;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=50;u=0;return h;return u;}}**搅拌器左侧扇页(几何—位置X,右侧扇页没有位置变化)**#include "apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName)static int h=75;static int u=125;if (GetTagBit("DI电机运行信号")){if ((h>=75)&&(h<125)){(h+=2);return h;}if ((u<=125)&&(u>75)){(u-=2);return u;}u=125;h=75;return h;return u;}if (!GetTagBit("DI电机运行信号")){h=75;u=125;return h;return u;}}**显示层按钮**SubX6309X94AE2X0000X0000_X6309X94AE2X0000X60C5_X6309X94AE2X00 00X653E_OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByValy)Dim objScreenDim CountLayerSet objScreen = HMIRuntime.Screens("layer")For CountLayer=1 To 32 Step 1yers(CountLayer).Visible = vbFalseNextyers(n).Visible = vbTrueEnd Subn=层数+1初始画面程序(画面空地--属性--事件--其它--打开画面--动作)**打印按钮**#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y){WinExec("PRTSCR.EXE -hardcopy",SW_SHOWNORMAL);}**一个圈代表电机两种状态**#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char*lpszPropertyName){char* opentag="DI1电机运行信号";char* closetag="DI2电机运行信号";BOOL open,close; open = GetTagBit(opentag); close = GetTagBit(closetag);if (open)return CO_GREEN;if (close)return CO_BLUE;。

wincc 脚本,实践可用

wincc 脚本,实践可用

1风机风叶c动作全局脚本触发器时间0.5s#include"apdefap.h"int gscAction( void ){#pragma option(mbcs)int a,b,c;b=GetTagWord("fdf");//风机风叶状态显示a=GetTagBit("i12");//风机运行反馈的I1.2if (a==1){b=b*2;if (b>4||b<1) b=1;}elseb=0;SetTagWord("fdf",b);return 0;}2 火焰状态全局vb 触发器时间0.5sOption ExplicitFunction actionDim a,b,c,d,ea=HMIRuntime.tags("huoyan2").Read 'plc变量火焰状态 0 1 2 3 b=HMIRuntime.tags("wc1").Read '火焰状态显示是内部变量16位无符号Select Case aCase 0HMIRuntime.tags("wc1").write 0Case 1b=b+1If b>2 Then b=1HMIRuntime.tags("wc1").write b'statementblock_1Case 2If b<4 Then b=4b=b*2If b>20 Then b=4HMIRuntime.tags("wc1").write b'statementblock_2Case 3If b<40 Then b=32b=b*2If b>128 Then b=32HMIRuntime.tags("wc1").write bCase ElseHMIRuntime.tags("wc1").write 0'statementblock_nEnd SelectEnd Function3 仓泵气阀开关状态显示这个在图形编辑器,圆属性的颜色属性c脚本触发时间0.25s#include"apdefap.h"long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) {#pragma option(mbcs)int a,b,c,d;a=GetTagWord("DB22_DW62");//plc 开关状态1 2 3 4SetTagBit("prec2",!GetTagBit("prec2")); //Return-Type: BOOLb=GetTagBit("prec2");//plc内部辅助变量这个运行的定义变量无法保存,所以要借用内部变量。

wincc全套脚本总结

wincc全套脚本总结

MessageBox (hwnd, "
", "
",
MB_OK|MB_SYSTEMMODAL|MB_SETFOREGROUND);
SetTagBit("TJ_ANNIU",0);
}
else B=0;
}
else
{
}
------------------------------------------
——————8
PlaySoundA("D:\\DCSDATA\\CG_wincc\\Horn\\alsndmgr.wav",NULL,1); -----------------------------------------------
——————9
BOOL-Q
32 -P
int a;int a1; a=GetTagBit("Q");a1=GetTagDWord("P"); if(a==1) { a1=a1+10; } if(a1>=100) {
"data_FLAG",1
) }
-------------------------------------
——————7
BOOL A;
BOOL B;
HWND hwnd=NULL;
int RetMsg;
A=GetTagBit("TJ_ANNIU");//Return-Type: BOOL
hwnd=FindWindow(NULL,"WinCC-
齐釐tu齐高 0检 } =====================================================
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

——————1、wincc全局脚本动作-------隐藏控件——————#include "apdefap.h"int gscAction( void ){// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_ENDint value;value=GetTagBit("IM_in");//"IM_in"为触发的变量。

if(value==1){SetVisible("lianxi.pdl","按钮8",TRUE);//lianxi.pdl为控制对象所在画面名,“按钮8”为对象名称}else{SetVisible("lianxi.pdl","按钮8",FALSE);//lianxi.pdl}// WINCC:PICNAME_SECTION_START// syntax: #define PicNameInAction "PictureName"// next PicID : 1// WINCC:PICNAME_SECTION_ENDreturn 0;}=====================================================说明:在触发器里选择变量IM_in——————2、wincc全局脚本动作----提示框——————#include "apdefap.h"int gscAction( void ){// WINCC:TAGNAME_SECTION_START// syntax: #define TagNameInAction "DMTagName"// next TagID : 1// WINCC:TAGNAME_SECTION_ENDint value;value=GetTagBit("IM_in");if(value==1){MessageBox(NULL,"请确认三厅相关门是否关好,或者请解锁。

","提示框",MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);}// WINCC:PICNAME_SECTION_START// syntax: #define PicNameInAction "PictureName"// next PicID : 1// WINCC:PICNAME_SECTION_ENDreturn 0;}=============================说明:在触发器中选择变量触发。

——————3、趋势面板——————————char * str_a = NULL;int Hi;int Lo;str_a = GetTagChar("TrendTagName1");Lo= GetTagSWord("TrendLo");Hi= GetTagSWord("TrendHi");SetPropWord(lpszPictureName,"qushi","TrendIndex",0);SetPropChar(lpszPictureName,"qushi","TrendTagName",str_a);SetPropWord(lpszPictureName,"qushi","ValueAxisBeginValue",Lo);SetPropWord(lpszPictureName,"qushi","ValueAxisEndV alue",Hi); ——————————————————————————————4、获取位号————————SetTagChar("TrendTagName1","ProcessValueArchive\\PT111"); //Return-Type: BOOL SetTagSWord("TrendHi",200);SetTagSWord("TrendLo",0);SetTagByte("Trenden",1);——————————————————————————————5、调用登陆函数——————#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()if (strcmp(GetTagChar("@CurrentUser"),"")==0){PWRTLogin('c');-------------------------------------——————6、时间同步——————void SetCpuTime(){#pragma code("kernel32.dll");void GetLocalTime(SYSTEMTIME *lpst);#pragma code();SYSTEMTIME timeBOOL ret;//printf("Start function SetCpuTime\r\n");GetLocalTime(&time);ret= SetTagMultiWait("%d%d%d%d%d%d%d","data_year",time.wYear-2000,"data_month",time.wMonth,"data_day",time.wDay,"data_hour",time.wHour,"data_MINUTE",time.wMinute,"data_SECOND",time.wSecond,"data_FLAG",1)}-------------------------------------——————7、对话框调用——————BOOL A;BOOL B;HWND hwnd=NULL;int RetMsg;A=GetTagBit("TJ_ANNIU"); //Return-Type: BOOLhwnd=FindWindow(NULL,"WinCC-运行系统- ");if (A==0)RetMsg =MessageBox (hwnd, "确定要停机?", "停机警告", MB_OKCANCEL|MB_SYSTEMMODAL|MB_SETFOREGROUND);if (RetMsg==IDOK){SetTagBit("TJ_ANNIU",1);MessageBox (hwnd, "停机", "停机警告", MB_OK|MB_SYSTEMMODAL|MB_SETFOREGROUND);SetTagBit("TJ_ANNIU",0);}else B=0;}else{}------------------------------------------——————8、声音报警——————#pragma code("Winmm.dll")VOID WINAPI PlaySoundA(char* pszSound,char* hmode,DWORD dwflag);#pragma code()if(GetTagFloat("LIST555")>500)PlaySoundA("D:\\DCSDATA\\CG_wincc\\Horn\\Horn_Attention.wav",NULL,1);if(GetTagFloat("LIST555")<300)PlaySoundA("D:\\DCSDATA\\CG_wincc\\Horn\\alsndmgr.wav",NULL,1);-----------------------------------------------——————9、水平移动——————建立内部变量BOOL-Q,无符号32位-P全局动作int a;int a1;a=GetTagBit("Q");a1=GetTagDWord("P");if(a==1){a1=a1+10;}if(a1>=100){a1=0;SetTagDWord("P",a1);然后用一个按钮控制二进制变量Q,为启动信号。

物体的X位置对应的是变量P,设置为模拟量。

当P为1的时候对应的X位置。

P为2的时候对应X的位置,以此类推,就可以做出物体移动画面了,要做全局脚本-----------------------------------------------——————10、WinCC中调用SQL语言——————1、创建一个SQL文件,此文件在ISQL中建立,文件内包含所要执行的SQL语句。

Windows 对话框实现。

具体如下:2、在WinCC中用C Script 调用上述SQL文件,如下所示:#include&quot;apdefap.h&quot;void OnLButtonDown(char* lpszPictureName,char* lpszObjectName,char* lpszPropertyName,UINT nFlags,int x,int y){char*a=&quot;c:siemenscommonSQLANYISQL-q-b-cUID=DBA;PWD=SQL;DBF=E:testsqltestsqlRT.DB;DBN=CC_testsql_99-12-03-12:48:26R;READE:testsqltest.sql&quot;;Printf(&quot;%srn&quot;,a);ProgramExcute(a);}下面是一个简单的SQL文件内容:select *from pde#hd#t#test;output to e:test2.txt FORMAT ascii注意:文件名及路径中不要带空格。

相关文档
最新文档