//-----------------------------------------------------------------------
//
// Copyright © 2012 Nils Hammar. All rights reserved.
//
//-----------------------------------------------------------------------
/*
* Software to access vehicle information via the OBD-II connector.
*
* Copyright © 2012 Nils Hammar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Alternative licensing is possible, see the licensing document.
*
* The above text may not be removed or modified.
*/
namespace SharedObjects
{
using System.IO;
using global::SharedObjects.Api;
using global::SharedObjects.CAN.Objects;
///
/// Various methods for event logging.
/// In no way the best logging, and with hindsight
/// Log4Net should have been selected.
///
public interface ILogging
{
///
/// Append a text with log level LOG_INFO.
/// Notice: The caller must supply line breaks.
///
/// Text to append.
void appendText(string txt);
///
/// Append a text with log level LOG_INFO.
/// Notice: The caller must supply line breaks.
///
/// Text to append.
void appendTextLn(string txt);
///
/// Append a text with log level LOG_INFO.
/// Notice: The caller must supply line breaks.
///
void appendTextLn();
///
/// Append a text with the given log level.
/// Notice: The caller must supply line breaks.
///
/// Text to append.
/// Logging level.
/// 'true' if execution can continue.
bool appendText(string txt, int logLevel);
///
/// Display contents of a message to/from the PassThru interface.
///
/// Prefix to use when displaying message, useful to distinguish between sent and received messages.
/// Message to display.
void dispMsg(string prefix, IPassThruMsg msg);
///
/// Display contents of a message to/from the PassThru interface.
///
/// Prefix to use when displaying message, useful to distinguish between sent and received messages.
/// Message to display.
/// Message address.
/// Message data.
void dispMsg(string prefix, IPassThruMsg msg, string addressStr, string data);
///
/// Test the result code for error and log.
///
/// Involved device.
/// Result code to test.
/// 'true' if execution can continue.
bool errTestDevice(IPassThruDevice passThruDevice, PassThruConstants.resultCode res);
///
/// Test the result code for error and log.
///
/// Related connection.
/// Result code to test.
/// 'true' if execution can continue.
bool errTestConnection(IPassThruConnection passThruConnection, PassThruConstants.resultCode res);
///
/// Test the result code for error and log.
///
/// Involved device.
/// Result code to test
/// Related error message (out data)
/// 'true' if execution can continue.
bool errTestDevice(IPassThruDevice passThruDevice, PassThruConstants.resultCode res, out string errtext);
///
/// Test the result code for error and log.
///
/// Related connection.
/// Result code to test
/// Related error message (out data)
/// 'true' if execution can continue.
bool errTestConnection(IPassThruConnection passThruConnection, PassThruConstants.resultCode res, out string errtext);
///
/// Get the writer for the data log (CSV format) file.
///
/// TextWriter instance
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Suitable in this case.")]
TextWriter getValueDataLogWriter();
///
/// Get the writer for the CAN data (ASC format) log.
///
/// TextWriter instance
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Suitable in this case.")]
TextWriter getCanDataLogWriter();
///
/// Add one row to the traffic table.
///
/// Traffic direction and layer level.
/// Address field.
/// Mode field.
/// PID field.
/// Payload length.
/// Payload data.
void addRow(rowMode direction, uint address, byte mode, uint pid, uint length, string rspStr);
///
/// Add raw log data to binary log file.
///
/// Binary object to write to file.
void addRawData(RawLogObject rawLogObject);
}
///
/// Log row modes.
///
public enum rowMode
{
///
/// Log raw in data.
///
transport_in,
///
/// Log raw out data.
///
transport_out,
///
/// Log Session layer in data.
///
session_in,
///
/// Log Session layer out data.
///
session_out,
///
/// Log formatted in data.
///
presentation_in,
///
/// Log formatted out data.
///
presentation_out,
///
/// Data discarded - no response sent.
///
data_discard,
}
///
/// Log levels.
///
public static class LogLevel
{
///
/// Error message.
///
public const int LOG_ERROR = 5;
///
/// Warning message.
///
public const int LOG_WARN = 4;
///
/// Information message.
///
public const int LOG_INFO = 3;
///
/// Debug message.
///
public const int LOG_DEBUG = 2;
///
/// Trace message.
///
public const int LOG_TRACE = 1;
}
}