浏览代码

1. 导出Core包

kunmeng 2 月之前
父节点
当前提交
666ed24e73
共有 6 个文件被更改,包括 31 次插入31 次删除
  1. 25 25
      BallCamera.go
  2. 2 2
      BallCamera_test.go
  3. 1 1
      Core/CallBack.go
  4. 1 1
      Core/Type.go
  5. 1 1
      Core/core.go
  6. 1 1
      Core/error.go

+ 25 - 25
BallCamera.go

@@ -10,7 +10,7 @@ import (
 	"encoding/binary"
 	"errors"
 	"fmt"
-	"gitea.com/kunmeng/HikNetSDKPkg/core"
+	"gitea.com/kunmeng/HikNetSDKPkg/Core"
 	"sync"
 	"time"
 	"unsafe"
@@ -161,15 +161,15 @@ var HikPTZEnum = struct {
 }
 
 type BallCamera struct {
-	userId       core.LONG
+	userId       Core.LONG
 	_type        uint8
-	deviceInfo   core.NET_DVR_DEVICEINFO_V30
+	deviceInfo   Core.NET_DVR_DEVICEINFO_V30
 	mu           sync.Mutex
 	expectedType byte
 }
 
 func NewBallCamera(Ip string, Port int, Username, Password string, Type uint8) (*BallCamera, error) {
-	UserId, DeviceInfo, err := core.Login(Ip, Port, Username, Password)
+	UserId, DeviceInfo, err := Core.Login(Ip, Port, Username, Password)
 	if err != nil {
 		return nil, err
 	}
@@ -191,7 +191,7 @@ func (this *BallCamera) GetPTZ() (PTZ, error) {
 		var data PTZ
 
 		ch := make(chan bool)
-		SerialStartHandle, err := core.SerialStart(this.userId, func(lSerialHandle core.LONG, lChannel core.LONG, pRecvDataBuffer []byte, dwBufSize core.DWORD, pUser unsafe.Pointer) {
+		SerialStartHandle, err := Core.SerialStart(this.userId, func(lSerialHandle Core.LONG, lChannel Core.LONG, pRecvDataBuffer []byte, dwBufSize Core.DWORD, pUser unsafe.Pointer) {
 			if dwBufSize != 7 {
 				ch <- false
 				return
@@ -220,7 +220,7 @@ func (this *BallCamera) GetPTZ() (PTZ, error) {
 			return data, err
 		}
 		defer func() {
-			err = core.SerialStop(SerialStartHandle)
+			err = Core.SerialStop(SerialStartHandle)
 			if err != nil {
 				println(err.Error())
 			}
@@ -250,9 +250,9 @@ func (this *BallCamera) GetPTZ() (PTZ, error) {
 		}
 		return data, nil
 	}
-	var data core.CDVR_PTZPOS
+	var data Core.CDVR_PTZPOS
 	var dataPtr = unsafe.Pointer(&data)
-	err := core.GetDVRConfig(this.userId, 293, 1, dataPtr, core.DWORD(unsafe.Sizeof(data)))
+	err := Core.GetDVRConfig(this.userId, 293, 1, dataPtr, Core.DWORD(unsafe.Sizeof(data)))
 	if err != nil {
 		return PTZ{}, err
 	}
@@ -274,13 +274,13 @@ func padding(n int) ([]byte, error) {
 
 func (this *BallCamera) PtzGotoPut(Action int, P, T, Z float64) error {
 	if this._type == BuKongQiu {
-		SerialStartHandle, err := core.SerialStart(this.userId, func(lSerialHandle core.LONG, lChannel core.LONG, pRecvDataBuffer []byte, dwBufSize core.DWORD, pUser unsafe.Pointer) {
+		SerialStartHandle, err := Core.SerialStart(this.userId, func(lSerialHandle Core.LONG, lChannel Core.LONG, pRecvDataBuffer []byte, dwBufSize Core.DWORD, pUser unsafe.Pointer) {
 		})
 		if err != nil {
 			return err
 		}
 		defer func() {
-			err = core.SerialStop(SerialStartHandle)
+			err = Core.SerialStop(SerialStartHandle)
 			if err != nil {
 				println(err.Error())
 			}
@@ -321,43 +321,43 @@ func (this *BallCamera) PtzGotoPut(Action int, P, T, Z float64) error {
 		zBuf = append(zBuf, zBufv)
 		switch Action {
 		case 1:
-			err = core.SerialSend(SerialStartHandle, pBuf)
+			err = Core.SerialSend(SerialStartHandle, pBuf)
 			if err != nil {
 				return err
 			}
-			err = core.SerialSend(SerialStartHandle, tBuf)
+			err = Core.SerialSend(SerialStartHandle, tBuf)
 			if err != nil {
 				return err
 			}
-			err = core.SerialSend(SerialStartHandle, zBuf)
+			err = Core.SerialSend(SerialStartHandle, zBuf)
 			if err != nil {
 				return err
 			}
 			break
 		case 2:
-			err = core.SerialSend(SerialStartHandle, pBuf)
+			err = Core.SerialSend(SerialStartHandle, pBuf)
 			if err != nil {
 				return err
 			}
 			break
 		case 3:
-			err = core.SerialSend(SerialStartHandle, tBuf)
+			err = Core.SerialSend(SerialStartHandle, tBuf)
 			if err != nil {
 				return err
 			}
 			break
 		case 4:
-			err = core.SerialSend(SerialStartHandle, zBuf)
+			err = Core.SerialSend(SerialStartHandle, zBuf)
 			if err != nil {
 				return err
 			}
 			break
 		case 5:
-			err = core.SerialSend(SerialStartHandle, pBuf)
+			err = Core.SerialSend(SerialStartHandle, pBuf)
 			if err != nil {
 				return err
 			}
-			err = core.SerialSend(SerialStartHandle, tBuf)
+			err = Core.SerialSend(SerialStartHandle, tBuf)
 			if err != nil {
 				return err
 			}
@@ -367,19 +367,19 @@ func (this *BallCamera) PtzGotoPut(Action int, P, T, Z float64) error {
 		}
 		return nil
 	}
-	var data core.CDVR_PTZPOS
+	var data Core.CDVR_PTZPOS
 	data.Set(float64(Action), P, T, Z)
 	var dataPtr = unsafe.Pointer(&data)
-	err := core.SetDVRConfig(this.userId, 292, 1, dataPtr, core.DWORD(unsafe.Sizeof(data)))
+	err := Core.SetDVRConfig(this.userId, 292, 1, dataPtr, Core.DWORD(unsafe.Sizeof(data)))
 	if err != nil {
 		return err
 	}
 	return nil
 }
 
-func (this *BallCamera) retrySend(handle core.LONG, cmd []byte, maxRetries int, ch <-chan bool) error {
+func (this *BallCamera) retrySend(handle Core.LONG, cmd []byte, maxRetries int, ch <-chan bool) error {
 	for retry := 0; retry < maxRetries; retry++ {
-		if err := core.SerialSend(handle, cmd); err != nil {
+		if err := Core.SerialSend(handle, cmd); err != nil {
 			return err
 		}
 
@@ -401,14 +401,14 @@ func (this *BallCamera) retrySend(handle core.LONG, cmd []byte, maxRetries int,
 }
 
 func (receiver *BallCamera) StartBus(direction int, speed int) error {
-	err := core.PTZControlWithSpeed_Other(receiver.userId, core.LONG(receiver.deviceInfo.ByStartChan), core.DWORD(direction), core.DWORD(0), core.DWORD(speed))
+	err := Core.PTZControlWithSpeed_Other(receiver.userId, Core.LONG(receiver.deviceInfo.ByStartChan), Core.DWORD(direction), Core.DWORD(0), Core.DWORD(speed))
 	if err != nil {
 		return err
 	}
 	return nil
 }
 func (receiver *BallCamera) StopBus(direction int, speed int) error {
-	err := core.PTZControlWithSpeed_Other(receiver.userId, core.LONG(receiver.deviceInfo.ByStartChan), core.DWORD(direction), core.DWORD(1), core.DWORD(speed))
+	err := Core.PTZControlWithSpeed_Other(receiver.userId, Core.LONG(receiver.deviceInfo.ByStartChan), Core.DWORD(direction), Core.DWORD(1), Core.DWORD(speed))
 	if err != nil {
 		return err
 	}
@@ -436,7 +436,7 @@ func (receiver *BallCamera) Logout() error {
 	//		return err
 	//	}
 	//}
-	err := core.Logout(receiver.userId)
+	err := Core.Logout(receiver.userId)
 	if err != nil {
 		return err
 	}

+ 2 - 2
BallCamera_test.go

@@ -2,12 +2,12 @@ package HikSDK
 
 import (
 	"fmt"
-	"gitea.com/kunmeng/HikNetSDKPkg/core"
+	"gitea.com/kunmeng/HikNetSDKPkg/Core"
 	"testing"
 )
 
 func TestCamera(t *testing.T) {
-	err := core.Init()
+	err := Core.Init()
 	if err != nil {
 		return
 	}

+ 1 - 1
core/CallBack.go → Core/CallBack.go

@@ -1,4 +1,4 @@
-package core
+package Core
 
 /*
 #cgo CFLAGS: -I../include

+ 1 - 1
core/Type.go → Core/Type.go

@@ -1,4 +1,4 @@
-package core
+package Core
 
 type DWORD uint32
 type WORD uint16

+ 1 - 1
core/core.go → Core/core.go

@@ -1,4 +1,4 @@
-package core
+package Core
 
 /*
 #cgo CFLAGS: -I../include

+ 1 - 1
core/error.go → Core/error.go

@@ -1,4 +1,4 @@
-package core
+package Core
 
 import "C"
 import (