初始化仓库

master
liuguijing 1 year ago
commit 2c8d7feb95

33
.gitignore vendored

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

Binary file not shown.

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

308
mvnw vendored

@ -0,0 +1,308 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
javaHome="$(dirname "\"$javaExecutable\"")"
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
javaHome="$(dirname "\"$javaExecutable\"")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
# Remove \r in case we run on Windows within Git Bash
# and check out the repository with auto CRLF management
# enabled. Otherwise, we may read lines that are delimited with
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
# splitting rules.
tr -s '\r\n' ' ' < "$1"
fi
}
log() {
if [ "$MVNW_VERBOSE" = true ]; then
printf '%s\n' "$1"
fi
}
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
log "$MAVEN_PROJECTBASEDIR"
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
if [ -r "$wrapperJarPath" ]; then
log "Found $wrapperJarPath"
else
log "Couldn't find $wrapperJarPath, downloading it ..."
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
while IFS="=" read -r key value; do
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
safeValue=$(echo "$value" | tr -d '\r')
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
log "Downloading from: $wrapperUrl"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
log "Found wget ... using wget"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
log "Found curl ... using curl"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
else
log "Falling back to using Java to download"
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=$(cygpath --path --windows "$javaSource")
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
log " - Compiling MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$javaClass" ]; then
log " - Running MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
wrapperSha256Sum=""
while IFS="=" read -r key value; do
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
if [ -n "$wrapperSha256Sum" ]; then
wrapperSha256Result=false
if command -v sha256sum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
elif command -v shasum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
exit 1
fi
if [ $wrapperSha256Result = false ]; then
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
exit 1
fi
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

205
mvnw.cmd vendored

@ -0,0 +1,205 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.shxy</groupId>
<artifactId>xyhkcamera</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xyhkcamera</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-boot-dependencies.version>2.5.6</spring-boot-dependencies.version>
</properties>
<dependencies>
<!-- SpringBoot的依赖配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>examples</artifactId>
<version>1.0</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--jna-->
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
<version>3.0.9</version>
</dependency>
<!-- 引入log4j2依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="GB2312"?>
<SdkLocal>
<SdkLog>
<logLevel>3</logLevel><!--req, 1-ERROR, 2-DEBUG, 3-INFO-->
<logDirectory>./SDKLOG/</logDirectory><!--the end of the string must be '/'-->
<autoDelete>true</autoDelete><!--true: There are less than 10 files in the directory, it will be auto deleted by sdk when the files are more than 10; false: No upper limit to the number of log files-->
</SdkLog>
<HeartbeatCfg>
<Interval>120</Interval> <!-- 心跳时间间隔单位秒等于0使用默认值120s取值范围为[30, 120] 小于30s间隔为30s大于120s间隔为120s-->
<Count>1</Count> <!-- 触发异常回调需要心跳交互异常的次数等于0使用默认值1次-->
</HeartbeatCfg>
</SdkLocal>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
The dll in this directory£¨iconv.dll,libxml2.dll,zlib1.dll,calib.dll£©only used in ClientDemo.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,20 @@
package com.shxy.xyhkcamera;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Component
public class AppRunner implements ApplicationRunner {
@Autowired
private SdkInitService hksdkInitService;
@Override
public void run(ApplicationArguments args) throws Exception {
hksdkInitService.initSdk();
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,117 @@
package com.shxy.xyhkcamera;
import com.sun.jna.Native;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* @description SDK
*/
@Slf4j
@Component
public class HcNetSdkUtil {
private static final Logger logger = LoggerFactory.getLogger(HcNetSdkUtil.class);
private HCNetSDK hCNetSDK = null;
/**
*
*/
private int userID;
/**
* win32 dll
*/
@Value("${hkconfig.winpath}")
private String winPath;
/**
* linux dll
*/
@Value("${hkconfig.linuxpath}")
private String linuxPath;
/**
*
*
* @return
*/
public HCNetSDK createSDKInstance() {
if (hCNetSDK == null) {
//Linux系统加载库路径
String path = System.getProperty("user.dir") + "/lib";
synchronized (HCNetSDK.class) {
if (OsSelect.isWindows()) {
//win系统加载库路径
try {
hCNetSDK = (HCNetSDK) Native.loadLibrary(winPath, HCNetSDK.class);
} catch (Exception e) {
System.out.println(e.getMessage());
}
log.info("海康动态库加载 Windows版");
} else if (OsSelect.isLinux()) {
log.info(">>>> " + path + "/libhcnetsdk.so");
hCNetSDK = HCNetSDK.INSTANCE;
log.info("海康动态库加载 Linux版");
}
}
if (OsSelect.isLinux()) {
//Linux版额外加载
load(path);
}
}
return hCNetSDK;
}
/**
* 使 linux
*
* @param path sdk
*/
private void load(String path) {
//设置HCNetSDKCom组件库所在路径
String strPathCom = path + "/";
HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
struComPath.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
//设置libcrypto.so所在路径
HCNetSDK.BYTE_ARRAY ptrByteArrayCrypto = new HCNetSDK.BYTE_ARRAY(256);
String strPathCrypto = path + "/libcrypto.so.1.1";
System.arraycopy(strPathCrypto.getBytes(), 0, ptrByteArrayCrypto.byValue, 0, strPathCrypto.length());
ptrByteArrayCrypto.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArrayCrypto.getPointer());
//设置libssl.so所在路径
HCNetSDK.BYTE_ARRAY ptrByteArraySsl = new HCNetSDK.BYTE_ARRAY(256);
String strPathSsl = path + "/libssl.so.1.1";
System.arraycopy(strPathSsl.getBytes(), 0, ptrByteArraySsl.byValue, 0, strPathSsl.length());
ptrByteArraySsl.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArraySsl.getPointer());
}
/**
*
*/
public void init() {
if (hCNetSDK == null) {
hCNetSDK = createSDKInstance();
if (Objects.isNull(hCNetSDK)) {
log.error("海康 SDK 初始化动态库失败");
throw new RuntimeException("海康 SDK 初始化动态库失败");
}
}
// 初始化
boolean initSuc = hCNetSDK.NET_DVR_Init();
if (!initSuc) {
log.error("海康 SDK 初始化失败");
throw new RuntimeException("海康 SDK 初始化失败");
}
}
}

