提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.frame.vto; |
H |
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.EventQueue; |
|
6 |
import java.awt.Panel; |
|
7 |
import java.awt.event.MouseAdapter; |
|
8 |
import java.awt.event.MouseEvent; |
|
9 |
import java.awt.event.WindowAdapter; |
|
10 |
import java.awt.event.WindowEvent; |
|
11 |
|
|
12 |
import javax.swing.JButton; |
|
13 |
import javax.swing.JFrame; |
|
14 |
import javax.swing.JLabel; |
|
15 |
import javax.swing.JOptionPane; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.JPasswordField; |
|
18 |
import javax.swing.JScrollPane; |
|
19 |
import javax.swing.JTabbedPane; |
|
20 |
import javax.swing.JTable; |
|
21 |
import javax.swing.JTextField; |
|
22 |
import javax.swing.ListSelectionModel; |
|
23 |
import javax.swing.ScrollPaneConstants; |
|
24 |
import javax.swing.SwingUtilities; |
|
25 |
import javax.swing.UIManager; |
|
26 |
import javax.swing.border.EmptyBorder; |
|
27 |
import javax.swing.border.TitledBorder; |
|
28 |
import javax.swing.table.DefaultTableCellRenderer; |
|
29 |
import javax.swing.table.DefaultTableModel; |
|
30 |
|
|
31 |
import com.sun.jna.Memory; |
|
32 |
import com.sun.jna.Pointer; |
|
33 |
|
|
34 |
import com.iailab.netsdk.common.FunctionList; |
|
35 |
import com.iailab.netsdk.common.PaintPanel; |
|
36 |
import com.iailab.netsdk.common.Res; |
|
37 |
import com.iailab.netsdk.demo.module.AlarmListenModule; |
|
38 |
import com.iailab.netsdk.demo.module.GateModule; |
|
39 |
import com.iailab.netsdk.demo.module.LoginModule; |
|
40 |
import com.iailab.netsdk.demo.module.RealPlayModule; |
|
41 |
import com.iailab.netsdk.demo.module.TalkModule; |
|
42 |
import com.iailab.netsdk.lib.NetSDKLib; |
|
43 |
import com.iailab.netsdk.lib.NetSDKLib.CtrlType; |
|
44 |
import com.iailab.netsdk.lib.NetSDKLib.EM_OPEN_DOOR_TYPE; |
|
45 |
import com.iailab.netsdk.lib.NetSDKLib.LLong; |
|
46 |
import com.iailab.netsdk.lib.NetSDKLib.NET_CTRL_ACCESS_OPEN; |
|
47 |
import com.iailab.netsdk.lib.ToolKits; |
|
48 |
|
|
49 |
public class VTODemo extends JFrame { |
|
50 |
private static final long serialVersionUID = 1L; |
|
51 |
|
|
52 |
private JPanel contentPane; |
|
53 |
private JTextField ipTextField; |
|
54 |
private JTextField portTextField; |
|
55 |
private JTextField userNameTextField; |
|
56 |
private JPasswordField passwordField; |
|
57 |
private JTable alarmTable; |
|
58 |
|
|
59 |
private Panel realPlay; |
|
60 |
private PaintPanel imagePanel; |
|
61 |
private JButton btnLogin; |
|
62 |
private JButton btnLogout; |
|
63 |
private JButton btnRealPlay; |
|
64 |
private JButton btnStopplay; |
|
65 |
private JButton btnTalk; |
|
66 |
private JButton btnStoptalk; |
|
67 |
private JButton btnOpendoor; |
|
68 |
private JButton btnClosedoor; |
|
69 |
private JButton btnOperate; |
|
70 |
private JButton btnStartlisten; |
|
71 |
private JButton btnStoplisten; |
|
72 |
private JButton btnStartrealload; |
|
73 |
private JButton btnStoprealload; |
|
74 |
JTabbedPane tabbedPane; |
|
75 |
private static boolean b_RealPlay = false; |
|
76 |
private static boolean b_Attachment = false; |
|
77 |
private boolean isListen = false; |
|
78 |
|
|
79 |
///////////////////// 主面板 ///////////////////// |
|
80 |
|
|
81 |
private static JFrame mainFrame = new JFrame(); |
|
82 |
private OperateManager manager = new OperateManager(); |
|
83 |
|
|
84 |
private Object[][] alarmData; |
|
85 |
private Object[][] realData; |
|
86 |
|
|
87 |
private DefaultTableModel alarmModel; |
|
88 |
private DefaultTableModel realModel; |
|
89 |
|
|
90 |
private final String[] alarmTableTitle = {Res.string().getVTOAlarmEventRoomNo(), |
|
91 |
Res.string().getVTOAlarmEventCardNo(), Res.string().getVTOAlarmEventTime(), |
|
92 |
Res.string().getVTOAlarmEventOpenMethod(), Res.string().getVTOAlarmEventStatus()}; |
|
93 |
private final String[] realTableTitle = {Res.string().getVTORealLoadRoomNO(), Res.string().getVTORealLoadCardNo(), |
|
94 |
Res.string().getVTORealLoadTime(), Res.string().getVTORealLoadEventInfo()}; |
|
95 |
|
|
96 |
/** |
|
97 |
* Launch the application. |
|
98 |
*/ |
|
99 |
public static void main(String[] args) { |
|
100 |
EventQueue.invokeLater(new Runnable() { |
|
101 |
public void run() { |
|
102 |
try { |
|
103 |
VTODemo frame = new VTODemo(); |
|
104 |
frame.setVisible(true); |
|
105 |
} catch (Exception e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} |
|
108 |
} |
|
109 |
}); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Create the frame. |
|
114 |
*/ |
|
115 |
public VTODemo() { |
|
116 |
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
117 |
setTitle(Res.string().getVTO()); |
|
118 |
setBounds(100, 100, 920, 651); |
|
119 |
contentPane = new JPanel(); |
|
120 |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
121 |
setContentPane(contentPane); |
|
122 |
contentPane.setLayout(null); |
|
123 |
try { |
|
124 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
|
125 |
} catch (Exception e) { |
|
126 |
e.printStackTrace(); |
|
127 |
} |
|
128 |
LoginModule.init(DefaultDisConnect.GetInstance(), DefaultHaveReconnect.getINSTANCE()); |
|
129 |
JPanel panel = new JPanel(); |
|
130 |
panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), Res.string().getLogin(), |
|
131 |
TitledBorder.LEFT, TitledBorder.TOP, null, new Color(0, 0, 0))); |
|
132 |
panel.setBounds(0, 0, 905, 46); |
|
133 |
contentPane.add(panel); |
|
134 |
panel.setLayout(null); |
|
135 |
|
|
136 |
JLabel ipLabel = new JLabel(Res.string().getIp()); |
|
137 |
ipLabel.setBounds(10, 15, 44, 21); |
|
138 |
panel.add(ipLabel); |
|
139 |
|
|
140 |
ipTextField = new JTextField(); |
|
141 |
ipTextField.setText("10.34.3.63"); |
|
142 |
ipTextField.setBounds(64, 15, 89, 21); |
|
143 |
panel.add(ipTextField); |
|
144 |
ipTextField.setColumns(10); |
|
145 |
|
|
146 |
JLabel portLabel = new JLabel(Res.string().getPort()); |
|
147 |
portLabel.setBounds(174, 15, 44, 21); |
|
148 |
panel.add(portLabel); |
|
149 |
|
|
150 |
portTextField = new JTextField(); |
|
151 |
portTextField.setText("37777"); |
|
152 |
portTextField.setColumns(10); |
|
153 |
portTextField.setBounds(228, 15, 66, 21); |
|
154 |
panel.add(portTextField); |
|
155 |
|
|
156 |
JLabel lblName = new JLabel(Res.string().getUserName()); |
|
157 |
lblName.setBounds(316, 15, 66, 21); |
|
158 |
panel.add(lblName); |
|
159 |
|
|
160 |
userNameTextField = new JTextField(); |
|
161 |
userNameTextField.setText("admin"); |
|
162 |
userNameTextField.setColumns(10); |
|
163 |
userNameTextField.setBounds(383, 15, 87, 21); |
|
164 |
panel.add(userNameTextField); |
|
165 |
|
|
166 |
JLabel lblPassword = new JLabel(Res.string().getPassword()); |
|
167 |
lblPassword.setBounds(492, 15, 66, 21); |
|
168 |
panel.add(lblPassword); |
|
169 |
|
|
170 |
passwordField = new JPasswordField(); |
|
171 |
passwordField.setBounds(568, 15, 112, 21); |
|
172 |
passwordField.setText("admin123"); |
|
173 |
panel.add(passwordField); |
|
174 |
|
|
175 |
btnLogin = new JButton(Res.string().getLogin()); |
|
176 |
btnLogin.setBounds(684, 14, 99, 23); |
|
177 |
panel.add(btnLogin); |
|
178 |
btnLogin.addMouseListener(new MouseAdapter() { |
|
179 |
@Override |
|
180 |
public void mouseClicked(MouseEvent e) { |
|
181 |
super.mouseClicked(e); |
|
182 |
login(); |
|
183 |
} |
|
184 |
}); |
|
185 |
btnLogout = new JButton(Res.string().getLogout()); |
|
186 |
btnLogout.setBounds(785, 14, 110, 23); |
|
187 |
panel.add(btnLogout); |
|
188 |
btnLogout.addMouseListener(new MouseAdapter() { |
|
189 |
@Override |
|
190 |
public void mouseClicked(MouseEvent e) { |
|
191 |
super.mouseClicked(e); |
|
192 |
logout(); |
|
193 |
} |
|
194 |
}); |
|
195 |
JPanel previewPanel = new JPanel(); |
|
196 |
previewPanel.setBorder( |
|
197 |
new TitledBorder(null, Res.string().getRealplay(), TitledBorder.LEFT, TitledBorder.TOP, null, null)); |
|
198 |
previewPanel.setBounds(10, 56, 409, 313); |
|
199 |
contentPane.add(previewPanel); |
|
200 |
previewPanel.setLayout(new BorderLayout(0, 0)); |
|
201 |
|
|
202 |
realPlay = new Panel(); |
|
203 |
realPlay.setBackground(Color.GRAY); |
|
204 |
previewPanel.add(realPlay, BorderLayout.CENTER); |
|
205 |
|
|
206 |
JPanel operatePanel = new JPanel(); |
|
207 |
operatePanel.setBorder( |
|
208 |
new TitledBorder(null, Res.string().getOperate(), TitledBorder.LEFT, TitledBorder.TOP, null, null)); |
|
209 |
operatePanel.setBounds(429, 56, 452, 194); |
|
210 |
contentPane.add(operatePanel); |
|
211 |
operatePanel.setLayout(null); |
|
212 |
|
|
213 |
btnRealPlay = new JButton(Res.string().getStartRealPlay()); |
|
214 |
btnRealPlay.setBounds(37, 23, 162, 29); |
|
215 |
operatePanel.add(btnRealPlay); |
|
216 |
btnRealPlay.addMouseListener(new MouseAdapter() { |
|
217 |
@Override |
|
218 |
public void mouseClicked(MouseEvent e) { |
|
219 |
super.mouseClicked(e); |
|
220 |
realPlay(); |
|
221 |
} |
|
222 |
}); |
|
223 |
btnTalk = new JButton(Res.string().getStartTalk()); |
|
224 |
btnTalk.setBounds(248, 23, 152, 29); |
|
225 |
operatePanel.add(btnTalk); |
|
226 |
btnTalk.addMouseListener(new MouseAdapter() { |
|
227 |
@Override |
|
228 |
public void mouseClicked(MouseEvent e) { |
|
229 |
super.mouseClicked(e); |
|
230 |
talk(); |
|
231 |
} |
|
232 |
}); |
|
233 |
btnStopplay = new JButton(Res.string().getStopRealPlay()); |
|
234 |
btnStopplay.setBounds(37, 62, 162, 29); |
|
235 |
operatePanel.add(btnStopplay); |
|
236 |
btnStopplay.addMouseListener(new MouseAdapter() { |
|
237 |
@Override |
|
238 |
public void mouseClicked(MouseEvent e) { |
|
239 |
super.mouseClicked(e); |
|
240 |
stopPlay(); |
|
241 |
} |
|
242 |
}); |
|
243 |
btnStoptalk = new JButton(Res.string().getStopTalk()); |
|
244 |
btnStoptalk.setBounds(248, 62, 152, 29); |
|
245 |
operatePanel.add(btnStoptalk); |
|
246 |
btnStoptalk.addMouseListener(new MouseAdapter() { |
|
247 |
@Override |
|
248 |
public void mouseClicked(MouseEvent e) { |
|
249 |
super.mouseClicked(e); |
|
250 |
stopTalk(); |
|
251 |
} |
|
252 |
}); |
|
253 |
btnOpendoor = new JButton(Res.string().getDoorOpen()); |
|
254 |
btnOpendoor.addMouseListener(new MouseAdapter() { |
|
255 |
@Override |
|
256 |
public void mouseClicked(MouseEvent e) { |
|
257 |
super.mouseClicked(e); |
|
258 |
openDoor(); |
|
259 |
} |
|
260 |
}); |
|
261 |
btnOpendoor.setBounds(37, 110, 162, 29); |
|
262 |
operatePanel.add(btnOpendoor); |
|
263 |
|
|
264 |
btnClosedoor = new JButton(Res.string().getDoorClose()); |
|
265 |
btnClosedoor.setBounds(37, 149, 162, 29); |
|
266 |
operatePanel.add(btnClosedoor); |
|
267 |
btnClosedoor.addMouseListener(new MouseAdapter() { |
|
268 |
@Override |
|
269 |
public void mouseClicked(MouseEvent e) { |
|
270 |
super.mouseClicked(e); |
|
271 |
closeDoor(); |
|
272 |
} |
|
273 |
}); |
|
274 |
btnOperate = new JButton(Res.string().getCardOperate()); |
|
275 |
btnOperate.addMouseListener(new MouseAdapter() { |
|
276 |
@Override |
|
277 |
public void mouseClicked(MouseEvent e) { |
|
278 |
if (manager == null) { |
|
279 |
manager = new OperateManager(); |
|
280 |
} |
|
281 |
manager.setVisible(true); |
|
282 |
} |
|
283 |
}); |
|
284 |
btnOperate.setBounds(248, 125, 152, 29); |
|
285 |
operatePanel.add(btnOperate); |
|
286 |
|
|
287 |
JPanel eventOperate = new JPanel(); |
|
288 |
eventOperate.setBorder(new TitledBorder(null, Res.string().getEventOperate(), TitledBorder.LEFT, |
|
289 |
TitledBorder.TOP, null, null)); |
|
290 |
eventOperate.setBounds(429, 260, 452, 104); |
|
291 |
contentPane.add(eventOperate); |
|
292 |
eventOperate.setLayout(null); |
|
293 |
|
|
294 |
btnStartlisten = new JButton(Res.string().getStartListen()); |
|
295 |
btnStartlisten.setBounds(35, 21, 178, 29); |
|
296 |
eventOperate.add(btnStartlisten); |
|
297 |
btnStartlisten.addMouseListener(new MouseAdapter() { |
|
298 |
@Override |
|
299 |
public void mouseClicked(MouseEvent e) { |
|
300 |
isListen = startListen(); |
|
301 |
tabbedPane.setSelectedIndex(0); |
|
302 |
} |
|
303 |
}); |
|
304 |
|
|
305 |
btnStoplisten = new JButton(Res.string().getStopListen()); |
|
306 |
btnStoplisten.setBounds(35, 60, 178, 29); |
|
307 |
eventOperate.add(btnStoplisten); |
|
308 |
btnStoplisten.addMouseListener(new MouseAdapter() { |
|
309 |
@Override |
|
310 |
public void mouseClicked(MouseEvent e) { |
|
311 |
//table清空数据 |
|
312 |
((DefaultTableModel) alarmTable.getModel()).setRowCount(0); |
|
313 |
stopListen(); |
|
314 |
} |
|
315 |
}); |
|
316 |
|
|
317 |
btnStartrealload = new JButton(Res.string().getStartRealLoad()); |
|
318 |
btnStartrealload.setBounds(234, 21, 195, 29); |
|
319 |
eventOperate.add(btnStartrealload); |
|
320 |
btnStartrealload.addMouseListener(new MouseAdapter() { |
|
321 |
@Override |
|
322 |
public void mouseClicked(MouseEvent e) { |
|
323 |
startRealLoad(); |
|
324 |
tabbedPane.setSelectedIndex(1); |
|
325 |
} |
|
326 |
}); |
|
327 |
|
|
328 |
btnStoprealload = new JButton(Res.string().getStopRealLoad()); |
|
329 |
btnStoprealload.setBounds(234, 60, 195, 29); |
|
330 |
eventOperate.add(btnStoprealload); |
|
331 |
btnStoprealload.addMouseListener(new MouseAdapter() { |
|
332 |
@Override |
|
333 |
public void mouseClicked(MouseEvent e) { |
|
334 |
//清空table数据 |
|
335 |
((DefaultTableModel) realLoadTable.getModel()).setRowCount(0); |
|
336 |
stopRealLoad(); |
|
337 |
//图片清空 |
|
338 |
imagePanel.setImage(null); |
|
339 |
imagePanel.repaint(); |
|
340 |
} |
|
341 |
}); |
|
342 |
|
|
343 |
tabbedPane = new JTabbedPane(JTabbedPane.TOP); |
|
344 |
tabbedPane.setBounds(10, 379, 871, 224); |
|
345 |
contentPane.add(tabbedPane); |
|
346 |
|
|
347 |
JPanel alarmPanel = new JPanel(); |
|
348 |
alarmPanel.setBorder( |
|
349 |
new TitledBorder(null, Res.string().getEventInfo(), TitledBorder.LEFT, TitledBorder.TOP, null, null)); |
|
350 |
tabbedPane.addTab(Res.string().getAlarmEvent(), null, alarmPanel, null); |
|
351 |
alarmPanel.setLayout(new BorderLayout(0, 0)); |
|
352 |
|
|
353 |
alarmData = new Object[0][5]; |
|
354 |
alarmTable = tableInit(alarmData, alarmTableTitle); |
|
355 |
alarmModel = (DefaultTableModel) alarmTable.getModel(); |
|
356 |
JScrollPane scrollPane = new JScrollPane(alarmTable); |
|
357 |
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
358 |
alarmPanel.add(scrollPane, BorderLayout.CENTER); |
|
359 |
|
|
360 |
JPanel realLoadPanel = new JPanel(); |
|
361 |
realLoadPanel.setBorder(new TitledBorder(null, Res.string().getVTORealLoadEventInfo(), TitledBorder.LEFT, |
|
362 |
TitledBorder.TOP, null, null)); |
|
363 |
tabbedPane.addTab(Res.string().getRealLoadEvent(), null, realLoadPanel, null); |
|
364 |
realLoadPanel.setLayout(null); |
|
365 |
|
|
366 |
imagePanel = new PaintPanel(); |
|
367 |
imagePanel.setBounds(671, 20, 185, 165); |
|
368 |
realLoadPanel.add(imagePanel); |
|
369 |
realData = new Object[0][4]; |
|
370 |
realLoadTable = tableInit(realData, realTableTitle); |
|
371 |
realModel = (DefaultTableModel) realLoadTable.getModel(); |
|
372 |
realScrollPane = new JScrollPane(realLoadTable); |
|
373 |
realScrollPane.setBounds(10, 20, 654, 165); |
|
374 |
realScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
375 |
realLoadPanel.add(realScrollPane); |
|
376 |
|
|
377 |
btnEnable(false); |
|
378 |
btnLogin.setEnabled(true); |
|
379 |
addWindowListener(new WindowAdapter() { |
|
380 |
@Override |
|
381 |
public void windowClosing(WindowEvent e) { |
|
382 |
if (LoginModule.m_hLoginHandle.longValue() != 0) { |
|
383 |
logout(); |
|
384 |
} |
|
385 |
LoginModule.cleanup(); |
|
386 |
dispose(); |
|
387 |
SwingUtilities.invokeLater(new Runnable() { |
|
388 |
public void run() { |
|
389 |
FunctionList demo = new FunctionList(); |
|
390 |
demo.setVisible(true); |
|
391 |
} |
|
392 |
}); |
|
393 |
} |
|
394 |
}); |
|
395 |
} |
|
396 |
|
|
397 |
/** |
|
398 |
* 按钮使能 |
|
399 |
* |
|
400 |
* @param enable |
|
401 |
*/ |
|
402 |
public void btnEnable(boolean enable) { |
|
403 |
btnLogin.setEnabled(enable); |
|
404 |
btnLogout.setEnabled(enable); |
|
405 |
btnRealPlay.setEnabled(enable); |
|
406 |
btnStopplay.setEnabled(enable); |
|
407 |
btnTalk.setEnabled(enable); |
|
408 |
btnStoptalk.setEnabled(enable); |
|
409 |
btnOpendoor.setEnabled(enable); |
|
410 |
btnClosedoor.setEnabled(enable); |
|
411 |
btnOperate.setEnabled(enable); |
|
412 |
btnStartlisten.setEnabled(enable); |
|
413 |
btnStoplisten.setEnabled(enable); |
|
414 |
btnStartrealload.setEnabled(enable); |
|
415 |
btnStoprealload.setEnabled(enable); |
|
416 |
} |
|
417 |
|
|
418 |
public JTable tableInit(Object[][] data, String[] columnName) { |
|
419 |
JTable table; |
|
420 |
DefaultTableModel model; |
|
421 |
model = new DefaultTableModel(data, columnName); |
|
422 |
table = new JTable(model) { |
|
423 |
@Override // 不可编辑 |
|
424 |
public boolean isCellEditable(int row, int column) { |
|
425 |
return false; |
|
426 |
} |
|
427 |
}; |
|
428 |
model = (DefaultTableModel) table.getModel(); |
|
429 |
|
|
430 |
|
|
431 |
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 只能选中一行 |
|
432 |
|
|
433 |
// 列表显示居中 |
|
434 |
DefaultTableCellRenderer dCellRenderer = new DefaultTableCellRenderer(); |
|
435 |
dCellRenderer.setHorizontalAlignment(JLabel.CENTER); |
|
436 |
table.setDefaultRenderer(Object.class, dCellRenderer); |
|
437 |
return table; |
|
438 |
} |
|
439 |
|
|
440 |
/** |
|
441 |
* 登录 |
|
442 |
*/ |
|
443 |
public boolean login() { |
|
444 |
if (LoginModule.login(ipTextField.getText(), Integer.parseInt(portTextField.getText()), |
|
445 |
userNameTextField.getText(), new String(passwordField.getPassword()))) { |
|
446 |
btnEnable(true); |
|
447 |
btnLogin.setEnabled(false); |
|
448 |
// 监听按钮使能 |
|
449 |
btnRealPlay.setEnabled(true); |
|
450 |
btnStopplay.setEnabled(false); |
|
451 |
btnStartlisten.setEnabled(true); |
|
452 |
btnStoplisten.setEnabled(false); |
|
453 |
btnStartrealload.setEnabled(true); |
|
454 |
btnStoprealload.setEnabled(false); |
|
455 |
btnTalk.setEnabled(true); |
|
456 |
btnStoptalk.setEnabled(false); |
|
457 |
} else { |
|
458 |
JOptionPane.showMessageDialog(null, Res.string().getLoginFailed() + ", " + ToolKits.getErrorCodeShow(), |
|
459 |
Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
460 |
return false; |
|
461 |
} |
|
462 |
return true; |
|
463 |
} |
|
464 |
|
|
465 |
/** |
|
466 |
* 登出 |
|
467 |
*/ |
|
468 |
public void logout() { |
|
469 |
if (b_RealPlay) { |
|
470 |
stopPlay(); |
|
471 |
} |
|
472 |
if (TalkModule.m_hTalkHandle != null) { |
|
473 |
stopTalk(); |
|
474 |
} |
|
475 |
if (isListen) { |
|
476 |
stopListen(); |
|
477 |
isListen = false; |
|
478 |
} |
|
479 |
stopRealLoad(); |
|
480 |
LoginModule.logout(); |
|
481 |
btnEnable(false); |
|
482 |
//清空两个表格 |
|
483 |
//普通事件table清空数据 |
|
484 |
((DefaultTableModel) alarmTable.getModel()).setRowCount(0); |
|
485 |
//智能事件table清空数据 |
|
486 |
((DefaultTableModel) realLoadTable.getModel()).setRowCount(0); |
|
487 |
//图片清空 |
|
488 |
imagePanel.setImage(null); |
|
489 |
imagePanel.repaint(); |
|
490 |
btnLogin.setEnabled(true); |
|
491 |
} |
|
492 |
|
|
493 |
private LLong m_hPlayHandle; |
|
494 |
|
|
495 |
public void realPlay() { |
|
496 |
if (!b_RealPlay) { |
|
497 |
m_hPlayHandle = RealPlayModule.startRealPlay(0, 0, realPlay); |
|
498 |
if (m_hPlayHandle.longValue() != 0) { |
|
499 |
b_RealPlay = true; |
|
500 |
btnRealPlay.setEnabled(false); |
|
501 |
btnStopplay.setEnabled(true); |
|
502 |
} else { |
|
503 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
504 |
JOptionPane.ERROR_MESSAGE); |
|
505 |
} |
|
506 |
} |
|
507 |
} |
|
508 |
|
|
509 |
/** |
|
510 |
* 停止实时预览 |
|
511 |
*/ |
|
512 |
public void stopPlay() { |
|
513 |
if (b_RealPlay) { |
|
514 |
RealPlayModule.stopRealPlay(m_hPlayHandle); |
|
515 |
realPlay.repaint(); |
|
516 |
b_RealPlay = false; |
|
517 |
btnRealPlay.setEnabled(true); |
|
518 |
btnStopplay.setEnabled(false); |
|
519 |
} |
|
520 |
} |
|
521 |
|
|
522 |
/** |
|
523 |
* 对讲 |
|
524 |
*/ |
|
525 |
public void talk() { |
|
526 |
if (TalkModule.startTalk(0, 0)) { |
|
527 |
btnTalk.setEnabled(false); |
|
528 |
btnStoptalk.setEnabled(true); |
|
529 |
} else { |
|
530 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
531 |
JOptionPane.ERROR_MESSAGE); |
|
532 |
} |
|
533 |
} |
|
534 |
|
|
535 |
/** |
|
536 |
* 停止对讲 |
|
537 |
*/ |
|
538 |
public void stopTalk() { |
|
539 |
TalkModule.stopTalk(); |
|
540 |
btnTalk.setEnabled(true); |
|
541 |
btnStoptalk.setEnabled(false); |
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* 开门 |
|
546 |
*/ |
|
547 |
public void openDoor() { |
|
548 |
NET_CTRL_ACCESS_OPEN openInfo = new NET_CTRL_ACCESS_OPEN(); |
|
549 |
openInfo.nChannelID = 0; |
|
550 |
openInfo.emOpenDoorType = EM_OPEN_DOOR_TYPE.EM_OPEN_DOOR_TYPE_REMOTE; |
|
551 |
|
|
552 |
Pointer pointer = new Memory(openInfo.size()); |
|
553 |
ToolKits.SetStructDataToPointer(openInfo, pointer, 0); |
|
554 |
boolean ret = LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, |
|
555 |
CtrlType.CTRLTYPE_CTRL_ACCESS_OPEN, pointer, null, 10000); |
|
556 |
if (!ret) { |
|
557 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
558 |
JOptionPane.ERROR_MESSAGE); |
|
559 |
return; |
|
560 |
} |
|
561 |
} |
|
562 |
|
|
563 |
/** |
|
564 |
* 关门 |
|
565 |
*/ |
|
566 |
public void closeDoor() { |
|
567 |
final NetSDKLib.NET_CTRL_ACCESS_CLOSE close = new NetSDKLib.NET_CTRL_ACCESS_CLOSE(); |
|
568 |
close.nChannelID = 0; // 对应的门编号 - 如何开全部的门 |
|
569 |
close.write(); |
|
570 |
Pointer pointer = new Memory(close.size()); |
|
571 |
boolean result = LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, |
|
572 |
NetSDKLib.CtrlType.CTRLTYPE_CTRL_ACCESS_CLOSE, close.getPointer(), null, 5000); |
|
573 |
close.read(); |
|
574 |
if (!result) { |
|
575 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
576 |
JOptionPane.ERROR_MESSAGE); |
|
577 |
} |
|
578 |
} |
|
579 |
|
|
580 |
/** |
|
581 |
* 监听事件 |
|
582 |
*/ |
|
583 |
public boolean startListen() { |
|
584 |
if (AlarmListenModule.startListen(VTOMessageCallBack.getINSTANCE(alarmTable, null))) { |
|
585 |
btnStartlisten.setEnabled(false); |
|
586 |
btnStoplisten.setEnabled(true); |
|
587 |
} else { |
|
588 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
589 |
JOptionPane.ERROR_MESSAGE); |
|
590 |
return false; |
|
591 |
} |
|
592 |
return true; |
|
593 |
} |
|
594 |
|
|
595 |
/** |
|
596 |
* 停止监听 |
|
597 |
*/ |
|
598 |
public void stopListen() { |
|
599 |
if (isListen) { |
|
600 |
if (AlarmListenModule.stopListen()) { |
|
601 |
isListen = false; |
|
602 |
btnStartlisten.setEnabled(true); |
|
603 |
btnStoplisten.setEnabled(false); |
|
604 |
} else { |
|
605 |
JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), |
|
606 |
JOptionPane.ERROR_MESSAGE); |
|
607 |
} |
|
608 |
} |
|
609 |
|
|
610 |
} |
|
611 |
|
|
612 |
private LLong m_attachHandle; |
|
613 |
private JTable realLoadTable; |
|
614 |
private JScrollPane realScrollPane; |
|
615 |
|
|
616 |
/** |
|
617 |
* 智能事件监听 |
|
618 |
*/ |
|
619 |
public void startRealLoad() { |
|
620 |
m_attachHandle = GateModule.realLoadPic(0, VTOAnalyzerCallBack.getINSTANCE(realLoadTable, imagePanel)); |
|
621 |
if (m_attachHandle != null && m_attachHandle.longValue() != 0) { |
|
622 |
btnStartrealload.setEnabled(false); |
|
623 |
btnStoprealload.setEnabled(true); |
|
624 |
} |
|
625 |
} |
|
626 |
|
|
627 |
/** |
|
628 |
* 停止智能事件监听 |
|
629 |
*/ |
|
630 |
public void stopRealLoad() { |
|
631 |
if (m_attachHandle != null && m_attachHandle.longValue() != 0) { |
|
632 |
GateModule.stopRealLoadPic(m_attachHandle); |
|
633 |
m_attachHandle.setValue(0); |
|
634 |
btnStartrealload.setEnabled(true); |
|
635 |
btnStoprealload.setEnabled(false); |
|
636 |
} |
|
637 |
|
|
638 |
} |
|
639 |
|
|
640 |
} |