2/14/2007 10:12 AM | |
Posts: 2 Rating:
|
WinCC generates alarms in Runtime through displaing messages in Message Window and signalling by sound from Global Script: #include "apdefap.h" int gscAction( void ) { #pragma code("Winmm.dll"); VOID WINAPI PlaySoundA (char* pszSound, char* hmode, DWORD dwFlag); #pragma code (); if ( (GetTagByte("status_z14")&0x2) || (GetTagByte("status_z15")&0x2)) PlaySoundA ("c:\\WINDOWS\\Media\\ding.WAV", NULL, 1); return 0; } [trigger of action : cyclic 5s.] What should I do to turn off the sound: Single message is acknowledged, bit is still set (e.g. 0x2), but sound shouldn’t being playing. Usage acknowledgment tag is not permitted. It should be do by other way. |
2/14/2007 11:24 AM | |
Joined: 9/27/2005 Last visit: 11/27/2007 Posts: 1398 Rating:
|
You can use the Status Tag instead. This lets you monitor the status of the alarm and the acknowledge state. Or you could modify the GMsgFunction to check the alarm state. If it's "came in" then you play the sound. If it's "acknowledged" then you stop the sound. Sorry I don't have any example code for this. |
2/14/2007 11:27 AM | |
Posts: 20 Rating:
|
Hi! Have you tried to use "Status tag" of Group Messages in alarm logging? You can specify this tag in the properties dialog of group messages of some class (Alarm class, for example). In this case alarm logging sets and resets the specified bit in the status tag, depending on the presence of unacknowledged message of that class. You can check this bit and play the sound or stop to play it. Here is an example: [code]#include "apdefap.h" int gscAction( void ) { #pragma code ("Winmm.dll") VOID WINAPI PlaySoundA ( char* pszSound, char* hmode, DWORD dwflag ); #pragma code () // WINCC:TAGNAME_SECTION_START #define SoundEnabled "SoundEnabled" //this tag is set or reset by operator #define AlarmStatus "Alarm_status" //this tag is set by alarm logging. //bit 0x100 refers to presence of unacknowledged alarm, //bit 0x200 refers to presence of unacknowledged warning // WINCC:TAGNAME_SECTION_END char AlarmPath[100]="C:\\Somepath\\FastSiren.wav"; char WarningPath[100]="C:\\Somepath\\SlowSiren.wav"; int status; if (GetTagBit(SoundEnabled)) { status = GetTagWord(AlarmStatus); if (status & 0x100) //There are some unacknowledged alarms PlaySoundA (AlarmPath, NULL, 0x0009); //Play file continiously else if (status & 0x200) //There are some unacknowledged warnings PlaySoundA (WarningPath, NULL, 0x0009); //Play file continiously else PlaySoundA (NULL, NULL, 0x0002); //Stop playing file } else PlaySoundA (NULL, NULL, 0x0002); //Stop playing file return 0; }[/code] |