zxl
昨天 3b0516a2959e25576e4f3fda697a3b025d06c8c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package com.ycl.api.YS.ptz.ptzextend;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.util.Common;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_PTZ_E;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_PTZ_TRACK_INFO_S;
 
import javax.swing.*;
 
/**
 * 
 * @description Path cruise includes recording cruise path,acquiring cruise path,starting cruise and stopping cruise
 * @introduction Support IPC/NVR
 */
public class RoutePatrols {
    /**
     * @introduction Acquiring cruise path.
     * @description Call the interface of NETDEV_PTZGetTrackCruise to acquire the cruise path.
     */
    public static void getRoutePatrols() {
        if(null == NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if(NetDemo.ChannelID == 0)
        {
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return;
        }
 
        NETDEV_PTZ_TRACK_INFO_S stTrackCruiseInfo = new NETDEV_PTZ_TRACK_INFO_S();
 
        boolean bRet = NetDemo.netdevsdk.NETDEV_PTZGetTrackCruise(NetDemo.lpUserID, NetDemo.ChannelID, stTrackCruiseInfo);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "PTZGetTrackCruise failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZGetTrackCruise failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        else 
        {
            NetDemo.jTextFieldPTZExtendRoutePatrolsName.setText(Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
        }
    }
    /**
     * @introduction To start the cruise.
     * @description  Call the interface of NETDEV_PTZGetTrackCruise and NETDEV_PTZTrackCruise to start the cruise.
     */
    public static void runRoutePatrols() {
        if(null == NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if(NetDemo.ChannelID == 0)
        {
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return;
        }
 
        NETDEV_PTZ_TRACK_INFO_S stTrackCruiseInfo = new NETDEV_PTZ_TRACK_INFO_S();
 
        boolean bRet = NetDemo.netdevsdk.NETDEV_PTZGetTrackCruise(NetDemo.lpUserID, NetDemo.ChannelID, stTrackCruiseInfo);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZGetTrackCruise failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        bRet = NetDemo.netdevsdk.NETDEV_PTZTrackCruise(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_TRACKCRUISE, Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZTrackCruise failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
    }
    /**
     * @introduction To stop the cruise.
     * @description  Call the interface of NETDEV_PTZGetTrackCruise and NETDEV_PTZTrackCruise to stop the cruise.
     */
    public static void stopRoutePatrols() {
        if(null == NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if(NetDemo.ChannelID == 0)
        {
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return;
        }
 
        NETDEV_PTZ_TRACK_INFO_S stTrackCruiseInfo = new NETDEV_PTZ_TRACK_INFO_S();
 
        boolean bRet = NetDemo.netdevsdk.NETDEV_PTZGetTrackCruise(NetDemo.lpUserID, NetDemo.ChannelID, stTrackCruiseInfo);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZGetTrackCruise failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        bRet = NetDemo.netdevsdk.NETDEV_PTZTrackCruise(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_TRACKCRUISESTOP, Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZTrackCruise failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
    }
    /**
     * @introduction To start to record the cruise path.
     * @description  Call the interface of NETDEV_PTZGetTrackCruise and NETDEV_PTZTrackCruise to record the cruise path.
     */
    public static void startRecordRoute() {
        
        if(null == NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if(NetDemo.ChannelID == 0)
        {
            JOptionPane.showMessageDialog(null, "Please select an online channel.");
            return;
        }
        NetDemo.jButtonPTZExtendRouteRecordStop.doClick();
        NETDEV_PTZ_TRACK_INFO_S stTrackCruiseInfo = new NETDEV_PTZ_TRACK_INFO_S();
        boolean bRet =  NetDemo.netdevsdk.NETDEV_PTZGetTrackCruise( NetDemo.lpUserID,  NetDemo.ChannelID, stTrackCruiseInfo);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZGetTrackCruise failed:%d\n",  NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if(stTrackCruiseInfo.dwTrackNum == 0)
        {
            /* Use PTZ to record route */
            boolean bRet2 =  NetDemo.netdevsdk.NETDEV_PTZTrackCruise( NetDemo.lpUserID,  NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_TRACKCRUISEADD, Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
            if(bRet2 != true)
            {
                JOptionPane.showMessageDialog(null, "The interface failed,error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
                System.out.printf("NETDEV_PTZTrackCruise failed:%d\n",  NetDemo.netdevsdk.NETDEV_GetLastError());
                return;
            }
 
            stTrackCruiseInfo.dwTrackNum++;
        }
 
 
       boolean bRet1 =  NetDemo.netdevsdk.NETDEV_PTZTrackCruise( NetDemo.lpUserID,  NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_TRACKCRUISEREC, Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
        if(bRet1 != true)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZTrackCruise failed:%d\n",  NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
    }
    
    /**
     * @introduction To stop to record the cruise path.
     * @description Call the interface of NETDEV_PTZGetTrackCruise and NETDEV_PTZTrackCruise to  stop recording the cruise path.
     */
    public static void stopRecordRoute() {
        if(null ==  NetDemo.lpUserID)
        {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        if( NetDemo.ChannelID == 0)
        {
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return;
        }
 
        NETDEV_PTZ_TRACK_INFO_S stTrackCruiseInfo = new NETDEV_PTZ_TRACK_INFO_S();
 
        boolean bRet =  NetDemo.netdevsdk.NETDEV_PTZGetTrackCruise( NetDemo.lpUserID,  NetDemo.ChannelID, stTrackCruiseInfo);
        if(false == bRet)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZGetTrackCruise failed:%d\n",  NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
 
        bRet =  NetDemo.netdevsdk.NETDEV_PTZTrackCruise( NetDemo.lpUserID,  NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_TRACKCRUISERECSTOP, Common.byteArrayToString(stTrackCruiseInfo.aszTrackName));
        if(false == bRet)
        {
            JOptionPane.showMessageDialog(null, "The interface failed,error code"+ NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_PTZTrackCruise failed:%d\n",  NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
    }
}