zxl
2 天以前 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.ycl.api.YS.config.temper;
 
import com.sun.jna.ptr.IntByReference;
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_CONFIG_COMMAND_E;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_TAMPER_ALARM_INFO_S;
 
import javax.swing.*;
 
/**
 *
 * @introduction Temper alarm
 * @description Support IPC/NVR
 */
public class TemperAlarm {
 
    /**
     *
     * @introduction Get temper alarm sensitivity
     * @description Calling the interface of NETDEV_GetDevConfig
     *
     */
    public static void getTemperSensitivity() {
        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;
        }
 
        NetDemo.textFieldConfigTemperEquipmentSensitivity.setText(null);
        NETDEV_TAMPER_ALARM_INFO_S stTamperAlarmInfo = new NETDEV_TAMPER_ALARM_INFO_S();
        stTamperAlarmInfo.write();
        IntByReference dwBytesReturned = new IntByReference();
 
        boolean bRet = NetDemo.netdevsdk.NETDEV_GetDevConfig(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_GET_TAMPERALARM, stTamperAlarmInfo.getPointer(), stTamperAlarmInfo.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 {
             stTamperAlarmInfo.read();
             NetDemo.textFieldConfigTemperEquipmentSensitivity.setText(String.valueOf(stTamperAlarmInfo.dwSensitivity));
        }
    }
 
    /**
     *
     * @introduction Set temper alarm sensitivity
     * @description Calling the interface of NETDEV_SetDevConfig
     *
     */
    public static void setTemperSensitivity() {
        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_TAMPER_ALARM_INFO_S stTamperAlarmInfo = new NETDEV_TAMPER_ALARM_INFO_S();
        String FieldConfigTemperEquipmentSensitivity=NetDemo.textFieldConfigTemperEquipmentSensitivity.getText();
        if(FieldConfigTemperEquipmentSensitivity==null||FieldConfigTemperEquipmentSensitivity.equals("")) {
            JOptionPane.showMessageDialog(null, "Sensitivity is null");
            return;
        }
        int TemperEquipmentSensitivity=1;
        try {
            TemperEquipmentSensitivity=Integer.parseInt(FieldConfigTemperEquipmentSensitivity);
        }catch(Exception o) {
            JOptionPane.showMessageDialog(null, "Sensitivity transformation Exception");
            NetDemo.textFieldConfigTemperEquipmentSensitivity.setText(null);
            return;
        }
 
        if(TemperEquipmentSensitivity<1 || TemperEquipmentSensitivity>100) {
            JOptionPane.showMessageDialog(null, "Sensitivity should between 1 and 100");
            NetDemo.textFieldConfigTemperEquipmentSensitivity.setText(null);
            return;
        }
 
        stTamperAlarmInfo.dwSensitivity = TemperEquipmentSensitivity;
        stTamperAlarmInfo.write();
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetDevConfig(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_CONFIG_COMMAND_E.NETDEV_SET_TAMPERALARM, stTamperAlarmInfo.getPointer(), stTamperAlarmInfo.size());
        if(bRet != 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.");
        }
    }
}