From f1c9b35607d45c357a318af39230bc304d2931dd Mon Sep 17 00:00:00 2001 From: 4670101279 Date: Tue, 12 Jul 2022 13:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A5=E5=85=89=E7=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/utils/CameraUtil.java | 5 ++ .../src/main/java/utils/RegisterUtil.java | 18 +++- .../src/main/java/utils/run_device_cfg.java | 83 ++++++++++++++++++- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/ruoyi-code/src/main/java/utils/CameraUtil.java b/ruoyi-code/src/main/java/utils/CameraUtil.java index cff6341..b817a03 100644 --- a/ruoyi-code/src/main/java/utils/CameraUtil.java +++ b/ruoyi-code/src/main/java/utils/CameraUtil.java @@ -29,6 +29,11 @@ public class CameraUtil { run_device_cfg cfg = new run_device_cfg(); cfg.getLigntCfg(loginID); + System.out.println("=================================="); + //设置参数 + cfg.setLightCfg(loginID, NetEnums.EM_DEV_SUP_LIGHT_MODE.EM_DEV_SUP_LIGHT_MODE_FORCE_AUTO,30,60,"13:50:00","14:00:00"); + System.out.println("=================================="); + cfg.getLigntCfg(loginID); } /** diff --git a/ruoyi-code/src/main/java/utils/RegisterUtil.java b/ruoyi-code/src/main/java/utils/RegisterUtil.java index 508285e..baf3c67 100644 --- a/ruoyi-code/src/main/java/utils/RegisterUtil.java +++ b/ruoyi-code/src/main/java/utils/RegisterUtil.java @@ -1077,9 +1077,23 @@ public class RegisterUtil implements ActionListener { /** * Launch the application. */ +// public static void main(String[] args) { +// RegisterUtil window = new RegisterUtil(); +// window.onBtnStartRegServer(); +// } + + public static void main(String[] args) { - RegisterUtil window = new RegisterUtil(); - window.onBtnStartRegServer(); + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + RegisterUtil window = new RegisterUtil(); + window.m_frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); } public List getLoginIDs(){ 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 4e80b76..255de9a 100644 --- a/ruoyi-code/src/main/java/utils/run_device_cfg.java +++ b/ruoyi-code/src/main/java/utils/run_device_cfg.java @@ -38,6 +38,7 @@ import com.sun.jna.ptr.IntByReference; import sdk.java.common.GlobalTool; import sdk.java.lib.DataUtils; import sdk.java.lib.netmanager.NetDefs; +import sdk.java.lib.netmanager.NetEnums; import sdk.java.lib.netmanager.NetLib; import sdk.java.lib.netmanager.NetEnums.EM_DEVICE_CFG_TYPE; import sdk.java.lib.netmanager.NetEnums.EM_WHITE_BALANCE; @@ -3525,9 +3526,89 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { public void getLigntCfg(NativeLong loginID){ int nCommand = EM_DEVICE_CFG_TYPE.DEVICE_CFG_SOC_CONSTANT_LAMP; NetStructs.STU_CFG_SOC_CONSTANT_LAMP_PARAM cfgSupplementLightItem = getCfgSupplementLightItem(loginID,nCommand); - System.out.println(JSON.toJSONString(cfgSupplementLightItem.stSOCLamps[0])); + NetStructs.STU_CFG_SOC_CONSTANT_LAMP_ITEM item = cfgSupplementLightItem.stSOCLamps[0]; + System.out.println(JSON.toJSON(item).toString()); + // 工作模式 EM_DEV_SUP_LIGHT_MODE (0-强制关闭 1-强制开启 2-自动 3-自动时间) + int emMode = item.emMode; + //亮度预设值,取值范围为0~100,无光敏时使用 + int nPreValue = item.nPreValue; + // 常亮灯亮度,范围[0, 100] + int nBrightness = item.nBrightness; + + NetStructs.STU_TIME_SECTION_SCHEDULE timeInterval = item.stuWeekTimeSection.stuTimeDay[0].stuTimeSection[0]; + int isEnable = timeInterval.bValue; + int startHour = timeInterval.nStartHour; + int startMinute = timeInterval.nStartMinute; + int startSecond = timeInterval.nStartSecond; + int endHour = timeInterval.nEndHour; + int endMinute = timeInterval.nEndMinute; + int endSecond = timeInterval.nEndSecond; + + System.out.println("emMode="+emMode); + System.out.println("nPreValue="+nPreValue); + System.out.println("nBrightness="+nBrightness); + System.out.println("isEnable="+isEnable); + System.out.println("startHour="+startHour); + System.out.println("startMinute="+startMinute); + System.out.println("startSecond="+startSecond); + System.out.println("endHour="+endHour); + System.out.println("endMinute="+endMinute); + System.out.println("endSecond="+endSecond); } + /** + * + * @param loginID 登录id + * @param emMode 工作模式 EM_DEV_SUP_LIGHT_MODE + * @param nPreValue 亮度预设值,取值范围为0~100,无光敏时使用 + * @param nBrightness 常亮灯亮度,范围[0, 100] + * @param startTime 开始时间 时:分:秒 + * @param endTime 结束时间 时:分:秒 + */ + public void setLightCfg(NativeLong loginID,int emMode,int nPreValue,int nBrightness,String startTime , String endTime){ + //10:10:11 + int startHour = Integer.parseInt(startTime.substring(0,2)); + int startMinute = Integer.parseInt(startTime.substring(3,5)); + int startSecond = Integer.parseInt(startTime.substring(6,8)); + int endHour = Integer.parseInt(endTime.substring(0,2)); + int endMinute = Integer.parseInt(endTime.substring(3,5)); + int endSecond = Integer.parseInt(endTime.substring(6,8)); + + int nCommand = EM_DEVICE_CFG_TYPE.DEVICE_CFG_SOC_CONSTANT_LAMP; + NetStructs.STU_CFG_SOC_CONSTANT_LAMP_PARAM cfgSupplementLightItem = getCfgSupplementLightItem(loginID,nCommand); + cfgSupplementLightItem.stSOCLamps[0].emMode = emMode; + cfgSupplementLightItem.stSOCLamps[0].nPreValue = nPreValue; + cfgSupplementLightItem.stSOCLamps[0].nBrightness = nBrightness; + + if(emMode == NetEnums.EM_DEV_SUP_LIGHT_MODE.EM_DEV_SUP_LIGHT_MODE_AUTO_TIME) + for (NetStructs.STU_DAY_TIME_SECTION_SCHEDULE s : cfgSupplementLightItem.stSOCLamps[0].stuWeekTimeSection.stuTimeDay) { + s.stuTimeSection[0].bValue = (byte) 1; + s.stuTimeSection[0].nStartHour= startHour; + s.stuTimeSection[0].nStartMinute= startMinute; + s.stuTimeSection[0].nStartSecond= startSecond; + s.stuTimeSection[0].nEndHour= endHour; + s.stuTimeSection[0].nEndMinute= endMinute; + s.stuTimeSection[0].nEndSecond= endSecond; + } + + IntByReference inBufferSize = new IntByReference(0); + inBufferSize.setValue(cfgSupplementLightItem.size()); + Pointer ptrInBuffer = DataUtils.sdk_data_createPtr(inBufferSize.getValue()); + assert ptrInBuffer != null; + DataUtils.sdk_data_structureToPtr(cfgSupplementLightItem, ptrInBuffer, 0); + + boolean result = NetLib.instance.Net_SetDeviceCfg( + loginID, + nCommand, + 0, + ptrInBuffer, + inBufferSize.getValue(), + 6000); + + System.out.println("set light config result = " + result); + } + + public NetStructs.STU_CFG_SOC_CONSTANT_LAMP_PARAM getCfgSupplementLightItem(NativeLong loginID, int nCommand){