fuliqi
2024-08-29 4163c93761115c7524ef74a557a1f5e01eafb429
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
98
99
100
101
102
103
104
105
106
package com.ycl.api.YS.alarm.thermal;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_LAPI_SUB_INFO_S;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_SUBSCRIBE_SUCC_INFO_S;
 
import javax.swing.*;
 
/**
 * @description ThermalAlarm
 * @introduction Support IPC/VMS-AIBox
 */
public class ThermalAlarm {
    public static void subscibeAlarm() {
        if(null == NetDemo.lpUserID){
            JOptionPane.showMessageDialog(null, "Please Login device first.");
            return;
        }
 
        if(-1 != NetDemo.udwThermalAlarmSubID)
        {
            JOptionPane.showMessageDialog(null, "Please UnSubLapiAlarm first.");
            return;
        }
 
        setAlarmCallBack();
 
         NETDEV_LAPI_SUB_INFO_S stSubInfo = new NETDEV_LAPI_SUB_INFO_S();
         //stSubInfo.udwType  = 12288; //bit12||bit13
         //stSubInfo.udwType  = 4096; //bit12
         stSubInfo.udwType  = 8192; //bit13
         NETDEV_SUBSCRIBE_SUCC_INFO_S stSubSuccInfo = new NETDEV_SUBSCRIBE_SUCC_INFO_S();
 
         boolean bRet = NetDemo.netdevsdk.NETDEV_SubscibeLapiAlarm(NetDemo.lpUserID, stSubInfo, stSubSuccInfo);
         if(false == bRet){
             System.out.printf("NETDEV_SubscibeLapiAlarm failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
             JOptionPane.showMessageDialog(null, "NETDEV_SubscibeLapiAlarm failed");
             return;
             }
         else{
             NetDemo.udwThermalAlarmSubID = stSubSuccInfo.udwID;
             JOptionPane.showMessageDialog(null, "NETDEV_SubscibeLapiAlarm success");
             }
         }
 
    public static void unSubscibeAlarm() {
        if(null == NetDemo.lpUserID){
            JOptionPane.showMessageDialog(null, "Please Login device first.");
            return;
        }
 
        boolean bRet = NetDemo.netdevsdk.NETDEV_UnSubLapiAlarm(NetDemo.lpUserID, NetDemo.udwThermalAlarmSubID);
        if(false == bRet){
            System.out.printf("NETDEV_UnSubLapiAlarm failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            JOptionPane.showMessageDialog(null, "NETDEV_UnSubLapiAlarm failed");
            return;
        }
        else
        {
            NetDemo.udwThermalAlarmSubID = -1;
            NetDemo.jComboBoxConflagration.removeAllItems();
            NetDemo.jComboBoxSmoking.removeAllItems();
            NetDemo.jTextFiledValueType.setText(null);
            NetDemo.jTextFiledAlarmValue.setText(null);
            JOptionPane.showMessageDialog(null, "NETDEV_UnSubLapiAlarm success");
            return;
        }
    }
 
    private static void setAlarmCallBack() {
        boolean bRet = NetDemo.netdevsdk.NETDEV_SetConflagrationAlarmCallBackV30(NetDemo.lpUserID, NetDemo.ConflagrationAlarmMessCB_V30, null);
        boolean bRet1 = NetDemo.netdevsdk.NETDEV_SetSmokeAlarmCallBack(NetDemo.lpUserID, NetDemo.SmokingAlarmMessCB, null);
        boolean bRet2 = NetDemo.netdevsdk.NETDEV_SetTemperatureDetcCallBack(NetDemo.lpUserID, NetDemo.TemperatureAlarmMessCB, null);
        //boolean bRet3 = NetDemo.netdevsdk.NETDEV_SetConflagrationAlarmCallBack(NetDemo.lpUserID, NetDemo.ConflagrationAlarmMessCB, NetDemo.lpUserID);
 
        if(true == (bRet && bRet1 && bRet2 )) {
            JOptionPane.showMessageDialog(null, "NETDEV_SetAlarmCallBack success");
        }
        else if(false == bRet){
            System.out.printf("NETDEV_SetConflagrationAlarmCallBackV30 failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            JOptionPane.showMessageDialog(null, "NETDEV_SetConflagrationAlarmCallBackV30 failed");
            return ;
        }
        else if(false == bRet1){
            System.out.printf("NETDEV_SetSmokeAlarmCallBack failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            JOptionPane.showMessageDialog(null, "NETDEV_SetSmokeAlarmCallBack failed");
            return ;
        }
        else if(false == bRet2){
            System.out.printf("NETDEV_SetTemperatureDetcCallBack failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            JOptionPane.showMessageDialog(null, "NETDEV_SetTemperatureDetcCallBack failed");
            return ;
        }
//        else if(false == bRet3){
//            System.out.printf("NETDEV_SetConflagrationAlarmCallBack failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
//            JOptionPane.showMessageDialog(null, "NETDEV_SetConflagrationAlarmCallBack failed");
//            return ;
//        }
        else {
            System.out.printf("NETDEV_SubscibeLapiAlarm failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            JOptionPane.showMessageDialog(null, "NETDEV_SubscibeLapiAlarm failed");
            return ;
        }
    }
 
}