Jelajahi Sumber

Merge branch 'dev' of ssh://10.10.100.21/source/smartschool-platform into dev

zhaoy 6 tahun lalu
induk
melakukan
5e040b246a

+ 81 - 55
applications/device/device-sdk-dahua/src/main/java/com/usoftchina/smartschool/device/dahua/lib/DahuaLibrary.java

@@ -7,6 +7,7 @@ import com.sun.jna.Structure;
 import com.sun.jna.ptr.IntByReference;
 import com.sun.jna.win32.StdCallLibrary;
 
+import java.nio.charset.Charset;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
@@ -20,6 +21,10 @@ import java.util.Date;
  * @date 2019/3/7
  */
 public interface DahuaLibrary extends Library {
+    /**
+     * 默认编码
+     */
+    Charset DEFAULT_CHARSET = Charset.forName("GBK");
     /**
      * 通用字符串长度4
      */
@@ -283,66 +288,70 @@ public interface DahuaLibrary extends Library {
     /**
      * 登陆网络环境设置
      */
-    @Structure.FieldOrder({"bReserved", "byNetType", "byPlaybackBufSize", "byReserved1", "nConnectBufSize",
-            "nConnectTime", "nConnectTryNum", "nGetConnInfoTime", "nGetDevInfoTime", "nPicBufSize", "nSearchRecordTime",
-            "nWaittime", "nsubConnectSpaceTime", "nsubDisconnetTime"})
+    @Structure.FieldOrder({"nWaittime", "nConnectTime", "nConnectTryNum", "nSubConnectSpaceTime", "nGetDevInfoTime",
+            "nConnectBufSize", "nGetConnInfoTime", "nSearchRecordTime", "nsubDisconnetTime", "byNetType",
+            "byPlaybackBufSize", "bDetectDisconnTime", "bKeepLifeInterval", "nPicBufSize", "bReserved"})
     class NET_PARAM extends Structure {
         /**
-         * 保留字段
+         * 等待超时时间(毫秒为单位),为0默认5000ms
          */
-        public byte[] bReserved = new byte[4];
+        public int nWaittime;
         /**
-         * 网络类型,0-LAN, 1-WAN
+         * 连接超时时间(毫秒为单位),为0默认1500ms
          */
-        public byte byNetType;
+        public int nConnectTime;
         /**
-         * 回放数据接收缓冲大小(M为单位),为0默认为4M
+         * 连接尝试次数,为0默认1次
          */
-        public byte byPlaybackBufSize;
+        public int nConnectTryNum;
         /**
-         * 保留字段
+         * 子连接之间的等待时间(毫秒为单位),为0默认10ms
+         */
+        public int nSubConnectSpaceTime;
+        /**
+         * 获取设备信息超时时间,为0默认1000ms
          */
-        public byte[] byReserved1 = new byte[2];
+        public int nGetDevInfoTime;
         /**
          * 每个连接接收数据缓冲大小(字节为单位),为0默认250*1024
          */
         public int nConnectBufSize;
         /**
-         * 连接超时时间(毫秒为单位),为0默认1500ms
+         * 获取子连接信息超时时间(毫秒为单位),为0默认1000ms
          */
-        public int nConnectTime;
+        public int nGetConnInfoTime;
         /**
-         * 连接尝试次数,为0默认1次
+         * 按时间查询录像文件的超时时间(毫秒为单位),为0默认为3000ms
          */
-        public int nConnectTryNum;
+        public int nSearchRecordTime;
         /**
-         * 获取子连接信息超时时间(毫秒为单位),为0默认1000ms
+         * 检测子链接断线等待时间(毫秒为单位),为0默认为60000ms
          */
-        public int nGetConnInfoTime;
+        public int nsubDisconnetTime;
         /**
-         * 获取设备信息超时时间,为0默认1000ms
+         * 网络类型,0-LAN, 1-WAN
          */
-        public int nGetDevInfoTime;
+        public byte byNetType;
         /**
-         * 实时图片接收缓冲大小(字节为单位),为0默认为2*1024*1024
+         * 回放数据接收缓冲大小(M为单位),为0默认为4M
          */
-        public int nPicBufSize;
+        public byte byPlaybackBufSize;
         /**
-         * 按时间查询录像文件的超时时间(毫秒为单位),为0默认为3000ms
+         * 心跳检测断线时间(单位为秒),为0默认为60s,最小时间为2s
          */
-        public int nSearchRecordTime;
+        public byte bDetectDisconnTime;
         /**
-         * 等待超时时间(毫秒为单位),为0默认5000ms
+         * 心跳包发送间隔(单位为秒),为0默认为10s,最小间隔为2s
          */
-        public int nWaittime;
+        public byte bKeepLifeInterval;
         /**
-         * 子连接之间的等待时间(毫秒为单位),为0默认10ms
+         * 实时图片接收缓冲大小(字节为单位),为0默认为2*1024*1024
          */
-        public int nsubConnectSpaceTime;
+        public int nPicBufSize;
         /**
-         * 检测子链接断线等待时间(毫秒为单位),为0默认为60000ms
+         * 保留字段
          */
-        public int nsubDisconnetTime;
+        public byte[] bReserved = new byte[4];
     }
 
     /**
@@ -704,25 +713,13 @@ public interface DahuaLibrary extends Library {
     /**
      * 设备信息
      */
-    @Structure.FieldOrder({"Reserved", "bReserved", "byLeftLogTimes", "byLimitLoginTime", "nAlarmInPortNum",
-            "nAlarmOutPortNum", "nChanNum", "nDVRType", "nDiskNum", "nLockLeftTime", "sSerialNumber"})
+    @Structure.FieldOrder({"sSerialNumber", "nAlarmInPortNum", "nAlarmOutPortNum", "nDiskNum", "nDVRType",
+            "nChanNum", "byLimitLoginTime", "byLeftLogTimes", "bReserved", "nLockLeftTime", "Reserved"})
     class NET_DEVICEINFO_Ex extends Structure {
         /**
-         * 保留
-         */
-        public byte[] Reserved = new byte[24];
-        /**
-         * 保留字节
-         */
-        public byte[] bReserved = new byte[2];
-        /**
-         * 当登陆失败原因为密码错误时,通过此参数通知用户,剩余登陆次数,为0时表示此参数无效
-         */
-        public byte byLeftLogTimes;
-        /**
-         * 在线超时时间,为0表示不限制登陆,非0表示限制的分钟数
+         * 序列号
          */
-        public byte byLimitLoginTime;
+        public byte[] sSerialNumber = new byte[DH_SERIALNO_LEN];
         /**
          * DVR报警输入个数
          */
@@ -732,9 +729,9 @@ public interface DahuaLibrary extends Library {
          */
         public int nAlarmOutPortNum;
         /**
-         * DVR通道个数
+         * DVR硬盘个数
          */
-        public int nChanNum;
+        public int nDiskNum;
         /**
          * DVR类型
          *
@@ -742,17 +739,46 @@ public interface DahuaLibrary extends Library {
          */
         public int nDVRType;
         /**
-         * DVR硬盘个数
+         * DVR通道个数
          */
-        public int nDiskNum;
+        public int nChanNum;
+        /**
+         * 在线超时时间,为0表示不限制登陆,非0表示限制的分钟数
+         */
+        public byte byLimitLoginTime;
+        /**
+         * 当登陆失败原因为密码错误时,通过此参数通知用户,剩余登陆次数,为0时表示此参数无效
+         */
+        public byte byLeftLogTimes;
+        /**
+         * 保留字节
+         */
+        public byte[] bReserved = new byte[2];
         /**
          * 当登陆失败,用户解锁剩余时间(秒数), -1表示设备未设置该参数
          */
         public int nLockLeftTime;
         /**
-         * 序列号
+         * 保留
          */
-        public byte[] sSerialNumber = new byte[DH_SERIALNO_LEN];
+        public byte[] Reserved = new byte[24];
+
+        @Override
+        public String toString() {
+            return "NET_DEVICEINFO_Ex{" +
+                    "sSerialNumber=" + new String(sSerialNumber) +
+                    ", nAlarmInPortNum=" + nAlarmInPortNum +
+                    ", nAlarmOutPortNum=" + nAlarmOutPortNum +
+                    ", nDiskNum=" + nDiskNum +
+                    ", nDVRType=" + nDVRType +
+                    ", nChanNum=" + nChanNum +
+                    ", byLimitLoginTime=" + (byLimitLoginTime & 0xff) +
+                    ", byLeftLogTimes=" + (byLeftLogTimes & 0xff) +
+                    ", bReserved=" + new String(bReserved) +
+                    ", nLockLeftTime=" + nLockLeftTime +
+                    ", Reserved=" + Arrays.toString(Reserved) +
+                    '}';
+        }
     }
 
     /**
@@ -1464,8 +1490,8 @@ public interface DahuaLibrary extends Library {
                     ", emAttendanceState=" + emAttendanceState +
                     ", szClassNumber=" + new String(szClassNumber) +
                     ", szPhoneNumber=" + new String(szPhoneNumber) +
-                    ", szCardName=" + new String(szCardName) +
-                    ", uSimilarity=" + uSimilarity +
+                    ", szCardName=" + new String(szCardName, DEFAULT_CHARSET) +
+                    ", uSimilarity=" + (uSimilarity & 0x0ffffffff) +
                     '}';
         }
     }
@@ -1530,11 +1556,11 @@ public interface DahuaLibrary extends Library {
         /**
          * 图片宽度, 单位:像素
          */
-        public int wWidth;
+        public short wWidth;
         /**
          * 图片高度, 单位:像素
          */
-        public int wHeight;
+        public short wHeight;
         /**
          * 文件路径
          */