Accessing file system domain
Hello all,
I want to access the file system domain through the Controller object. In the Flexpendant SDK userguide is written that I can do this as follows:
Private Acontroller As Controller
Private AFileSystem As FileSystem = Acontroller.FileSystem
When I 'build' the project there are no errormessages.
ABBCompTool compiles ok. On the Flexpendant (Virtual) I only get a white screen. No errormessages appear on the flexpendant.
What I have to do to get it right?
I want to use GetFilesAndDirectory to make a treelist for the operator to choose from. Does anyone have a working VB example?
Thanks
Comments
-
When you get the white screen that you describe, there is some problem with the way you are trying to use the SDK components. Usually you are getting a NullObjectException.
There are two basic approaches you can use:
1. Simply comment all of you code and see if you can at least get your UI components to display, then successively uncomment the code until the white screen returns.
2. Wrap all of your code in a Try/Catch block and catch the exception, then display it in a GTPUMessageBox.
By looking at your code above, it appears that you are not instantiating the controller object. You might try:
Private AController as New Controller
Russell Drown0 -
RussD,
Thanks for your reply.
I have tried the uncomment as you describe, untill I got my UI back.
I found out that it is in the definition of my objects. When I program it as:
Private Acontroller As Controller
Private AFileSystem As FileSystemDomain.FileSystemand fill the AFileSystem later on like this:
Region " ITpsViewActivation Members "
Sub Activate() Implements ITpsViewActivation.Activate
AFileSystem = AController.FileSystem
End Sub
#End RegionNow I can load my application without getting a white screen.
It looks like it is not allowed to define a filesystem object and to declare it directly in one single line.
0 -
Hello,
I've been trying to acces files in the RC from FP SDK, but can't seem to get it to work. So, now I have some questions:
- does GetFilesAndDirectory only work in RemoteDirectory?
- if so, how can I acces files outside the default directory?
- how do I set RemoteDirectory to a directory I want? I tried theFiles.RemoteDirectory="/hd0a/lasmod/" but get a nice crash (theFiles works correctly in getting RemoteDirectory string).
jan-jaap38768,9566203704Regards,
Jan-Jaap0 -
Hello,
Can someone help me with this problem? This functionality was OK on Virtual IRC5, but not on the real one.
Or is everybody celebrating carnaval ??
Regards,
Jan-Jaap0 -
I have experienced problems using RemoteDirectory and LocalDirectory as you are, despite the fact that they are shown as read/write properties.
It is useful to treat these properties as though they were environment variables with the following values:
RemoteDirectory = HOME dir of the active system on RC flash disk
LocalDirectory = TEMP dir on the FlexPendant's file system
You can use these values as a basis for forming a path to access files anywhere in the file system.
Using this information then, to access a file called "test.prg" in a folder called "Test" on the the root of /hd0a/, you can form the path in the following manner:
Dim strTestFile as String = "test.prg"
Dim ARemoteFile As String = ctrl.FileSystem.RemoteDirectory + "/../../Test/" + strTestFileOnce you have created a properly structured path in the form of a string, you can use this string as an argument to various methods in FileSystemDomain.
Note: the "/../" character sequence is used to move up one directory in the robot file system. Two instances of "/../", i.e. "/../../" retrieves the root of hd0a from the HOME directory.
RussD38777,6836574074Russell Drown0 -
Hello,
Itried your suggestions, and it works OK when loading RAPID modules, or getting/putting files. But when I want to test for the existence of a file, things don't go so smoothly. I tried two options:
Dim fileInf As ControllerFileSystemInfo() = TheFiles.GetFilesAndDirectories(TheFiles.RemoteDirectory + "/../../" + "lasmod/*.mod") and then test for the presence of any entries in fileInf. It remains empty.
If File.Exists(TheFiles.RemoteDirectory + "/../../" + "lasmod/<filename>.mod") = True Then
this doesn't work either, both when trying this path string as well as using /hd0a/lasmod/<filename>.mod. It always evaluates as false, whether the file exists or not.
So, my question is, what is the best way to test if a file exists?Regards,
Jan-Jaap0 -
Hello,
Is there anybody who has any good comments on my little problem? Or is it just to simple to answer?
Regards,
Jan-Jaap0 -
Copy the file to the local file system, then check if it exists. File.Exists("file") does not work for romote file.
0 -
Copy your file to the local file directory, then check if it exists.0
-
[QUOTE=jan-jaap]
Dim fileInf As ControllerFileSystemInfo() = TheFiles.GetFilesAndDirectories(TheFiles.RemoteDirectory + "/../../" + "lasmod/*.mod") and then test for the presence of any entries in fileInf. It remains empty.
([/QUOTE]
Hi.
When calling GetFilesAndDirectories you should only input the filename, and not the entire path since that information already exists in the TheFiles.RemoteDirectory property.
Hope this helps,
Johan.
0 -
Hi there,
Me too, I have to evaluate the existance of a file in the remote directory. As suggested by Alex Lu, I try to get a local copy of the file using:
GetFile(strRemoteFilePath, strLocalFilePath)
and then check the existance of the local file using:
System.IO.File.Exists(strLocalFilePath)
However, my application is having a pretty weird behaviour:
When strRemoteFilePath exists, everything goes fine; but when it doesn't, the method from which I call GetFile() just returns without completing the rest of instructions, showing no error message or crashing or anything.
I'm kinda desperate. Can anyone help me? Maybe jan-jaap found a way to check file existance?
Thanks in advance.
Yolanda Casas0 -
Hello Yolanda,
What I did was try to get the file using :
TheFiles.GetFile(RemoteDir + FileNameNew, LocalDir + FileNameNew)
where RemoteDir is hd0alasmod. If the file doesn't exist, there will be an error, which I handle in using:
On Error GoTo ErrGetFileFail
In the ErrGetFileFail part, I generate a GTPUmessagebox. This also works for the opposite: checking for file existance before overwriting the old file.
Hope you can use this info. If you have more problems, post your code.jan-jaap2006-5-12 8:15:9Regards,
Jan-Jaap0 -
Hello Jan-Jaap,
I followed your advice and include the GetFile sentence in a try-catch block (I use C#). I use the exception as a sign of the non-existance of the file and now I have my application up-and running. Thanks!
In case this can help someone, what puzzled me most was the fact that, before I added the try-catch, the unhandled exception didn't show up, and the method just returned at that point, without reaching the end. This happened because it was not a regular method, but a MessageBoxEventHandler and apparently in the Virtual Flexpendant the exceptions originated in these methods don't raise up (however, I think they actually do in the Real Flexpendant, forcing you to restart it!).
The moral of the story: don't forget to handle errors.
Regards,
Yolanda Casas0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings