zxl
1 天以前 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
78
79
package com.ycl.api.YS.config.io;
 
import com.sun.jna.ptr.IntByReference;
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.util.Common;
import com.ycl.api.YS.util.Util;
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_INPUT_SWITCH_INFO_LIST_S;
 
import javax.swing.*;
import java.util.Vector;
 
/**
 *
 * @introduction Alarm input information
 * @description Support IPC/NVR/VMS
 */
public class AlarmInput {
 
    /**
     *
     * @introduction Get alarm input information
     * @description Calling the interface of NETDEV_GetDevConfig
     *
     */
    public static void getAlarmInput() {
        if(null == NetDemo.lpUserID) {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        NETDEV_INPUT_SWITCH_INFO_LIST_S stInputSwitchInfoList = new NETDEV_INPUT_SWITCH_INFO_LIST_S();
        stInputSwitchInfoList.write();
        IntByReference dwBytesReturned = new IntByReference();
        boolean bRet = NetDemo.netdevsdk.NETDEV_GetDevConfig(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_GET_INPUTSWITCH_LIST_CFG, stInputSwitchInfoList.getPointer(), stInputSwitchInfoList.size(), dwBytesReturned );
        if(bRet != true) {
            JOptionPane.showMessageDialog(null, "Get data failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_GetDevConfig failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }else {
            stInputSwitchInfoList.read();
            NetDemo.ConfigIOAlarmInputTableModel.setRowCount(0);
            if(NetDemo.pstDeviceInfo.dwDeviceType == NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_VMS){
                 for(int i = 0; i < stInputSwitchInfoList.udwNum; i++) {
                    Vector<String> InputSwitchInfoVector = new Vector<String>();
                    InputSwitchInfoVector.add(Common.byteArrayToString(stInputSwitchInfoList.astInputSwitchesInfo[i].szName));
                    String getAlarmRunMode=null;
                    getAlarmRunMode=Util.getAlarmRunMode(stInputSwitchInfoList.astInputSwitchesInfo[i].dwRunMode);
                    InputSwitchInfoVector.add(getAlarmRunMode);
                    String getEnable=null;
                    getEnable=Util.getEnable(stInputSwitchInfoList.astInputSwitchesInfo[i].dwEnabled);
                    InputSwitchInfoVector.add(getEnable);
                    NetDemo.ConfigIOAlarmInputTableModel.addRow(InputSwitchInfoVector);
                    }
                 }else {
                     for(int i = 0; i < stInputSwitchInfoList.udwNum; i++) {
                        Vector<String> InputSwitchInfoVector = new Vector<String>();
                        if(stInputSwitchInfoList.astInputSwitchesInfo[i].dwChancelId==0) {
                            InputSwitchInfoVector.add("AlarmInput_A_"+String.valueOf(stInputSwitchInfoList.astInputSwitchesInfo[i].dwInputSwitchIndex));
                        }
                        else {
                            InputSwitchInfoVector.add("AlarmInput_D_"+String.valueOf(stInputSwitchInfoList.astInputSwitchesInfo[i].dwChancelId)+"_"+String.valueOf(stInputSwitchInfoList.astInputSwitchesInfo[i].dwInputSwitchIndex));
                        }
 
                        String getAlarmRunMode=null;
                        getAlarmRunMode=Util.getAlarmRunMode(stInputSwitchInfoList.astInputSwitchesInfo[i].dwRunMode);
                        InputSwitchInfoVector.add(getAlarmRunMode);
 
                        String getEnable=null;
                        getEnable=Util.getEnable(stInputSwitchInfoList.astInputSwitchesInfo[i].dwEnabled);
                        InputSwitchInfoVector.add(getEnable);
 
                        NetDemo.ConfigIOAlarmInputTableModel.addRow(InputSwitchInfoVector);
                        }
                     }
            }
        }
    }