LoadModuleFromFile works on VC but not Controller
BigM
✭
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???
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
0
Comments
-
Hi,Have you tried to put a temporally MessageBox in order to give some time to update this?Carlos Martinez
ABB0 -
Hi Carlos,Thanks for replying to my posts, I thought no one wouldNot 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 SubI'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,bigM0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings