📄 protocolbase.h
字号:
/*
* Copyright (c), Philips Semiconductors Gratkorn / Austria
*
* (C)PHILIPS Electronics N.V.2000
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* Philips reserves the right to make changes without notice at any time.
* Philips makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. Philips must not be liable for any loss or damage
* arising from its use.
*/
/*! \file ProtocolBase.h
*
* Projekt: MF EV X00 Firmware
*
* $Workfile:: ProtocolBase.h $
* $Modtime:: 23.07.01 15:32 $
* $Author:: Hb $
* $Revision:: 13 $
*
*/
#ifndef PROTOCOLBASE_H
#define PROTOCOLBASE_H
#ifdef __cplusplus
extern "C" {
#endif
//----------------------------------------------------------------------------
// INCLUDES
//----------------------------------------------------------------------------
#include <windows.h>
//----------------------------------------------------------------------------
// PROTOTYPE DECLARATIONS
//----------------------------------------------------------------------------
class CommandObject;
/// Base class for protocol descriptions
/*!
* \ingroup hostrdcom
* Abstract base class for 'protocol classes'
* (e.g. RS232ProtocolSimple, IrDAProtocol, ...).
*/
class DLLEXP_IMP ProtocolBase
{
//----------------------------------------------------------------------------
// Member Functions
//----------------------------------------------------------------------------
public:
// Construction, destruction
ProtocolBase();
virtual ~ProtocolBase();
/// Send one command and wait for response
/*!
* \param CmdObject Command object, where the transmit/receive data is handled
* \param RxTimeout default 0\n
* If a value larger than 0 is provided, this parameter overrides the globally set Rx-Timeout
* periode.
* \param TxTimeout default 0\n
* If a value larger than 0 is provided, this parameter overrides the globally set Tx-Timeout
* periode.
* \return depends on the protocol implementation
*
* This function sends one command to the reader and waits
* for the response. The function defines a critical section
* for the communication and calls the protected member function
* <em>DoCommunicationWork</em>.
*/
virtual short SendCommand(CommandObject& CmdObject,
unsigned long RxTimeout = 0,
unsigned long TxTimeout = 0);
/// Reset protocol to default values
/*!
* After calling this function, the initial state should
* be reached.
*/
virtual short ResetProtocol(void) = 0;
/// Receive / Transmit Timeout Period
/*! \name Timeout
* Any Protocol should handle different timeout periods
* for receiving and transmitting data. The appropriate
* values are stored in this base class.
* <ul>
* <li> RxTimeout timeout until whole data block is received
* <li> TxTimeout timeout until whole data block is sent
* </ul>
*
* In order to provide a complete interface, the corresponding
* Get-functions are included.
*/
//@{
virtual short SetRxTimeout(unsigned long RxTimeout);
virtual unsigned long GetRxTimeout() const;
virtual short SetTxTimeout(unsigned long TxTimeout);
virtual unsigned long GetTxTimeout() const;
//@}
private:
//! protected copy constructor
ProtocolBase(const ProtocolBase& protocol_base) {};
//! protected overridden assignment operator
ProtocolBase& operator= (const ProtocolBase& protocol_base)
{ return *this;};
protected:
/// state machine for reader communication
/*!
* \param CmdObject Command object, where the transmit/receive data is handled
* \param RxTimeout If a value larger than 0 is provided, this parameter overrides the globally set Rx-Timeout
* periode.
* \param TxTimeout If a value larger than 0 is provided, this parameter overrides the globally set Tx-Timeout
* periode.
* \return depends on the protocol implementation
*
* This function implements the state machine, which is necessary
* to transmit and receive data packets.
*/
virtual short DoCommunicationWork(CommandObject& CmdObject,
unsigned long RxTimeout,
unsigned long TxTimeout) = 0;
/// Default timeout values after startup
enum TIMEOUTS { RX_TIMEOUT = 6000, // 6000ms
TX_TIMEOUT = 6000, // 6000ms
};
/// local storage for Timeout values
unsigned long m_RxTimeout;
unsigned long m_TxTimeout;
/// Critical Section for Reader communication.
/*!
* This semaphore variable is used, in order to provide a
* thread safe reader communication.
*/
HANDLE m_hIdleSemaphore;
};
#ifdef __cplusplus
}
#endif
#endif // PROTCOOLBASE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -