Java implementation of NVR/DVR equipment working condition acquisition

Source: Internet
Author: User
Tags get ip

This feature requires knowledge of the JNA.

By consulting the Marine Equipment Network SDK Programming Guide (DVR&NVR), you know that the Hoi Hong SDK call method has the following procedure:

The flow of the dashed box is an optional part that does not affect the use of other processes and functions of the module. The specific module description can be referenced in the SDK development files yourself.

Main function Code:

Test example, so the dashed part function is not implemented

1. Initialize the Device SDK: Initialize the entire Network SDK system, memory pre-allocation and other operations.

Code: HCNETSDK SDK = hcnetsdk.instance;

Sdk.net_dvr_init ();//return Booleaan value

2. Registering the device: Realize the user's registration function, after the registration is successful, the returned user ID is the unique identifier of the other function operation.

Code: Nativelong uid=new Nativelong (-1);

Net_dvr_deviceinfo_v30 devinfo=new net_dvr_deviceinfo_v30 ();//Device information

Uid=sdk.net_dvr_login_v30 (String) IP, (short) PORT, (String) user,string () pwd,devinfo);//Returns a user number while writing device information to DevInfo

3. Device Operation status Acquisition (parameter configuration module):

Code: NET_DVR_WORKSTATE_V30 devwork=new net_dvr_workstate_v30 ();

SDK.NET_DVR_GETDVRWORKSTATE_V30 (UID, devwork);//Returns a Boolean value to determine whether to acquire device capabilities

Intbyreference ibrbytesreturned = new Intbyreference (0);//Get IP access configuration parameters

Net_dvr_ipparacfg ipcfg=new net_dvr_ipparacfg ();

Ipcfg.write ();

Pointer lpipparaconfig =ipcfg.getpointer ();

Sdk.net_dvr_getdvrconfig (Uid,sdk.net_dvr_get_ipparacfg,new nativelong (0), lpipparaconfig,ipcfg.size (), ibrbytesreturned);

Ipcfg.read ();

4. Logout Device:

Code: Sdk.net_dvr_logout (UID);

5. Release the SDK

Code: Sdk.net_dvr_cleanup ();

Detailed Examples:

Package Clientdemo;import Com.sun.jna.nativelong;import Com.sun.jna.pointer;import com.sun.jna.ptr.IntByReference; Import Clientdemo.hcnetsdk.net_dvr_deviceinfo_v30;import Clientdemo.hcnetsdk.net_dvr_ipparacfg;import Clientdemo.hcnetsdk.net_dvr_workstate_v30;public class Device_demo {public static void main (string[] args) {//TODO auto-generated method Stubhcnetsdk SDK = Hcnetsdk.instance;if (!sdk.net_dvr_init ()) {System.out.println ("SDK initialization failed"); return;} Nativelong uid=new Nativelong ( -1); Net_dvr_deviceinfo_v30 devinfo=new net_dvr_deviceinfo_v30 ();//device information string ip= " 192.168.10.191 "; Short port=8000;uid=sdk.net_dvr_login_v30 (Ip,port," admin "," hk123456 ", DevInfo);//Returns a user number, The device information is also written to Devinfoint Iuid=uid.intvalue (); if (iuid<0) {System.out.println ("Device registration failed"); return;} Net_dvr_workstate_v30 devwork=new net_dvr_workstate_v30 (); if (!sdk.net_dvr_getdvrworkstate_v30 (UID, devwork)) {// Returns a Boolean value that determines whether to acquire device capability System.out.println ("Return device state Failed");} Intbyreference ibrbytesreturned = new Intbyreference (0);//Get IP access configuration parameters net_Dvr_ipparacfg ipcfg=new net_dvr_ipparacfg (); Ipcfg.write (); Pointer lpipparaconfig =ipcfg.getpointer (); Sdk.net_dvr_getdvrconfig (Uid,sdk.net_dvr_get_ipparacfg,new NativeLong ( 0), Lpipparaconfig,ipcfg.size (), ibrbytesreturned); Ipcfg.read (); System.out.print ("IP address:" +IP); System.out.println ("| Device status:" +devwork.dwdevicestatic);//0 Normal, 1CPU high occupancy, 2 hardware error, 3 unknown//display analog channel for (int i=0;i< devinfo.bychannum;i++) {System.out.print ("camera" +i+1);//analog channel number name System.out.print ("| Whether recording:" + devwork.struchanstatic[i].byrecordstatic);//0 does not record, does not record System.out.print ("| Signal status:" +devwork.struchanstatic[i]. bysignalstatic);//0 Normal, 1 signal loss System.out.println ("| Hardware status:" +devwork.struchanstatic[i].byhardwarestatic);//0 Normal, 1 exception} Sdk.net_dvr_logout (UID); Sdk.net_dvr_cleanup ();}}

Output:

Java implementation of NVR/DVR equipment working condition acquisition

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.