sscott0203
Member
I've been working on a fairly large project for the last couple months and have come to a road block for the last week. I've spent countless hours searching and trying different methods and after many failed attempts, I'm hoping a knowledgeable fresh set of eyes can help get me back on the right track.
I'm designing a FTView Studio SE display screen that displays railcars in our railyard, utilizing RFID scanners we're scanning the railcar to get it's car ID number into a database so we can determine the contents and insure it get's unloaded to the correct destination.
So I have a display that I had planned to use across all 5 HMI Clients throughout our plant, but do to issues, have decided its best for now to get it working for 1 client, as all 5 are not a requirement, but would be nice eventually.
When this Display loads, I'm querying a SQL database and populating this data into an array, this all works as it should.
I'm stuck in a couple places..
1. getting the VB Code to consistently fire on grouped polygon click event. I'm using the touch to set a tag to a new unload destination (works fine) and then trying to run VB code on that click to refresh my combo box railcar values (works 80% of them time) it's like the click isn't always recognized.
2. The Captions will update correctly when the display is loaded, and my combo boxes populate correctly using a SQL select statement and using the captions in my WHERE clause. However I have really struggled to get this to work when the display is already loaded, thinking it's because I'm writing the new value to the tag through VB and then attempting to read it and then update the caption. Not sure what I'm missing here...
This is my first display from scratch, I have wrote VB in the past in excel and access, but this is new to me and I'm self taught, so any advise will be greatly appreciated.
Attached is a snap shot of the display with some comments, sorry if this ends up being a long post, just wanted to be as detailed as possible.
1st attempt to get the captions to set correctly
Another attempt to get the captions to set correctly
I'm designing a FTView Studio SE display screen that displays railcars in our railyard, utilizing RFID scanners we're scanning the railcar to get it's car ID number into a database so we can determine the contents and insure it get's unloaded to the correct destination.
So I have a display that I had planned to use across all 5 HMI Clients throughout our plant, but do to issues, have decided its best for now to get it working for 1 client, as all 5 are not a requirement, but would be nice eventually.
When this Display loads, I'm querying a SQL database and populating this data into an array, this all works as it should.
I'm stuck in a couple places..
1. getting the VB Code to consistently fire on grouped polygon click event. I'm using the touch to set a tag to a new unload destination (works fine) and then trying to run VB code on that click to refresh my combo box railcar values (works 80% of them time) it's like the click isn't always recognized.
2. The Captions will update correctly when the display is loaded, and my combo boxes populate correctly using a SQL select statement and using the captions in my WHERE clause. However I have really struggled to get this to work when the display is already loaded, thinking it's because I'm writing the new value to the tag through VB and then attempting to read it and then update the caption. Not sure what I'm missing here...
This is my first display from scratch, I have wrote VB in the past in excel and access, but this is new to me and I'm self taught, so any advise will be greatly appreciated.
Attached is a snap shot of the display with some comments, sorry if this ends up being a long post, just wanted to be as detailed as possible.
Code:
Option Explicit
Public WithEvents RailyardTagGroup As TagGroup
Private Sub Display_AnimationStart()
On Error GoTo ErrHandler
If RailyardTagGroup Is Nothing Then
Set RailyardTagGroup = Application.CreateTagGroup(Me.AreaName)
'Create a tag group based on the Area that the Display is located in
RailyardTagGroup.Add ("Railcar\ID0")
'Controller Tags to determine the current API Code and Supplier for each Silo
RailyardTagGroup.Add ("[CLGX1]SILO1_Code")
RailyardTagGroup.Add ("[CLGX1]SILO1_ResinSupplier")
'Controller Tags to determine the current silo destination selected for each System
RailyardTagGroup.Add ("[CLGX2]Unload1_Destination")
'Set the Tag Group that was created above to Active
RailyardTagGroup.Active = True
End If
'Set the Database Connection String
Call SetDB2
'Refresh Controller Tags for each Silo's API Code Number and Supplier to insure Tag was placed on scan
RailyardTagGroup.Item("[CLGX1]SILO1_Code").RefreshFromSource
RailyardTagGroup.Item("[CLGX1]SILO1_ResinSupplier").RefreshFromSource
'Created text field labels that are set using the Captions through VB in order to get Controller Tag Values and use them for a SQL Where Clause when Querying the Database
lblSilo1Code.Caption = RailyardTagGroup.Item("[CLGX1]SILO1_Code").Value
lblSilo1Supplier.Caption = RailyardTagGroup.Item("[CLGX1]SILO1_ResinSupplier").Value
'Call the UserForms to refresh OnTrack Inventory and both Systems Combo Box Values (additional code within each UserForm)
Call RefreshTrackInventory
Call RefreshSys1ComboBox
Call RefreshSys2ComboBox
Exit Sub
ErrHandler:
ThisDisplay.Application.LogDiagnosticsMessage "FactoryTalk View VBA Error" & Err.Number & ":" & Err.Description
MsgBox ("Factory TalkView VBA Error" & Err.Number & ": " & Err.Description)
Resume Next
End Sub
1st attempt to get the captions to set correctly
Code:
Private Sub StrDisplay_Silo1Suppler_Sys1_Change()
On Error GoTo ErrHandler
ThisDisplay.lblSilo1Supplier.Caption = ""
RailyardTagGroup.Item("[CLGX1]SILO1_ResinSupplier").RefreshFromSource
ThisDisplay.lblSilo1Supplier.Caption = RailyardTagGroup.Item("[CLGX1]SILO1_ResinSupplier").Value
ErrHandler:
ThisDisplay.Application.LogDiagnosticsMessage "FactoryTalk View VBA Error" & Err.Number & ":" & Err.Description
MsgBox ("Factory TalkView VBA Error" & Err.Number & ": " & Err.Description)
Resume Next
End Sub
Another attempt to get the captions to set correctly
Code:
Private Sub grpSilo2Supplier_Sys1_Click()
Dim intChangeConfirm
Dim frm As frmEnterCode
Dim intEmptyConfirm
Set frm = New frmEnterCode
intChangeConfirm = MsgBox("Are you sure you want to assign a different Supplier to Silo 2?", vbExclamation + vbYesNo)
If intChangeConfirm = 6 Then
intEmptyConfirm = MsgBox("Have you confirmed that Silo 2 is EMPTY?", vbExclamation + vbYesNo)
If intEmptyConfirm = 6 Then
ThisDisplay.lblSilo2Supplier.Caption = ""
frm.InstanceTag = "Silo 2"
frm.PLCTag = "[CLGX1]SILO2_ResinSupplier"
frm.show
On Error Resume Next
Set frm = Nothing
RailyardTagGroup.Item("[CLGX1]SILO2_ResinSupplier").RefreshFromSource
lblSilo2Supplier.Caption = RailyardTagGroup.Item("[CLGX1]SILO2_ResinSupplier").Value
Call RefreshSys1ComboBox
Call RefreshSys2ComboBox
End If
End If
End Sub
Code:
'REFRESH SYSTEM 1 RAILCAR SELECTION COMBO BOX UPON A NEW SILO DESTINATION SELECTION/CLICK (Grouped Polygon's)
Private Sub grp_Sys1_Silo1_Click()
ThisDisplay.Sys1_RailcarSelection_ComboBox.Clear
Call RefreshSys1ComboBox
End Sub