From 666ed24e737ff0d6ec5f42abbdcec9a87f83b0ac Mon Sep 17 00:00:00 2001 From: kunmeng Date: Thu, 27 Feb 2025 11:33:07 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=AF=BC=E5=87=BACore=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BallCamera.go | 50 +++++++++++++++++++------------------- BallCamera_test.go | 4 +-- {core => Core}/CallBack.go | 2 +- {core => Core}/Type.go | 2 +- {core => Core}/core.go | 2 +- {core => Core}/error.go | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) rename {core => Core}/CallBack.go (99%) rename {core => Core}/Type.go (98%) rename {core => Core}/core.go (99%) rename {core => Core}/error.go (97%) diff --git a/BallCamera.go b/BallCamera.go index 9e819dc..cd07bac 100644 --- a/BallCamera.go +++ b/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 } diff --git a/BallCamera_test.go b/BallCamera_test.go index 2d41722..9d00b90 100644 --- a/BallCamera_test.go +++ b/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 } diff --git a/core/CallBack.go b/Core/CallBack.go similarity index 99% rename from core/CallBack.go rename to Core/CallBack.go index 904d947..57ef24f 100644 --- a/core/CallBack.go +++ b/Core/CallBack.go @@ -1,4 +1,4 @@ -package core +package Core /* #cgo CFLAGS: -I../include diff --git a/core/Type.go b/Core/Type.go similarity index 98% rename from core/Type.go rename to Core/Type.go index 1994a94..4243891 100644 --- a/core/Type.go +++ b/Core/Type.go @@ -1,4 +1,4 @@ -package core +package Core type DWORD uint32 type WORD uint16 diff --git a/core/core.go b/Core/core.go similarity index 99% rename from core/core.go rename to Core/core.go index 2afe9b4..edb9ad0 100644 --- a/core/core.go +++ b/Core/core.go @@ -1,4 +1,4 @@ -package core +package Core /* #cgo CFLAGS: -I../include diff --git a/core/error.go b/Core/error.go similarity index 97% rename from core/error.go rename to Core/error.go index db4b710..110b888 100644 --- a/core/error.go +++ b/Core/error.go @@ -1,4 +1,4 @@ -package core +package Core import "C" import (