Load station from addin

mathias
mathias Lund, Sweden
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?

Comments

  • mathias
    mathias Lund, Sweden
    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.
  • mathias
    mathias Lund, Sweden
    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?
  • Johannes Weiman
    Johannes Weiman ABB Sweden admin
    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 Robotics
  • mathias
    mathias Lund, Sweden
    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!
  • Johannes Weiman
    Johannes Weiman ABB Sweden admin
    Not really. I'll note it as a suggestion though.
    Johannes Weiman
    Software Engineer
    RobotStudio Team, ABB Robotics