#include "cmwcalilaserkerf.h"
#include "ui_cmwcalilaserkerf.h"
#include "cprocess_laserkerf.h"
#include "callsystem.h"
#include "logic_local_def.h"
#include "cjig_driver.h"
#include "logic_compdef.h"

CMWCaliLaserKerf::CMWCaliLaserKerf(QWidget* parent)
    : CMWidget(parent)
{
    ui = new Ui::CMWCaliLaserKerf();
    ui->setupUi(this);

    m_iProcessId = PROCESS_LASERKERF;
}

CMWCaliLaserKerf::~CMWCaliLaserKerf()
{
    delete ui;
}

void CMWCaliLaserKerf::SetProcess(int iProcessID)
{
    m_iProcessId = iProcessID;
}

void CMWCaliLaserKerf::MInit()
{
    CProcess_LaserKerf* pKerf = GET_PROCESS(m_iProcessId,
                                            SM_MAIN, CProcess_LaserKerf);
    Q_ASSERT(pKerf);
    Variant* pparam[30] = { 0 };
    pparam[0] = pKerf->m_Variants.get_Variant(Var_Process_Kerf_BeforeSearchSleep_ID);
    pparam[1] = pKerf->m_Variants.get_Variant(Var_Process_Kerf_AfterSearchSleep_ID);
    pparam[2] = pKerf->m_Variants.get_Variant(Var_Process_Kerf_AutoThresRange_ID);
    pparam[3] = pKerf->m_Variants.get_Variant(Var_Process_Kerf_AutoThresStep_ID);
    pparam[4] = pKerf->m_Variants.get_Variant(Var_Process_Kerf_EnableAutoThres_ID);

    CJigDriver* pJigDriver = GET_CARD(JigDriver, CJigDriver);
    //中心位置
    pparam[5] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_AreaCenterX);
    pparam[6] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_AreaCenterY);
    pparam[7] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_ZFocusThickness);
    //划线的参数
    pparam[8] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_WorkTableYOffset);
    pparam[9] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_LineLength);
    pparam[10] = pKerf->m_Variants.get_Variant(Var_Process_LaserKerf_CheckPower);
    pparam[11] = pKerf->m_Variants.get_Variant(Var_Process_LaserKerf_CheckFreq);
    pparam[12] = pKerf->m_Variants.get_Variant(Var_Process_LaserKerf_CheckEpulse);
    pparam[13] = pKerf->m_Variants.get_Variant(Var_Process_LaserKerf_CheckBeamWidth);
    pparam[14] = pKerf->m_Variants.get_Variant(Var_Process_LaserKerf_Speed);
    //Focus的光源
    pparam[15] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_FocusLightDirect);
    pparam[16] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_FocusLightCircle);
    pparam[17] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_FocusExposure);
    pparam[18] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_FocusGain);

    pparam[19] = pKerf->m_Variants.get_Variant(Var_Process_KerfParm_LightDirect);
    pparam[20] = pKerf->m_Variants.get_Variant(Var_Process_KerfParm_LightCircle);
    pparam[21] = pKerf->m_Variants.get_Variant(Var_Process_KerfParm_Exposure);
    pparam[22] = pKerf->m_Variants.get_Variant(Var_Process_KerfParm_Gain);
    //区域的参数
    pparam[23] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_AreaCellDiameter);
    pparam[24] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_AreaValidWidth);
    pparam[25] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_LineStep);
    pparam[26] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_AreaType);
    pparam[27] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_OuterErosionDistance);
    pparam[28] = pJigDriver->m_Variants.get_Variant(Var_Process_LaserKerf_InnerErosionDistance);

    ui->widget->MParamInit_list(pparam, 29);
    mchildwidgets[intptr_t(ui->widget)] = ui->widget;
}

