Help - Search - Members - Calendar
Full Version: PROBLEM WITH CITECT SOUND
Forums.MrPLC.com > PLCs and Supporting Devices > General Topics - The Lounge > HMI & SCADA
PIONEER
hello dear all,
as i am new in citect, in my project i have problem with citect sound.
i set an alarm in category 1 and when this tag is activated it must sound an wave file in a loop until the tag is deactivated.
i use a function in cicode as below:

FUNCTION
PlayAlarmSound()
INT I=1
WHILE I<>0 DO
DspPlaySound("C:\Program Files\Citect\CitectSCADA\User\JNL\Urgent.WAV",0);
Sleep(3);
END
END

in "alarm>alarm categories>on action" I entered PlayAlarmSound();
when i run the project and enable that tag, alarm sounds one time unwilling,because it must sound it a loop for ever.in hardware alarm an alarm accrues like this:
foreground cicode cannot block ........... sleep ........... PlayAlarmSound
my sound file length is about 1 second.

so what is my problem,what is going wrong?

Fredrix
Citect complains about the sleep() function, sleep() is a blocking cicode function, which means it blocks everything else in the same thread until it's finished. Running blocking functions in forground task (the task that shows you graphics) are not allowed of obvious reasons (would lock up graphics).

This is also a very bad way to do this, how do you plan to stop the sound? This will loop forever once it's started, and making infinite-loops are not a good idea!

If you need the sleep you should make a wrapper function, and use TaskNew() to call this function, also you should make some code to detect when the alarm goes back to normal, so you can stop the sound again
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.