@ -0,0 +1,80 @@
package com.shxy.xyhkcamera;
import lombok.extern.slf4j.Slf4j;
import java.util.Objects;
@Slf4j
public class InitSdkTask implements Runnable {
/**
* sdk
*/
private static HCNetSDK hCNetSDK = SdkInitService.hCNetSDK;
@Override
public void run() {
try {
if (Objects.equals(OSUtils.getOsName(), "linux")) {
log.info("InitSdk-is-linux");
String userDir = System.getProperty("user.dir");
log.info("InitSdk-userDir={}", userDir);
String osPrefix = OSUtils.getOsPrefix();
if (osPrefix.toLowerCase().startsWith("linux-i386")) {
HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256);
HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256);
//这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限
//linux 下, 库加载参考OSUtils.getLoadLibrary()
String strPath1 = System.getProperty("user.dir") + "/hkliblinux32/libcrypto.so.1.1";
String strPath2 = System.getProperty("user.dir") + "/hkliblinux32/libssl.so.1.1";
System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length());
ptrByteArray1.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer());
System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length());
ptrByteArray2.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer());
//linux 下, 库加载参考OSUtils.getLoadLibrary()
String strPathCom = System.getProperty("user.dir") + "/hkliblinux32/HCNetSDKCom/";
HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
struComPath.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
} else if (osPrefix.toLowerCase().startsWith("linux-amd64")) {
HCNetSDK.BYTE_ARRAY ptrByteArray1 = new HCNetSDK.BYTE_ARRAY(256);
HCNetSDK.BYTE_ARRAY ptrByteArray2 = new HCNetSDK.BYTE_ARRAY(256);
//这里是库的绝对路径,请根据实际情况修改,注意改路径必须有访问权限
//linux 下, 库加载参考OSUtils.getLoadLibrary()
String strPath1 = System.getProperty("user.dir") + "/hkliblinux64/libcrypto.so.1.1";
String strPath2 = System.getProperty("user.dir") + "/hkliblinux64/libssl.so.1.1";
System.arraycopy(strPath1.getBytes(), 0, ptrByteArray1.byValue, 0, strPath1.length());
ptrByteArray1.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(3, ptrByteArray1.getPointer());
System.arraycopy(strPath2.getBytes(), 0, ptrByteArray2.byValue, 0, strPath2.length());
ptrByteArray2.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArray2.getPointer());
String strPathCom = System.getProperty("user.dir") + "/hkliblinux64/HCNetSDKCom/";
//linux 下, 库加载参考OSUtils.getLoadLibrary()
HCNetSDK.NET_DVR_LOCAL_SDK_PATH struComPath = new HCNetSDK.NET_DVR_LOCAL_SDK_PATH();
System.arraycopy(strPathCom.getBytes(), 0, struComPath.sPath, 0, strPathCom.length());
struComPath.write();
hCNetSDK.NET_DVR_SetSDKInitCfg(2, struComPath.getPointer());
} else {
log.info("osPrefix={}", osPrefix);
}
}
//初始化sdk
boolean isOk = hCNetSDK.NET_DVR_Init();
hCNetSDK.NET_DVR_SetConnectTime(10, 1);
hCNetSDK.NET_DVR_SetReconnect(100, true);
if (!isOk) {
log.error("=================== InitSDK init fail ===================");
} else {
log.info("============== InitSDK init success ====================");
}
} catch (Exception e) {
log.error("InitSDK-error,e={}", e.getMessage());
e.printStackTrace();
}
}
}

