//-------------------------------------------------------------------------------------------------
// <copyright file="SEProgram.h" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
// 	Declarations for SEProgram, which orchestrates program startup and shutdown
//  and interfaces the Controller class to CORBA
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#ifndef __SEProgram_h__
#define __SEProgram_h__

#include "EventTransceiver.h"
#include "LqrSMACIdl.h"
#include "LqrSMACSharedLib.h"
#include "SEController.h"
#include "SEProgramSettings.h"
#include "SensorProgram.h"

namespace LiquidRobotics {

namespace EventLib {
	class GPSSampleEvent;
}

namespace SensorExample {

class SHARED_LIB_PUBLIC SEProgram
: public LiquidRobotics::EventLib::SensorProgram
{
public:

	typedef LiquidRobotics::EventLib::SensorProgram Base;
	typedef LiquidRobotics::EventLib::GPSSampleEvent GPSSampleEvent;
	typedef LiquidRobotics::SMACFramework::PayloadDescription Desc;

	SEProgram(IObjectBroker& _broker, const SEProgramSettings& _settings, Logger& _logger);
	virtual ~SEProgram();

	virtual void Initialize(Object_ptr _pServer);
	virtual void Shutdown();

	virtual void SendCommand(const ::CORBA::Any& command, const char* requester, const char* transactionID, ::CORBA::Any_OUT_arg result);

protected:

	typedef LiquidRobotics::EventLib::IEventBase IEventBase;

	void GPSSampleHandlerAsSample(EventTransceiver& sender, const GPSSampleEvent& receivedEvent);
	void OnCommandCompleted(const EventLib::SensorControllerBaseCommandID& cmdID, const string& result);
	void OnReportedTag(const string& data, timeval& time, double lat, double lon);

	IObjectBroker& broker;
	const SEProgramSettings& settings;
	Logger& logger;
	double latSave, lonSave;
	SEControllerPtr ctrl;
	SEController::ScopedConnectionPtr commandCompletedConnection;
	SEController::ScopedConnectionPtr reportedTagConnection;
};

}
}

#endif
