資源描述:
《WinCC實現(xiàn)聲音報警的方法.doc》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在應用文檔-天天文庫。
1、#include"apdefap.h"intgscAction(void){#pragmacode("Winmm.dll")VOIDWINAPIPlaySoundA(char*pszSound,char*hmode,DWORDdwFlag);#pragmacode()if(GetTagByte("TI101")>100)??{PlaySoundA("C:\\ProgramFiles\\WindowsNT\\Pinball\\SOUND36.WAV",NULL,1);}return0;}報警可以用以下兩種實現(xiàn)方法
2、:1、建一個全局腳本,時基為2S#include"apdefap.h"intgscAction(void){#pragmacode("Winmm.dll")VOIDWINAPIPlaySoundA(char*pszSound,char*hmode,DWORDdwFlag);#pragmacode()if(GetTagByte("TAG")==1)????????????或????if(GetTagByte("TAG")>500)??{PlaySoundA("d:\ringout.wav",NULL,1);}return0;}
3、用以上程序就可以實現(xiàn)單個變量報警,開關量為1或模似量大于500都可以報警,用戶可以根據(jù)自己的情況改變以上數(shù)值,如果有多個變量可以增加多個if.2、通過報警記錄,先在報警記錄中組態(tài)好報警記錄建一個全局腳本,時基為2S#include"apdefap.h"intgscAction(void){MSG_RTDATA_STRUCTmRT;inti;char*pszToken;//Nowismycode#pragmacode("Winmm.dll")BOOLWINAPIsndPlaySoundA(char*szWave,DWORDdwF
4、lag);#pragmacode()DWORDSND_ASYNC=0x0001;DWORDSND_LOOP=0x0008;DWORDalarmsum,alarmunack;LPCMN_ERRORerrorunack,errorsum;#pragmacode("msrtcli.dll")#pragmacode()LPDWORDlpdwServiceID;MSG_SERVICE_NOTIFY_PROClpfnNotifyProc;LPMSG_FILTER_STRUCTlpMsgFilter;DWORDdwNotifyMask;LP
5、VOIDlpvUser;LPCMN_ERRORlpError;BOOLn1;n1=MSRTGetMsgQuit(&alarmunack,errorunack);SetTagDWord("number",alarmunack);MSRTGetMsgActual(&alarmsum,errorsum);SetTagDWord("sum",alarmsum);if(alarmsum==0)sndPlaySoundA(NULL,SND_ASYNC);else{if(alarmunack>0)sndPlaySoundA("C:\Pro
6、gramFiles\WindowsNT\Pinball\SOUND36.WAV",SND_ASYNC
7、SND_LOOP);elsesndPlaySoundA(NULL,SND_ASYNC);//sndPlaySoundA("C:\windows\media\office97\laser.wav",SND_ASYNC
8、SND_LOOP);}return1;}這個可以實現(xiàn)報警記錄中只要有報警發(fā)生,那么就觸發(fā)聲音報警。以上程序均已在WINCC5.1、WINCC6下運行通過