From 5bf74a24efce4d2b299b3a4310fc4c7e14c1e86f Mon Sep 17 00:00:00 2001 From: kunmeng Date: Wed, 21 May 2025 10:06:27 +0800 Subject: [PATCH] =?UTF-8?q?1.=20NVR=20Status=20=E4=BD=86=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=A4=B1=E8=B4=A5=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9Efalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Nvr.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Nvr.go b/Nvr.go index ddd6fee..75f1151 100644 --- a/Nvr.go +++ b/Nvr.go @@ -7,6 +7,7 @@ package HikSDK */ import "C" import ( + "errors" "gitea.com/kunmeng/HikNetSDKPkg/Core" "time" "unsafe" @@ -29,6 +30,9 @@ func NewNvr(Ip string, Port int, Username, Password string) (*Nvr, error) { } func (this *Nvr) GetTimeZone() (int, error) { + if this == nil { + return 0, errors.New("Nvr is nil") + } 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()))) @@ -41,7 +45,9 @@ func (this *Nvr) GetTimeZone() (int, error) { } func (this *Nvr) CheckTimeRegionWithMonth(Year, Month, Channel uint16) ([]uint8, error) { - + if this == nil { + return nil, errors.New("Nvr is nil") + } // //// 查当月 var struSearchParam Core.NET_DVR_MRD_SEARCH_PARAM struSearchParam.DwSize = Core.DWORD(unsafe.Sizeof(struSearchParam.GetC())) @@ -72,6 +78,9 @@ func (this *Nvr) CheckTimeRegionWithMonth(Year, Month, Channel uint16) ([]uint8, } func (this *Nvr) CheckTimeRegionWithDay(Year, Month, Day, Channel uint16) ([]TimeRange, error) { + if this == nil { + return nil, errors.New("Nvr is nil") + } var Data Core.NET_DVR_FILECOND Data.DwFileType = 0xff Data.DwIsLocked = 0xff @@ -163,6 +172,9 @@ func (this *Nvr) CheckTimeRegionWithDay(Year, Month, Day, Channel uint16) ([]Tim return res, nil } func (this *Nvr) Logout() error { + if this == nil { + return errors.New("Nvr is nil") + } return Core.Logout(this.userId) }