@ -0,0 +1,110 @@
package com.shxy.xyhkcamera;
import com.sun.jna.Platform;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
@Slf4j
public class OSUtils {
// 获取操作平台信息
public static String getOsPrefix() {
String arch = System.getProperty("os.arch").toLowerCase();
final String name = System.getProperty("os.name");
String osPrefix;
if (Platform.isWindows()) {
if ("i386".equals(arch)) {
arch = "x86";
}
osPrefix = "win32-" + arch;
} else if (Platform.isLinux()) {
if ("x86".equals(arch)) {
arch = "i386";
} else if ("x86_64".equals(arch)) {
arch = "amd64";
}
osPrefix = "linux-" + arch;
} else {
osPrefix = name.toLowerCase();
if ("x86".equals(arch)) {
arch = "i386";
}
if ("x86_64".equals(arch)) {
arch = "amd64";
}
int space = osPrefix.indexOf(" ");
if (space != -1) {
osPrefix = osPrefix.substring(0, space);
}
osPrefix += "-" + arch;
}
return osPrefix;
}
public static String getOsName() {
String osName = "";
String osPrefix = getOsPrefix();
if (osPrefix.toLowerCase().startsWith("win32-x86")
|| osPrefix.toLowerCase().startsWith("win32-amd64")) {
osName = "win";
} else if (osPrefix.toLowerCase().startsWith("linux-i386")
|| osPrefix.toLowerCase().startsWith("linux-amd64")) {
osName = "linux";
}
return osName;
}
/**
*
* winlinux
*
* @return
*/
public static String getLoadLibrary() {
if (isChecking()) {
return null;
}
String userDir = System.getProperty("user.dir");
log.info("getLoadLibrary-userDir={}", userDir);
String loadLibrary = "";
String library = "";
String osPrefix = getOsPrefix();
if (osPrefix.toLowerCase().startsWith("win32-x86")) {
loadLibrary = System.getProperty("user.dir") + File.separator + "sdk" + File.separator + "hklibwin32" + File.separator;
library = "HCNetSDK.dll";
} else if (osPrefix.toLowerCase().startsWith("win32-amd64")) {
loadLibrary = System.getProperty("user.dir") + File.separator + "sdk" + File.separator + "hklibwin64" + File.separator;
library = "HCNetSDK.dll";
} else if (osPrefix.toLowerCase().startsWith("linux-i386")) {
//同 linux-amd64
loadLibrary = "";
library = "libhcnetsdk.so";
} else if (osPrefix.toLowerCase().startsWith("linux-amd64")) {
//方式一:使用系统默认的加载库路径,在系统的/usr/lib文件中加入你Java工程所需要使用的so文件然后将HCNetSDKCom文件夹下的组件库也复制到/usr/lib目录HCNetSDKCom文件夹中的组件库不要随意更换路径。CentOS 64位需拷贝到/usr/lib64下。
//针对方式一,前缀就是绝对路径
//loadLibrary = "/usr/lib64/lib/hkliblinux64/";
//方式二配置LD_LIBRARY_PATH环境变量加载库文件配置/etc/ld.so.conf加上你自己的Java工程所需要的so文件的路径
//针对方式二无需添加前缀程序会从linux系统的so共享库中查找libhcnetsdk.so
loadLibrary = "";
library = "libhcnetsdk.so";
}
log.info("================= Load library Path :{} ==================", loadLibrary + library);
return loadLibrary + library;
}
private static boolean checking = false;
public static void setChecking() {
checking = true;
}
public static void clearChecking() {
checking = false;
}
public static boolean isChecking() {
return checking;
}
}

@ -0,0 +1,16 @@
package com.shxy.xyhkcamera;
/**
* @author jiangxin
* @create 2022-01-19-16:40
*/
public class OsSelect {
public static boolean isLinux() {
return System.getProperty("os.name").toLowerCase().contains("linux");
}
public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
}

@ -0,0 +1,46 @@
package com.shxy.xyhkcamera;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Component
public class SdkInitService {
@Autowired
private ThreadPoolExecutor executor;
public static HCNetSDK hCNetSDK = null;
static FExceptionCallBack_Imp fExceptionCallBack;
static class FExceptionCallBack_Imp implements HCNetSDK.FExceptionCallBack {
public void invoke(int dwType, int lUserID, int lHandle, Pointer pUser) {
System.out.println("异常事件类型:" + dwType);
return;
}
}
public SdkInitService() {
if (hCNetSDK == null) {
synchronized (HCNetSDK.class) {
try {
hCNetSDK = (HCNetSDK) Native.loadLibrary(OSUtils.getLoadLibrary(), HCNetSDK.class);
} catch (Exception ex) {
log.error("SdkInitService-init-hCNetSDK-error");
}
}
}
}
@Autowired
public void initSdk() {
log.info("HKSDKInitService-init-coming");
executor.execute(new InitSdkTask());
}
}

@ -0,0 +1,13 @@
//package com.shxy.xyhkcamera;
//
//public class Test {
// public static void main(String[] args) {
//
//// HcNetSdkUtil hcNetSdkUtil = new HcNetSdkUtil(56, "", "");
//// HCNetSDK sdkInstance = hcNetSdkUtil.createSDKInstance();
//// sdkInstance.NET_DVR_Init();
//// sdkInstance.NET_DVR_Login_V40();
//// sdkInstance.NET_DVR_STDXMLConfig();
//// sdkInstance.NET_DVR_StartRemoteConfig()
// }
//}

@ -0,0 +1,16 @@
package com.shxy.xyhkcamera;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@Slf4j
public class XyhkcameraApplication {
public static void main(String[] args) {
SpringApplication.run(XyhkcameraApplication.class, args);
}
}

@ -0,0 +1,14 @@
package com.shxy.xyhkcamera.impl;
import com.shxy.xyhkcamera.service.TempMeasureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class TempMeasureServiceImpl implements TempMeasureService {
@Override
public void measure() {
// hcNetSdkUtil.createSDKInstance();
}
}

@ -0,0 +1,24 @@
package com.shxy.xyhkcamera.schedule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author jingjing
* @date 2023-11-16 15:06
*/
@Component
@EnableScheduling
@Slf4j
public class ScheduledTask {
@Scheduled(fixedDelay = 60 * 60 * 1000)
public void cacyspupload() {
log.info("开始测温");
// webservcies.uploadyspData();
}
}

@ -0,0 +1,5 @@
package com.shxy.xyhkcamera.service;
public interface TempMeasureService {
void measure();
}

