locked
How to exit the DSShost automatically after the program ended? RRS feed

  • Question

  •  

    Hi,

     

    I used MVPL to program accept a series of input from the computer and send the commands to the lego robot.

    After the commands executed, the user will exit the program which is simply the end of the MVPL "flow chart".

     

    However, after the program ended, the DSSHost window is still showing up.  Is there a way to close that DSSHost automatically after the MVPL code ends?

     

    The problem is, if a user forget to close it manually and launch the dsshost startup script again, it will prompt an error message which the user may have no clue what it is.

     

    Thanks for your help!

     

    DDT

    Monday, October 6, 2008 11:45 PM

Answers

  • I saw this message and thought I could solve the problem by writing a simple service to shut down the DSS node. That worked fine, but the Run dialog was still displayed, with a message at the bottom of the scrolling list to say that all the services were shutting down. So in a sense it solves your problem because you can run another instance of VPL, but on the other hand it is confusing because it looks like the VPL program is still running.

     

    This would be better handled by another activity in VPL. However, that won't happen until the next release so it will not help you right now.

     

    If I have time I will try to post my service on my blog. The key part of the code is very simple. Create a new service, add an operation (I called it Stop) and then set up a handler as follows:

     

    Code Snippet

            [ServiceHandler]
            public virtual IEnumerator<ITask> StopHandler(Stop stop)
            {
                // Waste of time, but send a response anyway
                stop.ResponsePort.Post(DefaultUpdateResponseType.Instance);

     

                // Send a Drop Process message to the Control Panel
                // and force the process to be killed
                ControlPanel.DropProcess drop = new ControlPanel.DropProcess();
                drop.Body.ExitProcess = true;
                ControlPanelPort.Post(drop);

     

                yield break;
            }

     

     

    Now you can add this service to your diagram and when you send it a Stop request the DSS node will shut down.

     

    Trevor

    Wednesday, October 8, 2008 4:53 PM

All replies

  • I saw this message and thought I could solve the problem by writing a simple service to shut down the DSS node. That worked fine, but the Run dialog was still displayed, with a message at the bottom of the scrolling list to say that all the services were shutting down. So in a sense it solves your problem because you can run another instance of VPL, but on the other hand it is confusing because it looks like the VPL program is still running.

     

    This would be better handled by another activity in VPL. However, that won't happen until the next release so it will not help you right now.

     

    If I have time I will try to post my service on my blog. The key part of the code is very simple. Create a new service, add an operation (I called it Stop) and then set up a handler as follows:

     

    Code Snippet

            [ServiceHandler]
            public virtual IEnumerator<ITask> StopHandler(Stop stop)
            {
                // Waste of time, but send a response anyway
                stop.ResponsePort.Post(DefaultUpdateResponseType.Instance);

     

                // Send a Drop Process message to the Control Panel
                // and force the process to be killed
                ControlPanel.DropProcess drop = new ControlPanel.DropProcess();
                drop.Body.ExitProcess = true;
                ControlPanelPort.Post(drop);

     

                yield break;
            }

     

     

    Now you can add this service to your diagram and when you send it a Stop request the DSS node will shut down.

     

    Trevor

    Wednesday, October 8, 2008 4:53 PM
  •  

    Thank you so much for your response.

     

    I will give it a try!

     

    (The other way I'm thinking..... In my launching scripts, I may be able to check if there is any DSShost.exe running and kill it before I launch a new one...... It's brutal, but it may work .........)

     

    Thanks!

    Thursday, October 9, 2008 10:40 PM