AdvancedHMI Software

General Category => Open Discussion => Topic started by: sts69 on March 06, 2017, 09:39:42 PM

Title: Alarm Sound enabled/disabled per CheckBox
Post by: sts69 on March 06, 2017, 09:39:42 PM
Hello programmers,
is the following possible by code or similar?
I would like to activate / deactivate an acoustic alarm with a "CheckBox". The Alarm comes by DI Tag-address (for example, 10001).

This is certainly possible with a datasubscriber, I just do not know how :-(

Thank you for your support
Steffen
Title: Re: Alarm Sound enabled/disabled per CheckBox
Post by: Archie on March 07, 2017, 08:02:14 AM
- Add a Checkbox to the form
- Add a DataSubscriber
- Set PLCAddressValue to 10001
- Double click the DataSubscriber to get back to the code
- Enter this code:
Code: [Select]
if (e.ErrorID=0) AndAlso (e.Values IsNot Nothing) AndAlso (e.Values.Count>0) then
      If CheckBox1.Checked and e.Values(0)="True" then
          Dim player as New System.Media.SoundPlayer
          player.SoundLocation = ("C:\Windows\Media\Alarm01.wav")
          player.Play()
      End If
End If


You could also modify the SoundPlayer and give it an Enabled property.
Title: Re: Alarm Sound enabled/disabled per CheckBox
Post by: sts69 on March 07, 2017, 12:19:33 PM
Hello Archie,

Many Thanks. This works perfectly :-)

Steffen
Title: Re: Alarm Sound enabled/disabled per CheckBox
Post by: sts69 on March 07, 2017, 01:03:53 PM
"You could also modify the SoundPlayer and give it an Enabled property."

That would be great, but how does it work?

Steffen