提交 | 用户 | 时间
149dd0 1 package com.iailab.netsdk.demo.frame.scada;
H 2
3 import com.iailab.netsdk.lib.NetSDKLib;
4 import com.iailab.netsdk.lib.Utils;
5 import com.sun.jna.Pointer;
6
7 import javax.swing.*;
8 import javax.swing.table.DefaultTableModel;
9 import java.nio.charset.Charset;
10
11 /**
12  * className:SCADAAlarmAttachInfoCallBack
13  * description:动环主机:智能事件回调函数 订阅监测点报警信息回调
14  * author:251589
15  * createTime:2021/4/10 16:54
16  *
17  * @version v1.0
18  */
19
20 public class SCADAAlarmAttachInfoCallBack implements NetSDKLib.fSCADAAlarmAttachInfoCallBack {
21     // 多平台 编码
22     private final Charset encode = Charset.forName(Utils.getPlatformEncode());
23     private static SCADAAlarmAttachInfoCallBack INSTANCE;
24     private JTable table;
25
26     @Override
27     public void invoke(NetSDKLib.LLong lAttachHandle,
28                        NetSDKLib.NET_SCADA_NOTIFY_POINT_ALARM_INFO_LIST pInfo, int nBufLen,
29                        Pointer dwUser) {
30
31         System.out.println("————————————————————【订阅监测点报警信息回调】————————————————————");
32         //更新列表
33         if (table != null) {
34             DefaultTableModel model = (DefaultTableModel) table.getModel();
35             for (int i = 0; i < pInfo.nList; i++) {
36                 System.out.println(" 设备ID:" + new String(pInfo.stuList[i].szDevID).trim());
37                 System.out.println(" 点位ID:" + new String(pInfo.stuList[i].szPointID).trim());
38                 String alarmDesc = new String(pInfo.stuList[i].szAlarmDesc, encode).trim();
39                 System.out.println(" 报警描述:" + alarmDesc);
40
41                 System.out.println(" 报警标志:" + (pInfo.stuList[i].bAlarmFlag == 1));
42                 System.out.println(" 报警时间:" + pInfo.stuList[i].stuAlarmTime.toStringTime());
43                 System.out.println(" 报警级别(0~6):" + pInfo.stuList[i].nAlarmLevel);
44                 System.out.println(" 报警编号(同一个告警的开始和结束的编号是相同的):" + pInfo.stuList[i].nSerialNo);
45                 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});
46             }
47         }
48         System.out.println("————————————————————【订阅监测点报警信息回调】————————————————————");
49     }
50
51     private SCADAAlarmAttachInfoCallBack(JTable table) {
52         this.table = table;
53     }
54
55     public static SCADAAlarmAttachInfoCallBack getINSTANCE(JTable table) {
56         if (INSTANCE == null) {
57             INSTANCE = new SCADAAlarmAttachInfoCallBack(table);
58         }
59         if (table != null) {
60             INSTANCE.table = table;
61         }
62
63         return INSTANCE;
64     }
65
66 }