Camera Information System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

75 lines
1.9 KiB

namespace EC.Helper.CameraSDK;
public class YuShiSDK : ICameraSDK
{
#region Attr
private IntPtr LoginId { get; set; } = IntPtr.Zero;
#endregion Attr
public YuShiSDK(CameraInfo cameraInfo) : base(cameraInfo)
{
}
#region Base Method
public override bool Init()
{
bool ret = ConnectSuccess();
if (ret) return true;
YuShiOriSDK.NETDEV_DEVICE_LOGIN_INFO_S loginInfo = new();
loginInfo.szIPAddr = CameraInfo.Ip;
loginInfo.dwPort = CameraInfo.Port;
loginInfo.szUserName = CameraInfo.UserName;
loginInfo.szPassword = CameraInfo.Password;
YuShiOriSDK.NETDEV_SELOG_INFO_S logInfo = new();
LoginId = YuShiOriSDK.NETDEV_Login_V30(ref loginInfo, ref logInfo);
ret = ConnectSuccess();
return ret;
}
public override bool Destory()
{
bool ret = ConnectSuccess();
if (!ret) return true;
ret = YuShiOriSDK.NETDEV_Logout(LoginId);
if (ret) LoginId = IntPtr.Zero;
return ret;
}
public override bool ConnectSuccess()
{
return LoginId != IntPtr.Zero;
}
public override void BuildException()
{
int errCode = YuShiOriSDK.NETDEV_GetLastError();
if (errCode == 0) return;
throw CameraException.New(CameraType.YuShi, (int)errCode);
}
#endregion Base Method
#region Main Method
public override bool GetPtzInfo(out PtzInfo ptzInfo)
{
bool ret = ConnectSuccess();
if (!ret) { ptzInfo = PtzInfo.Default; return false; }
YuShiOriSDK.NETDEV_PTZ_STATUS_S entity = new();
ret = YuShiOriSDK.NETDEV_PTZGetStatus(LoginId, 1, ref entity);
if (!ret) { BuildException(); ptzInfo = PtzInfo.Default; return false; }
ptzInfo = PtzInfo.New(entity.fPanTiltX, entity.fPanTiltY, entity.fZoomX);
return true;
}
#endregion Main Method
}