1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
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
package com.netsdk.demo.customize.JordanPSD.module;
 
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.enumeration.ENUMERROR;
import com.sun.jna.Structure;
 
/**
 * @author 47040
 * @since Created at 2021/5/26 13:50
 */
public class ConfigModule {
 
    static NetSDKLib NetSdk = NetSDKLib.NETSDK_INSTANCE;
 
    static NetSDKLib NetConfig = NetSDKLib.CONFIG_INSTANCE;
 
    public static boolean GetConfig(NetSDKLib.LLong m_hLoginHandle, int nType, int channel, Structure stuObj, int nWaitTime) {
 
        stuObj.write();
        boolean ret = NetSdk.CLIENT_GetConfig(m_hLoginHandle, nType, channel, stuObj.getPointer(), stuObj.size(), nWaitTime, null);
        if (!ret) {
            System.err.println("GetConfig Filed:" + ENUMERROR.getErrorCode());
            return false;
        }
        stuObj.read();
        return true;
    }
 
    public static boolean SetConfig(NetSDKLib.LLong m_hLoginHandle, int nType, int channel, Structure stuObj, int nWaitTime) {
 
        stuObj.write();
        boolean ret = NetSdk.CLIENT_SetConfig(m_hLoginHandle, nType, channel, stuObj.getPointer(), stuObj.size(), nWaitTime, null, null);
        if (!ret) {
            System.err.println("SetConfig Filed:" + ENUMERROR.getErrorCode());
            return false;
        }
        stuObj.read();
        return true;
    }
 
    /**
     * 获取设备能力集
     *
     * @param m_hLoginHandle 登录句柄
     * @param nType          能力集枚举
     * @param stuIn          入参
     * @param stuOut         出参
     * @param nWaitTime      超时时间
     */
    public static boolean GetDeviceCapability(NetSDKLib.LLong m_hLoginHandle, int nType, Structure stuIn, Structure stuOut, int nWaitTime) {
        stuIn.write();
        stuOut.write();
        boolean ret = NetSdk.CLIENT_GetDevCaps(m_hLoginHandle, nType, stuIn.getPointer(), stuOut.getPointer(), nWaitTime);
        if (!ret) {
            System.err.println("GetDevCaps Filed:" + ENUMERROR.getErrorCode());
            return false;
        }
        stuOut.read();
        return true;
    }
 
 
    /**
     * 打包配置数据
     *
     * @param strCmd     配置枚举
     * @param bufferSize 缓冲区大小
     * @param cmdObject  配置结构体
     * @return jsonByte
     */
    public static byte[] PackageData2JsonByte(String strCmd, int bufferSize, Structure cmdObject) {
        byte[] strBuffer = new byte[bufferSize];
        boolean ret = NetConfig.CLIENT_PacketData(strCmd, cmdObject.getPointer(), cmdObject.size(), strBuffer, bufferSize);
        if (!ret) {
            System.err.println("PacketData Failed:" + ENUMERROR.getErrorCode());
            return null;
        }
        return strBuffer;
    }
 
}