#include "VSensor.h" 
#include <signal.h> 
#include <direct.h> 
#pragma comment(lib, "VSensorSDK.lib")
using namespace std;
using namespace VSENSOR;
int main()
{
    //获取相对路径
    char cwd[200];
    if (_getcwd(cwd, 200) == NULL)
    {
        printf("get path failed\n");
    }
    //实例化设备
    VSensor* pVSensor = new VSensor();
    //获取设备列表
    VSensorCameraInfo cameraList[20];
    int num = 0;
    pVSensor->GetDeviceList(cameraList, &num);
    for (int i = 0; i < num; i++)
    {
        printf("device num %d : list[%d] = %s\n", i, i, cameraList[i].CameraName);
    }
    //连接设备，0为连接第一台设备  
    int status = pVSensor->DeviceConnect(0);
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("connect device failed status = %d\n", status);
        system("pause");
    }
    //设备参数初始化，仅初次上电时需要进行此操作且该函数需要等待15s
    printf("waiting for parameter init...\n");
    status = pVSensor->DeviceParameterInit();
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("parameter init failed, status = %d\n", status);
        system("pause");
    }
    //重置用户设置数据
    status = pVSensor->ResetUserSettingData();
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("reset user setting data failed, status = %d\n", status);
        system("pause");
    }
    //保存用户设置数据
    status = pVSensor->SaveUserSettingData(string(cwd) + "//setting.ini");
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("save user setting data failed, status = %d\n", status);
        system("pause");
    }
    //加载用户设置数据
    status = pVSensor->LoadUserSettingData(string(cwd) + "//setting.ini");
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("load user setting data failed, status = %d\n", status);
        system("pause");
    }
    //反初始化设备
    status = pVSensor->DeviceUnInit();
    if (status != CAMERA_STATUS_SUCCESS)
    {
        printf("device release failed, status = %d\n", status);
        system("pause");
    }
    delete pVSensor;
    printf("run success\n");
    system("pause");
    return 0;
}