| | |
| | | |
| | | import com.sun.jna.Pointer; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import com.ycl.api.DH.lib.ToolKits; |
| | | import com.ycl.api.DH.utils.DHApi; |
| | | import com.ycl.api.YS.lib.NetDEVSDKLib; |
| | | import com.ycl.api.YS.login.Login; |
| | | import com.ycl.api.YS.util.Common; |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import com.ycl.utils.StringUtils; |
| | | import enumeration.DeviceType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.table.DefaultTableModel; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Vector; |
| | | import java.util.Date; |
| | | |
| | | import static com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_LOGIN_PROTO_E.NETDEV_LOGIN_PROTO_ONVIF; |
| | | |
| | |
| | | public class YSApi { |
| | | |
| | | public static OSDResult getOsd(String ip, String userName, String password) { |
| | | log.info("ip:{},用户:{},密码:{}", ip, userName, password); |
| | | //登录 |
| | | NetDEVSDKLib.NETDEV_DEVICE_LOGIN_INFO_S stDevLoginInfo = new NetDEVSDKLib.NETDEV_DEVICE_LOGIN_INFO_S(); |
| | | NetDEVSDKLib.NETDEV_SELOG_INFO_S stSELogInfo = new NetDEVSDKLib.NETDEV_SELOG_INFO_S(); |
| | |
| | | NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[] stVideoChlList = (NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[]) new NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S().toArray(nMaxChlCount); |
| | | boolean bRe = YSInit.netdevsdk.NETDEV_QueryVideoChlDetailListEx(lpUserID, dwChlCount, stVideoChlList); |
| | | if (!bRe) { |
| | | log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | // log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | return null; |
| | | } |
| | | //获取时间 |
| | | NetDEVSDKLib.NETDEV_TIME_CFG_S stTimeCfg = new NetDEVSDKLib.NETDEV_TIME_CFG_S(); |
| | | stTimeCfg.write(); |
| | | boolean bRetime = NetDemo.netdevsdk.NETDEV_GetSystemTimeCfg(lpUserID, stTimeCfg); |
| | | Date checkTime = new Date(); |
| | | osdResult.setCheckTime(checkTime); |
| | | if (!bRetime) { |
| | | log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | // log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | return null; |
| | | } else { |
| | | stTimeCfg.read(); |
| | |
| | | try { |
| | | osdResult.setOsdTime(format.parse(strTime)); |
| | | } catch (Exception e) { |
| | | log.error(ip + "时间解析有误"); |
| | | // log.error(ip + "时间解析有误"); |
| | | } |
| | | } |
| | | //获取osd |
| | |
| | | |
| | | boolean bRet = YSInit.netdevsdk.NETDEV_GetDevConfig(lpUserID, stVideoChlList[0].dwChannelID, NetDEVSDKLib.NETDEV_CONFIG_COMMAND_E.NETDEV_GET_OSDCFG, stOSDInfo.getPointer(), 616, dwBytesReturned); |
| | | if (!bRet) { |
| | | log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | // log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | return null; |
| | | } |
| | | stOSDInfo.read(); |
| | | //省份 |
| | | String name = new String(stOSDInfo.stNameOSD.szOSDText, StandardCharsets.UTF_8); |
| | | String name = new String(stOSDInfo.stNameOSD.szOSDText, StandardCharsets.UTF_8).trim(); |
| | | osdResult.setOSD1(name); |
| | | // log.info("name"+name); |
| | | int num = 0; |
| | | for (NetDEVSDKLib.NETDEV_OSD_TEXT_OVERLAY_S osd : stOSDInfo.astTextOverlay) { |
| | | String text = new String(osd.szOSDText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("num:"+num+",texr:"+text); |
| | | if (num == 0) { |
| | | osdResult.setOSD2(text); |
| | | } else if (num == 1) { |
| | |
| | | } |
| | | //登出 |
| | | YSInit.netdevsdk.NETDEV_Logout(lpUserID); |
| | | osdResult.setDeviceBrand(DeviceType.YS.getType()); |
| | | return osdResult; |
| | | } else { |
| | | log.error("error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | // log.error("ip:"+ip+",error code" + YSInit.netdevsdk.NETDEV_GetLastError()); |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static void demo() { |