//
//  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:   CommandProcessor.cpp
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      
//

#include "StdAfx.h"
#include "CommandProcessor.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// CCommandProcessor class implementation.

CCommandProcessor::CCommandProcessor(   PFN_HANDLER_CALLBACK    pfnHandlerCallback,
                                        void                   *pvParam,
                                        char                   *pszAddress,
                                        const unsigned long    &rulPort,
                                        const unsigned long    &rulMaxMessageSize )

                  :CMessageProcessor(   pfnHandlerCallback,
                                        pvParam,
                                        pszAddress,
                                        rulPort,
                                        rulMaxMessageSize )
{
}

CCommandProcessor::~CCommandProcessor( void )
{
}

bool CCommandProcessor::HandleSonarMessage( const unsigned long &rulTimeStamp,
                                            CEdgeTechMessage    &rMessage )
{
    // Filter messages of interest otherwise give the base class a chance to deal with them.

    bool bSuccess = false;

    switch ( rMessage.SonarMessage() )
    {
        case SONAR_MESSAGE_SYSTEM_RESET:
        case SONAR_MESSAGE_SYSTEM_TIME:
        case SONAR_MESSAGE_TIME_DELTA:
        case SONAR_MESSAGE_SYSTEM_VERSION:
        case SONAR_MESSAGE_OVERRIDE:
        case SONAR_MESSAGE_RUN_POST_DIAGNOSTICS:
        case SONAR_MESSAGE_DATA_NETWORK_WINDOW:
        case SONAR_MESSAGE_DATA_ACTIVE:
        case SONAR_MESSAGE_PROCESSING_ENHANCE_WINDOW:
        case SONAR_MESSAGE_PROCESSING_DIRECT_PATH:
        case SONAR_MESSAGE_PING:
        case SONAR_MESSAGE_PING_GAIN:
        case SONAR_MESSAGE_PING_LIST:
        case SONAR_MESSAGE_PING_SELECT:
        case SONAR_MESSAGE_PING_RATE:
        case SONAR_MESSAGE_PING_TRIGGER:
        case SONAR_MESSAGE_PING_DELAY:
        case SONAR_MESSAGE_PING_MAX_SAMPLES:
        case SONAR_MESSAGE_PING_RANGE:
        case SONAR_MESSAGE_PING_COUPLING_PARAMETERS:
        case SONAR_MESSAGE_PING_FISH_LIST:
        case SONAR_MESSAGE_ADC_GAIN:
        case SONAR_MESSAGE_ADC_AGC:
        case SONAR_MESSAGE_ADC_RATE:

            bSuccess = CallCallback( rulTimeStamp, rMessage );
            break;

        default:

            bSuccess = CMessageProcessor::HandleSonarMessage( rulTimeStamp, rMessage );
            break;
    }

    return bSuccess;
}

