The following is a listing of the sample program for the External Alarm State Management API:
#include <inc_path/examgr.h>
#include <conio.h>
class CAMIPSample:public CExternalAlarmManager
{
public:
//overide
virtual void OnAlarmAck(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId);
virtual void OnAlarmClear(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId);
virtual void OnAlarmDel(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId);
virtual void OnShutdown();
virtual void OnInited();
void GenAlarms();
};
void CAMIPSample::OnAlarmAck(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId)
{
char response;
printf("Do you want to Ack Alarm ID %s, Resource %s, Ref ID %s",
alarmId, frId, refId);
response = getch();
printf("%c\n",response) ;
if (response == 'Y' || response =='y')
AckAlarm(alarmId,frId,refId);
}
void CAMIPSample::OnAlarmClear(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId)
{
char response;
printf("Do you want to Clear Alarm ID %s, Resource %s, Ref ID %s",
alarmId, frId, refId);
response = getch();
printf("%c\n",response) ;
if (response == 'Y' || response =='y')
ResetAlarm(alarmId,frId,refId);
}
void CAMIPSample::OnAlarmDel(LPCTSTR alarmId, LPCTSTR frId,
LPCTSTR refId)
{
char response;
printf("Do you want to Del Alarm ID %s, Resource %s, Ref ID %s",
alarmId, frId, refId);
response = getch();
printf("%c\n",response) ;
if (response == 'Y' || response =='y')
DeleteAlarm(alarmId,frId,refId);
}
void CAMIPSample::OnShutdown()
{
printf(_T("\nShutdown\n"));
}
void CAMIPSample::OnInited()
{
GenAlarms() ;
}
void CAMIPSample::GenAlarms()
{
GenerateAlarm("TEST1","R1",NULL);
GenerateAlarm("TEST2","R1",NULL);
GenerateAlarm("TEST3","R1",NULL);
GenerateAlarm("TEST4","R1",NULL);
GenerateAlarm("TEST5","R1",NULL);
GenerateAlarm("TEST6","R1",NULL);
GenerateAlarm("TEST7","R1",NULL);
GenerateAlarm("TEST8","R1",NULL);
GenerateAlarm("TEST9","R1",NULL);
GenerateAlarm("TEST10","R1",NULL);
}
void main(int argc,char **argv)
{
int i ;
CAMIPSample sample;
if (!sample.Start(TRUE))
{
printf("Error in Starting\nExiting ...");
exit(-1);
}
while(1)
{
Sleep(30 * 1000) ;
sample.GenAlarms() ;
}
}
Sample program. |