提交 | 用户 | 时间
|
ce910c
|
1 |
package com.netsdk.demo.module; |
H |
2 |
|
|
3 |
import com.netsdk.lib.NetSDKLib; |
|
4 |
import com.netsdk.lib.NetSDKLib.LLong; |
|
5 |
import com.netsdk.lib.ToolKits; |
|
6 |
|
|
7 |
/** |
|
8 |
* 智能交通接口实现 |
|
9 |
* 主要有 :智能订阅、开闸、关闸功能 |
|
10 |
*/ |
|
11 |
public class TrafficEventModule { |
|
12 |
// 智能订阅句柄 |
|
13 |
public static LLong m_hAttachHandle = new LLong(0); |
|
14 |
|
|
15 |
/** |
|
16 |
* 新版本开闸 |
|
17 |
*/ |
|
18 |
public static boolean New_OpenStrobe() { |
|
19 |
NetSDKLib.NET_CTRL_OPEN_STROBE openStrobe = new NetSDKLib.NET_CTRL_OPEN_STROBE(); |
|
20 |
openStrobe.nChannelId = 0; |
|
21 |
String plate = new String("浙A888888"); |
|
22 |
|
|
23 |
System.arraycopy(plate.getBytes(), 0, openStrobe.szPlateNumber, 0, plate.getBytes().length); |
|
24 |
openStrobe.write(); |
|
25 |
if (LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_CTRL_OPEN_STROBE, openStrobe.getPointer(), null, 3000)) { |
|
26 |
System.out.println("Open Success!"); |
|
27 |
} else { |
|
28 |
System.err.println("Failed to Open." + ToolKits.getErrorCodePrint()); |
|
29 |
return false; |
|
30 |
} |
|
31 |
openStrobe.read(); |
|
32 |
|
|
33 |
return true; |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* 新版本关闸 |
|
38 |
*/ |
|
39 |
public static void New_CloseStrobe() { |
|
40 |
NetSDKLib.NET_CTRL_CLOSE_STROBE closeStrobe = new NetSDKLib.NET_CTRL_CLOSE_STROBE(); |
|
41 |
closeStrobe.nChannelId = 0; |
|
42 |
closeStrobe.write(); |
|
43 |
if (LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_CTRL_CLOSE_STROBE, closeStrobe.getPointer(), null, 3000)) { |
|
44 |
System.out.println("Close Success!"); |
|
45 |
} else { |
|
46 |
System.err.println("Failed to Close." + ToolKits.getErrorCodePrint()); |
|
47 |
} |
|
48 |
closeStrobe.read(); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* 手动抓图按钮事件 |
|
53 |
*/ |
|
54 |
public static boolean manualSnapPicture(int chn) { |
|
55 |
NetSDKLib.MANUAL_SNAP_PARAMETER snapParam = new NetSDKLib.MANUAL_SNAP_PARAMETER(); |
|
56 |
snapParam.nChannel = chn; |
|
57 |
String sequence = "11111"; // 抓图序列号,必须用数组拷贝 |
|
58 |
System.arraycopy(sequence.getBytes(), 0, snapParam.bySequence, 0, sequence.getBytes().length); |
|
59 |
|
|
60 |
snapParam.write(); |
|
61 |
boolean bRet = LoginModule.netsdk.CLIENT_ControlDeviceEx(LoginModule.m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_MANUAL_SNAP, snapParam.getPointer(), null, 5000); |
|
62 |
if (!bRet) { |
|
63 |
System.err.println("Failed to manual snap, last error " + ToolKits.getErrorCodePrint()); |
|
64 |
return false; |
|
65 |
} else { |
|
66 |
System.out.println("Seccessed to manual snap"); |
|
67 |
} |
|
68 |
snapParam.read(); |
|
69 |
return true; |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* 订阅实时上传智能分析数据 |
|
74 |
* @return |
|
75 |
*/ |
|
76 |
public static boolean attachIVSEvent(int ChannelId, NetSDKLib.fAnalyzerDataCallBack m_AnalyzerDataCB) { |
|
77 |
/** |
|
78 |
* 说明: |
|
79 |
* 通道数可以在有登录是返回的信息 m_stDeviceInfo.byChanNum 获取 |
|
80 |
* 下列仅订阅了0通道的智能事件. |
|
81 |
*/ |
|
82 |
int bNeedPicture = 1; // 是否需要图片 |
|
83 |
|
|
84 |
m_hAttachHandle = LoginModule.netsdk.CLIENT_RealLoadPictureEx(LoginModule.m_hLoginHandle, ChannelId, NetSDKLib.EVENT_IVS_ALL, |
|
85 |
bNeedPicture , m_AnalyzerDataCB , null , null); |
|
86 |
if( m_hAttachHandle.longValue() != 0 ) { |
|
87 |
System.out.println("CLIENT_RealLoadPictureEx Success ChannelId : \n" + ChannelId); |
|
88 |
} else { |
|
89 |
System.err.println("CLIENT_RealLoadPictureEx Failed!" + ToolKits.getErrorCodePrint()); |
|
90 |
return false; |
|
91 |
} |
|
92 |
|
|
93 |
return true; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* 停止上传智能分析数据-图片 |
|
98 |
*/ |
|
99 |
public static void detachIVSEvent() { |
|
100 |
if (0 != m_hAttachHandle.longValue()) { |
|
101 |
LoginModule.netsdk.CLIENT_StopLoadPic(m_hAttachHandle); |
|
102 |
System.out.println("Stop detach IVS event"); |
|
103 |
m_hAttachHandle.setValue(0); |
|
104 |
} |
|
105 |
} |
|
106 |
} |