create a list and display it based on data from plc
Need some help,
I need to create a list of interlocks and display it on each drive screen. Right now this is done statically where all interlocks are static text boxes on each drive screen and I toggle their visibility by attaching it to a bit in the drives interlock mask/ Problem with this is that when the interlock is not visible, it creates a gap between visible interlocks (not very pleasant looking).
So what I’m trying to accomplish so that it loops through drives, loops through interlocks, creates a list of interlocks that apply to that drive and displays them on a screen for that drive… I’ll have to add interlock status and an alarm if the drive is being started with interlock "on", but that’s for later.
I need help to point me in the right direction and in terms of accessing values and creating a text boxes and accessing property of the text box in VBA
VBA Code:
Sub Drive_Latch_Interlock()
Dim i As Integer 'drive#
Dim j As Integer 'interlockBit#
Dim k As Integer 'temp_interlock#
'loop for number of drives that is dictated by config in PLC, max 16 drives
'NumDrvLatch is a PVI driver variable
For i = 0 To thisProject.Variables.Item("NumDrvLatch").Value - 1
'loop for number of interlocks, max possible number of interlocks is 16
For j = 0 To 15
'if interlock applies (0=applies, 1=not available) for drive i, Drive_Latch_Interlock_Mask[drive#] is a string array from PLC of 16 elements,
'Each array element contains a mask of 16 bits, Drive_Latch_Interlock_Mask[drive#] = jjjj_jjjj_jjjj_jjjj
If Not (thisProject.Variables.Item("Drive_Latch_Interlock_Mask.j").Value) Then
'then
'1 copy interlock name to a temp list for drive i
'Drive_Latch_Interlock_Text[0] = "Interlock 1"
'Drive_Latch_Interlock_Text[1] = "Interlock 2"
'.
'.
'Drive_Latch_Interlock_Text[15]= "Interlock 16"
thisProject.Variables.Item("Drive_Latch_Interlock_Text_Load[k]").Value = thisProject.Variables.Item("Drive_Latch_Interlock_Text[j]").Value
'2 increment position for temp_interlock#
k = k + 1
End If
'check for next interlock
Next j
'display the temp list of interlocks for drive i on screen_drive_i
'help here as well
'create k number of text boxes with thisProject.Variables.Item("Drive_Latch_Interlock_Text_Load[k]").Value text
'display each k text boxin vertical arrangement
'this is not dynamic, this is created and displayed once on screen open
'reinitilize temp interlock list for next drive
k = 0
'check for next drive
Next i
End Sub
Thanks
This is a migrated post! Originally posted on 01.05.2015 by user mkudin. Please be aware that information can be outdated.