FTView SE - VBA - Switchover to 2nd Server

Revnus

Member
Join Date
Aug 2019
Location
Brazil
Posts
71
I have a VBA on an alarm banner that calls a large number of pop-ups alarms based on changes of digital PLC tag value.

Problem is that when the HMI Server switchover from Server 1 to Server 2 it calls all active alarms popups again, even if operator already closed it.

I suspect that the value in VBA changes to 0 and goes back to 1 again, but I dont know how to fix it in VBA. (Not much experience on VBA).

Any ideas?

An example of the code:

Dim WithEvents oTag1 As Tag
Dim WithEvents oGroup As TagGroup
Dim Value As Variant
[Dim TimeStamp As Date
Dim Quality As TagQualityConstants
Dim SubStatus As tagSubStatusConstants
Dim Limit As tagLimitConstants

_________________

Private Sub Display_AnimationStart ()
Set oGroup = Application.CreateTagGroup(Me.AreaName, 500)
oGroup.Add "{/DATASERVER::[SHORTCUT]AlarmPop1}"
oGroup.Active = True
Set oTag1 = oGroup.Item("/DATASERVER::[SHORTCUT]AlarmPop1}")

End Sub

______________________

Sub oTag1_Change (ByVal Value, ByVal TimeStamp As Date, ByVal Quality As tagQualityConstants, ByVal SubStatus As tagSubStatusConstants, ByVal Limit As tagLimitConstants)

If Value = "True" Then
Application.ExecuteCommand "Display HMI_Alarm_Pop1"
Else
Application.ExecuteCommand "Abort HMI_Alarm_Pop1"
End if

End Sub
 
I don't know how the failover works, but I am pretty sure that, in the Display_AnimationStart subroutine, that that oTag1 Tag is actually a separate tag within VBA when it gets its data from the new server (see the oGroup.Add and oGroup.Item calls).

So what is needed is a "memory" of the value from the previous server, global in scope and persistent, e.g. summat like this
Dim AlarmPop1Value as Variant = "False" ''' Server-independent global value
near the top of that file, before the first Private Sub line, and then use that almost like a one-shot memory bit in the Sub oTag1_Change:
Code:
Sub oTag1_Change (ByVal Value, ByVal TimeStamp As Date, ByVal Quality As  tagQualityConstants, ByVal SubStatus As tagSubStatusConstants, ByVal  Limit As tagLimitConstants)

    If Value = "True" Then
        [COLOR=Blue][B]If AlarmPopup1 = "False" Then[/B][/COLOR]
            Application.ExecuteCommand "Display HMI_Alarm_Pop1"
        [COLOR=blue][B]End if[/B][/COLOR]
    Else
        [COLOR=Blue][B]If AlarmPopup1 = "True" Then[/B][/COLOR]
            Application.ExecuteCommand "Abort HMI_Alarm_Pop1"
[COLOR=blue][B]         End if[/B][/COLOR]
    End if

    [COLOR=blue][B]AlarmPopup1 = Value    ''' Save server-independent global value[/B][/COLOR]

End Sub
The new code is in bold blue above.

Caveats

  • I am only guessing.
  • This assumes the VBA environment is continuous, and does not start up each time, so the server-independent value is indeed global and persistent.
  • There might be an edge case if the value changes across the server switchover, but I don't think there is.
P.S. this might be simpler:
Code:
Sub oTag1_Change (ByVal Value, ByVal TimeStamp As Date, ByVal Quality As   tagQualityConstants, ByVal SubStatus As tagSubStatusConstants, ByVal   Limit As tagLimitConstants)

    [COLOR=Blue][B]If AlarmPopup1 = Value Then Return

[/B][/COLOR]    If Value = "True" Then
        Application.ExecuteCommand "Display HMI_Alarm_Pop1"
    Else
        Application.ExecuteCommand "Abort HMI_Alarm_Pop1"
    End if

    [COLOR=blue][B]AlarmPopup1 = Value    ''' Save new, [COLOR=Red]server-independent[/COLOR], global value[/B][/COLOR]

End Sub
 
Last edited:
Sorry for the late answer to your reply. Your idea worked! Allthought, I had to replace "Return" with "Exit Sub", because Return needs Go Sub, and VBA was halting.
Thank you
 

Similar Topics

Hi all. Currently I'm working on a VBa script for FTView. I would like to understand a bit better about some commands. 1) What are the...
Replies
3
Views
559
Hi all. I'm running a VBA code on my FTView which is actually working, but everytime I open the display that calls the VBA code, it throws the...
Replies
28
Views
1,665
Greetings, I have this question: How can I add a tag, in my case LS:0 {#5} (literal string of tag #5), to a variable using VBA? I couldn't find...
Replies
4
Views
874
Hello Every one, I need a help on vba code for getting data from MSSQL server 2014 to display in FTview SE client version 12 . Thanks. Please...
Replies
4
Views
1,751
I've been messing around with trying to find a way to clear all PlantPAx AOI latched alarms via the Alarm Banner or Summary objects. So far, I can...
Replies
2
Views
1,707
Back
Top Bottom