@ -0,0 +1,85 @@
package com.shxy.xyhkcamera.test;
import com.sun.jna.ptr.IntByReference;
/**
* \if ENGLISH_LANG
* Capture Picture Interface
* contains:localremotetimer and stop capture picture
* \else
*
* :
* \endif
*/
public class CapturePictureModule {
/**
* \if ENGLISH_LANG
* Remote Capture Picture
* \else
*
* \endif
*/
public static boolean remoteCapturePicture(int chn) {
return snapPicture(chn, 0, 0);
}
/**
* \if ENGLISH_LANG
* Timer Capture Picture
* \else
*
* \endif
*/
public static boolean timerCapturePicture(int chn) {
return snapPicture(chn, 1, 2);
}
/**
* \if ENGLISH_LANG
* Stop Timer Capture Picture
* \else
*
* \endif
*/
public static boolean stopCapturePicture(int chn) {
return snapPicture(chn, -1, 0);
}
/**
* \if ENGLISH_LANG
* Capture Picture (except local capture picture, others all call this interface)
* \else
* (, )
* \endif
*/
private static boolean snapPicture(int chn, int mode, int interval) {
// send caputre picture command to device
NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS();
stuSnapParams.Channel = chn; // channel
stuSnapParams.mode = mode; // capture picture mode
stuSnapParams.Quality = 3; // picture quality
stuSnapParams.InterSnap = interval; // timer capture picture time interval
stuSnapParams.CmdSerial = 0; // request serial
IntByReference reserved = new IntByReference(0);
if (!INetSDK.netsdk.CLIENT_SnapPictureEx(INetSDK.m_hLoginHandle, stuSnapParams, reserved)) {
System.err.printf("CLIENT_SnapPictureEx Failed!" + INetSDK.netsdk.CLIENT_GetLastError());
return false;
} else {
System.out.println("CLIENT_SnapPictureEx success");
}
return true;
}
/**
* \if ENGLISH_LANG
* Set Capture Picture Callback
* \else
*
* \endif
*/
public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){
INetSDK.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null);
}
}

