//-----------------------------------------------------------------------
//
// 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.Protocol
{
using global::SharedObjects.Api;
using global::SharedObjects.Protocol;
///
/// Interface to layer that acts as an intermediate between the API and the protocol handler.
///
public interface IMessageHandler
{
///
/// Glue method for error handler.
///
/// Result code.
/// Error text.
/// 'true' if execution can continue.
bool errTestConnection(PassThruConstants.resultCode res, out string errtext);
///
/// Get the payload part of the message with the header stripped off.
///
/// Message to get payload from.
/// Byte array with payload data.
byte[] getPayload(IPassThruMsg msg);
///
/// Perform a fast initialization. (Only KWP2000)
///
/// Protocol ID
/// Source address to use.
/// Result message from init.
/// Result status, 0=success.
PassThruConstants.resultCode IoctlFastInit(int protocolId, uint srcaddress, out IPassThruMsg result);
///
/// Perform a five baud initialization. (Only for ISO9141, KWP2000)
///
/// Target address.
/// Number of received bytes.
/// Keyword 1.
/// Keyword 2.
/// Result status, 0=success.
PassThruConstants.resultCode IoctlFiveBaudInit(uint target, out uint outBytes, out uint keyword1, out uint keyword2);
///
/// Gets locking object to handle concurrency when writing to raw log file.
///
object messageLockObject { get; }
///
/// Send the given message.
///
/// Message to send.
/// Status code from operation, 0=Success.
PassThruConstants.resultCode sendMessage(IPassThruMsg txmsg);
///
/// Configure the protocol handler for this message handler.
///
/// Protocol handler instance.
void setProtocolCallback(IMsgCallback protocolHandler);
///
/// Set the receiver of raw messages for this protocol handler.
/// Notice that the value may be 'null'.
///
/// Instance of raw data receiver.
void setRawReceiver(IRawReceiver rawReceiver);
///
/// Change the timeout value.
///
/// New timeout value.
void setTimeout(int timeout);
///
/// Starts a periodically sent message, e.g. for keep alive of a connection.
///
/// Message to send.
/// Message ID.
/// Status of action.
PassThruConstants.resultCode startPeriodicMessage(IPassThruMsg msg, out int msgId);
///
/// Start Message Listener thread.
///
void startThread();
///
/// Stops a periodically sent message.
///
/// ID of message to stop as provided by startPeriodicMessage()
void stopPeriodicMessage(int msgId);
///
/// Stop the Message Listener thread.
///
void stopThread();
}
}