zxl
4 小时以前 3b0516a2959e25576e4f3fda697a3b025d06c8c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.ycl.api.YS.discovery;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.util.Common;
 
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.stream.Collectors;
 
/**
 * 
 * @introduction discover equipment
 * @description Support IPC/NVR/VMS
 */
public class Discovery {
    /**
     * 
     * @introduction discover equipment
     * @description Calling the interface of NETDEV_SetDiscoveryCallBack
     */
        public static void discoverEquipment() {
            NetDemo.DiscoveryTableModel.setRowCount(0);
            String strBeginIP = NetDemo.jTextFieldStartIP.getText();
            String strEndIP = NetDemo.jTextFieldEndIP.getText();
            if(strBeginIP.isEmpty() && strEndIP.isEmpty()) {
                NetDemo.netdevsdk.NETDEV_SetDiscoveryCallBack(NetDemo.cbDiscoveryCallBack, null);
                NetDemo.netdevsdk.NETDEV_Discovery("0.0.0.0", "0.0.0.0");
                NetDemo.jButtonCheckSameDevice.doClick();
                }
            /* Determine IP address format */
            else if(Common.isIP(strBeginIP) && Common.isIP(strEndIP)) {
                NetDemo.netdevsdk.NETDEV_SetDiscoveryCallBack(NetDemo.cbDiscoveryCallBack, null);  
                boolean bRet = NetDemo.netdevsdk.NETDEV_Discovery(strBeginIP, strEndIP);
                if(!bRet) {
                    JOptionPane.showMessageDialog(null, "Discovery failed. Please check the entered IP address.");
                }else  {
                    NetDemo.jButtonCheckSameDevice.doClick();
                }
            }else {
                JOptionPane.showMessageDialog(null, "Please enter the correct start and end addresses, or do not enter.");
            }
        }
        
        /**
         * 
         * @introduction Check the same device
         * @description 
         */
        public static void checkSameDevice() {
            List list=new ArrayList();
            Vector deviceDetail=null;
            /* Record the parameters of the equipment */
            for(int s=0;s<NetDemo.DiscoveryTableModel.getRowCount();s++) 
            {
                deviceDetail=new Vector();
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 0));
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 1));
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 2));
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 3));
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 4));
                deviceDetail.add(NetDemo.DiscoveryTableModel.getValueAt(s, 5));
                list.add(deviceDetail);
            }
            /* Check repeat equipment */
            List getcheckList=(List) list.stream().distinct().collect(Collectors.toList());
            NetDemo.DiscoveryTableModel.setRowCount(0);
            for(int u=0;u<getcheckList.size();u++) 
            {   
                Vector send=(Vector) getcheckList.get(u);
                NetDemo.DiscoveryTableModel.insertRow(u,send);
            }
            NetDemo.DiscoveryTable.setModel(NetDemo.DiscoveryTableModel);
            
        }
}