/// <summary>
        /// creates a new StationController instance with the given path to the sc interpreter
        /// </summary>
        /// <param name="scPath">path to the sc interpreter</param>
        public StationController(string scPath, int debugPort)
        {
            IsRunning  = false;
            _scProcess = new Process();
            _scPath    = scPath;
            for (int i = 0; i < 3; i++)
            {
                _debugPort         = debugPort;
                _scProcess.Exited += _scProcess_Exited;
                try
                {
                    _connector = new SocketConnector(debugPort);
                    break;
                }
                catch (SocketException)
                {
                    //port seems to be already in use
                    debugPort++;
                }
            }

            if (_connector == null)
            {
                throw new ApplicationException("Could not open port for debug socket connection");
            }

            _connector.ClientConnected    += StationControllerConnected;
            _connector.ClientDisconnected += StationControllerDisconnected;
            _connector.DataReceived       += StationControllerDataReceived;


            _connector.Start();
        }
 /// <summary>
 /// dispose method ensures that the process will be stopped if running
 /// </summary>
 public void Dispose()
 {
     if (_scProcess != null)
     {
         try
         {
             _scProcess.Kill();
         }
         catch { }
         _scProcess.Dispose();
         _scProcess = null;
         IsRunning  = false;
     }
     if (_connector != null)
     {
         _connector.Stop();
         _connector = null;
     }
 }