版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、.用戶(hù)注銷(xiāo):#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogout();2.用戶(hù)登錄:#pragma code ("useadmin.dll")#include "PWRT_api.h"#pragma code()PWRTLogin('c');3.關(guān)閉項(xiàng)目并退出wincc:ExitWinCC ();4.退出運(yùn)行到wincc資源管理器:DeactivateRTProject ();按鈕變?nèi)N顏色#includ
2、e "apdefap.h" 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;一個(gè)調(diào)用按鈕變色#include "apdefap.h"
3、; long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)#pragma option(mbcs)if(GetTagWord("NewTag")=0)return 0x0000ff00;elsereturn 0x00ffffff;5.結(jié)束監(jiān)控并關(guān)閉計(jì)算機(jī)(會(huì)彈出確認(rèn)對(duì)話(huà)框)HWND hWnd = NULL;/Author:Smartsysint iRet;hWnd = FindWindow(NULL,"WinCC-運(yùn)行系統(tǒng) - ");iRet=Mess
4、ageBox(hWnd,"結(jié)束監(jiān)控并關(guān)閉計(jì)算機(jī)","關(guān)閉操作站",MB_YESNO|MB_ICONWARNING|MB_APPLMODAL);if(iRet=IDYES) DMExitWinCCEx (DM_SDMODE_POWEROFF);6.點(diǎn)擊事件彈出對(duì)話(huà)框,通過(guò)點(diǎn)擊彈出對(duì)話(huà)框的確定和取消按鈕實(shí)現(xiàn)對(duì)變量的置位或取消:int r;r=MessageBox(NULL, "YES為開(kāi),NO為關(guān)", "確定開(kāi)命令:", MB_YESNO |MB_SYSTEMMODAL);if (r=
5、IDYES)SetTagBit("TAGNAME",TRUE);elseSetTagBit("TAGNAME",FALSE);7.開(kāi)顯示關(guān)顯示:(要在內(nèi)部變量中建立三個(gè)二進(jìn)制變量COLSE_DISPLAY、DISPLAY_NO和DISPLAY_COMMENT)/ Funktion: Bit in Doppelwort setzen;if (GetTagBitWait("COLSE_DISPLAY")=1 )SetTagBit("COLSE_DISPLAY",0);SetTagBit("DISPLAY_NO
6、",0); /Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);else SetTagBit("COLSE_DISPLAY",1);SetTagBit("DISPLAY_NO",1); /Return-Type: BOOLSetTagBit("DISPLAY_COMMENT",0);8.開(kāi)閥確認(rèn):BOOL a;a=GetTagBit("30T制水啟動(dòng)"); /Return-Type :short intif
7、 (a=0)if(MessageBox(NULL,"真的要啟動(dòng)制水嗎?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) = 6) SetTagBit("30T制水啟動(dòng)",1);/Return-Type :BOOLelseif(MessageBox(NULL,"真的要停止制水嗎?","操作提示",MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL) =
8、6) SetTagBit("30T制水停止",1);9.將WinCC運(yùn)行畫(huà)面最小化HWND WinCCHwnd;WinCCHwnd=FindWindow(NULL,"WinCC-Runtime - "); /如果運(yùn)行語(yǔ)言為英文if (WinCCHwnd=0) WinCCHwnd=FindWindow(NULL,"WinCC-運(yùn)行系統(tǒng) - "); /如果運(yùn)行語(yǔ)言為中文CloseWindow(WinCCHwnd);10.顯示或不顯示(其中hiddVtext為內(nèi)部的二進(jìn)制變量)if(GetTagBit("hiddVtext&quo
9、t;)=0) /Return-Type: BOOLSetTagBit("hiddVtext",TRUE); /Return-Type: BOOL/Return-Type: BOOLelseSetTagBit("hiddVtext",FALSE);10.打開(kāi)編輯畫(huà)面的腳本#pragma option(mbcs)#ifdef RUN_ON_WEBNAVIGATOR#else HWND hExplorerWindow= NULL; HWND hRuntimeWindow= NULL;
10、; hExplorerWindow= FindWindow("WinCCExplorerFrameWndClass",NULL); hRuntimeWindow= FindWindow("PDLRTisAliveAndWaitsForYou",NULL); if(hExplorerWindow) ShowWindow(hExp
11、lorerWindow, SW_MINIMIZE); / This entry is only necessary for Windows 2000 ShowWindow(hExplorerWindow, SW_SHOWNORMAL); SetForegroundWindow(hExplorerWindow); else
12、0;printf("rn SetForeground failed");#endif11.如何在WINCC中制作一個(gè)保持型按鈕方法1:if( GetTagBit("M10") ) SetTagBit("M10",0);else SetTagBit("M10",1);方法2:SetTagBit("M1.0",(SHORT)!GetTagBit("M1.0");求反指令,如果為1點(diǎn)擊變?yōu)?,如果為0點(diǎn)擊變?yōu)?方法
13、3:或者做兩個(gè)按鈕,按鈕一:顯示,直接連接m1.0,是-不顯示,否-顯示 。事件,直接連接,源,常數(shù)1,變量M1.0;按鈕二:事件,直接連接,源,常數(shù)0,變量M1.0;用按鈕一覆蓋按鈕二12變量每秒加1DWORD a;a=GetTagDWord("Tank");a+=1;if(a>100) (a=0);SetTagDWord("Tank",a);return 0; WINCC動(dòng)畫(huà)腳本電機(jī)風(fēng)扇旋轉(zhuǎn)(幾何-起始角度):#include "apdefap.h" long _main(char* lpszPictureName
14、, char* lpszObjectName, char* lpszPropertyName)static DWORD f=20;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)") f= f+30;if (f=360) (f=0);return f;電機(jī)風(fēng)扇旋轉(zhuǎn)(幾何-結(jié)束角度):#include "apdefap.h" long _main(char* lpszPictureName, char* lpszObjectName, char* lp
15、szPropertyName)static DWORD i=80;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)") i = i+30;if (i=360) (i=0);return i; *物料水平右移動(dòng)(幾何-位置X)(停車(chē)后,物料回到原點(diǎn))*#include "apdefap.h" long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyN
16、ame)static int a=350;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)") && (a<=730) a+=20;if (a>=720) (a=350); if (!GetTagBit("DI電機(jī)運(yùn)行信號(hào)") (a=350); return a;物料水平右移動(dòng)(幾何-位置X)(停車(chē)后,物料停在該點(diǎn))#include "apdefap.h"
17、;long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)static int a=350;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)") && (a<=730) a+=20;if (a>=720) (a=350); return a; 物料向上移動(dòng)(幾何-位置Y)
18、(停車(chē)后,物料停在該點(diǎn))#include "apdefap.h" long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)static int b=450;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)") && (b>=290) b-=10;if (b<=280) (b=450); &
19、#160; return b;年月日(靜態(tài)文本)#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->
20、tm_year-100+2000,ptm->tm_mon+1,ptm->tm_mday);return(p); 時(shí)分秒(靜態(tài)文本)#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);sprin
21、tf(p,"%02d:%02d:%02d",ptm->tm_hour,ptm->tm_min,ptm->tm_sec); return(p);登陸到指定的用戶(hù)名無(wú)須手動(dòng)輸入(按鈕操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)#pragma code(&q
22、uot;useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用戶(hù)名", "口令"); *顯示登陸對(duì)話(huà)框無(wú)須熱鍵(按鈕操作)*#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)#pragma code (
23、"useadmin.dll")#include "PWRT_api.h"#pragma code( ) PWRTLogin('c'); 退出WINCC運(yùn)行(按鈕操作)#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y) DeactivateRTProject
24、();單位遞增按鈕(到上限不提示出錯(cuò))#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)DWORD value;value=GetTagDWord("AI標(biāo)簽"); if (value>90) (value=上限);else value=value+10;SetTagDWord("AI標(biāo)簽",value); 單位遞減按鈕(到下限不提
25、示出錯(cuò))#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)DWORD value;value=GetTagDWord("AI標(biāo)簽"); if (value<10) (value=下限);else value=value-10;SetTagDWord("AI標(biāo)簽",value); *單位遞增按鈕(到上限提示出錯(cuò))*#include &
26、quot;apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)DWORD value;HWND hWnd=NULL ; hWnd=FindWindow(NULL,"Wincc-運(yùn)行系統(tǒng)- "); value=GetTagDWord("AI標(biāo)簽"); if (value<=90) (value=value+10);else MessageBox(hWnd,"已到達(dá)上限值!&quo
27、t;,"錯(cuò)誤",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI標(biāo)簽",value); *單位遞減按鈕(到下限提示出錯(cuò))*#include "apdefap.h"void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)DWORD value;HWND hWnd=NULL ; hWnd=FindWindow(NULL,&q
28、uot;Wincc-運(yùn)行系統(tǒng)- "); value=GetTagDWord("AI標(biāo)簽"); if (value>0) (value=value-10);else MessageBox(hWnd," 已到達(dá)下限值!"," 錯(cuò)誤",MB_OK|MB_ICONWARNING|MB_APPLMODAL);SetTagDWord("AI標(biāo)簽",value); *自動(dòng)登陸到指定的用戶(hù)(畫(huà)面屬性-其它授權(quán))*#include "apdefap.h&quo
29、t; long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)#pragma code("useadmin.dll")#include "PWRT_API.H"#pragma code()PWRTSilentLogin("用戶(hù)名", "口令");return(0X0); *詢(xún)問(wèn)框(最好用于單機(jī)啟動(dòng),組啟也可,2個(gè)按鈕,NO不操作)*#include "apdefap.h"vo
30、id OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nFlags, int x, int y)HWND hWnd=NULL;int 上位啟動(dòng)信號(hào);hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI備妥")上位啟動(dòng)信號(hào)=MessageBox(hWnd,"電源已備妥,您現(xiàn)在確定要啟動(dòng)嗎?","啟動(dòng)!",
31、160; MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL);printf("rnExample 3rn"); if (上位啟動(dòng)信號(hào)=IDNO) (printf("User selected NO button rn"); else (SetTagByte("上位啟動(dòng)信號(hào)"
32、;,1);elseMessageBox(hWnd,"電源未備妥,請(qǐng)查證后重試!","啟動(dòng)!", MB_OK|MB_ICONHAND|MB_APPLMODAL);*詢(xún)問(wèn)框(最好用于單機(jī)啟動(dòng),組啟也可,3個(gè)按鈕,NO復(fù)位)*#include "apdefap.h"void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char* lpszProper
33、tyName, UINT nFlags, int x, int y)HWND hWnd=NULL;int上位啟動(dòng)信號(hào);hWnd=FindWindow(NULL,"WinCC C-Course");if (GetTagBit("DI備妥")上位啟動(dòng)信號(hào)=MessageBox(hWnd," 電源已備妥,您現(xiàn)在確定要啟動(dòng)嗎?","啟動(dòng)!",
34、160; MB_YESNOCANCEL|MB_ICONQUESTION|MB_APPLMODAL); if (上位啟動(dòng)信號(hào)=IDCANCEL) (printf("User selected NO button rn"); else
35、; if (上位啟動(dòng)信號(hào)=IDYES) (SetTagByte("上位啟動(dòng)信號(hào)",1); else (SetTagByte("上位啟動(dòng)信號(hào)",0); elseMessageBox(hWnd," 電源未備妥,請(qǐng)查證后重試!","啟動(dòng)
36、!", MB_OK|MB_ICONHAND|MB_APPLMODAL); *攪拌器左側(cè)扇頁(yè)(幾何寬度)*#include "apdefap.h" long _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)static int h=50;static int u=0;if (GetT
37、agBit("DI電機(jī)運(yùn)行信號(hào)")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電機(jī)運(yùn)行信號(hào)")h=50;u=0;return h;return u; *攪拌器左側(cè)扇頁(yè)(幾何位置X,右側(cè)扇頁(yè)沒(méi)有位置變化)*#include "apdefap.h" lo
38、ng _main(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)static int h=75;static int u=125;if (GetTagBit("DI電機(jī)運(yùn)行信號(hào)")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電機(jī)運(yùn)行信號(hào)")h=75;u=125;return h;r
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年湘師大新版八年級(jí)地理上冊(cè)月考試卷
- 中小金融機(jī)構(gòu)風(fēng)險(xiǎn)管理體系的薄弱問(wèn)題與挑戰(zhàn)
- 「海鮮天下」2025年海鮮餐飲合作合同范本3篇
- 2025年重慶市建筑安全員-C證考試(專(zhuān)職安全員)題庫(kù)附答案
- 研究生培養(yǎng)不同學(xué)科領(lǐng)域的差異化需求探索
- 2025年度現(xiàn)金借款合同收據(jù)制作與管理規(guī)范3篇
- 第15課《貨幣的使用與世界貨幣體系的形成》說(shuō)課稿-2023-2024學(xué)年高二上學(xué)期歷史統(tǒng)編版(2019)選擇性必修1國(guó)家制度與社會(huì)治理001
- 2024年專(zhuān)業(yè)美術(shù)教育機(jī)構(gòu)合作協(xié)議范本3篇
- 2024昆山版權(quán)許可合同許可使用范圍與許可條件的復(fù)雜規(guī)定
- 2024年岳麓版必修3英語(yǔ)上冊(cè)月考試卷含答案
- 錨桿錨索鉆機(jī)操作規(guī)程
- 《錄音技術(shù)與藝術(shù)》課程教學(xué)大綱
- 部編版七年級(jí)語(yǔ)文上下冊(cè)教材解讀分析精編ppt
- InternationalSettlementsLecture3InternationalClearingSystems
- (完整版)景觀園林工程施工規(guī)范和技術(shù)要求
- (完整版)六年級(jí)轉(zhuǎn)述句練習(xí)題
- 蘇武傳作文素材整理-
- 小學(xué)一年級(jí)班會(huì)課教案匯編 全冊(cè)
- 公司董事會(huì)、總經(jīng)理辦公會(huì)議事清單.docx
- 煤礦礦井供電設(shè)計(jì)(DOC26頁(yè))
- 中國(guó)鶴翔莊氣功之五站樁功
評(píng)論
0/150
提交評(píng)論