package HikSDK

import (
	"fmt"
	"testing"
	"time"
)

func TestCamera(t *testing.T) {
	err := Init()
	if err != nil {
		return
	}
	//Camera, err := NewBallCamera("192.168.211.62", 8000, "admin", "ubis3333", BuKongQiux)
	Camera, err := NewBallCamera("192.168.211.48", 8000, "admin", "okwy1234", BuKongQiu)
	if err != nil {
		t.Errorf("NewBallCamera() error = %v", err)
		return
	}

	err = Camera.StartBus(PTZEnum.PTZ_RIGHT, 1)
	if err != nil {
		return
	}
	time.Sleep(2000 * time.Millisecond)
	err = Camera.StopBus(PTZEnum.PTZ_RIGHT, 1)
	if err != nil {
		return
	}

	err = Camera.PtzGotoPut(5, 11, 355, 14)
	if err != nil {
		return
	}

	for i := 0; i < 10; i++ {
		ptzdata, err := Camera.GetPTZ()
		if err != nil {
			t.Errorf("GetPTZ() error = %v", err)
			return
		}
		time.Sleep(1000 * time.Millisecond)
		fmt.Printf("%.2f %.2f %.2f \n", ptzdata.P, ptzdata.T, ptzdata.Z)
	}
	err = Camera.Logout()
	if err != nil {
		return
	}
}
