报警可以用以下两种实现方法:
1、建一个全局脚本,时基为2S
#include "apdefap.h"
int gscAction( void )
{
#pragma code("Winmm.dll")
VOID WINAPI PlaySoundA(char* pszSound,char* hmode,DWORD dwFlag);
#pragma code( )
if (GetTagByte("TAG")==1) 或 if (GetTagByte("TAG")>500)
{PlaySoundA("d:\\ringout.wav",NULL,1);}
return 0;
}
用以上程序就可以实现单个变量报警,开关量为1或模似量大于500都可以报警,
用户可以根据自己的情况改变以上数值,如果有多个变量可以增加多个if .
2、通过报警记录,先在报警记录中组态好报警记录
建一个全局脚本,时基为2S
#include "apdefap.h"
int gscAction( void )
{
MSG_RTDATA_STRUCT mRT;
int i;
char* pszToken;
//Now is my code
#pragma code("Winmm.dll")
BOOL WINAPI sndPlaySoundA(char* szWave,DWORD dwFlag);
#pragma code()
DWORD SND_ASYNC=0x0001;
DWORD SND_LOOP=0x0008;
DWORD alarmsum,alarmunack;
LPCMN_ERROR errorunack,errorsum;
#pragma code("msrtcli.dll")
#pragma code()
LPDWORD lpdwServiceID;
MSG_SERVICE_NOTIFY_PROC lpfnNotifyProc;
LPMSG_FILTER_STRUCT lpMsgFilter;
DWORD dwNotifyMask;
LPVOID lpvUser;
LPCMN_ERROR lpError;
BOOL n1;
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:\\Program Files\\Windows NT\\Pinball\\SOUND36.WAV",SND_ASYNC|SND_LOOP);
else
sndPlaySoundA(NULL,SND_ASYNC);
//sndPlaySoundA("C:\\windows\\media\\office97\\laser.wav",SND_ASYNC|SND_LOOP);
}
return 1;
}
这个可以实现报警记录中只要有报警发生,那么就触发声音报警。