Load station from addin
mathias
✭
in RobotStudio
Hi, I am trying to load a station into robotstudio from an addin when robotstudio starts up, but I am not succeeding.
I have created an addin and configured the rsaddin configuration file with <Dependencies>None</Dependencies> to enable the addin to start immediately upon launching RobotStudio.
In order to give the RS environment some breathing space when starting I have hooked up a small state machine on the idle callback.
UIEnvironment.Idle += SequencedSetup;
I use this state machine to perform the load.
private static void SequencedSetup(object sender, EventArgs e)
{
Station station = null;
switch (state)
{
case 0:
if (Project.ActiveProject == null && !Station.IsLoading)
{
var ctrl = UIEnvironment.CommandBarControls["FileNewEmptyStation"];
var btn = ctrl as CommandBarButton;
btn.Execute();
}
if (Project.ActiveProject != null)
{
state++;
}
break;
case 1:
string path = AppData.Path + "\\RobotStudio\\Stations\\xxx.rsstn";
station = Station.Load(path, false);
state++;
break;
case 2:
if (!Station.IsLoading)
state++;
break;
case 3:
Project.ActiveProject = station;
UIEnvironment.Idle -= SequencedSetup;
break;
}
}
I am trying to get the Station.Load method to work. First, it seems that RS is unable to call the method unless there is a station previously loaded, I have solved this with a "hack", i.e. state 0, then the station is loaded in state 1, waiting for completion in state 2 and finally set as active in state 3. The code executes all states with no error message, but in later states the station does not load. If I load the station manually in RS it works. What am I doing wrong?
I have created an addin and configured the rsaddin configuration file with <Dependencies>None</Dependencies> to enable the addin to start immediately upon launching RobotStudio.
In order to give the RS environment some breathing space when starting I have hooked up a small state machine on the idle callback.
UIEnvironment.Idle += SequencedSetup;
I use this state machine to perform the load.
private static void SequencedSetup(object sender, EventArgs e)
{
Station station = null;
switch (state)
{
case 0:
if (Project.ActiveProject == null && !Station.IsLoading)
{
var ctrl = UIEnvironment.CommandBarControls["FileNewEmptyStation"];
var btn = ctrl as CommandBarButton;
btn.Execute();
}
if (Project.ActiveProject != null)
{
state++;
}
break;
case 1:
string path = AppData.Path + "\\RobotStudio\\Stations\\xxx.rsstn";
station = Station.Load(path, false);
state++;
break;
case 2:
if (!Station.IsLoading)
state++;
break;
case 3:
Project.ActiveProject = station;
UIEnvironment.Idle -= SequencedSetup;
break;
}
}
I am trying to get the Station.Load method to work. First, it seems that RS is unable to call the method unless there is a station previously loaded, I have solved this with a "hack", i.e. state 0, then the station is loaded in state 1, waiting for completion in state 2 and finally set as active in state 3. The code executes all states with no error message, but in later states the station does not load. If I load the station manually in RS it works. What am I doing wrong?
Tagged:
0
Comments
-
Update: it is possible to utilize StationServices.UnpackAndWork instead of Station.Load above. However, the "magic" initialization performed by pressing the FileNewEmptyStation is still necessary.0
-
Update: it seem now that the load has started to work partially (magic still needed). The controller is loaded. However, the graphics corresponding to the contained rslib is not loaded. Problem with paths in the rsstn file?
0 -
Hi Mathias,
To speed up startup, only portions of the RS code is loaded at launch. That is what the <Dependencies> element is for, and that is why the "magic" is needed.
But if all you want to do is open the station, you can just add the path to the command line.
Regards,
Johannes
Johannes Weiman
Software Engineer
RobotStudio Team, ABB Robotics0 -
I take it there is no possibility for the addin to be in charge of the setup process including station selection? Anyhow, I think I can make do with your suggested solution. Thanks for the answer!0
-
Not really. I'll note it as a suggestion though.Johannes Weiman
Software Engineer
RobotStudio Team, ABB Robotics0
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)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings