Environment

C++ in MFC using namespace Vieworks::vivix,
Instance : CVivixSDK vivixSDK; CDetector* detectorIns;
C# in Winform using Vieworks.vivix.net, using Vieworks.vivix.net.detector; using Vieworks.vivix.net.scu;
Instance: VivixNet netSDK; DETECTOR_INFO DetInfo;Detector detectorIns;

Discription

Perform several calibrations(offset, gain), defect calibration can be loaded only

C++
RESULT result = RESULT::RESULT_SDK_IS_NOT_INITIALIZED;

CALIBRATION_READY_STATE crs;
result = detectorIns->CalibrationReadyStateGet(&crs);

//offsetcalibration part is not nessary for 1717V, 1751S
if (crs.OffsetIsReady == false)
{
    //offsetcalibration

    //must set calibration mode, unless calibration function will not be performed->
    result = detectorIns->CalibrationModeSet(true);

    OFFSET_CALIBRATION_PARAM ocp;
    ocp.action = OFFSET_CALIBRATION_PARAM::_ACTION::START;
    ocp.shotCount = 5;
    result = detectorIns->OffsetCalibration(ocp);

    result = detectorIns->CalibrationSave(CALIBRATION_FILE_TYPE::CALIBRATION_FILE_OFFSET, @"C:\detector\offset->dat");

        result = detectorIns->CalibrationModeSet(false);

}

//gaincalibration part
if (crs.GainIsReady == false)
{
    //must set calibration mode, unless calibration function will not be performed->
    result = detectorIns->CalibrationModeSet(true);

    GAIN_CALIBRATION_PARAM gcp = new GAIN_CALIBRATION_PARAM();
    gcp.action = GAIN_CALIBRATION_PARAM::_ACTION::STANDBY;
    gcp.shotCount = 0;
    result = detectorIns->GainCalibration(gcp);

    gcp.action = GAIN_CALIBRATION_PARAM::_ACTION::GET_GAIN_DATA;
    gcp.shotCount = 5;
    result = detectorIns->GainCalibration(gcp);
    //after perform gaincalibration by GET GAIN DATA, shot xray, then progress is alarmed by CalibrationStep callback

    //Wait callback->->

    //after end of xray shot, the gain calibration process->
    gcp.action = GAIN_CALIBRATION_PARAM::_ACTION::STOP;
    gcp.shotCount = 0;
    result = detectorIns->GainCalibration(gcp);

    result = detectorIns->CalibrationModeSet(false);

    result = detectorIns->CalibrationSave(CALIBRATION_FILE_TYPE::CALIBRATION_FILE_GAIN, @"C:\detector\gain.dat");

        //or load supported file
        // result = detectorIns->CalibrationLoad(CALIBRATION_FILE_TYPE->CALIBRATION_FILE_GAIN, @"C:\detector\gain.dat");
}

//defect calibration cannot be performed by user, so just load supported defect cal file
if (crs.DefectIsReady == false)
{

    result = detectorIns->CalibrationLoad(CALIBRATION_FILE_TYPE::CALIBRATION_FILE_DEFECT, _T(“D:\offset.dat”));
}

//check the calibration file is loaded
bool enable = false;
result = detectorIns->CalibrationApplyGet(CALIBRATION_TYPE::CALIBRATION_OFFSET, &enable);
if (result == RESULT::RESULT_SUCCESS && enable == false)
{
    result = detectorIns->CalibrationApplySet(CALIBRATION_TYPE::CALIBRATION_OFFSET, true);

}

result = detectorIns->CalibrationApplyGet(CALIBRATION_TYPE::CALIBRATION_GAIN, &enable);
if (result == RESULT::RESULT_SUCCESS && enable == false)
{
    result = detectorIns->CalibrationApplySet(CALIBRATION_TYPE::CALIBRATION_GAIN, true);

}

result = detectorIns->CalibrationApplyGet(CALIBRATION_TYPE::CALIBRATION_DEFECT, &enable);
if (result == RESULT::RESULT_SUCCESS && enable == false)
{
    result = detectorIns->CalibrationApplySet(CALIBRATION_TYPE::CALIBRATION_DEFECT, true);

}

 

C#
RESULT result = RESULT.RESULT_SDK_IS_NOT_INITIALIZED;

CALIBRATION_READY_STATE crs;
result = detectorIns.CalibrationReadyStateGet(out crs);

//offsetcalibration part is not nessary for 1717V, 1751S
if (crs.OffsetIsReady == false)
{
    //offsetcalibration

    //must set calibration mode, unless calibration function will not be performed.
    result = detectorIns.CalibrationModeSet(true);

    OFFSET_CALIBRATION_PARAM ocp = new OFFSET_CALIBRATION_PARAM();
    ocp.action = OFFSET_CALIBRATION_PARAM._ACTION.START;
    ocp.shotCount = 5;
    result = detectorIns.OffsetCalibration(ocp);

    result = detectorIns.CalibrationSave(CALIBRATION_FILE_TYPE.CALIBRATION_FILE_OFFSET, @"C:\detector\offset.dat");

        result = detectorIns.CalibrationModeSet(false);

}

//gaincalibration part
if (crs.GainIsReady == false)
{
    //must set calibration mode, unless calibration function will not be performed.
    result = detectorIns.CalibrationModeSet(true);

    GAIN_CALIBRATION_PARAM gcp = new GAIN_CALIBRATION_PARAM();
    gcp.action = GAIN_CALIBRATION_PARAM._ACTION.STANDBY;
    gcp.shotCount = 0;
    result = detectorIns.GainCalibration(gcp);

    gcp.action = GAIN_CALIBRATION_PARAM._ACTION.GET_GAIN_DATA;
    gcp.shotCount = 5;
    result = detectorIns.GainCalibration(gcp);
    //after perform gaincalibration by GET GAIN DATA, shot xray, then progress is alarmed by CalibrationStep callback

    //Wait callback..

    //after end of xray shot, the gain calibration process.
    gcp.action = GAIN_CALIBRATION_PARAM._ACTION.STOP;
    gcp.shotCount = 0;
    result = detectorIns.GainCalibration(gcp);

    result = detectorIns.CalibrationModeSet(false);

    result = detectorIns.CalibrationSave(CALIBRATION_FILE_TYPE.CALIBRATION_FILE_GAIN, @"C:\detector\gain.dat");

        //or load supported file
        // result = detectorIns.CalibrationLoad(CALIBRATION_FILE_TYPE.CALIBRATION_FILE_GAIN, @"C:\detector\gain.dat");
}

//defect calibration cannot be performed by user, so just load supported defect cal file
if (crs.DefectIsReady == false)
{
    result = detectorIns.CalibrationLoad(CALIBRATION_FILE_TYPE.CALIBRATION_FILE_DEFECT, @"C:\detector\gain.dat");
}

//check the calibration file is loaded
bool enable = false;
result = detectorIns.CalibrationApplyGet(CALIBRATION_TYPE.CALIBRATION_OFFSET, out enable);
if (result == RESULT.RESULT_SUCCESS && enable == false)
{
    result = detectorIns.CalibrationApplySet(CALIBRATION_TYPE.CALIBRATION_OFFSET, true);

}

result = detectorIns.CalibrationApplyGet(CALIBRATION_TYPE.CALIBRATION_GAIN, out enable);
if (result == RESULT.RESULT_SUCCESS && enable == false)
{
    result = detectorIns.CalibrationApplySet(CALIBRATION_TYPE.CALIBRATION_GAIN, true);

}

result = detectorIns.CalibrationApplyGet(CALIBRATION_TYPE.CALIBRATION_DEFECT, out enable);
if (result == RESULT.RESULT_SUCCESS && enable == false)
{
    result = detectorIns.CalibrationApplySet(CALIBRATION_TYPE.CALIBRATION_DEFECT, true);

}