Exemplo n.º 1
0
 private void Logger_LogStop(object sender, LogStopEventArgs args)
 {
     this.filter.LogStop();
     if (this.logStop != null)
     {
         this.logStop(this, args);
     }
 }
Exemplo n.º 2
0
        private void EndMultipleReadCallback(IAsyncResult asyncResult)
        {
            byte[]             rawValues;
            Exception          exception  = null;
            InternalLogProfile oldProfile = (InternalLogProfile)asyncResult.AsyncState;

            try
            {
                rawValues = this.ecu.EndMultipleRead(asyncResult);
                oldProfile.StoreSsmValues(rawValues);
                if (this.LogEntry != null)
                {
                    this.LogEntry(this, oldProfile.LogEventArgs);
                }

                if (this.state == LoggerState.Logging)
                {
                    InternalLogProfile newProfile = this.internalProfile;
                    if (newProfile != oldProfile)
                    {
                        if (this.LogStop != null)
                        {
                            LogStopEventArgs stopArgs = new LogStopEventArgs(oldProfile.LogEventArgs.UserData);
                            this.LogStop(this, stopArgs);
                        }

                        if (this.LogStart != null)
                        {
                            this.LogStart(this, newProfile.LogEventArgs);
                        }
                    }

                    if (this.queryAddress != 0)
                    {
                        // Read a single value from the ECU before resuming logging.
                        int address = this.queryAddress;
                        this.queryAddress = 0;
                        this.ecu.BeginBlockRead(address, 4, QueryCallback, newProfile);
                    }
                    else
                    {
                        // Continue logging rows as usual.
                        this.ecu.BeginMultipleRead(newProfile.Addresses, EndMultipleReadCallback, newProfile);
                    }
                }
                else
                {
                    this.SetState(LoggerState.Stopped, "EndMultipleReadCallback", delegate
                    {
                        if (this.stopLoggingAsyncResult != null)
                        {
                            this.stopLoggingAsyncResult.Completed();
                            this.stopLoggingAsyncResult = null;
                        }
                    });

                    if (this.LogStop != null)
                    {
                        LogStopEventArgs stopArgs = new LogStopEventArgs(oldProfile.LogEventArgs.UserData);
                        this.LogStop(this, stopArgs);
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                exception = ex;
            }
            catch (IOException ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                Trace.WriteLine("SsmBasicLogger.EndMultipleReadCallback: Exception thrown from consumer's log event handler");
                LogErrorEventArgs args = new LogErrorEventArgs(exception);
                if (this.LogError != null)
                {
                    this.LogError(this, args);
                }

                this.SetState(LoggerState.Stopped, "EndMultipleReadCallback, exception thrown");
                if (this.LogStop != null)
                {
                    LogStopEventArgs stopArgs = new LogStopEventArgs(oldProfile.LogEventArgs.UserData);
                    this.LogStop(this, stopArgs);
                }

                if (this.stopLoggingAsyncResult != null)
                {
                    this.stopLoggingAsyncResult.Completed();
                    this.stopLoggingAsyncResult = null;
                }
            }
        }