Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        public void Play()
        {
            /*Ha engdélyezve van a törlés, akkor indulás előtt törli az előzményeket.*/
            if (_paramters.PlayHistoryClearEnabled)
            {
                _adapterStat.Reset();
                _messageStat.Default();
                _messageTrace.Clear();
                _filters.Default();
            }

            Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "()");

            _shutdownEvent       = new AutoResetEvent(false);
            _readyToDisposeEvent = new AutoResetEvent(false);



            uint baudrate = 0;

            if (_paramters.Baudrate.Contains("Custom"))
            {
                /*Baudrate = "B003D007 Custom Baud"*/
                baudrate = UInt32.Parse(_paramters.Baudrate.Remove(_paramters.Baudrate.IndexOf(@"Custom")).Trim(), System.Globalization.NumberStyles.HexNumber);
            }
            else
            {
                /*Baudrate = 5.000kBaud*/
                baudrate = CanBaudRateCollection.GetBaudRates().First(n => n.Name == _paramters.Baudrate).Value;
            }

            if (_paramters.DeviceName != VirtualDeviceName)
            {
                try
                {
                    _adapter = new CanAdapterDevice();
                    _adapter.ConnectTo(_paramters.DeviceName);
                    _adapter.Services.Reset();
                    _adapter.Attributes.ListenOnly            = _paramters.ListenOnly;
                    _adapter.Attributes.Loopback              = _paramters.Loopback;
                    _adapter.Attributes.NonAutoRetransmission = _paramters.NonAutoReTx;
                    _adapter.Attributes.Termination           = _paramters.Termination;
                    _adapter.Open(baudrate);
                    _statusUpdateTimestamp = 0;
                }
                catch (Exception)
                {
                    _adapter.Dispose();
                    OnStopped();
                    throw;
                }
            }
            else
            {
                _virtualAdapterFrameCounter = 0;
            }

            try
            {
                if (_project.Parameters.LogEnabled)
                {
                    _log = new LogFileItem(_project.Loaction, _project.FileName, DateTime.Now.ToString(AppConstants.FileNameTimestampFormat));
                    _log.Messages.AddToStorageBegin();
                }

                var th = new Thread(new ThreadStart(DoWork))
                {
                    Name     = "Adapter",
                    Priority = Settings.Default.AdapterThreadPriority
                };
                th.Start();
                _toolTables.SetTxQueue(_txQueue);
                _toolTables.Start();
            }
            catch
            {
                OnStopped();
                throw;
            }
        }
 protected override void OnClick(System.EventArgs e)
 {
     base.OnClick(e);
     _statistics.Reset();
 }