RobotStudio event

LoadModuleFromFile works on VC but not Controller


Hi,
I'm using RAB 5.12 and Robotware Version 5.12.0138.00
 
I have a button on my GUI which allows a user to load a module file from the controller (which would contain the path for a particular part) using the "GtpuOpenFileDialog".
 
Upon choosing a module, the program deletes all modules except the standard modules of the controller (BASE, user, LINKEDM) and my standard program modules (MainModule, Support).
 
It then loads the users module, obtains the procedure name inside it and replaces the text of the button with the routine name. It also updates a RAPID string with the name of the procedure also.
 
I've added extra commenting to help read code.
 
My dilema is...
 
The program WORKS PERFECT on the Virtual Controller.  I have tested on the VC by loading dummy modules into the controller and then using my app to check that it does indeed delete all of the unneccessary modules before loading in the users chosen module and updating the button text.
 
On the REAL FLEXPENDANT, the unneccessary modules are deleted (Part 1 of commented code below) but the loading of the user chosen module and the updating of the button text does not occur (Part 2 of commented code below)???? Why is this so???  Confused
 
Do i require some sort of delay before loading a module???
 
Any help would be grreatly apprecated.
 
 
 
Private Sub GtpuOpenFileDialog_Part_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GtpuOpenFileDialog_Part.Closed
'

Dim myTask As Task = aController.Rapid.GetTask("T_ROB1")

Dim myModules() As [Module]

Dim myroutines() As [Routine]

Dim LoadModule As String

Dim pos As Integer

Dim length As Integer

'

Dim rd_strRoutine As RapidData = DirectCast(Me.aController.Rapid.GetRapidData("T_ROB1", "MainModule", "strRoutine"), RapidData)

Dim strRoutine As RapidDomain.String = DirectCast(rd_strRoutine.Value, RapidDomain.String)

'

'If user answered 'OK' then...

If GtpuOpenFileDialog_Part.DialogResult = System.Windows.Forms.DialogResult.OK Then

'

'Part 1) Delete all modules except BASE, USER, MAINMODULE, SUPPORT, in task T_ROB1

'

' Get all modules in the T_ROB1

myModules = myTask.GetModules

'

'Delete all non-essential modules

For Each m As [Module] In myModules

  ' Delete module

  If m.Name <> "user" And m.Name <> "BASE" And m.Name <> "MainModule" And m.Name <> "Support" And m.Name <> "LINKEDM" Then

     m.Delete()

  End If

Next

'

'Part 2) If valid module chosen, Load Module and assign the chosen Routine to the Button label

'

'Find the name of loading module

length = Len(GtpuOpenFileDialog_Part.FileName)

pos = InStrRev(GtpuOpenFileDialog_Part.FileName, "/")

LoadModule = Mid(GtpuOpenFileDialog_Part.FileName, pos + 1, length - pos - 4)

'

If LoadModule <> "user" And LoadModule <> "BASE" And LoadModule <> "MainModule" And LoadModule <> "Support" And LoadModule <> "LINKEDM" Then

  'Load module

  myTask.LoadModuleFromFile(GtpuOpenFileDialog_Part.FileName, RapidLoadMode.Replace)

  '

  'Store routine name and use as text for button

  myModules = myTask.GetModules

  For Each m As [Module] In myModules

    If m.Name <> "user" And m.Name <> "BASE" And m.Name <> "MainModule" And m.Name <> "Support" And m.Name <> "LINKEDM" Then

      myroutines = m.GetRoutines

      For Each r As [Routine] In myroutines

        Button_Part.Text = r.Name

        Routine = r.Name

        'Update rapiddate strRoutine

        strRoutine.FillFromString(r.Name)

        rd_strRoutine.Value = strRoutine

      Next

    End If

  Next

    Else

      'Was not valid part, ensure its text is set as below

      Button_Part.Text = "No Part Selected"

      Routine = "No Part Selected"

      'Update rapiddata value

      strRoutine.FillFromString("No Part Selected")

      rd_strRoutine.Value = strRoutine

    End If

    '

End If

'

myTask.Dispose()

rd_strRoutine.Dispose()

'

End Sub

 

 

Regards,

 

BigM

Comments

  • Hi,
     

    Have you tried to put a temporally MessageBox in order to give some time to update this?

     

     

     
    Carlos Martinez
    ABB
  • Hi Carlos,
     

    Thanks for replying to my posts, I thought no one would Clap

     

    Not sure about a MessageBox but i have a 'WaitTime' function...

     

        'WaiTtime Routine
        Public Sub WaitTime(ByVal Seconds As Double)
            ' "Wait" for the specified number of seconds.
            Dim EndTime As Date = DateAdd("s", Seconds, Now)
            Do
            Loop Until Now >= EndTime
        End Sub

     

    I've added a delay of 2s after the deleting of modules (part 1) and for loading the new module (part 2).

     

    Haven't had an opportunity to test yet but I will let you know when I have.

     

    Regards,

    bigM