Exemple #1
0
        public void Start()
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            try
            {
                engine = new NMEAProtocolEngine((double)settings["movement_threshold"].Value);
                if ((bool)settings["mirror"].Value)
                {
                    out_port        = application.GetPort(this, (string)settings["out_port"].Value);
                    out_port.Read  += new PortReadEvent(out_port_Read);
                    out_port.Error += new PortErrorEvent(out_port_Error);
                    out_port.Open();
                }
                in_port        = application.GetPort(this, (string)settings["in_port"].Value);
                in_port.Read  += new PortReadEvent(in_port_Read);
                in_port.Error += new PortErrorEvent(in_port_Error);
                bool bSucc = in_port.Open();
                if (!bSucc)
                {
                    application.LogMessage(this, "Error: Failed to open input port");
                }
            }
            catch
            {
                engine = null;
                if (in_port != null)
                {
                    in_port.Close();
                    in_port.Dispose();
                    in_port = null;
                }
                if (out_port != null)
                {
                    out_port.Close();
                    out_port.Dispose();
                    out_port = null;
                }
                throw;
            }
        }
        public void Stop()
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            in_port.Close();
            in_port.Dispose();
            in_port = null;

            if (out_port != null)
            {
                out_port.Close();
                out_port.Dispose();
                out_port = null;
            }

            engine = null;
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (in_port != null)
                    {
                        in_port.Dispose();
                        in_port = null;
                    }
                    if (out_port != null)
                    {
                        out_port.Dispose();
                        out_port = null;
                    }
                }
                application = null;
                config      = null;
                engine      = null;

                disposed = true;
            }
        }
		protected virtual void Dispose(bool disposing)
		{
			if (! disposed) 
			{
				if (disposing)
				{
					if (in_port != null)
					{
						in_port.Dispose();
						in_port = null;
					}
					if (out_port != null)
					{
						out_port.Dispose();
						out_port = null;
					}
				}
				application = null;
				config = null;
				engine = null;

				disposed = true;
			}
		}
		public void Stop()
		{
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);

			in_port.Close();
			in_port.Dispose();
			in_port = null;

			if (out_port != null)
			{
				out_port.Close();
				out_port.Dispose();
				out_port = null;
			}

			engine = null;
		}
		public void Start()
		{
			if (disposed)
				throw new ObjectDisposedException(GetType().Name);

			try
			{
				engine = new NMEAProtocolEngine((double)settings["movement_threshold"].Value);
				if ((bool)settings["mirror"].Value)
				{
					out_port = application.GetPort(this, (string)settings["out_port"].Value);
					out_port.Read += new PortReadEvent(out_port_Read);
					out_port.Error += new PortErrorEvent(out_port_Error);
					out_port.Open();
				}
				in_port = application.GetPort(this, (string)settings["in_port"].Value);
				in_port.Read += new PortReadEvent(in_port_Read);
				in_port.Error += new PortErrorEvent(in_port_Error);
				in_port.Open();
			}
			catch
			{
				engine = null;
				if (in_port != null)
				{
					in_port.Close();
					in_port.Dispose();
					in_port = null;
				}
				if (out_port != null)
				{
					out_port.Close();
					out_port.Dispose();
					out_port = null;
				}
				throw;
			}
		}