CigiIO Class Reference

#include <CigiIO.h>

List of all members.

Public Member Functions

 CigiIO (CigiIncomingMsg &InMsg, CigiOutgoingMsg &OutMsg)
virtual ~CigiIO ()
int Send (void)
int Receive (void)
int Recv (void)

Protected Member Functions

virtual int Write (Cigi_uint8 *Buffer, int Length)=0
virtual int Read (Cigi_uint8 *Buffer, int MaxLength)=0

Protected Attributes

CigiIncomingMsgMsgIn
CigiOutgoingMsgMsgOut


Detailed Description

The base class for Cigi IO.
This class must be inherited.

Definition at line 58 of file CigiIO.h.


Constructor & Destructor Documentation

CigiIO::CigiIO ( CigiIncomingMsg InMsg,
CigiOutgoingMsg OutMsg 
)

General Constructor

Definition at line 68 of file CigiIO.cpp.

References CigiOutgoingMsg::BeginMsg(), CIGI_SUCCESS, and MsgOut.

00069        : MsgIn(InMsg), MsgOut(OutMsg)
00070 {
00071    int stat = CIGI_SUCCESS;
00072 
00073    stat = MsgOut.BeginMsg();
00074 
00075 }

CigiIO::~CigiIO (  )  [virtual]

General Destructor

Definition at line 80 of file CigiIO.cpp.

00081 {
00082 
00083 }


Member Function Documentation

virtual int CigiIO::Read ( Cigi_uint8 Buffer,
int  MaxLength 
) [protected, pure virtual]

A pure virtual function to input the data.
This function is not implemented by this class.

Parameters:
Buffer - A pointer to the buffer to fill.
MaxLength - The maximum length allowed for the message in bytes.
Returns:
This returns the number of bytes in the message

Referenced by Receive(), and Recv().

int CigiIO::Receive ( void   ) 

Receive and processes a message

Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Definition at line 118 of file CigiIO.cpp.

References CigiIncomingMsg::AdvanceCrntBuffer(), CIGI_ERROR_MISCELLANEOUS, CIGI_SUCCESS, CigiIncomingMsg::GetMsgBuffer(), CigiIncomingMsg::GetMsgBufSize(), MsgIn, CigiIncomingMsg::ProcessIncomingMsg(), Read(), and CigiIncomingMsg::SetCrntMsgSize().

00119 {
00120    int stat = CIGI_SUCCESS;
00121 
00122    MsgIn.AdvanceCrntBuffer();
00123 
00124    Cigi_uint8 *NextBuf = MsgIn.GetMsgBuffer();
00125 
00126    int size = Read(NextBuf,MsgIn.GetMsgBufSize());
00127 
00128    if(size > 0)
00129    {
00130       MsgIn.SetCrntMsgSize(size);
00131 
00132       MsgIn.ProcessIncomingMsg();
00133 
00134    }
00135    else
00136    {
00137       size = 0;
00138       stat = CIGI_ERROR_MISCELLANEOUS;
00139       MsgIn.SetCrntMsgSize(size);
00140    }
00141 
00142    return(stat);
00143 
00144 }

int CigiIO::Recv ( void   ) 

Receive a message and store it for later processing

Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Definition at line 150 of file CigiIO.cpp.

References CigiIncomingMsg::AdvanceCrntBuffer(), CIGI_ERROR_MISCELLANEOUS, CIGI_SUCCESS, CigiIncomingMsg::GetMsgBuffer(), CigiIncomingMsg::GetMsgBufSize(), MsgIn, Read(), and CigiIncomingMsg::SetCrntMsgSize().

00151 {
00152    int stat = CIGI_SUCCESS;
00153 
00154    MsgIn.AdvanceCrntBuffer();
00155 
00156    Cigi_uint8 *NextBuf = MsgIn.GetMsgBuffer();
00157 
00158    int size = Read(NextBuf,MsgIn.GetMsgBufSize());
00159 
00160    if(size > 0)
00161    {
00162       MsgIn.SetCrntMsgSize(size);
00163 
00164       MsgIn.AdvanceCrntBuffer();
00165 
00166    }
00167    else
00168    {
00169       size = 0;
00170       stat = CIGI_ERROR_MISCELLANEOUS;
00171       MsgIn.SetCrntMsgSize(size);
00172    }
00173 
00174    return(stat);
00175 
00176 }

int CigiIO::Send ( void   ) 

Processes and send a message.

Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Definition at line 92 of file CigiIO.cpp.

References CigiOutgoingMsg::BeginMsg(), CIGI_SUCCESS, CigiOutgoingMsg::GetMsg(), CigiOutgoingMsg::LockMsg(), MsgOut, CigiOutgoingMsg::UnlockMsg(), CigiOutgoingMsg::UpdateFrameCntr(), and Write().

00093 {
00094    Cigi_uint8 *buff;
00095    int len;
00096 
00097    int stat = CIGI_SUCCESS;
00098 
00099    stat = MsgOut.UpdateFrameCntr();
00100 
00101    stat = MsgOut.LockMsg();
00102 
00103         buff = MsgOut.GetMsg(len);
00104 
00105    Write(buff,len);
00106 
00107    stat = MsgOut.UnlockMsg();
00108 
00109    stat = MsgOut.BeginMsg();  // prep for next message
00110 
00111    return(stat);
00112 
00113 }

virtual int CigiIO::Write ( Cigi_uint8 Buffer,
int  Length 
) [protected, pure virtual]

A pure virtual function to output the data.
This function is not implemented by this class.

Parameters:
Buffer - A pointer to the buffer to write
Length - The length of the message in bytes.
Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Referenced by Send().


Member Data Documentation

CigiIncomingMsg& CigiIO::MsgIn [protected]

Message In
A referance to a Cigi incoming message object.

Definition at line 109 of file CigiIO.h.

Referenced by Receive(), and Recv().

CigiOutgoingMsg& CigiIO::MsgOut [protected]

Message Out
A referance to a Cigi outgoing message object.

Definition at line 115 of file CigiIO.h.

Referenced by CigiIO(), and Send().


The documentation for this class was generated from the following files:
Generated on Wed Apr 29 09:00:09 2009 for CCL by  doxygen 1.4.7