/******************************************************************************
 *	COMMENTS....
 *****************************************************************************/

#ifndef __SERIAL_DEVICE_MG_H
#define __SERIAL_DEVICE_MG_H

#include <vector>
#include "serial_device.h" 
//#include "./ser_devices/tms_device.h"
//#include "./ser_devices/logging_device.h"

class SerialDeviceMG {
public:
	SerialDeviceMG();
	bool	init();			
	bool	registerDev(SerialDevice* const sDevicePtr);	
	void	runSensors();
	void	runActuate();
	void	runTest();
	void	dump();
	friend  void *send_t(void*);
	~SerialDeviceMG();		// should never be destructed			

private:
	vector<SerialDevice*>	SerDevDB;
	int			sleep_period;		
	pthread_t		workers[256];	// arbitray, should NEVER
						// EXCEED 256
	fd_set			rfds;
	struct	timeval		tv;
	int			maxfd;
	int		turn;	// key specific	
	// copy of the current device is prohibited
	SerialDeviceMG& operator=(const SerialDeviceMG& rhs);
	SerialDeviceMG(const SerialDeviceMG& rhs);
	static int numSerialSensors;			// serial sensor object counter

};

extern SerialDeviceMG serialSensors;
extern SerialDeviceMG serialActuators;

#endif
