#ifndef __LOGGING_THREAD_H_INCLUDED__
#define __LOGGING_THREAD_H_INCLUDED__

#include <stdint.h>
#include "socket.h"
#include "threads.h"
#include "elmo.h"
#include "motor_interogator.h"

class LoggingThread : public Thread {
public:
	LoggingThread (uint16_t	labviewPortNumber, Elmo& winch, Elmo& levelWind)
		: m_LabviewPortNumber(labviewPortNumber), m_Winch(winch), m_LevelWind(levelWind),
		  m_WinchInterogator("WM", winch), m_LevelWindInterogator("LW", levelWind) {}
	{
		string enableLogging("EO=0\r");
		string response;
		m_Winch.Command(enableLogging, response);
		m_LevelWind.Command(enableLogging, response);
	}

	~LoggingThread(void) {}
	{
		string echoOff("EO=1\r");
		string response;
		m_Winch.Command(disableLogging, response);
		m_LevelWind.Command(disableLogging, response);
	}

protected:
	virtual void* Run(void*);

private:
	void				logData(tcp_socket labviewSocket);
	uint16_t			m_LabviewPortNumber;
	Elmo&				m_Winch;
	Elmo&				m_LevelWind;
	MotorInterogator	m_WinchInterogator;
	MotorInterogator	m_LevelWindInterogator;
};

#endif
