package com.ycl.api.YS.config.network; import com.sun.jna.ptr.IntByReference; import com.ycl.api.YS.NetDemo; import com.ycl.api.YS.util.Common; import com.ycl.api.YS.lib.NetDEVSDKLib; import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_CONFIG_COMMAND_E; import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_DEVICE_TYPE_E; import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_SYSTEM_IPADDR_INFO_S; import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_SYSTEM_NTP_INFO_LIST_S; import javax.swing.*; import java.util.InputMismatchException; /** * * @introduction NTP * @description Support IPC/NVR */ public class NTP { /** * * @introduction Get NTP information * @description Calling the interface of NETDEV_GetDevConfig * */ public static void getNTPInfo() { if(null == NetDemo.lpUserID){ JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError()); return; } if(NetDemo.ChannelID == 0){ JOptionPane.showMessageDialog(null, "Please select an online channel after login."); return; } NETDEV_SYSTEM_NTP_INFO_LIST_S stNTPInfo = new NETDEV_SYSTEM_NTP_INFO_LIST_S(); for(int i =0; i65535) { JOptionPane.showMessageDialog(null, "NTP port should between 0 and 65535"); NetDemo.textFieldConfigNetWorkNTPPort.setText(null); return; } stNTPInfo.astNTPServerInfoList[0].ulPort = getFieldConfigNetWorkNTPPort; String SynchronizeInterval=NetDemo.textFieldConfigNetWorkNTPSynchronizeInterval.getText(); int Interval=0; try { Interval=Integer.valueOf(SynchronizeInterval); }catch(Exception t) { JOptionPane.showMessageDialog(null, "Interval is null or transformation Exception"); return; } stNTPInfo.astNTPServerInfoList[0].ulSynchronizeInterval = Interval; stNTPInfo.write(); boolean bRet2 = NetDemo.netdevsdk.NETDEV_SetDevConfig(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_SET_NTPCFG_EX, stNTPInfo.getPointer(), stNTPInfo.size()); if(bRet2 != true) { JOptionPane.showMessageDialog(null, "Set data failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError()); System.out.printf("NETDEV_SetDevConfig failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError()); return; }else { JOptionPane.showMessageDialog(null, "Set success"); } } } /** * * @introduction Choose IP type * @description * */ public static void changeIPType() { if(NetDemo.pstDeviceInfo.dwDeviceType == NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_IPC || NetDemo.pstDeviceInfo.dwDeviceType == NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_IPC_FISHEYE || NetDemo.pstDeviceInfo.dwDeviceType == NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_IPC_ECONOMIC_FISHEYE || NetDemo.pstDeviceInfo.dwDeviceType == NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_IPC_ACS) { if(NetDemo.jComboBoxConfigNetWorkNTPIPType.getSelectedIndex()==1) { NetDemo.jComboBoxConfigNetWorkNTPIPType.setSelectedIndex(0); NetDemo.textFieldConfigNetWorkNTPDomainName.setEnabled(false); NetDemo.textFieldConfigNetWorkNTPServerIP.setEnabled(true); JOptionPane.showMessageDialog(null, "Not support ipv6,please wait other version,please choose IPV4 or domain name"); return; } } if(NetDemo.jComboBoxConfigNetWorkNTPIPType.getSelectedIndex()==0) { NetDemo.textFieldConfigNetWorkNTPDomainName.setEnabled(false); NetDemo.textFieldConfigNetWorkNTPServerIP.setEnabled(true); }else if(NetDemo.jComboBoxConfigNetWorkNTPIPType.getSelectedIndex()==2) { NetDemo.textFieldConfigNetWorkNTPDomainName.setEnabled(true); NetDemo.textFieldConfigNetWorkNTPServerIP.setEnabled(false); }else { NetDemo.jComboBoxConfigNetWorkNTPIPType.setSelectedIndex(0); NetDemo.textFieldConfigNetWorkNTPDomainName.setEnabled(false); NetDemo.textFieldConfigNetWorkNTPServerIP.setEnabled(true); JOptionPane.showMessageDialog(null, "Not support ipv6,please wait other version,please choose IPV4 or domain name"); return; } } }