1
0

2 Commits e936405e13 ... cefba47e97

Autor SHA1 Nachricht Datum
  kunmeng cefba47e97 1. NVR 和 BallCamera 添加 Status 功能 vor 5 Tagen
  kunmeng a97fc849b8 Merge branch 'kun' of kunmeng/HikNetSDKPkg into master vor 1 Monat
5 geänderte Dateien mit 17 neuen und 5 gelöschten Zeilen
  1. 4 0
      BallCamera.go
  2. 2 2
      BallCamera_test.go
  3. 4 0
      Core/core.go
  4. 6 2
      Nvr.go
  5. 1 1
      Nvr_test.go

+ 4 - 0
BallCamera.go

@@ -432,3 +432,7 @@ func verify(data []byte) (byte, error) {
 func (this *BallCamera) Logout() error {
 	return Core.Logout(this.userId)
 }
+
+func (this *BallCamera) Status() bool {
+	return Core.NET_DVR_RemoteControl(this.userId)
+}

+ 2 - 2
BallCamera_test.go

@@ -12,8 +12,8 @@ func TestCamera(t *testing.T) {
 	if err != nil {
 		return
 	}
-	Camera, err := NewBallCamera("192.168.211.48", 8000, "admin", "okwy1234", BuKongQiu)
-	//Camera, err := NewBallCamera("192.168.211.64", 8000, "admin", "ubis3333", Base)
+	//Camera, err := NewBallCamera("192.168.211.48", 8000, "admin", "okwy1234", BuKongQiu)
+	Camera, err := NewBallCamera("192.168.211.64", 8000, "admin", "ubis3333", Base)
 	if err != nil {
 		t.Errorf("NewBallCamera() error = %v", err)
 		return

+ 4 - 0
Core/core.go

@@ -58,6 +58,10 @@ func Login(Ip string, Port int, Username string, Password string) (LONG, NET_DVR
 	return LONG(cUserId), DeviceInfo, nil
 }
 
+func NET_DVR_RemoteControl(userId LONG) bool {
+	return C.NET_DVR_RemoteControl(C.LONG(userId), C.DWORD(20005), nil, C.DWORD(0)) == C.TRUE
+}
+
 func Logout(userId LONG) error {
 	if userId > -1 {
 		cResult := C.NET_DVR_Logout(C.LONG(userId))

+ 6 - 2
Nvr.go

@@ -28,7 +28,7 @@ func NewNvr(Ip string, Port int, Username, Password string) (*Nvr, error) {
 	}, nil
 }
 
-func (this *Nvr) getNvrUTCDiff() (int, error) {
+func (this *Nvr) GetTimeZone() (int, error) {
 	var data Core.NET_DVR_NETAPPCFG
 	var dataPtr = unsafe.Pointer(data.GetCPtr())
 	err := Core.GetDVRConfig(this.userId, 222, 0, dataPtr, Core.DWORD(unsafe.Sizeof(data.GetC())))
@@ -105,7 +105,7 @@ func (this *Nvr) CheckTimeRegionWithDay(Year, Month, Day, Channel uint16) ([]Tim
 	if err != nil {
 		return nil, err
 	}
-	ByUTCDiff, err := this.getNvrUTCDiff()
+	ByUTCDiff, err := this.GetTimeZone()
 	if err != nil {
 		return nil, err
 	}
@@ -166,6 +166,10 @@ func (this *Nvr) Logout() error {
 	return Core.Logout(this.userId)
 }
 
+func (this *Nvr) Status() bool {
+	return Core.NET_DVR_RemoteControl(this.userId)
+}
+
 type TimeRange struct {
 	StartTime time.Time
 	EndTime   time.Time

+ 1 - 1
Nvr_test.go

@@ -15,7 +15,7 @@ func TestNewNvr(t *testing.T) {
 	if err != nil {
 		t.Error(err)
 	}
-	diff, err := nvr.getNvrUTCDiff()
+	diff, err := nvr.GetTimeZone()
 	if err != nil {
 		return
 	}