#include "vst_idle_coat.h"
#include "logic.h"
#include "vst_work_coat.h"
VST_Idle_Coat::VST_Idle_Coat(int iID, const QString &sName,
                                       VSM_Thread *pParent)
    :VST_Idle_Base(  iID,  sName, pParent)
{

}

void VST_Idle_Coat::do_Msg(const V_Msg &msg)
{
	if(msg.m_iID==VarMsg_Driver_ID)
	{
		V_Msg msg1=msg;
		Q_ASSERT(msg1.m_vlInput.size()>=2);
		int iDriverID=msg1.m_vlInput.at(0).toInt();
		int iDriverMsgID=msg1.m_vlInput.at(1).toInt();
		msg1.m_vlInput.pop_front();
		msg1.m_vlInput.pop_front();
		CDriverCard* pDriverCard= GET_CARD(iDriverID,CDriverCard);
		Q_ASSERT(pDriverCard);
		pDriverCard->do_msg(iDriverMsgID,msg1.m_vlInput,msg1.m_pvlOutput);
	}
    else if(msg.m_iID==VarMsg_Coat_BumpTest )
    {
        m_pNextState=new VST_Work_Coat(VarState_Bump_ID,
                                       QObject::trUtf8("Bump test state"),
                                       m_pParent,this,0);
        for(int i=0;i<=200;i++)
        {
            ((VST_Work_Coat*)m_pNextState)->m_VarMsgProcess.
                    pushback_Msg(VarMsg_Process_ID,
                                 QObject::trUtf8("Bump test Sig"),
                                 QVariantList()<<PROCESS_COAT
                                 <<CProcess_Coat::BUMP_TEST<<i);
            ((VST_Work_Coat*)m_pNextState)->LoadMsgProcess();

        }
		((VST_Work_Coat*)m_pNextState)->LoadMsgProcess();
        m_pParent->SetState(m_pNextState);

    }
    else if(msg.m_iID==VarMsg_Coat_SpayTest )
    {
        m_pNextState=new VST_Work_Coat(VarState_Spay_ID,
                                       QObject::trUtf8("Spay test state"),
                                       m_pParent,this,0);
        for(int i=0;i<=200;i++)
        {
            ((VST_Work_Coat*)m_pNextState)->m_VarMsgProcess.
                    pushback_Msg(VarMsg_Process_ID,
                                 QObject::trUtf8("Spary test Sig"),
                                 QVariantList()<<PROCESS_COAT
                                 <<CProcess_Coat::SPARY_TEST<<i);
            ((VST_Work_Coat*)m_pNextState)->LoadMsgProcess();

        }
		((VST_Work_Coat*)m_pNextState)->LoadMsgProcess();
        m_pParent->SetState(m_pNextState);

    }
	else if(msg.m_iID == VarMsg_Coat_ReplaceFluid)
	{
		m_pNextState=new VST_Work_Coat(VarState_ReplaceFluid_ID,
			QObject::trUtf8("Change coat liquid"),
			m_pParent,this,0);
		for(int i=0;i<=200;i++)
		{
			((VST_Work_Coat*)m_pNextState)->m_VarMsgProcess.
				pushback_Msg(VarMsg_Process_ID,
				QObject::trUtf8("Change coat liquid Sig"),
				QVariantList()<<PROCESS_COAT
				<<CProcess_Coat::REPLACE_COATFLUID<<i);

		}
		((VST_Work_Coat*)m_pNextState)->LoadMsgProcess();
		m_pParent->SetState(m_pNextState);
	}

    VST_Idle_Base::do_Msg(msg);
}
