//
//  Copyright © 2001 - 2002, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   7kAcknowlege.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      

#if !defined(AFX_7KACKNOWLEGE_H__27BB4ED8_CC95_44DA_BF1D_FCC83D5CA06B__INCLUDED_)
#define AFX_7KACKNOWLEGE_H__27BB4ED8_CC95_44DA_BF1D_FCC83D5CA06B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "7kProtocol.h"
#include "SystemTime.h"

class EXPORT_DLL C7kAcknowlege : public C7kProtocol
{
public:

    ///////////////
    // Defintions.

    typedef enum tagESTATUS
    {
        statusRejected,
        statusAccepted,
        statusUnknown
    }
    ESTATUS;

    ///////////////
    // Services.

                    C7kAcknowlege   (   void );
                    C7kAcknowlege   (   const C7kAcknowlege &rRhs );

    virtual        ~C7kAcknowlege   (   void );

    C7kAcknowlege & operator =      (   const C7kAcknowlege &rRhs );

    bool            Encode          (   const ESTATUS        &reStatus,
                                        const unsigned long  &rulCommandId,
                                        const int            &riSensorId,
                                        const bool           &rbUseChecksum = false );

    bool            Decode          (   BYTE                *pbyStream,
                                        const unsigned long &rulTotalBytes,
                                        const bool          &rbUseChecksum,
                                        ESTATUS             &reStatus,
                                        unsigned long       &rulCommandId,
                                        int                 &riSensorId );

    operator        BYTE *          ( void ) const;

    operator        unsigned long   ( void ) const;

private:

    ///////////////
    // Defintions.

#pragma pack( push, ACKNOWLEGE7K_H_PACK, 1 )

    typedef struct tagRECORDTYPEHEADER
    {
        unsigned long   m_ulCommandId;
        int             m_iSensorId;
        unsigned long   m_ulStatus;

        static unsigned long Size( void )
        {
            return sizeof( struct tagRECORDTYPEHEADER );
        }

        tagRECORDTYPEHEADER(    const unsigned long         &rulCommandId  = 0UL,
                                const int                   &riSensorId    = 0,
                                const unsigned long         &rulStatus     = 0UL )
        {
            Reset();

            m_ulCommandId = rulCommandId;
            m_iSensorId   = riSensorId;
            m_ulStatus    = rulStatus;
        }

        void Reset( void )
        {
            memset( this, 0x00, Size() );
        }
    }
    RECORDTYPEHEADER, *PRECORDTYPEHEADER;

#pragma pack( pop, ACKNOWLEGE7K_H_PACK )

    ///////////////
    // Attributes.

    const unsigned long     m_ulRecordHeaderSize;
    const unsigned long     m_ulRecordType;

    ///////////////
    // Services.

    void            SetDefaultHeader(   RECORDHEADER7K      *psRecordHeader );

};

#endif // !defined(AFX_7KACKNOWLEGE_H__27BB4ED8_CC95_44DA_BF1D_FCC83D5CA06B__INCLUDED_)
