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
package com.ycl.api.YS.ptz.basicptz;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_PTZ_E;
 
import javax.swing.*;
 
/**
 * 
 * @description The control of PTZ direction、Zoom settings、Focus settings and preset location settings
 *
 */
public class BasicPTZ {
    /**
     * 
     * @introduction PTZ direction control
     * @description  The PTZ is controlled by transferring different parameters
     * @param [direction] [PTZ moving direction]
     */
    public static void directionControl(int direction) {
        if(null == NetDemo.lpUserID) {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
            }
        int nSpeed = NetDemo.jComboBoxPTZSpeed.getSelectedIndex()+1;
        if(null == NetDemo.lpPlayHandle)
        {
            boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl_Other(NetDemo.lpUserID, NetDemo.ChannelID, direction, nSpeed);
            if(!bRet){
                JOptionPane.showMessageDialog(null, "Check if the corresponding device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            }
        }
        else
        {
            boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl(NetDemo.lpPlayHandle, direction, nSpeed);
            if(!bRet)
            {
                JOptionPane.showMessageDialog(null, "Check if the corresponding device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            }
        }
    }
    
    /**
     * 
     * @introduction PTZ pause 
     * @description
     */
    public static void PTZPause() {
        if(null == NetDemo.lpUserID) {
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
            }
        if(NetDemo.ptzPause==0) 
        {
            int nSpeed = NetDemo.jComboBoxPTZSpeed.getSelectedIndex()+1;
            if(null == NetDemo.lpPlayHandle)
            {
                boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl_Other(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_ALLSTOP, nSpeed);
                if(!bRet){
                    System.out.println( "Check if the corresponding1 device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                }else {
                    NetDemo.ptzPause=1;
                }
            }
            else
            {
                boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl(NetDemo.lpPlayHandle, NETDEV_PTZ_E.NETDEV_PTZ_ALLSTOP, nSpeed);
                if(!bRet)
                {
                    System.out.println( "Check if the corresponding device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                }
                else
                {
                    NetDemo.ptzPause=1;
                }
            }
        }
        else if(NetDemo.ptzPause==1) 
        {
            int nSpeed = NetDemo.jComboBoxPTZSpeed.getSelectedIndex()+1;
            if(null == NetDemo.lpPlayHandle)
            {
                boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl_Other(NetDemo.lpUserID, NetDemo.ChannelID, NETDEV_PTZ_E.NETDEV_PTZ_ALLSTOP, nSpeed);
                if(!bRet)
                {
                    System.out.println( "Check if the corresponding2 device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                }else {
                    NetDemo.ptzPause=0;
                }
            }
            else
            {
                boolean bRet = NetDemo.netdevsdk.NETDEV_PTZControl(NetDemo.lpPlayHandle, NETDEV_PTZ_E.NETDEV_PTZ_ALLSTOP, nSpeed);
                if(!bRet)
                {
                    System.out.println( "Check if the corresponding device supports PTZ or if the selected channel is correct.error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
                }
                else 
                {
                    NetDemo.ptzPause=0;
                }
                }
        }
    }     
}