#include "stable.h"
#include "cmwmanualtrans.h"

CMWManualTrans::CMWManualTrans(QWidget *parent)
	: CMWidget(parent)
{
	ui.setupUi(this);
}

CMWManualTrans::~CMWManualTrans()
{

}

void CMWManualTrans::MFresh()
{
	CMWidget::MFresh();

	CWorker* pWorker=GET_CHDIRECT(M_WORKER,CWorker);
	if(pWorker->m_workLevel>=LEVEL_FACTORAY){
		bool bVisible = true;
		ui.btnReadCleanConfig->setVisible(bVisible);
		ui.btnWriteCleanConfig->setVisible(bVisible);
		ui.btnReadCoatConfig->setVisible(bVisible);
		ui.btnWriteCoatConfig->setVisible(bVisible);
	}else{
		bool bVisible = false;
		ui.btnReadCleanConfig->setVisible(bVisible);
		ui.btnWriteCleanConfig->setVisible(bVisible);
		ui.btnReadCoatConfig->setVisible(bVisible);
		ui.btnWriteCoatConfig->setVisible(bVisible);
	}
}

void CMWManualTrans::MTimeFresh()
{
	//if(m_gSystem.IsSMAutoRun(SM_MAIN))
	//	setEnabled(false);
	//else
	//	setEnabled(true);
}

void CMWManualTrans::on_btnCleanToCheckbox_clicked()
{
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Clean to Cupboard Sig"),
    //    QVariantList()<<CProcess_Trans::TRANSCLEANTOCHECKBOX);
    //m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCTToCass_clicked()
{
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Coat to Cass Sig"),
    //    QVariantList()<<CProcess_Trans::TRANSCOATTOCASS);
    //m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCoatToCheckbox_clicked()
{
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Coat to Cupboard Sig"),
    //    QVariantList()<<CProcess_Trans::TRANSCOATTOCHECKBOX);
    //m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCheckboxToCass_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Cupboard to Cass Sig"),
        QVariantList()<<CProcess_Trans::kTransCheckBoxToCass);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCleanCoatTable_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID,
                          QObject::trUtf8("Clean coattable Sig"),
                          QVariantList()<<CLEANTABLE_ACTION<<-1<<-1,0);
    m_gSystem.start_test(SM_COAT, msgqueue);
}

void CMWManualTrans::on_btnCleanCleanTable_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID,
                          QObject::trUtf8("Clean coattable Sig"),
                          QVariantList()<<CLEANTABLE_ACTION<<-1<<-1,0);
    m_gSystem.start_test(SM_CLEAN, msgqueue);
}

void CMWManualTrans::on_btnCleanWorktable_clicked()
{

}

void CMWManualTrans::on_btnClean_CoatTableLiquid_clicked()
{

}


void CMWManualTrans::on_btnCheckBoxToCoat_clicked()
{
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Cupboard to Coat Sig"),
    //    QVariantList()<<CProcess_Trans::TRANSCHECKBOXTOCOAT);
    //m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCoatToClean_clicked()
{
    //V_MsgQueue msgqueue;
    //msgqueue.pushback_Msg(VarMsg_StartSemi_ID,QObject::trUtf8("Coat to Clean Sig"),
    //    QVariantList()<<CProcess_Trans::TRANSCOATTOCLEAN);
    //m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnReadCleanConfig_clicked()
{
    CProcess_Clean* pClean=GET_PROCESS(PROCESS_CLEAN,
                                            SM_CLEAN,
                                            CProcess_Clean);
    pClean->ReadWriteCleanTable(false);

}

void CMWManualTrans::on_btnWriteCleanConfig_clicked()
{
    CProcess_Clean* pClean=GET_PROCESS(PROCESS_CLEAN,
                                            SM_CLEAN,
                                            CProcess_Clean);
    pClean->ReadWriteCleanTable(true);

}

void CMWManualTrans::on_btnWtTest_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_PlatformCheck_ID,
                          QObject::trUtf8("Power Check"));
    m_gSystem.start_manual(SM_MAIN, msgqueue, true);
}

void CMWManualTrans::on_btnRailNearLocation_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Rail Near Location Sig"),
                          QVariantList() << CProcess_Trans::kTransRailNearLocation);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnRailNearLocationManual_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Rail Near Location Manual Sig"),
                          QVariantList() << CProcess_Trans::kTransRailNearLocationManual);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCupboardToClean_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Cupboard To Clean Sig"),
                          QVariantList() << VarMsg_Transfer_Component << CProcess_Trans::kTransCheckboxToClean);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnCupboardToCoat_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Cupboard To Coat Sig"),
                          QVariantList() << VarMsg_Transfer_Component << CProcess_Trans::kTransCheckboxToCoat);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnAbortTrans_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Abort Trans sig"),
                          QVariantList() << CProcess_Trans::kAbortTrans);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnAbortLoad_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Abort Load sig"),
                          QVariantList() << CProcess_Trans::kAbortLoad);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnAbortUnload_clicked()
{
    V_MsgQueue msgqueue;
    msgqueue.pushback_Msg(VarMsg_StartSemi_ID, QObject::trUtf8("Abort Trans sig"),
                          QVariantList() << CProcess_Trans::kAbortUnload);
    m_gSystem.start_test(SM_TRANS, msgqueue);
}

void CMWManualTrans::on_btnReadCoatConfig_clicked()
{
    CProcess_Coat* pCoat=GET_PROCESS(PROCESS_COAT,
                                             SM_COAT,
                                             CProcess_Coat);
    pCoat->ReadWriteCleanTable(false);
}

void CMWManualTrans::on_btnWriteCoatConfig_clicked()
{
    CProcess_Coat* pCoat=GET_PROCESS(PROCESS_COAT,
                                             SM_COAT,
                                             CProcess_Coat);
    pCoat->ReadWriteCleanTable(false);
}

