diff --git a/ruoyi-code/src/main/java/utils/CameraUtil.java b/ruoyi-code/src/main/java/utils/CameraUtil.java index 3a02fbb..dc87f2b 100644 --- a/ruoyi-code/src/main/java/utils/CameraUtil.java +++ b/ruoyi-code/src/main/java/utils/CameraUtil.java @@ -12,34 +12,11 @@ import java.util.Date; public class CameraUtil { public static void main(String[] args) { - NetLib.instance.Net_Init(null, null); - String strIp="36.134.51.220"; - int nPort= 16754; - String strUsername="admin"; - String strPassword="admin123"; - String strDevSN="8R23R300003"; +// NetLib.instance.Net_Init(null, null); - IntByReference nErr = new IntByReference(0); + run_device_cfg cfg = new run_device_cfg(); + cfg.startCfg(); - // 此接口专为 主动注册登陆 接口,与 Net_LoginDevice 有区别 - NativeLong lLoginID = NetLib.instance.Net_LoginDeviceSpec( - strIp, - nPort, - strUsername, - strPassword, - NetEnums.EM_LOGIN_PROTOCAL_TYPE.EM_LOGIN_PROTOCAL_TYPE_REG_SERVER, - strDevSN, - null, - nErr); - System.out.println(lLoginID); - - //重启设备 -// boolean bResult = NetLib.instance.Net_RebootDevice(loginID); -// System.out.println("Net_RebootDevice = " + bResult); - -// boolean r2 = NetLib.instance.Net_LogoutDevice(loginID); -// System.out.println("r2 = " + r2); -// NetLib.instance.Net_Exit(); } public static boolean deal(NativeLong loginID){ diff --git a/ruoyi-code/src/main/java/utils/run_device_cfg.java b/ruoyi-code/src/main/java/utils/run_device_cfg.java index 5f5e621..411120b 100644 --- a/ruoyi-code/src/main/java/utils/run_device_cfg.java +++ b/ruoyi-code/src/main/java/utils/run_device_cfg.java @@ -1226,7 +1226,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgAutoMain(Vector> tableContent, - STU_CFG_AUTO_MAINTAIN stuCfgAutoMaintain) + STU_CFG_AUTO_MAINTAIN stuCfgAutoMaintain) { String value = 1 == stuCfgAutoMaintain.bEnable ? "是" : "否"; insertRow(tableContent, "是否使能", value); @@ -1239,7 +1239,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgFaceGroupRecResult(Vector> tableContent, - STU_CFG_FACE_GROUP_RECOGNIZE_RULES stuCfgFaceGroupRecRules) + STU_CFG_FACE_GROUP_RECOGNIZE_RULES stuCfgFaceGroupRecRules) { String value = String.format("%d", stuCfgFaceGroupRecRules.nRuleCount); insertRow(tableContent, "人脸识别规则实际数目", value); @@ -1728,7 +1728,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgNetStorageTrans(Vector> tableContent, - STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans) + STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans) { String value = String.format("%d", stuCfgNetStorageTrans.uItemCount); insertRow(tableContent, "网络存储配置个数", value); @@ -1981,7 +1981,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgIntelliSceneFaceDetect(Vector> tableContent, - STU_CFG_INTELLI_SCENE_FACE_DETECT stuCfgIntelliSceneFaceDetect) + STU_CFG_INTELLI_SCENE_FACE_DETECT stuCfgIntelliSceneFaceDetect) { String value = DataUtils.sdk_data_byteArrayToString(stuCfgIntelliSceneFaceDetect.szClass, GlobalTool.getEncodeType()); insertRow(tableContent, "业务大类, 不可设置", value); @@ -2019,7 +2019,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgIntelliRuleFaceDetect(Vector> tableContent, - STU_CFG_INTELLI_RULE_FACE_DETECT stuCfgIntelliRuleFaceDetect) + STU_CFG_INTELLI_RULE_FACE_DETECT stuCfgIntelliRuleFaceDetect) { String value = 1 == stuCfgIntelliRuleFaceDetect.bEnable ? "是" : "否"; insertRow(tableContent, "人脸检测规则使能", value); @@ -2071,7 +2071,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } private void insertCfgIntelliRuleFaceSta(Vector> tableContent, - STU_CFG_INTELLI_RULE_FACE_STATISTIC stuCfgIntelliRuleFaceSta) + STU_CFG_INTELLI_RULE_FACE_STATISTIC stuCfgIntelliRuleFaceSta) { String value = 1 == stuCfgIntelliRuleFaceSta.bEnable ? "是" : "否"; insertRow(tableContent, "人脸检测统计规则使能", value); @@ -2637,25 +2637,23 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { int nNewValue = (stuCfgNetStorageTrans.stuItemArray[0].bOfflineEnable + 1) % 2; stuCfgNetStorageTrans.stuItemArray[0].bOfflineEnable = nNewValue; - /* - for(int i=0; i= i+1){ + arr[i] = newArr[i]; + }else { + arr[i] = 0; + } + } + return arr; + } + private Pointer createStuCfgStorage(IntByReference inBufferSize) { STU_CFG_STORAGE stuCfgStorage = (STU_CFG_STORAGE) m_curStuObj; @@ -3328,6 +3342,8 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { if(null == ptrInBuffer) return false; + System.out.println("ptrInBuffer="+JSON.toJSON(ptrInBuffer).toString()); + System.out.println("inBufferSize="+ inBufferSize.getValue()); boolean bResult = NetLib.instance.Net_SetDeviceCfg( m_loginID, nCommand, @@ -3473,4 +3489,150 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { } }); } + + + ////////////////////////////////////////////////////////// + public void startCfg(){ + String strIp="192.168.1.64"; + int nPort= 27778; + String strUsername="admin"; + String strPassword="admin123"; + String strDevSN="8R23R300003"; + IntByReference nError = new IntByReference(0); + + NativeLong loginID = NetLib.instance.Net_LoginDevice(strIp, nPort, strUsername, strPassword, null, nError); + System.out.println("loginID = "+loginID); + + //bRealtimeEnable为0时 bOfflineEnable只能为0 + int bRealtimeEnable = 0; + int bOfflineEnable = 0; + String szAddress = "192.168.1.1"; + int uFtpPort = 22; + String szUserName = "test"; + String szPassword = "test123"; + boolean result = setDeviceFtpCfg(loginID, bRealtimeEnable, bOfflineEnable, szAddress, uFtpPort, szUserName, szPassword); + + System.out.println("result = " + result); + } + + /** + * + * @param bRealtimeEnable 使能 0-否 1-是 + * @param szAddress 服务地址 + * @param bOfflineEnable 断网续传 0-否 1-是 + * @param uFtpPort 端口 + * @param szUserName 用户名 + * @param szPassword 密码 + * @return + */ + public boolean setDeviceFtpCfg(NativeLong loginID, int bRealtimeEnable,int bOfflineEnable,String szAddress,int uFtpPort,String szUserName,String szPassword){ + //上传图片路径规则 + String szPathRule = "/%n/%Y/%M/%D/%Y_%M_%D_%h_%m_%s.jpg"; + byte[] szPathRuleBytes = getNewArray(160,DataUtils.sdk_data_stringToByteArray(szPathRule,GlobalTool.getEncodeType())); + //路径编码类型 + int emPathEncodeType = 0; + byte[] szAddressBytes = getNewArray(64,DataUtils.sdk_data_stringToByteArray(szAddress,GlobalTool.getEncodeType())); + byte[] szUserNameBytes = getNewArray(64,DataUtils.sdk_data_stringToByteArray(szUserName,GlobalTool.getEncodeType())); + byte[] szPasswordBytes = getNewArray(64,DataUtils.sdk_data_stringToByteArray(szPassword,GlobalTool.getEncodeType())); + + + // 句柄 - 网络存储传输配置 + int nCommand = EM_DEVICE_CFG_TYPE.DEVICE_CFG_NET_STORAGE_TRANS; + + STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans = getStuCfgNetStorageTrans(loginID,nCommand); + IntByReference inBufferSize = new IntByReference(0); + Pointer ptrInBuffer = getDeviceCfgPointer(stuCfgNetStorageTrans,inBufferSize,bRealtimeEnable,bOfflineEnable,szAddressBytes,uFtpPort,szUserNameBytes,szPasswordBytes,szPathRuleBytes,emPathEncodeType); + + if(null == ptrInBuffer) + return false; + + System.out.println("ptrInBuffer="+JSON.toJSON(ptrInBuffer).toString()); + System.out.println("inBufferSize="+ inBufferSize.getValue()); + + boolean bResult2 = NetLib.instance.Net_SetDeviceCfg( + loginID, + nCommand, + 0, + ptrInBuffer, + inBufferSize.getValue(), + 6000); + + if(!bResult2) + { + int error = NetLib.instance.Net_LastError(); + String strError = String.format("Net_SetDeviceCfg fail, command = %d, errorCode = %d", nCommand, error); + System.out.println(strError); + return false; + } + + + System.out.println("33333333333333333333333333333333"); + STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans2 = getStuCfgNetStorageTrans(loginID,nCommand); + System.out.println(JSON.toJSON(stuCfgNetStorageTrans2.stuItemArray[1]).toString()); + return true; + } + + public STU_CFG_NET_STORAGE_TRANS getStuCfgNetStorageTrans(NativeLong loginID, int nCommand){ + + IntByReference outBufferSize = new IntByReference(0); + IntByReference nReturnSize = new IntByReference(0); + Pointer ptrOutBuffer = initStuData(nCommand, outBufferSize); + boolean bResult = NetLib.instance.Net_GetDeviceCfg( + loginID, + nCommand, + 0, + ptrOutBuffer, + outBufferSize.getValue(), + nReturnSize, + 6000); + + if(!bResult) + { + int error = NetLib.instance.Net_LastError(); + String strError = String.format("Net_GetDeviceCfg fail, command = %d, errorCode = %d", nCommand, error); + System.out.println(strError); + return null; + } + + STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans = new STU_CFG_NET_STORAGE_TRANS(); + DataUtils.sdk_data_ptrToStructure(ptrOutBuffer, stuCfgNetStorageTrans); + + return stuCfgNetStorageTrans; + } + + public Pointer getDeviceCfgPointer(STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans,IntByReference inBufferSize,int bRealtimeEnable, + int bOfflineEnable,byte[] szAddress,int uFtpPort, + byte[] szUserName,byte[] szPassword,byte[] szPathRule,int emPathEncodeType){ + + if(0 < stuCfgNetStorageTrans.uItemCount) + { + for(int i=0; i