Sign in to follow this  
Followers 0
PIONEER

PROBLEM WITH CITECT SOUND

2 posts in this topic

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0