package main

import (
	"fmt"
	"time"

	"hnyfkj.com.cn/rtu/bxs-sy/baseapp"
	takephoto "hnyfkj.com.cn/rtu/bxs-sy/mvs_takephoto"
)

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

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

		var imgMark takephoto.SImgMark
		var err error

		start := time.Now()
		imgMark, err = takephoto.TakePhoto(imgType, imgFile, 300)
		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("拍照测试任务结束")
}
