CigiIGMsgV3 Class Reference

#include <CigiIGMsgV3.h>

Inheritance diagram for CigiIGMsgV3:

CigiBaseIGMsg CigiBaseVariableSizePckt CigiBasePacket List of all members.

Public Member Functions

 CigiIGMsgV3 ()
virtual ~CigiIGMsgV3 ()
virtual int Pack (CigiBasePacket *Base, Cigi_uint8 *Buff, void *Spec) const
virtual int Unpack (Cigi_uint8 *Buff, bool Swap, void *Spec)
virtual int GetTruePacketSize (CigiBaseVariableSizePckt &refPacket)
int SetMsg (const Cigi_Ascii *MsgIn, bool bndchk=true)

Detailed Description

Definition at line 59 of file CigiIGMsgV3.h.


Constructor & Destructor Documentation

CigiIGMsgV3::CigiIGMsgV3 (  ) 

General Constructor

Definition at line 72 of file CigiIGMsgV3.cpp.

References CIGI_IG_MSG_PACKET_ID_V3, CigiBasePacket::MinorVersion, CigiBaseIGMsg::Msg, CigiBaseIGMsg::MsgID, CigiBaseIGMsg::MsgLen, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, CigiBaseVariableSizePckt::VariableDataSize, and CigiBasePacket::Version.

00073 {
00074 
00075    PacketID = CIGI_IG_MSG_PACKET_ID_V3;
00076    Version = 3;
00077    MinorVersion = 0;
00078 
00079    MsgID = 0;
00080 
00081    VariableDataSize = MsgLen = 4;
00082    memset(Msg,0,4);
00083    PacketSize = 8;
00084 
00085 }

CigiIGMsgV3::~CigiIGMsgV3 (  )  [virtual]

General Destructor

Definition at line 90 of file CigiIGMsgV3.cpp.

00091 {
00092 
00093 }


Member Function Documentation

int CigiIGMsgV3::GetTruePacketSize ( CigiBaseVariableSizePckt refPacket  )  [virtual]

A virtual function to determine the size that the packet will take up when packed.

Parameters:
refPacket - A pointer to the current pack point.
Returns:
The size that the packet will take up when packed

Implements CigiBaseIGMsg.

Definition at line 172 of file CigiIGMsgV3.cpp.

References CigiBaseVariableSizePckt::GetVariableDataSize().

00173 {
00174    return(refPacket.GetVariableDataSize() + 4);
00175 }

int CigiIGMsgV3::Pack ( CigiBasePacket Base,
Cigi_uint8 Buff,
void *  Spec 
) const [virtual]

The virtual Pack function for CIGI 3

Parameters:
Base - A pointer to the instance of the packet to be packed. (Downcast to CigiBasePacket)
Buff - A pointer to the current pack point.
Spec - A pointer to special data - This is not used in this class.
Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Implements CigiBaseIGMsg.

Definition at line 102 of file CigiIGMsgV3.cpp.

References PackPointerUnion::c, CigiBaseIGMsg::Msg, CigiBaseIGMsg::MsgID, CigiBaseIGMsg::MsgLen, CigiBasePacket::PacketID, CigiBasePacket::PacketSize, and PackPointerUnion::s.

00103 {
00104 
00105    PackPointer CDta;
00106 
00107    CigiBaseIGMsg * Data = ( CigiBaseIGMsg *)Base;
00108 
00109    CDta.c = Buff;
00110 
00111    *CDta.c++ = PacketID;
00112    *CDta.c++ = Data->PacketSize;
00113 
00114    *CDta.s++ = Data->MsgID;
00115 
00116    memcpy(CDta.c,Data->Msg,Data->MsgLen);
00117 
00118    return(Data->PacketSize);
00119 
00120 }

int CigiIGMsgV3::SetMsg ( const Cigi_Ascii MsgIn,
bool  bndchk = true 
)

Sets the Msg with bound checking control

Parameters:
MsgIn - Message string
bndchk - Enables (true) or disables (false) bounds checking.
Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Definition at line 187 of file CigiIGMsgV3.cpp.

References CIGI_SUCCESS, CigiBaseIGMsg::Msg, CigiBaseIGMsg::MsgLen, CigiBasePacket::PacketSize, and CigiBaseVariableSizePckt::VariableDataSize.

00188 {
00189 
00190    MsgLen = strlen(MsgIn);
00191 
00192    if(MsgLen == 0)
00193    {
00194       MsgLen = 4;
00195       memset(Msg,0,4);
00196    }
00197    else if(MsgLen >= 99)
00198    {
00199       MsgLen = 100;
00200       memcpy(Msg,MsgIn,99);
00201       Msg[99] = 0;
00202    }
00203    else
00204    {
00205       memcpy(Msg,MsgIn,MsgLen);
00206 
00207       int tadj = (MsgLen + 5) % 8;
00208 
00209       tadj = (tadj == 0) ? 1 : (9 - tadj);
00210 
00211       memset(&Msg[MsgLen],0,tadj);
00212 
00213       MsgLen += tadj;
00214    }
00215 
00216    VariableDataSize = MsgLen;
00217    PacketSize = VariableDataSize + 4;
00218 
00219    return(CIGI_SUCCESS);
00220 }

int CigiIGMsgV3::Unpack ( Cigi_uint8 Buff,
bool  Swap,
void *  Spec 
) [virtual]

The virtual Unpack function for CIGI 3

Parameters:
Buff - A pointer to the current pack point.
Swap - N/A for V1 & V2
Spec - A pointer to special data - This is not used in this class.
Returns:
This returns CIGI_SUCCESS or an error code defined in CigiErrorCodes.h

Implements CigiBaseIGMsg.

Definition at line 125 of file CigiIGMsgV3.cpp.

References PackPointerUnion::c, CigiSwap2(), CigiBaseIGMsg::Msg, CigiBaseIGMsg::MsgID, CigiBaseIGMsg::MsgLen, CigiBasePacket::PacketSize, and PackPointerUnion::s.

00126 {
00127 
00128    PackPointer CDta;
00129 
00130 
00131    int tPktSz;
00132 
00133    CDta.c = Buff;
00134 
00135    CDta.c++;  // Step over packet id
00136 
00137    tPktSz = *CDta.c++;  // Get packet size
00138 
00139    if(!Swap)
00140       MsgID = *CDta.s++;
00141    else
00142       CigiSwap2(&MsgID, CDta.s++);
00143 
00144    if(tPktSz > 104)
00145    {
00146       PacketSize = 104;
00147       memcpy(&Msg,CDta.c,99);
00148       Msg[99] = 0;
00149    }
00150    else if(tPktSz <= 5)
00151    {
00152       PacketSize = tPktSz;
00153       Msg[0] = 0;
00154    }
00155    else
00156    {
00157       PacketSize = tPktSz;
00158       memcpy(&Msg,CDta.c,(tPktSz - 4));
00159       Msg[(tPktSz - 5)] = 0;
00160    }
00161 
00162    MsgLen = PacketSize - 4;
00163 
00164    return(tPktSz);
00165 
00166 }


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