@ -0,0 +1,192 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.shxy.xyhkcamera.test;
import java.io.BufferedReader;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
/**
*
* @author LENOVO
*/
public class DBHelper {
private static String DRIVER="";
//private static final String URL="jdbc:mysql://192.168.1.188/dss";
private static String URL="";
private static String USER="";
private static String PASSWORD="";
public void GetText(String path){
if(DRIVER!=""){
return;
}
// 1.定义目标文件
File srcFile = new File(path);
// 2.创建一个流,指向目标文件
BufferedReader is = null;
try {
is = new BufferedReader(new FileReader(srcFile));
int i= 0;
String s = null;
while ((s = is.readLine()) != null) {// 使用readLine方法一次读一行
if(i==0){
DRIVER = s;
}
if(i==1){
URL = s;
}
if(i==2){
USER = s;
}
if(i==3){
PASSWORD = s;
}
i++;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭io流
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
*
* @return
*/
public Connection getConnection(){
// GetText("D://shjdconfig.txt");
GetText("/home/shjdconfig.txt");
Connection conn=null;
try {
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn=DriverManager.getConnection(URL, USER, PASSWORD);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
/**
*
* @param rs
* @param pstmt
* @param conn
*/
public void closeAll(ResultSet rs,PreparedStatement pstmt,Connection conn){
try {
if(rs!=null){
rs.close();
}
if(pstmt!=null){
pstmt.close();
}
if(conn!=null){
conn.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
*
* @param sql
* @return true or false
*/
public int excuteUpdate(String sql){
int res=0;//受影响的行数
Connection conn=null;
PreparedStatement pstmt = null;
ResultSet rs=null;
try {
conn=getConnection();
pstmt=conn.prepareStatement(sql);//装载sql语句
res=pstmt.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeAll(rs, pstmt, conn);
}
return res;
}
/**
* 使
* @param sql
* @param params
* @param cls
* @return
*/
public <T> List<T> executeQuery(String sql,List<Object> params,Class<T> cls) throws Exception{
Connection conn=null;
PreparedStatement pstmt = null;
ResultSet rs=null;
List<T> data=new ArrayList<T>();
try {
conn=getConnection();
pstmt=conn.prepareStatement(sql);//装载sql语句
if(params!=null){
//加入有?占位符,在执行之前把?占位符替换掉
for(int i=0;i<params.size();i++){
pstmt.setObject(i+1, params.get(i));
}
}
rs=pstmt.executeQuery();
//把查询出来的记录封装成对应的实体类对象
ResultSetMetaData rsd=rs.getMetaData();//获得列对象,通过此对象可以得到表的结构,包括,列名,列的个数,列的数据类型
while(rs.next()){
T m=cls.newInstance();
for(int i=0;i<rsd.getColumnCount();i++){
String col_name=rsd.getColumnName(i+1);//获得列名
Object value=rs.getObject(col_name);//获得列所对应的值
Field field=cls.getDeclaredField(col_name);
field.setAccessible(true);//给私有属性设置可访问权
field.set(m, value);//给对象的私有属性赋值
}
data.add(m);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
closeAll(rs, pstmt, conn);
}
return data;
}
}

@ -0,0 +1,576 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Container class="javax.swing.JFrame" name="jFrame1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JFrame" name="jFrame2">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.ButtonGroup" name="TypeGroup">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="ClientDemo"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="&#x5b8b;&#x4f53;" size="10" style="0"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPaneHorizontal" alignment="0" pref="16050" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPaneHorizontal" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPaneHorizontal">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder/>
</Border>
</Property>
<Property name="dividerLocation" type="int" value="155"/>
<Property name="dividerSize" type="int" value="2"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanelUserInfo">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder>
<Color PropertyName="highlight" blue="ff" green="ff" red="cc" type="rgb"/>
</EtchetBorder>
</Border>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[500, 878]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabelIPAddress1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jTextFieldPwd" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jButtonRealPlay" min="-2" pref="87" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButtonLogin" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabelPortNumber1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jTextFieldPortNumber" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPaneTree" alignment="0" max="32767" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabelPortNumber4" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="nPresetIdTxt" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Component id="jLabelPortNumber2" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabelPortNumber3" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="26" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="nRuleId" max="32767" attributes="0"/>
<Component id="nMeterType1" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="jButton2" alignment="0" min="-2" pref="87" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabelIPAddress" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabelPortNumber" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTextFieldIPAddress" max="32767" attributes="0"/>
<Component id="jTextFieldUser" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace pref="20" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabelIPAddress" min="-2" max="-2" attributes="0"/>
<Component id="jTextFieldIPAddress" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabelPortNumber" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextFieldUser" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabelIPAddress1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jTextFieldPwd" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabelPortNumber1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jTextFieldPortNumber" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jButtonLogin" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jButtonRealPlay" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="nPresetIdTxt" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabelPortNumber4" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabelPortNumber3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="nMeterType1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="nRuleId" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabelPortNumber2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jScrollPaneTree" min="-2" pref="167" max="-2" attributes="0"/>
<EmptySpace pref="349" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButtonRealPlay">
<Properties>
<Property name="text" type="java.lang.String" value="&#x9884;&#x89c8;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonRealPlayActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButtonLogin">
<Properties>
<Property name="text" type="java.lang.String" value="&#x9000;&#x51fa;&#x9884;&#x89c8;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonLoginActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabelIPAddress">
<Properties>
<Property name="text" type="java.lang.String" value="IP&#x5730;&#x5740;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextFieldUser">
<Properties>
<Property name="text" type="java.lang.String" value="admin"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextFieldIPAddress">
<Properties>
<Property name="text" type="java.lang.String" value="192.168.1.108"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelPortNumber">
<Properties>
<Property name="text" type="java.lang.String" value="&#x7528;&#x6237;&#x540d;&#xff1a;"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPaneTree">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="jTreeDevice">
<Properties>
<Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="this.initialTreeModel()" type="code"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="&#x83b7;&#x53d6;&#x6e29;&#x5ea6;"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="jTextFieldPortNumber">
<Properties>
<Property name="text" type="java.lang.String" value="37777"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelPortNumber1">
<Properties>
<Property name="text" type="java.lang.String" value="&#x7aef;&#x53e3;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelIPAddress1">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5bc6;&#x7801;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextFieldPwd">
<Properties>
<Property name="text" type="java.lang.String" value="admin12345"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextFieldPwdActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabelPortNumber2">
<Properties>
<Property name="text" type="java.lang.String" value="&#x89c4;&#x5219;&#x7f16;&#x53f7;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="nRuleId">
<Properties>
<Property name="text" type="java.lang.String" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelPortNumber3">
<Properties>
<Property name="text" type="java.lang.String" value="&#x6d4b;&#x6e29;&#x9879;&#x7c7b;&#x578b;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelPortNumber4">
<Properties>
<Property name="text" type="java.lang.String" value="&#x9884;&#x7f6e;&#x70b9;&#x7f16;&#x53f7;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="nPresetIdTxt">
<Properties>
<Property name="text" type="java.lang.String" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="nMeterType1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="1">
<StringItem index="0" value="&#x8bf7;&#x9009;&#x62e9;&#x7c7b;&#x578b;"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JSplitPane" name="jSplitPaneVertical">
<Properties>
<Property name="dividerLocation" type="int" value="579"/>
<Property name="dividerSize" type="int" value="2"/>
<Property name="orientation" type="int" value="0"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanelRealplayArea">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder>
<Color PropertyName="color" blue="66" green="ff" red="99" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="top"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<Component id="Realplay" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="15366" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="Realplay" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="49" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="java.awt.Panel" name="Realplay">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[500, 500]"/>
</Property>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="RealplayMousePressed"/>
</Events>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="500" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="500" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
</Component>
<Container class="java.awt.Panel" name="panel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="fTemperStdTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="fTemperMidTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="fTemperMinTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="fTemperMaxTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="fTemperAverTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="nTemperUnitTxt" min="-2" pref="118" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="15659" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="nTemperUnitTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="fTemperAverTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="fTemperMaxTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="fTemperMinTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="fTemperMidTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="fTemperStdTxt" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="52" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="&#x6d4b;&#x6e29;&#x5355;&#x4f4d;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="nTemperUnitTxt">
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5e73;&#x5747;&#x6e29;&#x5ea6;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="fTemperAverTxt">
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="&#x4e2d;&#x95f4;&#x503c;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="fTemperMidTxt">
</Component>
<Component class="javax.swing.JTextField" name="fTemperMinTxt">
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="&#x6700;&#x5c0f;&#x6e29;&#x5ea6;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="&#x6700;&#x9ad8;&#x6e29;&#x5ea6;&#xff1a;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="fTemperMaxTxt">
</Component>
<Component class="javax.swing.JTextField" name="fTemperStdTxt">
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="&#x6807;&#x51c6;&#x65b9;&#x5dee;&#x503c;&#xff1a;"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,678 @@
package com.shxy.xyhkcamera.test;
import java.awt.Panel;
import java.io.File;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.examples.win32.W32API;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
import javax.swing.SwingUtilities;
public class INetSDK {
static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
private static NetSDKLib playsdk = NetSDKLib.CONFIG_dhplay;
// 设备信息
public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
// 登陆句柄
public static NativeLong m_hLoginHandle = new NativeLong(0);
// 预览句柄
public static NativeLong m_hPlayHandle = new NativeLong(0);
// 智能订阅句柄
public static NativeLong m_hAttachHandle = new NativeLong(0);
// 下载句柄
public static NativeLong m_hDownLoadHandle = new NativeLong(0);
private static boolean bInit = false;
private static boolean bLogopen = false;
/**
* \if ENGLISH_LANG
* Init
* \else
*
* \endif
*/
public static boolean init(NetSDKLib.fDisConnect disConnect, NetSDKLib.fHaveReConnect haveReConnect) {
bInit = netsdk.CLIENT_Init(disConnect, new NativeLong(0));
if (!bInit) {
System.out.println("Initialize SDK failed");
return false;
}
//打开日志,可选
NetSDKLib.LOG_SET_PRINT_INFO setLog = new NetSDKLib.LOG_SET_PRINT_INFO();
File path = new File("./sdklog/");
if (!path.exists()) {
path.mkdir();
}
String logPath = path.getAbsoluteFile().getParent() + "\\sdklog\\" + ToolKits.getDate() + ".log";
setLog.nPrintStrategy = 0;
setLog.bSetFilePath = 1;
System.arraycopy(logPath.getBytes(), 0, setLog.szLogFilePath, 0, logPath.getBytes().length);
System.out.println(logPath);
setLog.bSetPrintStrategy = 1;
setLog.nPrintStrategy = 0;
bLogopen = netsdk.CLIENT_LogOpen(setLog);
if (!bLogopen) {
System.err.println("Failed to open NetSDK log");
}
// 设置断线重连回调接口设置过断线重连成功回调函数后当设备出现断线情况SDK内部会自动进行重连操作
// 此操作为可选操作,但建议用户进行设置
netsdk.CLIENT_SetAutoReconnect(haveReConnect, new NativeLong(0));
//设置登录超时时间和尝试次数,可选
int waitTime = 5000; //登录请求响应超时时间设置为5S
int tryTimes = 1; //登录时尝试建立链接1次
netsdk.CLIENT_SetConnectTime(waitTime, tryTimes);
// 设置更多网络参数NET_PARAM的nWaittimenConnectTryNum成员与CLIENT_SetConnectTime
// 接口设置的登录设备超时时间和尝试次数意义相同,可选
NetSDKLib.NET_PARAM netParam = new NetSDKLib.NET_PARAM();
netParam.nConnectTime = 10000; //登录时尝试建立链接的超时时间
netsdk.CLIENT_SetNetworkParam(netParam);
return true;
}
/**
* \if ENGLISH_LANG
* CleanUp
* \else
*
* \endif
*/
public static void cleanup() {
if (bLogopen) {
netsdk.CLIENT_LogClose();
}
if (bInit) {
netsdk.CLIENT_Cleanup();
}
}
/**
* \if ENGLISH_LANG
* Login Device
* \else
*
* \endif
*/
public static boolean login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
IntByReference nError = new IntByReference(0);
m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null, m_stDeviceInfo, nError);
if (m_hLoginHandle.longValue() == 0) {
System.err.printf("Login Device[%s] Port[%d]Failed. Last Error[0x%x]\n", m_strIp, m_nPort, netsdk.CLIENT_GetLastError());
} else {
System.out.println("Login Success [ " + m_strIp + " ]");
}
return m_hLoginHandle.longValue() == 0 ? false : true;
}
/**
* \if ENGLISH_LANG
* Logout Device
* \else
*
* \endif
*/
public static boolean logout() {
if (m_hLoginHandle.longValue() == 0) {
return false;
}
boolean bRet = netsdk.CLIENT_Logout(m_hLoginHandle);
if (bRet) {
m_hLoginHandle.setValue(0);
}
return bRet;
}
/**
*
*/
public static String getErrorCode() {
return Res.string().getErrorCode(netsdk.CLIENT_GetLastError());
}
/**
*
*/
public static boolean ptzControlnPresetId(int nChannelID, int lParam1, int lParam2, int lParam3, int dwStop, Pointer param4) {
return netsdk.CLIENT_DHPTZControlEx2(m_hLoginHandle, nChannelID, NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_MOVE_CONTROL, lParam1, lParam2, lParam3, dwStop, param4);
}
/**
* \if ENGLISH_LANG
* Start RealPlay
* \else
*
* \endif
*/
public static fRealDataCallBackEx fReal = new fRealDataCallBackEx();
public static W32API.HWND hwnd;//窗体句柄
public static boolean startRealPlay(int channel, int stream, Panel realPlayWindow) {
hwnd = new W32API.HWND(Native.getComponentPointer(realPlayWindow));
boolean bOpenRet = playsdk.PLAY_OpenStream(new NativeLong(0), null, 0, 1024 * 500);
if (bOpenRet) {
// 开始播放
boolean bPlayRet = playsdk.PLAY_Play(new NativeLong(0), hwnd);
if (bPlayRet) {
m_hPlayHandle = netsdk.CLIENT_RealPlayEx(m_hLoginHandle, channel, null, stream);
//m_hPlayHandle = netsdk.CLIENT_RealPlayEx(m_hLoginHandle, channel, Native.getComponentPointer(realPlayWindow), stream);
}
boolean real = netsdk.CLIENT_SetRealDataCallBackEx(m_hPlayHandle, fReal, m_hLoginHandle, 0x1f);
}
if (m_hPlayHandle.longValue() == 0) {
System.err.println("开始实时监视失败,错误码" + String.format("[0x%x]", netsdk.CLIENT_GetLastError()));
} else {
//boolean real = netsdk.CLIENT_SetRealDataCallBackEx(m_hPlayHandle,fReal,m_hLoginHandle,0x1f);
System.out.println("Success to start realplay");
}
return m_hPlayHandle.longValue() == 0 ? false : true;
}
//摄像头回调: 通过 startRealPlay
public static class fRealDataCallBackEx implements NetSDKLib.fRealDataCallBackEx {
public void invoke(NativeLong lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int param, NativeLong dwUser) {
boolean bInput = false;
if (0 != lRealHandle.intValue()) {
switch (dwDataType) {
case 0:
//原始音视频混合数据
bInput = playsdk.PLAY_InputData(new NativeLong(0), pBuffer, dwBufSize);
if (!bInput) {
System.out.println("error");
}
break;
case 1:
//标准视频数据
break;
case 2:
//yuv 数据
break;
case 3:
//pcm 音频数据
break;
case 4:
//原始音频数据
break;
default:
break;
}
}
}
}
/**
* \if ENGLISH_LANG
* Start CLIENT_QueryDevInfo
* \else
*
* \endif
*/
//Pointer a = new Pointer(MemoryBlockFactory.createMemoryBlock(4 * 10));
public static boolean CLIENT_QueryDevInfo(int nQueryType, Pointer pInBuf, Pointer pOutBuf, Pointer pReservedL, int nWaitTime) {
//m_hLoginHandle.setValue(123);
boolean Isdate = netsdk.CLIENT_QueryDevInfo(m_hLoginHandle, nQueryType, pInBuf, pOutBuf, null, 3000);
if (!Isdate) {
System.err.println("查看失败,错误码:" + String.format("[0x%x]", netsdk.CLIENT_GetLastError()));
} else {
System.out.println("Success Look");
}
return Isdate;
}
/**
* \if ENGLISH_LANG
* Start RealPlay
* \else
*
* \endif
*/
public static void stopRealPlay() {
if (m_hPlayHandle.longValue() == 0) {
return;
}
boolean bRet = netsdk.CLIENT_StopRealPlayEx(m_hPlayHandle);
if (bRet) {
m_hPlayHandle.setValue(0);
}
}
public static void SetSnapRevCallBack(NetSDKLib.fSnapRev m_SnapReceiveCB) {
//设置抓图回调函数, 图片主要在m_SnapReceiveCB中返回
netsdk.CLIENT_SetSnapRevCallBack(m_SnapReceiveCB, new NativeLong(0));
}
/**
*
*/
public static boolean snapPicture(int chn) {
// 发送抓图命令给前端设备,抓图的信息
NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS();
stuSnapParams.Channel = chn; //抓图通道
stuSnapParams.mode = 0; //表示请求一帧
stuSnapParams.Quality = 3;
stuSnapParams.InterSnap = 5;
stuSnapParams.CmdSerial = 0; // 请求序列号,有效值范围 0~65535超过范围会被截断为
IntByReference reserved = new IntByReference(0);
if (!netsdk.CLIENT_SnapPictureEx(m_hLoginHandle, stuSnapParams, reserved)) {
System.err.printf("CLIENT_SnapPictureEx Failed!Last Error[%x]\n", netsdk.CLIENT_GetLastError());
return false;
} else {
System.out.println("CLIENT_SnapPictureEx success");
}
return true;
}
/********************************************************************************
* *
********************************************************************************/
/**
*
*/
public static boolean ptzControlUpStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlUpEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlDownStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlDownEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlLeftStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID, NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlLeftEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlRightStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlRightEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlLeftUpStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlLeftUpEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlRightUpStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlRightUpEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlLeftDownStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlLeftDownEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
0, 0, 0, 1);
}
/**
*
*/
public static boolean ptzControlRightDownStart(int nChannelID, int lParam1, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
lParam1, lParam2, 0, 0);
}
public static boolean ptzControlRightDownEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
0, 0, 0, 1);
}
/**
* +
*/
public static boolean ptzControlZoomAddStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlZoomAddEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
0, 0, 0, 1);
}
/**
* -
*/
public static boolean ptzControlZoomDecStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlZoomDecEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
0, 0, 0, 1);
}
/**
* +
*/
public static boolean ptzControlFocusAddStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlFocusAddEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
0, 0, 0, 1);
}
/**
* -
*/
public static boolean ptzControlFocusDecStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlFocusDecEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
0, 0, 0, 1);
}
/**
* +
*/
public static boolean ptzControlIrisAddStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlIrisAddEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
0, 0, 0, 1);
}
/**
* -
*/
public static boolean ptzControlIrisDecStart(int nChannelID, int lParam2) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
0, lParam2, 0, 0);
}
public static boolean ptzControlIrisDecEnd(int nChannelID) {
return netsdk.CLIENT_DHPTZControlEx(m_hLoginHandle, nChannelID,
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
0, 0, 0, 1);
}
/********************************************************************************
* *
********************************************************************************/
/**
*
*/
public static void Old_OpenStrobe(int bTriggerBtnClick) {
if (m_hLoginHandle.longValue() != 0) {
System.out.println("Trigger Button Action");
NetSDKLib.ALARMCTRL_PARAM param = new NetSDKLib.ALARMCTRL_PARAM();
param.nAction = bTriggerBtnClick;
; // 1触发报警0停止报警. 按钮按下
if (netsdk.CLIENT_ControlDeviceEx(m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_TRIGGER_ALARM_OUT, param.getPointer(), null, 3000)) {
System.out.println("控制成功");
} else {
System.err.printf("Failed to Open 0x%x", netsdk.CLIENT_GetLastError());
}
}
}
/**
*
*/
public static boolean New_OpenStrobe() {
NetSDKLib.NET_CTRL_OPEN_STROBE openStrobe = new NetSDKLib.NET_CTRL_OPEN_STROBE();
openStrobe.nChannelId = 0;
String plate = new String("浙A888888");
System.arraycopy(plate.getBytes(), 0, openStrobe.szPlateNumber, 0, plate.getBytes().length);
openStrobe.write();
if (netsdk.CLIENT_ControlDeviceEx(m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_CTRL_OPEN_STROBE, openStrobe.getPointer(), null, 3000)) {
System.out.println("Open Success!");
} else {
System.err.printf("Failed to Open 0x%x\n", netsdk.CLIENT_GetLastError());
return false;
}
openStrobe.read();
return true;
}
/**
*
*/
public static void New_CloseStrobe() {
NetSDKLib.NET_CTRL_CLOSE_STROBE closeStrobe = new NetSDKLib.NET_CTRL_CLOSE_STROBE();
closeStrobe.nChannelId = 0;
closeStrobe.write();
if (netsdk.CLIENT_ControlDeviceEx(m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_CTRL_CLOSE_STROBE, closeStrobe.getPointer(), null, 3000)) {
System.out.println("Close Success!");
} else {
System.err.printf("Failed to Close 0x%x\n", netsdk.CLIENT_GetLastError());
}
closeStrobe.read();
}
/**
*
*/
public static boolean manualSnapPicture(int chn) {
NetSDKLib.MANUAL_SNAP_PARAMETER snapParam = new NetSDKLib.MANUAL_SNAP_PARAMETER();
snapParam.nChannel = chn;
String sequence = "11111"; // 抓图序列号,必须用数组拷贝
System.arraycopy(sequence.getBytes(), 0, snapParam.bySequence, 0, sequence.getBytes().length);
snapParam.write();
boolean bRet = netsdk.CLIENT_ControlDeviceEx(m_hLoginHandle, NetSDKLib.CtrlType.CTRLTYPE_MANUAL_SNAP, snapParam.getPointer(), null, 5000);
if (!bRet) {
System.err.println("Failed to manual snap, last error " + String.format("[0x%x]", netsdk.CLIENT_GetLastError()));
return false;
} else {
System.out.println("Seccessed to manual snap");
}
snapParam.read();
return true;
}
/**
*
*
* @return
*/
public static boolean attachIVSEvent(int ChannelId, NetSDKLib.fAnalyzerDataCallBack m_AnalyzerDataCB) {
/**
*
* m_stDeviceInfo.byChanNum
* 0.
*/
int bNeedPicture = 1; // 是否需要图片
m_hAttachHandle = netsdk.CLIENT_RealLoadPictureEx(m_hLoginHandle, ChannelId, NetSDKLib.EVENT_IVS_ALL,
bNeedPicture, m_AnalyzerDataCB, null, null);
if (m_hAttachHandle.longValue() != 0) {
System.out.println("CLIENT_RealLoadPictureEx Success ChannelId : \n" + ChannelId);
} else {
System.err.printf("CLIENT_RealLoadPictureEx Failed!LastError = %x\n", netsdk.CLIENT_GetLastError());
return false;
}
return true;
}
/**
*
*/
public static void detachIVSEvent() {
if (0 != m_hAttachHandle.longValue()) {
netsdk.CLIENT_StopLoadPic(m_hAttachHandle);
System.out.println("Stop detach IVS event");
m_hAttachHandle.setValue(0);
}
}
// 查找录像文件
public static boolean queryRecordFile(int nChannelId,
NetSDKLib.NET_TIME stTimeStart,
NetSDKLib.NET_TIME stTimeEnd,
NetSDKLib.NET_RECORDFILE_INFO[] stFileInfo,
IntByReference nFindCount) {
// RecordFileType 录像类型 0:所有录像 1:外部报警 2:动态监测报警 3:所有报警 4:卡号查询 5:组合条件查询 6:录像位置与偏移量长度 8:按卡号查询图片(目前仅HB-U和NVS特殊型号的设备支持) 9:查询图片(目前仅HB-U和NVS特殊型号的设备支持) 10:按字段查询 15:返回网络数据结构(金桥网吧) 16:查询所有透明串数据录像文件
int nRecordFileType = 0;
boolean bRet = netsdk.CLIENT_QueryRecordFile(m_hLoginHandle, nChannelId, nRecordFileType, stTimeStart, stTimeEnd, null, stFileInfo, stFileInfo.length * stFileInfo[0].size(), nFindCount, 5000, false);
if (bRet) {
System.out.println("QueryRecordFile Succeed! \n" + "查询到的视频个数:" + nFindCount.getValue());
} else {
System.err.println("QueryRecordFile Failed!" + netsdk.CLIENT_GetLastError());
return false;
}
return true;
}
public static void setStreamType(int m_streamType) {
// 设置回放时的码流类型
IntByReference steamType = new IntByReference(m_streamType);// 0-主辅码流,1-主码流,2-辅码流
int emType = NetSDKLib.EM_USEDEV_MODE.NET_RECORD_STREAM_TYPE;
boolean bret = netsdk.CLIENT_SetDeviceMode(m_hLoginHandle, emType, steamType.getPointer());
if (!bret) {
System.err.printf("Set Stream Type Failed, Get last error [0x%x]\n", netsdk.CLIENT_GetLastError());
} else {
System.out.println("Set Stream Type Succeed!");
}
}
public static NativeLong downloadRecordFile(int nChannelId,
int nRecordFileType,
NetSDKLib.NET_TIME stTimeStart,
NetSDKLib.NET_TIME stTimeEnd,
String SavedFileName,
NetSDKLib.fTimeDownLoadPosCallBack cbTimeDownLoadPos) {
m_hDownLoadHandle = netsdk.CLIENT_DownloadByTimeEx(m_hLoginHandle, nChannelId, nRecordFileType,
stTimeStart, stTimeEnd, SavedFileName,
cbTimeDownLoadPos, null, null, null, null);
if (m_hDownLoadHandle.longValue() != 0) {
System.out.println("Downloading RecordFile!");
} else {
System.err.println("Download RecordFile Failed!" + netsdk.CLIENT_GetLastError());
}
return m_hDownLoadHandle;
}
public static void stopDownLoadRecordFile(NativeLong m_hDownLoadHandle) {
if (m_hDownLoadHandle.longValue() == 0) {
return;
}
netsdk.CLIENT_StopDownload(m_hDownLoadHandle);
}
}

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

@ -0,0 +1,45 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.shxy.xyhkcamera.test;
/**
*
* @author LENOVO
*/
public class Login extends javax.swing.JPanel {
/**
* Creates new form Login
*/
public Login() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save