| | |
| | | import com.ycl.api.DH.lib.structure.*; |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import com.ycl.utils.StringUtils; |
| | | import constant.ApiConstants; |
| | | import enumeration.DeviceType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.File; |
| | |
| | | netsdk.CLIENT_SetAutoReconnect(haveReConnect, null); |
| | | |
| | | //设置登录超时时间和尝试次数,可选 |
| | | int waitTime = 5000; //登录请求响应超时时间设置为5S |
| | | int waitTime = 3000; //登录请求响应超时时间设置为5S |
| | | int tryTimes = 1; //登录时尝试建立链接1次 |
| | | netsdk.CLIENT_SetConnectTime(waitTime, tryTimes); |
| | | |
| | |
| | | // 设置更多网络参数,NET_PARAM的nWaittime,nConnectTryNum成员与CLIENT_SetConnectTime |
| | | // 接口设置的登录设备超时时间和尝试次数意义相同,可选 |
| | | NetSDKLib.NET_PARAM netParam = new NetSDKLib.NET_PARAM(); |
| | | netParam.nConnectTime = 10000; // 登录时尝试建立链接的超时时间 |
| | | netParam.nConnectTime = 3000; // 登录时尝试建立链接的超时时间 |
| | | netParam.nGetConnInfoTime = 3000; // 设置子连接的超时时间 |
| | | netParam.nGetDevInfoTime = 3000;//获取设备信息超时时间,为0默认1000ms |
| | | netsdk.CLIENT_SetNetworkParam(netParam); |
| | |
| | | return bRet; |
| | | } |
| | | |
| | | public static OSDResult getOsd(LLong loginId) { |
| | | public static OSDResult getOsd(String serialNumber,LLong loginId) { |
| | | OSDResult osdResult = new OSDResult(); |
| | | NetSDKLib.NET_TIME deviceTime = new NetSDKLib.NET_TIME(); |
| | | if (!netsdk.CLIENT_QueryDeviceTime(loginId, deviceTime, 3000)) { |
| | |
| | | |
| | | NET_CFG_GBMODE_INFO osdInfo = new NET_CFG_GBMODE_INFO(); |
| | | osdInfo.write(); |
| | | boolean b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | boolean b = false; |
| | | /** |
| | | * 通过国标倒数第七位判断通道 0/全景 1/细节 |
| | | * 对于海康来说: 国标倒7: 0/全景/通道2 1/细节/通道1 |
| | | * 对于大华来说: 国标倒7: 0/全景/通道1 1/细节/通道2 |
| | | * 宇视单通道不考虑 |
| | | */ |
| | | if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All ) { |
| | | b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | }else if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail){ |
| | | b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 1, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | } |
| | | |
| | | if (!b) { |
| | | // log.error("CLIENT_GetConfig Failed!" + ToolKits.getErrorCodePrint()); |
| | | return null; |
| | |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("TEXT:"+osdStr); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | osdResult.setOSD4(osdStr); |
| | | } |
| | |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("TEXT:"+osdStr); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | if(num ==0){ |
| | | osdResult.setOSD1(osdStr); |
| | |
| | | } |
| | | } |
| | | } |
| | | osdResult.setDeviceBrand(DeviceType.DH.getType()); |
| | | return osdResult; |
| | | } |
| | | |