From b4c50572d8f0201cc427e6be9c40bada6b2bdffe Mon Sep 17 00:00:00 2001 From: kunmeng Date: Wed, 21 May 2025 10:11:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=20BallCamera=20Status=20=E4=BD=86=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=88=9D=E5=A7=8B=E5=8C=96=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9Efalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BallCamera.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/BallCamera.go b/BallCamera.go index 4effbbb..29d2753 100644 --- a/BallCamera.go +++ b/BallCamera.go @@ -187,6 +187,9 @@ type PTZ struct { } func (this *BallCamera) GetPTZ() (PTZ, error) { + if this == nil { + return PTZ{}, errors.New("BallCamera is nil") + } if this._type == BuKongQiu { var data PTZ @@ -273,6 +276,9 @@ func padding(n int) ([]byte, error) { } func (this *BallCamera) PtzGotoPut(Action int, P, T, Z float64) error { + if this == nil { + return errors.New("BallCamera is nil") + } 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) { }) @@ -400,7 +406,9 @@ func (this *BallCamera) retrySend(handle Core.LONG, cmd []byte, maxRetries int, } func (receiver *BallCamera) StartBus(direction int, speed int) error { - + if receiver == nil { + return errors.New("BallCamera is nil") + } err := Core.PTZControlWithSpeed_Other(receiver.userId, Core.LONG(receiver.deviceInfo.ByStartChan), Core.DWORD(PTZEnum.toHikPTZEnum(direction)), Core.DWORD(0), Core.DWORD(speed)) if err != nil { return err @@ -408,6 +416,9 @@ func (receiver *BallCamera) StartBus(direction int, speed int) error { return nil } func (receiver *BallCamera) StopBus(direction int, speed int) error { + if receiver == nil { + return errors.New("BallCamera is nil") + } err := Core.PTZControlWithSpeed_Other(receiver.userId, Core.LONG(receiver.deviceInfo.ByStartChan), Core.DWORD(PTZEnum.toHikPTZEnum(direction)), Core.DWORD(1), Core.DWORD(speed)) if err != nil { return err @@ -429,9 +440,15 @@ func verify(data []byte) (byte, error) { } func (this *BallCamera) Logout() error { + if this == nil { + return errors.New("BallCamera is nil") + } return Core.Logout(this.userId) } func (this *BallCamera) Status() bool { + if this == nil { + return false + } return Core.NET_DVR_RemoteControl(this.userId) }