//
//  Copyright © 2004, 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:   BlueFinVC.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      
//

#if !defined(AFX_BLUEFINVC_H__B4A100AF_D5CD_4E37_AC77_5768033190BD__INCLUDED_)
#define AFX_BLUEFINVC_H__B4A100AF_D5CD_4E37_AC77_5768033190BD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
#endif

#include "Resource.h"                                               // Main DLL resource symbols.
#include "SensorInterface.h"
#include "VehicleData.h"

#include "..\..\..\Utils\NetUtils\SensorList.h"                     // Linked list of sensor objects.
#include "..\..\..\Utils\NetUtils\WatchSentinel.h"                  // Sentinel watch-dog thread.

#include "..\..\Include\SurveyEventTypes.h"                         // Survey Event log types (alarms, warnings etc).

class CBlueFinVCApp : public CWinApp, public CSensorInterface
{
public:

    ///////////////
    // Services.

                                        CBlueFinVCApp           (   void );
    virtual                            ~CBlueFinVCApp           (   void );

    static CBlueFinVCApp *              This                    (   void );

    CSensorList<CVehicleData> &         SensorList              (   void )  const;

    CString                             Address                 (   void )  const;
    unsigned long                       Port                    (   void )  const;

    bool                                WatchSentinel           (   const bool             &rbEnable,
                                                                    const unsigned long    &rulCheckPeriod  = 5000UL );

    ///////////////
    // Attributes.

    CCritical                           m_SensorListGuard;

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CBlueFinVCApp)
	public:
    virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

    //{{AFX_MSG(CBlueFinVCApp)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()

private:

    ///////////////
    // Attributes.

    mutable CSensorList<CVehicleData>   m_SensorList;
    CString                             m_Address;
    unsigned long                       m_ulPort;
    CWatchSentinel                     *m_pWatchSentinel;

    ///////////////
    // Services.

    void                                SettingsFromRegistry        (   void );

    static void                         StatusCheckCallback         (   void                   *pvParam,
                                                                        const int              &riSensorIndex );

    void                                CheckAndReportHealth        (   const int              &riSensorIndex );

};

// Misc global scope helpers (definitions and macros etc).

#define GetApp_m()                      CBlueFinVCApp::This()

bool    ReportAlarm     (   const bool &rbSet,
                            const int  &riAlarmId,
                            char       *pszFormat, ... );

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_BLUEFINVC_H__B4A100AF_D5CD_4E37_AC77_5768033190BD__INCLUDED_)
