潘志宝
2024-12-10 29b971556c85da59d9f820dce13f8bce4d52056a
提交 | 用户 | 时间
149dd0 1 package com.iailab.netsdk.demo.frame;
H 2
3 import java.awt.AWTEvent;
4 import java.awt.BorderLayout;
5 import java.awt.Color;
6 import java.awt.Dimension;
7 import java.awt.EventQueue;
8 import java.awt.FlowLayout;
9 import java.awt.GridLayout;
10 import java.awt.Panel;
11 import java.awt.Toolkit;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ActionListener;
14 import java.awt.event.MouseEvent;
15 import java.awt.event.MouseListener;
16 import java.awt.event.WindowAdapter;
17 import java.awt.event.WindowEvent;
18 import java.awt.image.BufferedImage;
19 import java.io.ByteArrayInputStream;
20 import java.io.File;
21 import java.io.IOException;
22 import java.io.UnsupportedEncodingException;
23 import java.util.Vector;
24
25 import javax.imageio.ImageIO;
26 import javax.swing.DefaultComboBoxModel;
27 import javax.swing.JButton;
28 import javax.swing.JComboBox;
29 import javax.swing.JFrame;
30 import javax.swing.JLabel;
31 import javax.swing.JOptionPane;
32 import javax.swing.JPanel;
33 import javax.swing.JScrollPane;
34 import javax.swing.JTable;
35 import javax.swing.JTextField;
36 import javax.swing.ListSelectionModel;
37 import javax.swing.SwingUtilities;
38 import javax.swing.UIManager;
39 import javax.swing.border.EmptyBorder;
40 import javax.swing.table.DefaultTableCellRenderer;
41 import javax.swing.table.DefaultTableModel;
42
43 import com.iailab.netsdk.common.*;
44 import com.iailab.netsdk.demo.module.LoginModule;
45 import com.iailab.netsdk.demo.module.RealPlayModule;
46 import com.iailab.netsdk.demo.module.TrafficEventModule;
47 import com.iailab.netsdk.lib.*;
48 import com.iailab.netsdk.lib.NetSDKLib.LLong;
49
50 import com.sun.jna.CallbackThreadInitializer;
51 import com.sun.jna.Native;
52 import com.sun.jna.Pointer;
53
54 /*
55  * 智能交通Demo
56  */
57 class TrafficEventFrame extends JFrame {
58     private static final long serialVersionUID = 1L;
59     private Vector<String> chnlist = new Vector<String>();
60
61     private DefaultTableModel model;
62     private AnalyzerDataCB m_AnalyzerDataCB = new AnalyzerDataCB();
63     // 设备断线通知回调
64     private static DisConnect disConnect       = new DisConnect();
65
66     // 网络连接恢复
67     private static HaveReConnect haveReConnect = new HaveReConnect();
68
69     // 预览句柄
70     public static LLong m_hPlayHandle = new LLong(0);
71
72     boolean b_openStrobe = false;
73     boolean b_realplay = false;
74     boolean b_attach = false;
75
76     private int i = 1;  // 列表序号
77
78     private class TRAFFIC_INFO {
79         private String m_EventName;               // 事件名称
80         private String m_PlateNumber;             // 车牌号
81         private String m_PlateType;               // 车牌类型
82         private String m_PlateColor;                  // 车牌颜色
83         private String m_VehicleColor;                // 车身颜色
84         private String m_VehicleType;             // 车身类型
85         private String m_VehicleSize;                 // 车辆大小
86         private String m_FileCount;                  // 文件总数
87         private String m_FileIndex;                  // 文件编号
88         private String m_GroupID;                  // 组ID
89         private String m_IllegalPlace;              // 违法地点
90         private String m_LaneNumber;              // 通道号
91         private NetSDKLib.NET_TIME_EX m_Utc;      // 事件时间
92         private int m_bPicEnble;                       // 车牌对应信息,BOOL类型
93         private int m_OffSet;                          // 车牌偏移量
94         private int m_FileLength;                 // 文件大小
95         private NetSDKLib.DH_RECT m_BoundingBox;  // 包围盒
96     }
97
98     private  TRAFFIC_INFO trafficInfo = new TRAFFIC_INFO();
99     private BufferedImage snapImage = null;
100     private BufferedImage plateImage = null;
101
102     private java.awt.Component  target     = this;
103
104     // 获取界面窗口
105     private static JFrame frame = new JFrame();
106
107     public TrafficEventFrame() {
108         setTitle(Res.string().getITSEvent());
109         setLayout(new BorderLayout());
110         pack();
111         setSize(800, 565);
112         setResizable(false);
113         setLocationRelativeTo(null);
114         LoginModule.init(disConnect, haveReConnect);   // 打开工程,初始化
115
116         try {
117             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
118         } catch (Exception e) {
119             e.printStackTrace();
120         }
121
122         loginPanel = new LoginPanel();
123         itsPanel = new ItsPanel();
124
125         add(loginPanel, BorderLayout.NORTH);
126         add(itsPanel, BorderLayout.CENTER);
127
128         loginPanel.addLoginBtnActionListener(new ActionListener() {
129             @Override
130             public void actionPerformed(ActionEvent e) {
131                 if(loginPanel.checkLoginText()) {
132                     if(login()) {
133                         frame = ToolKits.getFrame(e);
134                         frame.setTitle(Res.string().getITSEvent() + " : " + Res.string().getOnline());
135                     }
136                 }
137             }
138         });
139
140         loginPanel.addLogoutBtnActionListener(new ActionListener() {
141             @Override
142             public void actionPerformed(ActionEvent e) {
143                 frame.setTitle(Res.string().getITSEvent());
144                 logout();
145             }
146         });
147
148         addWindowListener(new WindowAdapter() {
149             public void windowClosing(WindowEvent e) {
150                 RealPlayModule.stopRealPlay(m_hPlayHandle);
151                 TrafficEventModule.detachIVSEvent();
152                 LoginModule.logout();
153                 LoginModule.cleanup();  // 关闭工程,释放资源
154                 dispose();
155
156                 SwingUtilities.invokeLater(new Runnable() {
157                     public void run() {
158                         FunctionList demo = new FunctionList();
159                         demo.setVisible(true);
160                     }
161                 });
162             }
163         });
164     }
165
166     /////////////////面板///////////////////
167     // 设备断线回调: 通过 CLIENT_Init 设置该回调函数,当设备出现断线时,SDK会调用该函数
168     private static class DisConnect implements NetSDKLib.fDisConnect {
169         public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
170             System.out.printf("Device[%s] Port[%d] DisConnect!\n", pchDVRIP, nDVRPort);
171             // 断线提示
172             SwingUtilities.invokeLater(new Runnable() {
173                 public void run() {
174                     frame.setTitle(Res.string().getITSEvent() + " : " + Res.string().getDisConnectReconnecting());
175                 }
176             });
177         }
178     }
179
180     // 网络连接恢复,设备重连成功回调
181     // 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数
182     private static class HaveReConnect implements NetSDKLib.fHaveReConnect {
183         public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
184             System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort);
185
186             // 重连提示
187             SwingUtilities.invokeLater(new Runnable() {
188                 public void run() {
189                     frame.setTitle(Res.string().getITSEvent() + " : " + Res.string().getOnline());
190                 }
191             });
192         }
193     }
194     // 登录
195     public boolean login() {
196         Native.setCallbackThreadInitializer(m_AnalyzerDataCB,
197                 new CallbackThreadInitializer(false, false, "traffic callback thread"));
198         if(LoginModule.login(loginPanel.ipTextArea.getText(),
199                 Integer.parseInt(loginPanel.portTextArea.getText()),
200                 loginPanel.nameTextArea.getText(),
201                 new String(loginPanel.passwordTextArea.getPassword()))) {
202
203             loginPanel.setButtonEnable(true);
204             setButtonEnable(true);
205
206             for(int i = 1; i < LoginModule.m_stDeviceInfo.byChanNum + 1; i++) {
207                 chnlist.add(Res.string().getChannel() + " " + String.valueOf(i));
208             }
209
210             // 登陆成功,将通道添加到控件
211             chnComboBox.setModel(new DefaultComboBoxModel(chnlist));
212         } else {
213             JOptionPane.showMessageDialog(null, Res.string().getLoginFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
214             return false;
215         }
216         return true;
217     }
218
219     // 登出
220     public void logout() {
221         RealPlayModule.stopRealPlay(m_hPlayHandle);
222         TrafficEventModule.detachIVSEvent();
223         LoginModule.logout();
224
225         loginPanel.setButtonEnable(false);
226         setButtonEnable(false);
227         realPlayWindow.repaint();
228         eventnameTextField.setText("");
229         licensePlateTextField.setText("");
230         eventTimeTextField.setText("");
231
232         b_realplay = false;
233         realplayBtn.setText(Res.string().getStartRealPlay());
234         b_attach = false;
235         attachBtn.setText(Res.string().getAttach());
236         b_openStrobe = false;
237         openStrobeButton.setText(Res.string().getOpenStrobe());
238
239         i = 1; // 列表序号置1
240
241         for(int i = 0; i < LoginModule.m_stDeviceInfo.byChanNum; i++) {
242             chnlist.clear();
243         }
244
245         chnComboBox.setModel(new DefaultComboBoxModel());
246
247         // 列表清空
248         defaultModel.setRowCount(0);
249         defaultModel.setRowCount(8);
250         table.updateUI();
251
252         SnapImagePanel.setOpaque(true);
253         SnapImagePanel.repaint();
254
255         plateImagePanel.setOpaque(true);
256         plateImagePanel.repaint();
257     }
258
259     private class ItsPanel extends JPanel {
260         private static final long serialVersionUID = 1L;
261
262         public ItsPanel() {
263             BorderEx.set(this, null, 2);
264             setLayout(new BorderLayout());
265
266             operatePanel = new OperatePanel();
267             realPlayPanel = new RealPlayPanel();
268             eventInfoPanel = new EventInfoPanel();
269             messagePanel = new MessagePanel();
270
271             add(operatePanel, BorderLayout.NORTH);
272             add(realPlayPanel, BorderLayout.WEST);
273             add(eventInfoPanel, BorderLayout.CENTER);
274             add(messagePanel, BorderLayout.SOUTH);
275         }
276     }
277
278     /**
279      * 操作面板
280      */
281     private class OperatePanel extends JPanel {
282         private static final long serialVersionUID = 1L;
283
284         public OperatePanel() {
285             BorderEx.set(this, Res.string().getOperate(), 2);
286             setLayout(new FlowLayout());
287
288             chnlabel = new JLabel(Res.string().getChannel());
289             chnComboBox = new JComboBox();
290
291             JLabel nullLabel2 = new JLabel("   ");
292             JLabel nullLabel3 = new JLabel("   ");
293             JLabel nullLabel4 = new JLabel("   ");
294             JLabel nullLabel5 = new JLabel("   ");
295
296             realplayBtn = new JButton(Res.string().getStartRealPlay());
297             attachBtn = new JButton(Res.string().getAttach());
298             manualSnapBtn = new JButton(Res.string().getManualCapture());
299             openStrobeButton = new JButton(Res.string().getOpenStrobe());
300
301             chnComboBox.setPreferredSize(new Dimension(100, 20));
302             realplayBtn.setPreferredSize(new Dimension(125, 20));
303             attachBtn.setPreferredSize(new Dimension(120, 20));
304             manualSnapBtn.setPreferredSize(new Dimension(125, 20));
305             openStrobeButton.setPreferredSize(new Dimension(120, 20));
306
307             add(chnlabel);
308             add(chnComboBox);
309             add(nullLabel2);
310             add(realplayBtn);
311             add(nullLabel3);
312             add(attachBtn);
313             add(nullLabel4);
314             add(manualSnapBtn);
315             add(nullLabel5);
316             add(openStrobeButton);
317
318             chnComboBox.setEnabled(false);
319             realplayBtn.setEnabled(false);
320             attachBtn.setEnabled(false);
321             manualSnapBtn.setEnabled(false);
322             openStrobeButton.setEnabled(false);
323
324             realplayBtn.addActionListener(new ActionListener() {
325                 @Override
326                 public void actionPerformed(ActionEvent arg0) {
327                     realplay();
328                 }
329             });
330
331             attachBtn.addActionListener(new ActionListener() {
332                 @Override
333                 public void actionPerformed(ActionEvent arg0) {
334                     attach();
335                 }
336             });
337
338             manualSnapBtn.addActionListener(new ActionListener() {
339                 public void actionPerformed(ActionEvent e) {
340                     if(!TrafficEventModule.manualSnapPicture(chnComboBox.getSelectedIndex())) {
341                         JOptionPane.showMessageDialog(null, Res.string().getManualCaptureFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
342                     }
343                 }
344             });
345
346             openStrobeButton.addActionListener(new ActionListener() {
347                 public void actionPerformed(ActionEvent e) {
348                     openstrobe();
349                 }
350             });
351         }
352     }
353
354     // 预览
355     public void realplay() {
356         if(!b_realplay) {
357             m_hPlayHandle = RealPlayModule.startRealPlay(chnComboBox.getSelectedIndex(), 0,
358                     realPlayWindow);
359             if(m_hPlayHandle.longValue() != 0) {
360                 realPlayWindow.repaint();
361                 b_realplay = true;
362                 chnComboBox.setEnabled(false);
363                 realplayBtn.setText(Res.string().getStopRealPlay());
364             }
365         } else {
366             RealPlayModule.stopRealPlay(m_hPlayHandle);
367             realPlayWindow.repaint();
368             b_realplay = false;
369             chnComboBox.setEnabled(true);
370             realplayBtn.setText(Res.string().getStartRealPlay());
371         }
372     }
373
374     // 订阅
375     public void attach() {
376         if(!b_attach) {
377             if(TrafficEventModule.attachIVSEvent(chnComboBox.getSelectedIndex(),
378                     m_AnalyzerDataCB)) {
379                 b_attach = true;
380                 attachBtn.setText(Res.string().getDetach());
381             }
382         } else {
383             TrafficEventModule.detachIVSEvent();
384             b_attach = false;
385             attachBtn.setText(Res.string().getAttach());
386         }
387     }
388
389     // 出入口开闸
390     public void openstrobe() {
391         if(!b_openStrobe) {
392             if(TrafficEventModule.New_OpenStrobe()) {
393                 b_openStrobe = true;
394                 openStrobeButton.setText(Res.string().getCloseStrobe());
395             } else {
396                 JOptionPane.showMessageDialog(null, Res.string().getOpenStrobeFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
397             }
398         } else {
399             TrafficEventModule.New_CloseStrobe();
400             b_openStrobe = false;
401             openStrobeButton.setText(Res.string().getOpenStrobe());
402         }
403     }
404     /**
405      * 预览面板
406      */
407     private class RealPlayPanel extends JPanel {
408         private static final long serialVersionUID = 1L;
409
410         public RealPlayPanel() {
411             BorderEx.set(this, Res.string().getRealplay(), 2);
412             setLayout(new BorderLayout());
413             Dimension dim = getPreferredSize();
414             dim.height = 280;
415             dim.width = 320;
416             setPreferredSize(dim);
417
418             JPanel reaJPanel = new JPanel();
419             reaJPanel.setLayout(new BorderLayout());
420             reaJPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
421             add(reaJPanel, BorderLayout.CENTER);
422
423             realPlayWindow = new Panel();
424             realPlayWindow.setBackground(Color.GRAY);
425
426             reaJPanel.add(realPlayWindow, BorderLayout.CENTER);
427         }
428     }
429
430     /**
431      * 事件及图片面板
432      */
433     private class EventInfoPanel extends JPanel {
434         private static final long serialVersionUID = 1L;
435
436         public EventInfoPanel() {
437             Dimension dimension = new Dimension(-1, -1);
438
439             BorderEx.set(this, Res.string().getEventPicture(), 2);
440             setLayout(new BorderLayout());
441
442             //////// 车牌及抓图时间面板
443             JPanel paramPanel = new JPanel();
444             JPanel textPanel = new JPanel();
445             JPanel platePanel = new JPanel();
446
447             ///////////车牌小图
448             plateImagePanel = new PaintPanel(); // 车牌小图
449             plateImageLabel = new JLabel(Res.string().getPlatePicture());
450
451             dimension.width = 145;
452             dimension.height = 49;
453             plateImagePanel.setPreferredSize(dimension);
454             platePanel.setLayout(new BorderLayout());
455             platePanel.add(plateImagePanel, BorderLayout.SOUTH);
456             platePanel.add(plateImageLabel, BorderLayout.CENTER);
457
458             ///////////
459             eventnameLabel = new JLabel(Res.string().getEventName());
460             eventnameTextField = new JTextField("");
461             eventTimeLabel = new JLabel(Res.string().getEventTime());
462             eventTimeTextField = new JTextField("");
463             licensePlateLabel = new JLabel(Res.string().getLicensePlate());
464             licensePlateTextField = new JTextField("");
465
466             dimension.width = 165;
467             dimension.height = 45;
468             paramPanel.setPreferredSize(dimension);
469             paramPanel.setLayout(new BorderLayout());
470             paramPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
471
472             textPanel.setLayout(new GridLayout(6, 2));
473             textPanel.add(eventnameLabel);
474             textPanel.add(eventnameTextField);
475             textPanel.add(eventTimeLabel);
476             textPanel.add(eventTimeTextField);
477             textPanel.add(licensePlateLabel);
478             textPanel.add(licensePlateTextField);
479             eventnameTextField.setEditable(false);
480             eventTimeTextField.setEditable(false);
481             licensePlateTextField.setEditable(false);
482
483
484             paramPanel.add(platePanel, BorderLayout.NORTH);
485             paramPanel.add(textPanel, BorderLayout.CENTER);
486
487             ///////// 事件大图面板 ////////////////////////////
488             SnapImagePanel = new PaintPanel(); // 事件大图
489             SnapImagePanel.setSize(291, 200);
490
491             JPanel snapJPanel = new JPanel();
492             snapJPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
493             snapJPanel.setLayout(new BorderLayout());
494             snapJPanel.add(SnapImagePanel, BorderLayout.CENTER);
495
496             add(snapJPanel, BorderLayout.CENTER);
497             add(paramPanel, BorderLayout.WEST);
498         }
499     }
500
501     /**
502      * 事件信息显示面板
503      */
504     private class MessagePanel extends JPanel {
505         private static final long serialVersionUID = 1L;
506
507         public MessagePanel() {
508             BorderEx.set(this, Res.string().getEventInfo(), 2);
509
510             Dimension dim = getPreferredSize();
511             dim.height = 195;
512             setPreferredSize(dim);
513             setLayout(new BorderLayout());
514
515             //////////////
516             defaultModel = new DefaultTableModel(null, Res.string().getTrafficTableName());
517             table = new JTable(defaultModel) {   // 列表不可编辑
518                 private static final long serialVersionUID = 1L;
519                 @Override
520                 public boolean isCellEditable(int row, int column) {
521                     return false;
522                 }
523             };
524             defaultModel.setRowCount(8);
525             model = (DefaultTableModel)table.getModel();
526
527             table.getColumnModel().getColumn(0).setPreferredWidth(50);
528             table.getColumnModel().getColumn(1).setPreferredWidth(120);
529             table.getColumnModel().getColumn(2).setPreferredWidth(100);
530             table.getColumnModel().getColumn(3).setPreferredWidth(140);
531             table.getColumnModel().getColumn(4).setPreferredWidth(80);
532             table.getColumnModel().getColumn(5).setPreferredWidth(80);
533             table.getColumnModel().getColumn(6).setPreferredWidth(80);
534             table.getColumnModel().getColumn(7).setPreferredWidth(80);
535             table.getColumnModel().getColumn(8).setPreferredWidth(80);
536             table.getColumnModel().getColumn(9).setPreferredWidth(80);
537             table.getColumnModel().getColumn(10).setPreferredWidth(60);
538             table.getColumnModel().getColumn(11).setPreferredWidth(100);
539             table.getColumnModel().getColumn(12).setPreferredWidth(100);
540             table.getColumnModel().getColumn(13).setPreferredWidth(90);
541
542             table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  // 只能选中一行
543
544             // 列表显示居中
545             DefaultTableCellRenderer dCellRenderer = new DefaultTableCellRenderer();
546             dCellRenderer.setHorizontalAlignment(JLabel.CENTER);
547             table.setDefaultRenderer(Object.class, dCellRenderer);
548
549             table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
550             JScrollPane scrollPane = new JScrollPane(table);
551             add(scrollPane, BorderLayout.CENTER);
552
553             table.addMouseListener(new MouseListener() {
554                 @Override
555                 public void mouseReleased(MouseEvent e) {
556                 }
557
558                 @Override
559                 public void mousePressed(MouseEvent e) {
560                 }
561
562                 @Override
563                 public void mouseExited(MouseEvent e) {
564                 }
565
566                 @Override
567                 public void mouseEntered(MouseEvent e) {
568                 }
569
570                 @Override
571                 public void mouseClicked(MouseEvent e) {
572                     if(e.getClickCount() < 2) {
573                         return;
574                     }
575                     // 列表点击显示图片
576                     SwingUtilities.invokeLater(new Runnable() {
577                         public void run() {
578                             int row = table.getSelectedRow();
579
580                             if(model.getValueAt(row, 3) == null || String.valueOf(model.getValueAt(row, 3)).trim().equals("")) {
581                                 return;
582                             }
583
584                             if(model.getValueAt(row, 9) == null || String.valueOf(model.getValueAt(row, 9)).trim().equals("")) {
585                                 return;
586                             }
587
588                             if(model.getValueAt(row, 10) == null || String.valueOf(model.getValueAt(row, 10)).trim().equals("")) {
589                                 return;
590                             }
591
592                             if(model.getValueAt(row, 11) == null || String.valueOf(model.getValueAt(row, 11)).trim().equals("")) {
593                                 return;
594                             }
595
596                             String str2 = String.valueOf(model.getValueAt(row, 3)).trim().replace(" ", "_").replace("/", "").replace(":", "");
597                             String str9 = "_" +String.valueOf(model.getValueAt(row, 9)).trim();
598                             String str10 = "-" + String.valueOf(model.getValueAt(row, 10)).trim();
599                             String str11 = "-" + String.valueOf(model.getValueAt(row, 11)).trim();
600
601                             String selectPicture = SavePath.getSavePath().getSaveTrafficImagePath() + "Big_Time_" + str2 + str9 + str10 + str11 + ".jpg";
602                             BufferedImage bufferedImage = null;
603
604                             if(selectPicture == null || selectPicture.equals("")) {
605                                 return;
606                             }
607
608                             File file = new File(selectPicture);
609                             if(!file.exists()) {
610                                 return;
611                             }
612                             try {
613                                 bufferedImage = ImageIO.read(file);
614                             } catch (IOException e) {
615                                 e.printStackTrace();
616                             }
617                             ListPictureShowDialog demo = new ListPictureShowDialog();
618                             demo.listPanel.setOpaque(false);
619                             demo.listPanel.setImage(bufferedImage);
620                             demo.setVisible(true);
621                         }
622                     });
623                 }
624             });
625         }
626     }
627
628     class TrafficEvent extends AWTEvent {
629         private static final long serialVersionUID = 1L;
630         public static final int EVENT_ID = AWTEvent.RESERVED_ID_MAX + 1;
631
632         private TRAFFIC_INFO trafficInfo = null;
633         private BufferedImage snapImage = null;
634         private BufferedImage plateImage = null;
635
636         public TrafficEvent(Object target,
637                             BufferedImage snapImage,
638                             BufferedImage plateImage,
639                             TRAFFIC_INFO info) {
640             super(target,EVENT_ID);
641
642             this.snapImage = snapImage;
643             this.plateImage = plateImage;
644             this.trafficInfo = info;
645         }
646
647         public BufferedImage getSnapBufferedImage() {
648             return snapImage;
649         }
650
651         public BufferedImage getPlaBufferedImage() {
652             return plateImage;
653         }
654
655         public TRAFFIC_INFO getTrafficInfo() {
656             return trafficInfo;
657         }
658     }
659
660     @Override
661     protected void processEvent( AWTEvent event)
662     {
663         if ( event instanceof TrafficEvent )
664         {
665
666             TrafficEvent ev = (TrafficEvent) event;
667
668             TRAFFIC_INFO trafficInfo =  ev.getTrafficInfo();
669             BufferedImage snapImage = ev.getSnapBufferedImage();
670             BufferedImage plateImage = ev.getPlaBufferedImage();
671
672             // 列表显示事件信息
673             showTrafficEventInfo(trafficInfo);
674
675             // 界面显示图片
676             showPicture(snapImage, plateImage);
677         }
678
679         else    // other events go to the system default process event handler
680         {
681             super.processEvent( event );
682         }
683     }
684
685     /*
686      * 智能报警事件回调
687      */
688     private class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack {
689         public int invoke(LLong lAnalyzerHandle, int dwAlarmType,
690                           Pointer pAlarmInfo, Pointer pBuffer, int dwBufSize,
691                           Pointer dwUser, int nSequence, Pointer reserved)
692         {
693             if (lAnalyzerHandle.longValue() == 0) {
694                 return -1;
695             }
696
697             if(dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFICJUNCTION
698                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_RUNREDLIGHT
699                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_OVERLINE
700                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_RETROGRADE
701                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_TURNLEFT
702                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_TURNRIGHT
703                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_UTURN
704                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_OVERSPEED
705                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_UNDERSPEED
706                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_PARKING
707                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_WRONGROUTE
708                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_CROSSLANE
709                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_OVERYELLOWLINE
710                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_YELLOWPLATEINLANE
711                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_PEDESTRAINPRIORITY
712                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_MANUALSNAP
713                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINROUTE
714                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINBUSROUTE
715                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_BACKING
716                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING
717                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING
718                     || dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_WITHOUT_SAFEBELT) {
719
720                 // 获取识别对象 车身对象 事件发生时间 车道号等信息
721                 GetStuObject(dwAlarmType, pAlarmInfo);
722
723                 boolean flag=true;
724
725                 if((dwAlarmType == NetSDKLib.EVENT_IVS_TRAFFIC_MANUALSNAP)){
726                     NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO();
727                     ToolKits.GetPointerData(pAlarmInfo, msg);
728                     byte bPicEnble = msg.stuObject.bPicEnble;
729
730                     if(bPicEnble==0){
731                         flag=false;
732                     }
733                 }
734
735                 if(flag){
736                     // 保存图片,获取图片缓存
737                     savePlatePic(pBuffer, dwBufSize, trafficInfo);
738
739                     // 列表、图片界面显示
740                     EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
741                     if (eventQueue != null)
742                     {
743                         eventQueue.postEvent( new TrafficEvent(target,
744                                 snapImage,
745                                 plateImage,
746                                 trafficInfo));
747                     }
748                 }else {
749                     // 保存图片,获取图片缓存
750                     savePlatePic(pBuffer, dwBufSize, trafficInfo);
751
752                     // 列表、图片界面显示
753                     EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
754                     if (eventQueue != null)
755                     {
756                         eventQueue.postEvent( new TrafficEvent(target,
757                                 snapImage,
758                                 null,
759                                 trafficInfo));
760                     }
761                 }
762
763
764             }
765
766             return 0;
767         }
768
769         // 获取识别对象 车身对象 事件发生时间 车道号等信息
770         private void GetStuObject(int dwAlarmType, Pointer pAlarmInfo)  {
771             if(pAlarmInfo == null) {
772                 return;
773             }
774
775             switch(dwAlarmType) {
776                 case NetSDKLib.EVENT_IVS_TRAFFICJUNCTION: ///< 交通卡口事件
777                 {
778                     NetSDKLib.DEV_EVENT_TRAFFICJUNCTION_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFICJUNCTION_INFO();
779                     ToolKits.GetPointerData(pAlarmInfo, msg);
780
781                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFICJUNCTION);
782                     try {
783                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
784                     } catch (UnsupportedEncodingException e) {
785                         e.printStackTrace();
786                     }
787                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
788                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
789                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
790                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
791                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
792                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
793                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
794                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
795                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
796                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
797                     trafficInfo.m_Utc = msg.UTC;
798                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
799                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
800                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
801                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
802
803
804                     break;
805                 }
806                 case NetSDKLib.EVENT_IVS_TRAFFIC_RUNREDLIGHT: ///< 闯红灯事件
807                 {
808                     NetSDKLib.DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO();
809                     ToolKits.GetPointerData(pAlarmInfo, msg);
810
811                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_RUNREDLIGHT);
812                     try {
813                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
814                     } catch (UnsupportedEncodingException e) {
815                         e.printStackTrace();
816                     }
817                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
818                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
819                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
820                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
821                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
822                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
823                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
824                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
825                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
826                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
827                     trafficInfo.m_Utc = msg.UTC;
828                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
829                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
830                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
831                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
832
833                     break;
834                 }
835                 case NetSDKLib.EVENT_IVS_TRAFFIC_OVERLINE: ///< 压车道线事件
836                 {
837                     NetSDKLib.DEV_EVENT_TRAFFIC_OVERLINE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_OVERLINE_INFO();
838                     ToolKits.GetPointerData(pAlarmInfo, msg);
839
840                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_OVERLINE);
841                     try {
842                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
843                     } catch (UnsupportedEncodingException e) {
844                         e.printStackTrace();
845                     }
846                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
847                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
848                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
849                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
850                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
851                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
852                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
853                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
854                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
855                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
856                     trafficInfo.m_Utc = msg.UTC;
857                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
858                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
859                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
860                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
861
862                     break;
863                 }
864                 case NetSDKLib.EVENT_IVS_TRAFFIC_RETROGRADE: ///< 逆行事件
865                 {
866                     NetSDKLib.DEV_EVENT_TRAFFIC_RETROGRADE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_RETROGRADE_INFO();
867                     ToolKits.GetPointerData(pAlarmInfo, msg);
868
869                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_RETROGRADE);
870                     try {
871                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
872                     } catch (UnsupportedEncodingException e) {
873                         e.printStackTrace();
874                     }
875                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
876                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
877                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
878                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
879                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
880                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
881                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
882                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
883                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
884                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
885                     trafficInfo.m_Utc = msg.UTC;
886                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
887                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
888                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
889                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
890
891                     break;
892                 }
893                 case NetSDKLib.EVENT_IVS_TRAFFIC_TURNLEFT: ///< 违章左转
894                 {
895                     NetSDKLib.DEV_EVENT_TRAFFIC_TURNLEFT_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_TURNLEFT_INFO();
896                     ToolKits.GetPointerData(pAlarmInfo, msg);
897
898                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_TURNLEFT);
899                     try {
900                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
901                     } catch (UnsupportedEncodingException e) {
902                         e.printStackTrace();
903                     }
904                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
905                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
906                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
907                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
908                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
909                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
910                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
911                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
912                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
913                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
914                     trafficInfo.m_Utc = msg.UTC;
915                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
916                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
917                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
918                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
919
920                     break;
921                 }
922                 case NetSDKLib.EVENT_IVS_TRAFFIC_TURNRIGHT: ///< 违章右转
923                 {
924                     NetSDKLib.DEV_EVENT_TRAFFIC_TURNRIGHT_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_TURNRIGHT_INFO();
925                     ToolKits.GetPointerData(pAlarmInfo, msg);
926
927                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_TURNRIGHT);
928                     try {
929                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
930                     } catch (UnsupportedEncodingException e) {
931                         e.printStackTrace();
932                     }
933                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
934                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
935                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
936                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
937                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
938                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
939                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
940                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
941                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
942                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
943                     trafficInfo.m_Utc = msg.UTC;
944                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
945                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
946                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
947                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
948
949                     break;
950                 }
951                 case NetSDKLib.EVENT_IVS_TRAFFIC_UTURN: ///< 违章掉头
952                 {
953                     NetSDKLib.DEV_EVENT_TRAFFIC_UTURN_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_UTURN_INFO();
954                     ToolKits.GetPointerData(pAlarmInfo, msg);
955
956                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_UTURN);
957                     try {
958                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
959                     } catch (UnsupportedEncodingException e) {
960                         e.printStackTrace();
961                     }
962                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
963                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
964                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
965                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
966                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
967                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
968                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
969                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
970                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
971                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
972                     trafficInfo.m_Utc = msg.UTC;
973                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
974                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
975                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
976                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
977
978                     break;
979                 }
980                 case NetSDKLib.EVENT_IVS_TRAFFIC_OVERSPEED: ///< 超速
981                 {
982                     NetSDKLib.DEV_EVENT_TRAFFIC_OVERSPEED_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_OVERSPEED_INFO();
983                     ToolKits.GetPointerData(pAlarmInfo, msg);
984
985                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_OVERSPEED);
986                     try {
987                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
988                     } catch (UnsupportedEncodingException e) {
989                         e.printStackTrace();
990                     }
991                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
992                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
993                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
994                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
995                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
996                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
997                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
998                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
999                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1000                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1001                     trafficInfo.m_Utc = msg.UTC;
1002                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1003                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1004                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1005                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1006
1007                     break;
1008                 }
1009                 case NetSDKLib.EVENT_IVS_TRAFFIC_UNDERSPEED: ///< 低速
1010                 {
1011                     NetSDKLib.DEV_EVENT_TRAFFIC_UNDERSPEED_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_UNDERSPEED_INFO();
1012                     ToolKits.GetPointerData(pAlarmInfo, msg);
1013
1014                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_UNDERSPEED);
1015                     try {
1016                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1017                     } catch (UnsupportedEncodingException e) {
1018                         e.printStackTrace();
1019                     }
1020                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1021                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1022                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1023                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1024                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1025                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1026                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1027                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1028                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1029                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1030                     trafficInfo.m_Utc = msg.UTC;
1031                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1032                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1033                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1034                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1035
1036                     break;
1037                 }
1038                 case NetSDKLib.EVENT_IVS_TRAFFIC_PARKING: ///< 违章停车
1039                 {
1040                     NetSDKLib.DEV_EVENT_TRAFFIC_PARKING_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PARKING_INFO();
1041                     ToolKits.GetPointerData(pAlarmInfo, msg);
1042
1043                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_PARKING);
1044                     try {
1045                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1046                     } catch (UnsupportedEncodingException e) {
1047                         e.printStackTrace();
1048                     }
1049                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1050                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1051                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1052                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1053                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1054                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1055                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1056                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1057                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1058                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1059                     trafficInfo.m_Utc = msg.UTC;
1060                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1061                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1062                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1063                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1064
1065                     break;
1066                 }
1067                 case NetSDKLib.EVENT_IVS_TRAFFIC_WRONGROUTE: ///< 不按车道行驶
1068                 {
1069                     NetSDKLib.DEV_EVENT_TRAFFIC_WRONGROUTE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_WRONGROUTE_INFO();
1070                     ToolKits.GetPointerData(pAlarmInfo, msg);
1071
1072                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_WRONGROUTE);
1073                     try {
1074                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1075                     } catch (UnsupportedEncodingException e) {
1076                         e.printStackTrace();
1077                     }
1078                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1079                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1080                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1081                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1082                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1083                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1084                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1085                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1086                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1087                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1088                     trafficInfo.m_Utc = msg.UTC;
1089                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1090                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1091                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1092                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1093
1094                     break;
1095                 }
1096                 case NetSDKLib.EVENT_IVS_TRAFFIC_CROSSLANE: ///< 违章变道
1097                 {
1098                     NetSDKLib.DEV_EVENT_TRAFFIC_CROSSLANE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_CROSSLANE_INFO();
1099                     ToolKits.GetPointerData(pAlarmInfo, msg);
1100
1101                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_CROSSLANE);
1102                     try {
1103                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1104                     } catch (UnsupportedEncodingException e) {
1105                         e.printStackTrace();
1106                     }
1107                     trafficInfo.m_PlateType = new String(msg.stuTrafficCar.szPlateType).trim();
1108                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1109                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1110                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1111                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stuTrafficCar.szDeviceAddress);
1112                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1113                     trafficInfo.m_PlateColor = new String(msg.stuTrafficCar.szPlateColor).trim();
1114                     trafficInfo.m_VehicleColor = new String(msg.stuTrafficCar.szVehicleColor).trim();
1115                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1116                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stuTrafficCar.nVehicleSize);
1117                     trafficInfo.m_Utc = msg.UTC;
1118                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1119                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1120                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1121                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1122
1123                     break;
1124                 }
1125                 case NetSDKLib.EVENT_IVS_TRAFFIC_OVERYELLOWLINE: ///< 压黄线
1126                 {
1127                     NetSDKLib.DEV_EVENT_TRAFFIC_OVERYELLOWLINE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_OVERYELLOWLINE_INFO();
1128                     ToolKits.GetPointerData(pAlarmInfo, msg);
1129
1130                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_OVERYELLOWLINE);
1131                     try {
1132                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1133                     } catch (UnsupportedEncodingException e) {
1134                         e.printStackTrace();
1135                     }
1136                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1137                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1138                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1139                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1140                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1141                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1142                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1143                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1144                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1145                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1146                     trafficInfo.m_Utc = msg.UTC;
1147                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1148                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1149                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1150                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1151
1152                     break;
1153                 }
1154                 case NetSDKLib.EVENT_IVS_TRAFFIC_YELLOWPLATEINLANE: ///< 黄牌车占道事件
1155                 {
1156                     NetSDKLib.DEV_EVENT_TRAFFIC_YELLOWPLATEINLANE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_YELLOWPLATEINLANE_INFO();
1157                     ToolKits.GetPointerData(pAlarmInfo, msg);
1158
1159                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_YELLOWPLATEINLANE);
1160                     try {
1161                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1162                     } catch (UnsupportedEncodingException e) {
1163                         e.printStackTrace();
1164                     }
1165                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1166                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1167                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1168                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1169                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1170                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1171                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1172                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1173                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1174                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1175                     trafficInfo.m_Utc = msg.UTC;
1176                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1177                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1178                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1179                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1180
1181                     break;
1182                 }
1183                 case NetSDKLib.EVENT_IVS_TRAFFIC_PEDESTRAINPRIORITY: ///< 斑马线行人优先事件
1184                 {
1185                     NetSDKLib.DEV_EVENT_TRAFFIC_PEDESTRAINPRIORITY_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PEDESTRAINPRIORITY_INFO();
1186                     ToolKits.GetPointerData(pAlarmInfo, msg);
1187
1188                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_PEDESTRAINPRIORITY);
1189                     try {
1190                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1191                     } catch (UnsupportedEncodingException e) {
1192                         e.printStackTrace();
1193                     }
1194                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1195                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1196                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1197                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1198                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1199                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1200                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1201                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1202                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1203                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1204                     trafficInfo.m_Utc = msg.UTC;
1205                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1206                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1207                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1208                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1209
1210                     break;
1211                 }
1212                 case NetSDKLib.EVENT_IVS_TRAFFIC_MANUALSNAP: ///< 交通手动抓拍事件
1213                 {
1214                     JOptionPane.showMessageDialog(null, Res.string().getManualCaptureSucceed(), Res.string().getPromptMessage(), JOptionPane.INFORMATION_MESSAGE);
1215                     NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO();
1216                     ToolKits.GetPointerData(pAlarmInfo, msg);
1217
1218                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_MANUALSNAP);
1219                     try {
1220                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1221                     } catch (UnsupportedEncodingException e) {
1222                         e.printStackTrace();
1223                     }
1224                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1225                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1226                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1227                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1228                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1229                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1230                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1231                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1232                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1233                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1234                     trafficInfo.m_Utc = msg.UTC;
1235                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1236
1237                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1238                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1239                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1240
1241
1242                     break;
1243                 }
1244                 case NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINROUTE: ///< 有车占道事件
1245                 {
1246                     NetSDKLib.DEV_EVENT_TRAFFIC_VEHICLEINROUTE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_VEHICLEINROUTE_INFO();
1247                     ToolKits.GetPointerData(pAlarmInfo, msg);
1248
1249                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINROUTE);
1250                     try {
1251                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1252                     } catch (UnsupportedEncodingException e) {
1253                         e.printStackTrace();
1254                     }
1255                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1256                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1257                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1258                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1259                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1260                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1261                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1262                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1263                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1264                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1265                     trafficInfo.m_Utc = msg.UTC;
1266                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1267                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1268                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1269                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1270
1271                     break;
1272                 }
1273                 case NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINBUSROUTE: ///< 占用公交车道事件
1274                 {
1275                     NetSDKLib.DEV_EVENT_TRAFFIC_VEHICLEINBUSROUTE_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_VEHICLEINBUSROUTE_INFO();
1276                     ToolKits.GetPointerData(pAlarmInfo, msg);
1277
1278                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_VEHICLEINBUSROUTE);
1279                     try {
1280                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1281                     } catch (UnsupportedEncodingException e) {
1282                         e.printStackTrace();
1283                     }
1284                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1285                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1286                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1287                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1288                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1289                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1290                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1291                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1292                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1293                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1294                     trafficInfo.m_Utc = msg.UTC;
1295                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1296                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1297                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1298                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1299
1300                     break;
1301                 }
1302                 case NetSDKLib.EVENT_IVS_TRAFFIC_BACKING: ///< 违章倒车事件
1303                 {
1304                     NetSDKLib.DEV_EVENT_IVS_TRAFFIC_BACKING_INFO msg = new NetSDKLib.DEV_EVENT_IVS_TRAFFIC_BACKING_INFO();
1305                     ToolKits.GetPointerData(pAlarmInfo, msg);
1306
1307                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_BACKING);
1308                     try {
1309                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1310                     } catch (UnsupportedEncodingException e) {
1311                         e.printStackTrace();
1312                     }
1313                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1314                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1315                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1316                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1317                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1318                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1319                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1320                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1321                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1322                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1323                     trafficInfo.m_Utc = msg.UTC;
1324                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1325                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1326                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1327                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1328
1329                     break;
1330                 }
1331                 case NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING: ///< 车位有车事件
1332                 {
1333                     NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO();
1334                     ToolKits.GetPointerData(pAlarmInfo, msg);
1335
1336                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING);
1337                     try {
1338                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1339                     } catch (UnsupportedEncodingException e) {
1340                         e.printStackTrace();
1341                     }
1342                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1343                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1344                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1345                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1346                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1347                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1348                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1349                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1350                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1351                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1352                     trafficInfo.m_Utc = msg.UTC;
1353                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1354                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1355                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1356                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1357
1358                     break;
1359                 }
1360                 case NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING: ///< 车位无车事件
1361                 {
1362                     NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO();
1363                     ToolKits.GetPointerData(pAlarmInfo, msg);
1364
1365                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING);
1366                     try {
1367                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1368                     } catch (UnsupportedEncodingException e) {
1369                         e.printStackTrace();
1370                     }
1371                     trafficInfo.m_PlateType = new String(msg.stTrafficCar.szPlateType).trim();
1372                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1373                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1374                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1375                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stTrafficCar.szDeviceAddress);
1376                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1377                     trafficInfo.m_PlateColor = new String(msg.stTrafficCar.szPlateColor).trim();
1378                     trafficInfo.m_VehicleColor = new String(msg.stTrafficCar.szVehicleColor).trim();
1379                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1380                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stTrafficCar.nVehicleSize);
1381                     trafficInfo.m_Utc = msg.UTC;
1382                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1383                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1384                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1385                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1386
1387                     break;
1388                 }
1389                 case NetSDKLib.EVENT_IVS_TRAFFIC_WITHOUT_SAFEBELT: ///< 交通未系安全带事件
1390                 {
1391                     NetSDKLib.DEV_EVENT_TRAFFIC_WITHOUT_SAFEBELT msg = new NetSDKLib.DEV_EVENT_TRAFFIC_WITHOUT_SAFEBELT();
1392                     ToolKits.GetPointerData(pAlarmInfo, msg);
1393
1394                     trafficInfo.m_EventName = Res.string().getEventName(NetSDKLib.EVENT_IVS_TRAFFIC_WITHOUT_SAFEBELT);
1395                     try {
1396                         trafficInfo.m_PlateNumber = new String(msg.stuObject.szText, "GBK").trim();
1397                     } catch (UnsupportedEncodingException e) {
1398                         e.printStackTrace();
1399                     }
1400                     trafficInfo.m_PlateType = new String(msg.stuTrafficCar.szPlateType).trim();
1401                     trafficInfo.m_FileCount = String.valueOf(msg.stuFileInfo.bCount);
1402                     trafficInfo.m_FileIndex = String.valueOf(msg.stuFileInfo.bIndex);
1403                     trafficInfo.m_GroupID =  String.valueOf(msg.stuFileInfo.nGroupId);
1404                     trafficInfo.m_IllegalPlace = ToolKits.GetPointerDataToByteArr(msg.stuTrafficCar.szDeviceAddress);
1405                     trafficInfo.m_LaneNumber = String.valueOf(msg.nLane);
1406                     trafficInfo.m_PlateColor = new String(msg.stuTrafficCar.szPlateColor).trim();
1407                     trafficInfo.m_VehicleColor = new String(msg.stuTrafficCar.szVehicleColor).trim();
1408                     trafficInfo.m_VehicleType = new String(msg.stuVehicle.szObjectSubType).trim();
1409                     trafficInfo.m_VehicleSize = Res.string().getTrafficSize(msg.stuTrafficCar.nVehicleSize);
1410                     trafficInfo.m_Utc = msg.UTC;
1411                     trafficInfo.m_bPicEnble = msg.stuObject.bPicEnble;
1412                     trafficInfo.m_OffSet = msg.stuObject.stPicInfo.dwOffSet;
1413                     trafficInfo.m_FileLength = msg.stuObject.stPicInfo.dwFileLenth;
1414                     trafficInfo.m_BoundingBox = msg.stuObject.BoundingBox;
1415
1416                     break;
1417                 }
1418                 default:
1419                     break;
1420             }
1421         }
1422
1423     }
1424
1425     /*
1426      * 显示事件名称、车牌号、事件时间
1427      */
1428     private void showTrafficEventInfo(TRAFFIC_INFO trafficInfo) {
1429         // 事件名称
1430         if(trafficInfo.m_EventName.equals("")) {
1431             eventnameTextField.setText("");
1432         } else {
1433             eventnameTextField.setText(trafficInfo.m_EventName);
1434         }
1435
1436         // 车牌号
1437         if(trafficInfo.m_PlateNumber.equals("") ) {
1438             licensePlateTextField.setText(Res.string().getNoPlate());
1439             plateImagePanel.setOpaque(true);
1440             plateImagePanel.repaint();
1441         } else {
1442             licensePlateTextField.setText(trafficInfo.m_PlateNumber);
1443         }
1444
1445         // 事件时间
1446         if(trafficInfo.m_Utc == null
1447                 || trafficInfo.m_Utc.toStringTime().equals("")) {
1448             eventTimeTextField.setText("");
1449         } else {
1450             eventTimeTextField.setText(trafficInfo.m_Utc.toStringTime());
1451         }
1452
1453         Vector<String> vector = new Vector<String>();
1454
1455
1456         vector.add(String.valueOf(i));                     // 序号
1457         vector.add(trafficInfo.m_EventName);             // 事件名称
1458         vector.add(trafficInfo.m_PlateNumber);             // 车牌号
1459
1460         // 事件时间
1461         if(trafficInfo.m_Utc == null || trafficInfo.m_Utc.toStringTime().equals("")) {
1462             vector.add("");
1463         } else {
1464             vector.add(trafficInfo.m_Utc.toStringTime());
1465         }
1466
1467         vector.add(trafficInfo.m_PlateType);             // 车牌类型
1468         vector.add(trafficInfo.m_PlateColor);             // 车牌颜色
1469         vector.add(trafficInfo.m_VehicleColor);         // 车身颜色
1470         vector.add(trafficInfo.m_VehicleType);             // 车身类型
1471         vector.add(trafficInfo.m_VehicleSize);             // 车辆大小
1472         vector.add(trafficInfo.m_FileCount);             // 文件总数
1473         vector.add(trafficInfo.m_FileIndex);             // 文件编号
1474         vector.add(trafficInfo.m_GroupID);                 // 组ID
1475         vector.add(trafficInfo.m_IllegalPlace);         // 违法地点
1476         vector.add(trafficInfo.m_LaneNumber);             // 车道号
1477
1478         defaultModel.insertRow(0, vector);
1479         defaultModel.setRowCount(8);
1480
1481         table.updateUI();
1482
1483         i++;
1484     }
1485
1486     /*
1487      * 界面显示图片
1488      */
1489     private void showPicture(BufferedImage snapImage, BufferedImage plateImage) {
1490         if (snapImage == null) {
1491             SnapImagePanel.setOpaque(true);  // 不透明
1492             SnapImagePanel.repaint();
1493
1494             plateImagePanel.setOpaque(true);
1495             plateImagePanel.repaint();
1496             return;
1497         }
1498
1499         SnapImagePanel.setOpaque(false);  // 透明
1500         SnapImagePanel.setImage(snapImage);
1501         SnapImagePanel.repaint();
1502
1503         if(plateImage == null) {
1504             plateImagePanel.setOpaque(true);
1505             plateImagePanel.repaint();
1506             return;
1507         }
1508
1509         plateImagePanel.setOpaque(false);
1510         plateImagePanel.setImage(plateImage);
1511         plateImagePanel.repaint();
1512     }
1513     /*
1514      * 保存车牌小图:DH早期交通抓拍机,设备不传单独的车牌小图文件,只传车牌在大图中的坐标;由应用来自行裁剪。
1515      * 2014年后,陆续有设备版本,支持单独传车牌小图,小图附录在pBuffer后面。
1516      */
1517     private void savePlatePic(Pointer pBuffer, int dwBufferSize, TRAFFIC_INFO trafficInfo) {
1518
1519         String bigPicture; // 大图
1520         String platePicture; // 车牌图
1521
1522         if (pBuffer == null || dwBufferSize <= 0 ) {
1523             return;
1524         }
1525
1526         // 保存大图
1527         byte[] buffer = pBuffer.getByteArray(0, dwBufferSize);
1528         ByteArrayInputStream byteArrInput = new ByteArrayInputStream(buffer);
1529
1530         bigPicture = SavePath.getSavePath().getSaveTrafficImagePath() + "Big_" + trafficInfo.m_Utc.toStringTitle() + "_" +
1531                 trafficInfo.m_FileCount + "-" + trafficInfo.m_FileIndex + "-" + trafficInfo.m_GroupID + ".jpg";
1532
1533         try {
1534             snapImage = ImageIO.read(byteArrInput);
1535             if(snapImage == null) {
1536                 return;
1537             }
1538             ImageIO.write(snapImage, "jpg", new File(bigPicture));
1539         } catch (IOException e2) {
1540             e2.printStackTrace();
1541         }
1542
1543         if(bigPicture == null || bigPicture.equals("")) {
1544             return;
1545         }
1546
1547         if (trafficInfo.m_bPicEnble == 1) {
1548             //根据pBuffer中数据偏移保存小图图片文件
1549             if (trafficInfo.m_FileLength > 0) {
1550                 platePicture = SavePath.getSavePath().getSaveTrafficImagePath() + "plate_" + trafficInfo.m_Utc.toStringTitle() + "_" +
1551                         trafficInfo.m_FileCount + "-" + trafficInfo.m_FileIndex + "-" + trafficInfo.m_GroupID + ".jpg";
1552
1553                 int size = 0;
1554                 if(dwBufferSize <= trafficInfo.m_OffSet) {
1555                     return;
1556                 }
1557
1558                 if(trafficInfo.m_FileLength <= dwBufferSize - trafficInfo.m_OffSet) {
1559                     size = trafficInfo.m_FileLength;
1560                 } else {
1561                     size = dwBufferSize - trafficInfo.m_OffSet;
1562                 }
1563                 byte[] bufPlate = pBuffer. getByteArray(trafficInfo.m_OffSet, size);
1564                 ByteArrayInputStream byteArrInputPlate = new ByteArrayInputStream(bufPlate);
1565                 try {
1566                     plateImage = ImageIO.read(byteArrInputPlate);
1567                     if(plateImage == null) {
1568                         return;
1569                     }
1570                     ImageIO.write(plateImage, "jpg", new File(platePicture));
1571                 } catch (IOException e) {
1572                     e.printStackTrace();
1573                 }
1574             }
1575         }
1576         else {
1577             if(trafficInfo.m_BoundingBox == null) {
1578                 return;
1579             }
1580             //根据大图中的坐标偏移计算显示车牌小图
1581
1582             NetSDKLib.DH_RECT dhRect = trafficInfo.m_BoundingBox;
1583             //1.BoundingBox的值是在8192*8192坐标系下的值,必须转化为图片中的坐标
1584             //2.OSD在图片中占了64行,如果没有OSD,下面的关于OSD的处理需要去掉(把OSD_HEIGHT置为0)
1585             final int OSD_HEIGHT = 0;
1586
1587             long nWidth = snapImage.getWidth(null);
1588             long nHeight = snapImage.getHeight(null);
1589
1590             nHeight = nHeight - OSD_HEIGHT;
1591             if ((nWidth <= 0) || (nHeight <= 0)) {
1592                 return ;
1593             }
1594
1595             NetSDKLib.DH_RECT dstRect = new NetSDKLib.DH_RECT();
1596
1597             dstRect.left.setValue((long)((double)(nWidth * dhRect.left.longValue()) / 8192.0));
1598             dstRect.right.setValue((long)((double)(nWidth * dhRect.right.longValue()) / 8192.0));
1599             dstRect.bottom.setValue((long)((double)(nHeight * dhRect.bottom.longValue()) / 8192.0));
1600             dstRect.top.setValue((long)((double)(nHeight * dhRect.top.longValue()) / 8192.0));
1601
1602             int x = dstRect.left.intValue();
1603             int y = dstRect.top.intValue() + OSD_HEIGHT;
1604             int w = dstRect.right.intValue() - dstRect.left.intValue();
1605             int h = dstRect.bottom.intValue() - dstRect.top.intValue();
1606
1607             if(x == 0 || y == 0 || w <= 0 || h <= 0) {
1608                 return;
1609             }
1610
1611             try {
1612                 plateImage = snapImage.getSubimage(x, y, w, h);
1613                 platePicture = SavePath.getSavePath().getSaveTrafficImagePath() + "plate_" + trafficInfo.m_Utc.toStringTitle() + "_" +
1614                         trafficInfo.m_FileCount + "-" + trafficInfo.m_FileIndex + "-" + trafficInfo.m_GroupID + ".jpg";
1615                 if(plateImage == null) {
1616                     return;
1617                 }
1618                 ImageIO.write(plateImage, "jpg", new File(platePicture));
1619             } catch (Exception e) {
1620                 e.printStackTrace();
1621             }
1622         }
1623     }
1624
1625     private void setButtonEnable(boolean bln) {
1626         chnComboBox.setEnabled(bln);
1627         realplayBtn.setEnabled(bln);
1628         attachBtn.setEnabled(bln);
1629         manualSnapBtn.setEnabled(bln);
1630         openStrobeButton.setEnabled(bln);
1631     }
1632
1633     //登录组件
1634     private LoginPanel loginPanel;
1635
1636     private ItsPanel itsPanel;
1637     private OperatePanel operatePanel;
1638     private JButton realplayBtn;
1639     private JButton attachBtn;
1640
1641     /**
1642      * 事件信息显示组件
1643      */
1644     private MessagePanel messagePanel;
1645     private DefaultTableModel defaultModel;
1646     private JTable table;
1647
1648     /**
1649      * 实时预览组件
1650      */
1651     private RealPlayPanel realPlayPanel;
1652     Panel realPlayWindow;
1653     private JLabel chnlabel;
1654     JComboBox chnComboBox;
1655     JComboBox streamComboBox;
1656
1657     /**
1658      * 事件及图片组件
1659      */
1660     private EventInfoPanel eventInfoPanel;
1661     private PaintPanel SnapImagePanel;
1662     private PaintPanel plateImagePanel;
1663     private JLabel plateImageLabel;
1664
1665     private JLabel eventnameLabel;
1666     private JTextField eventnameTextField;
1667
1668     private JLabel eventTimeLabel;
1669     private JTextField eventTimeTextField;
1670
1671     private JLabel licensePlateLabel;
1672     private JTextField licensePlateTextField;
1673
1674     private JButton manualSnapBtn;
1675     private JButton openStrobeButton;
1676
1677 }
1678
1679 public class TrafficEvent {
1680     public static void main(String[] args) {
1681         SwingUtilities.invokeLater(new Runnable() {
1682             public void run() {
1683                 TrafficEventFrame demo = new TrafficEventFrame();
1684                 demo.setVisible(true);
1685             }
1686         });
1687     }
1688 };
1689