AnsweredAssumed Answered

Challenge: Creating audible and visual alarm with a large amount of pi tags

Question asked by Kopko on Aug 8, 2017
Latest reply on Aug 8, 2017 by rdavin

Hello everyone,

I'm new here and starting to learn about ProcessBook.

 

My problem: I have 200 PI Tags that can assume two states: on and off (0 or 1). These PI Tags are distributed in 40 areas (around 5 PI tags for each area).

My objective: create a visual and audible alarm to alert when one PI Tag of a specific area change its value. Also, I want to give an option to the operator stop the audio alarm (but continue with the visual).

 

So my first idea is to make 40 multi-state rectangles that each one contains a expression with 5 PI_Tags like: { IF ‘tag’<> “on” AND ‘tag’<> “off” .... THEN “0” ELSE "1’" }.  And set different colors for the output 0 and 1.

The second thing that I did was search for an audible alarm with the option to desactive it. I got this:

 

[code] Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long)  As Long

Const SND_ASYNC = &H1

Const SND_NODEFAULT = &H2

Const SND_LOOP = &H8

Const sAlert = "notify.wav"

Const sAlert2 = "buzzer.wav"

Private Sub Graphic1_Click(ByVal lvarX As Long, ByVal lvarY As Long)

    'Stop audio alarm & hide stop icon

    PlaySound 0, 0, &H1

    ThisDisplay.Graphic1.Visible = False

End Sub

Private Sub Rectangle1_StateChanged(bCancelDefault As Boolean)

    If ThisDisplay.Rectangle1.GetMultiState.CurrentState = 1 Then

        PlaySound sAlert, 0, &H1 Or &H2 Or &H8

        PlaySound sAlert2, 0, &H1 Or &H2 Or &H8

        ThisDisplay.Graphic1.Visible = True

    End If

End Sub [/code]

 

But I have some doubts:

1) How can I make this button that is called "Graphic1" works properly? I want to show a popup saying which area is beeping and also a button to desactive the sound.

2) To make this work in real time I have to play the code or something like that? Or just declaring the Private Function is enough to start the code?

3) I tried the buzzer.wav but it seems that is not working.

4) I need to get a button with a macro?

 

Thanks a lot for your help.

Outcomes