package main

import (
	"fmt"
	"time"

	"hnyfkj.com.cn/rtu/linux/baseapp"
	camera "hnyfkj.com.cn/rtu/linux/mvs_u_takephoto"
)

func main() {
	baseapp.ModuleInit()
	if !camera.ModuleInit() {
		return
	}

	baseapp.Logger.Info("开始拍照测试 ...")
	imgType := 0
	imgFile := ""
	for i := range 9 {
		switch i {
		case 0:
			imgType = camera.IMG_TYPE_BMP
			imgFile = fmt.Sprintf("./test%d.bmp", i+1)
		default:
			imgType = camera.IMG_TYPE_JPG
			imgFile = fmt.Sprintf("./test%d.jpg", i+1)
		}

		var imgMark camera.SImgMark
		var err error

		start := time.Now()
		imgMark, err = camera.TakePhoto(imgType, imgFile, 60)
		elapsed := time.Since(start).Milliseconds()

		if err == nil {
			baseapp.Logger.Infof("输出: \"%s\", 用时: %dms, 拍照信息: %+v", imgFile, elapsed, imgMark)
		} else {
			baseapp.Logger.Errorf("拍照时发生错误: %v, 用时: %dms, 请修复所有问题后重试!!", err, elapsed)
		}
	}
	baseapp.Logger.Info("拍照测试任务结束")
}
