Author Topic: Play Sound by digitalInput 1  (Read 3563 times)

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Play Sound by digitalInput 1
« on: September 22, 2013, 08:18:48 PM »
Hallo,
can play a Sound like "Alarm.wav" if the value from modbus tcp tag = 1 ?
I need this for audible Alert .
thank you

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Play Sound by digitalInput 1
« Reply #1 on: September 22, 2013, 08:48:19 PM »
One way to do this is to add a DataSubscriber to the form and set the PLCAddressValue. Double click the DataSubscriber and add this code:

if DataSubscriber1.Value="1" then
  My.Computer.Audio.Play("c:\alarm.wav")
End if

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Play Sound by digitalInput 1
« Reply #2 on: September 22, 2013, 09:51:03 PM »
Ohh, very fast :-)
i will test this tomorrow.
Thank You

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Play Sound by digitalInput 1
« Reply #3 on: September 23, 2013, 11:22:00 AM »
Hallo Archie,

i have tray this:

Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        If DataSubscriber1.Value = "1" Then
            My.Computer.Audio.Play("c:\Advanced HMI 2\AdvancedHMI\Resources\Alarm.wav")
        End If
    End Sub

but is no Sound playing after change the value from 0 to 1   :-(

THX
Steffen

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Play Sound by digitalInput 1
« Reply #4 on: September 23, 2013, 11:24:22 AM »
Put a break point at the first line "If DataSubscriber...." by clicking in the margin to the left. You will get a red dot to indicate the breakpoint. The run the application to see if the event fires.

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Play Sound by digitalInput 1
« Reply #5 on: September 23, 2013, 01:05:28 PM »
can you hereby do something?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Play Sound by digitalInput 1
« Reply #6 on: September 23, 2013, 03:24:53 PM »
It is definitely firing the event. When it reaches the breakpoint, hover the mouse over .Value and see what it equals at that point.

Then step through the code (F8 or F11 depending on your Visual Studio version) to see if it executes the play.

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Play Sound by digitalInput 1
« Reply #7 on: September 23, 2013, 04:05:36 PM »
yes thank you. the tip was great :-)
the value is retrieved correctly ("True" or "False"). I have modified then the value from "1" to "True", this Make it work. Simple!

many thanks again
Steffen