FTView SE Tag Change VBA code

ASF

Lifetime Supporting Member
Join Date
Jun 2012
Location
Australia
Posts
3,921
Hi all,

I have an FTView SE application where I'm trying to get one of the clients to display a popup when the PLC turns on a bit. My understanding of how this should work is:

- Create a tag in the HMI tags section of Studio, and link it to this bit in the PLC
- Using VBA, define a tag group with events
- Add said tag to tag group
- In the TagGroup_Change section of the VBA code, check if the desired tag = 1. If it is then execute Application.ShowDisplay ("popup") and set the tag back to zero

I can't get it working. So I'm trying more and more basic things to troubleshoot where I'm going wrong, and well, I can't get anything to work!

Here's my code so far.


Public WithEvents TestTags As TagGroup

Public Sub Display_AnimationStart()
Dim TestLogicInt As Integer
If TestTags Is Nothing Then
Set TestTags = Application.CreateTagGroup(Me.AreaName, 1000)
TestTags.Add "{Utilities\TestBool}"
End If

TestTags.Item("{Utilities\TestBool}").Value = False
Elements.Item("text1").Caption = TestLogicInt

End Sub

Private Sub TestTags_Change(ByVal TagNames As IGOMStringList)
TestLogicInt = TestLogicInt + 1
Elements.Item("text1").Caption = TestLogicInt
Application.ShowDisplay ("popup")
End Sub

I'm trying to be really simple about it. On my test display I have a button, a numeric display, and some text. The button toggles the TestBool tag (which is a tag not tied to the PLC, just a local HMI tag for testing). Then my numeric display shows the state of the TestBool tag. When I go to test display, clicking the button makes the numeric display change from 1 to 0 and back again, so I know the tag is changing. Then, in the tag change sub, I increment 1 and set the text to display the current count. So if this was working, every time I clicked the button, the number shown in the text box would increment, but it doesn't. It increments once when the display first starts, and then stays at 1 from then on.

One other thing to note is that I'm doing all this from the development environment. But I have tied the alarm and event server and the HMI server to my local machine, and they're running happily (in grace mode). I know that I won't be able to actually call a display from the development environment, but if I can get it as far as an error saying "you can't do that in development environment", then I know my logic at least works :)
 
What screen is this code located on? The screen must be running for the code to be executed. It can be in the background though.
 
At the moment I'm just trying to make it work testing the display in the development environment. Once I get it working it'll be on a navigation panel that stays docked to the bottom of the screen.
 
Yes. Please read the last line of my original post.

At the moment I'll be happy if I can get it to process any code at all
on a tag change. Once I can make that work, calling the display is easy.
 
I don't see where you put the tag group on scan. I don't have my computer on at the moment, but I think it's something like taggroup.activate which you specify the rag scan rate.
 
Aha. Yes, I have to call TagGroup.Active = True.

That still didn't work, but digging through the help files a bit more told me that after I set it to Active, I have to use the TagGroup.RefreshFromSource command as well. That didn't work either, but I copied the example from the help file in, and that works, so now it's just a matter of working out what they've done that I haven't.

Thanks for the pointers!
 
Here's a late answer

Pasted from several locations, so hopefully, I didn't miss anything, but here's the code that works - I think you're missing the WithEvents in the tag declaration:

' *** Dim WithEvents needs to be done in the Declarations section!
Dim WithEvents tagGroup As TagGroup
Dim WithEvents tag1 As Tag

Private Sub Display_AnimationStart()

Set tagGroup = Application.CreateTagGroup(Me.AreaName, 1000)
With tagGroupSql
.Add "<tagpath>"
.Active = True
End With

Set tag1 = tagGroup.Item(<tagpath>)

End Sub

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

If Quality = tagQualityGood Then ' Ensure the tag quality is good.
If Value = "True" Then
Application.ShowDisplay "popup"
value = False
End If
End If

End Sub
 

Similar Topics

I want to set user security level based on the value of a tag in my PLC called "ActiveUser". That tag will contain the A-P code which we use for...
Replies
6
Views
205
Hi, I have an issue accessing tags in 3 of my plcs'. When I go to select a tag there is no folder drop down as can be seen in the photo. Any...
Replies
0
Views
83
Hi Guys, I know it's not a great product, but using it because of no choice. Was working on V10 without much gripes. Then came V12. I'm facing...
Replies
2
Views
1,199
Dear colleagues, I am reaching out for assistance with an issue I am having. I have a code that can successfully insert data from FactoryTalk...
Replies
6
Views
1,042
Does anyone know how to make the FT View Tag Browser Column with persistent? Every time I open the browser, I have to resize the Name column...
Replies
0
Views
633
Back
Top Bottom