#include "stdafx.h"
#include "CenterModule.h"
#include "USBModule.h"
#include "UserModule.h"
#include "FileModule.h"
CCenterModule::CCenterModule()
{

}

CCenterModule::~CCenterModule()
{

}

void CCenterModule::onMsgPdu( CInterProtocl *pdu )
{
	pushMsg(pdu);
}

void CCenterModule::HeartBeat_Imp()
{
	m_queMutex.acquire();
	int size = m_pduQueue.size();
	if (size == 0)
	{
		m_queMutex.release();
		return;
	}
	CInterProtocl *pdu = m_pduQueue.front();
	m_pduQueue.pop_front();
	m_queMutex.release();
	switch (pdu->m_desModule)
	{
	case USB_MODULE:
		{
			m_pUsb->pushMsg(pdu);
		}
		break;
	case USER_MODULE:
		{
			m_pUser->pushMsg(pdu);
		}
		break;
	case FILE_MODULE:
		{
			m_pFile->pushMsg(pdu);
		}
		break;
	}
}