发布于 2012-03-27 08:22:17
1楼
你的上位机使用的是什么软件呢?wincc本身就包含这个功能,wincc的horn组件,或者wincc自己做脚本播放wav格式的文件,wav文件自己录制,你需要什么声音就录什么。
wincc全局脚本,触发周期为5s(根据你的声音文件播放需要的最长时间的那个来定)
#include "apdefap.h"
int gscAction( void )
{
#pragma code("Winmm.dll")
void WINAPI PlaySoundA(char* pszSound ,char* hmode,DWORD dwFlag);
#pragma code()
DWORD A1,A2,A3,A4,A5,A6,A7;
DWORD B1,B2,B3,B4,B5,B6,B7;
A1=GetTagDWord("YQ_ALARM_1");
A2=GetTagDWord("YQ_ALARM_2");
A3=GetTagDWord("YQ_ALARM_3");
A4=GetTagDWord("YQ_ALARM_4");
A5=GetTagDWord("YQ_ALARM_5");
A6=GetTagDWord("YQ_ALARM_6");
A7=GetTagDWord("COMM_ALARM");
B1=GetTagDWord("YQ_ALARM_SAVE_1");
B2=GetTagDWord("YQ_ALARM_SAVE_2");
B3=GetTagDWord("YQ_ALARM_SAVE_3");
B4=GetTagDWord("YQ_ALARM_SAVE_4");
B5=GetTagDWord("YQ_ALARM_SAVE_5");
B6=GetTagDWord("YQ_ALARM_SAVE_6");
B7=GetTagDWord("COMM_ALARM_SAVE");
if(
((A1^B1)&A1)
((A2^B2)&A2)
((A3^B3)&A3)
((A4^B4)&A4)
((A5^B5)&A5)
((A6^B6)&A6)
((A7^B7)&A7)
)
SetTagBit("yq_alarm_out",1);
if (GetTagBit("yq_alarm_out"))
PlaySoundA("c:\\winnt\\Media\\chord.wav",NULL,1);
SetTagDWord("YQ_ALARM_SAVE_1",A1);
SetTagDWord("YQ_ALARM_SAVE_2",A2);
SetTagDWord("YQ_ALARM_SAVE_3",A3);
SetTagDWord("YQ_ALARM_SAVE_4",A4);
SetTagDWord("YQ_ALARM_SAVE_5",A5);
SetTagDWord("YQ_ALARM_SAVE_6",A6);
SetTagDWord("COMM_ALARM_SAVE",A7);
return 0;
}
这是多个报警触发一个报警声音(变量yq_alarm_out)
活到老,学到老!为了生活学习吧!