| | |
| | | package com.ruoyi.device.dhsdk.module; |
| | | |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib; |
| | | import com.sun.jna.Structure; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | |
| | | /** |
| | | * @Description: |
| | | * @ClassName: ConfigModule |
| | | * @Author: 刘苏义 |
| | | * @Date: 2023年10月14日14:57:01 |
| | | **/ |
| | | public class ConfigModule { |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; |
| | | |
| | | public static boolean GetDevConfig(NetSDKLib.LLong hLoginHandle, int nType, Structure cmdObject) { |
| | | boolean result = false; |
| | | IntByReference error = new IntByReference(0); |
| | | int nBufferLen = 2 * 1024 * 1024; |
| | | netsdk.CLIENT_QueryDevState(hLoginHandle, nType, cmdObject.getPointer(), nBufferLen, error, 3000); |
| | | return result; |
| | | } |
| | | /** |
| | | * 查询设备状态 |
| | | */ |
| | | public static boolean queryDevState(NetSDKLib.LLong hLoginHandle, int nType, NetSDKLib.SdkStructure stuInfo) { |
| | | |
| | | IntByReference intRetLen = new IntByReference(); |
| | | stuInfo.write(); |
| | | if (!LoginModule.netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) { |
| | | return false; |
| | | } |
| | | stuInfo.read(); |
| | | return true; |
| | | } |
| | | } |
| | | package com.ruoyi.device.dhsdk.module;
|
| | |
|
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib;
|
| | | import com.sun.jna.Structure;
|
| | | import com.sun.jna.ptr.IntByReference;
|
| | | import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
|
| | |
|
| | | /**
|
| | | * @Description:
|
| | | * @ClassName: ConfigModule
|
| | | * @Author: 刘苏义
|
| | | * @Date: 2023年10月14日14:57:01
|
| | | **/
|
| | | public class ConfigModule {
|
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
|
| | | public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE;
|
| | | /**
|
| | | * 查询设备状态
|
| | | */
|
| | | public static boolean queryDevState(NetSDKLib.LLong hLoginHandle, int nType, NetSDKLib.SdkStructure stuInfo) {
|
| | |
|
| | | IntByReference intRetLen = new IntByReference();
|
| | | stuInfo.write();
|
| | | if (!netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) {
|
| | | return false;
|
| | | }
|
| | | stuInfo.read();
|
| | | return true;
|
| | | }
|
| | | /**
|
| | | * 设置单个配置
|
| | | * @param hLoginHandle 登陆句柄
|
| | | * @param nChn 通道号,-1 表示全通道
|
| | | * @param strCmd 配置名称
|
| | | * @param cmdObject 配置对应的结构体对象
|
| | | * @return 成功返回 true
|
| | | */
|
| | | public static boolean SetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) {
|
| | | boolean result = false;
|
| | | int nBufferLen = 2*1024*1024;
|
| | | byte szBuffer[] = new byte[nBufferLen];
|
| | | for(int i=0; i<nBufferLen; i++)szBuffer[i]=0;
|
| | | IntByReference error = new IntByReference(0);
|
| | | IntByReference restart = new IntByReference(0);
|
| | | cmdObject.write();
|
| | | if (configsdk.CLIENT_PacketData(strCmd, cmdObject.getPointer(), cmdObject.size(), szBuffer, nBufferLen)) {
|
| | | cmdObject.read();
|
| | | if( configsdk.CLIENT_SetNewDevConfig(hLoginHandle, strCmd , nChn , szBuffer, nBufferLen, error, restart, 3000)) {
|
| | | result = true;
|
| | | } else {
|
| | | System.err.printf("Set %s Config Failed! Last Error = %s\n" , strCmd , getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | | } else {
|
| | | System.err.println("Packet " + strCmd + " Config Failed!" + getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | }
|