Jay
2024-11-08 02722a3f9eca857ce7fffea352e9f7ee692a1b71
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
package com.iailab.netsdk.demo.frame.scada;
 
import com.iailab.netsdk.lib.NetSDKLib;
import com.iailab.netsdk.lib.Utils;
import com.sun.jna.Pointer;
 
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.nio.charset.Charset;
 
/**
 * className:SCADAAlarmAttachInfoCallBack
 * description:动环主机:智能事件回调函数 订阅监测点报警信息回调
 * author:251589
 * createTime:2021/4/10 16:54
 *
 * @version v1.0
 */
 
public class SCADAAlarmAttachInfoCallBack implements NetSDKLib.fSCADAAlarmAttachInfoCallBack {
    // 多平台 编码
    private final Charset encode = Charset.forName(Utils.getPlatformEncode());
    private static SCADAAlarmAttachInfoCallBack INSTANCE;
    private JTable table;
 
    @Override
    public void invoke(NetSDKLib.LLong lAttachHandle,
                       NetSDKLib.NET_SCADA_NOTIFY_POINT_ALARM_INFO_LIST pInfo, int nBufLen,
                       Pointer dwUser) {
 
        System.out.println("————————————————————【订阅监测点报警信息回调】————————————————————");
        //更新列表
        if (table != null) {
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            for (int i = 0; i < pInfo.nList; i++) {
                System.out.println(" 设备ID:" + new String(pInfo.stuList[i].szDevID).trim());
                System.out.println(" 点位ID:" + new String(pInfo.stuList[i].szPointID).trim());
                String alarmDesc = new String(pInfo.stuList[i].szAlarmDesc, encode).trim();
                System.out.println(" 报警描述:" + alarmDesc);
 
                System.out.println(" 报警标志:" + (pInfo.stuList[i].bAlarmFlag == 1));
                System.out.println(" 报警时间:" + pInfo.stuList[i].stuAlarmTime.toStringTime());
                System.out.println(" 报警级别(0~6):" + pInfo.stuList[i].nAlarmLevel);
                System.out.println(" 报警编号(同一个告警的开始和结束的编号是相同的):" + pInfo.stuList[i].nSerialNo);
                model.addRow(new Object[]{new String(pInfo.stuList[i].szDevID).trim(), new String(pInfo.stuList[i].szPointID).trim(), alarmDesc, pInfo.stuList[i].stuAlarmTime.toStringTime(), pInfo.stuList[i].nAlarmLevel});
            }
        }
        System.out.println("————————————————————【订阅监测点报警信息回调】————————————————————");
    }
 
    private SCADAAlarmAttachInfoCallBack(JTable table) {
        this.table = table;
    }
 
    public static SCADAAlarmAttachInfoCallBack getINSTANCE(JTable table) {
        if (INSTANCE == null) {
            INSTANCE = new SCADAAlarmAttachInfoCallBack(table);
        }
        if (table != null) {
            INSTANCE.table = table;
        }
 
        return INSTANCE;
    }
 
}