Genius Vision
日本語
  • Home
  • Products
    • NVR Subscription Edition
      • NVR Lite
      • NVR Enterprise (x64)
      • Community
      • Community (x64)
      • Hybrid Option
  • Services
    • Community Platform
    • Example System
    • ONVIF
    • Consultancy>
      • SDK
      • Remote Assistance
      • Software Modification
  • About Us
    • Track Records
    • Featured Installations
  • Documentation
  • FAQ
  • How to Buy
  • Contact Us
Example System / Genius Vision SDK Documentation

Search by question:   

Genius Vision SDK Documentation

Genius Vision SDK Documentation

Copyright and Preface

Licensing Prerequisites

Purpose

Target audience

Copyright Notice & Disclaimer

Getting Started

Overview

GvClientX Control: Example Page

GvClientX Control: Example Page in Preview Browser

Insert an OBJECT tag for GvClientX control

Insert an OBJECT tag for GvLiveX control

Single-Sign-On Example with PHP

GvClientX Control References

Control Summary Information

Function OpenSimpleConsole()

Synopsis

Syntax

Parameters

Options

Function TakeJPEGSnapshot()

Synopsis

Syntax

Parameters

Function OpenFullConsole()

Synopsis

Syntax

Parameters

Remarks

Function OpenFullConsole2()

Synopsis

Syntax

Parameters

Remarks

See also

Function SetLanguage()

Synopsis

Syntax

Parameters

Remarks

Function ParseScalarTime()

Synopsis

Syntax

Parameters

Return Value

Function PlaySeek()

Synopsis

Syntax

Parameters

GvLiveX Control References

Control Summary Information

Function OpenSimpleConsole()

Synopsis

Syntax

Parameters

Options

Function SetLanguage()

Synopsis

Syntax

Parameters

Remarks

Function OpenControl()

Synopsis

Syntax

Parameters

Options

EventOptions

Function OpenLivePlayer()

Synopsis

Syntax

Parameters

Options

Function PtzControl()

Synopsis

Syntax

Parameters

PTZ Commands

Function ParseScalarTime()

Synopsis

Syntax

Parameters

Return Value

Function FormatScalarTime()

Synopsis

Syntax

Parameters

Return Value

Function OpenQueryQueue()

Synopsis

Syntax

Parameters

Function QueryEvent()

Synopsis

Syntax

Parameters

Event Object Reference

DeviceInfo Reference

How to use SDK to receive and query events

Introduction

Establishing Control Connection

Getting Channel Events

DeviceInfo Overview

How to open multiple live view windows (and from multiple NVR servers)

Switching between multi-channel 2x2 layout and 3x3 layout

How to query archived events

How to query live alarm information and receive notification

How to control remote PTZ camera


Copyright and Preface

Licensing Prerequisites

You are required to sign the "SDK Licensing Terms" document (a separate legal document, available upon request) and acquire the rights to use the SDK, before you can proceed with reading and using any materials specified in this document. If you have not yet signed the "SDK Licensing Terms", then you are not authorized to use this SDK/API or any information in it. In this case, You should not retain any copies of related materials as well.

Purpose

The GvLiveX SDK is for ActiveX/Web based integration and allows third-party to write simple programs to manipulate the Genius Vision NVR client-side functions externally.

Target audience

You need to have basic understanding of HTML and web client-side (JavaScript) scripting in order to understand this section.

Copyright Notice & Disclaimer

The "Software" or "SDK" are proprietary properties of "Genius Vision Inc." It is a violation of international copyright law to redistribute or reverse-engineer the software without explicit permission from Genius Vision Inc. We reserve all rights to the software except for the online evaluation demonstration purpose.

 

Following is the no warranty disclaimer to give forward warning to users that are about to use the "Software", given by Genius Vision Inc. as a commercial software developer in good will:

 

Genius Vision Inc. develops commercial software in the hope that it will be useful. However all commercial software vendors, including Genius Vision Inc., cannot and will not guarantee the "Software" itself is free of defects or vulnerabilities. We exclude the implied warranty of (1) fitness for a particular purpose (2)merchantability (3) non-infringement. We WILL ALSO NOT be held liable in any damages that may be caused by non-malicious intentions. Therefore before you put the "Software" into serious use, it is your sole responsibility to evaluate and ensure its fitness.

 

In the situation of SDK interface, we do not guarantee that (1) the interface do not change (2) give notification upon notification.

 

If bugs or defects are found, we are willing to fix them with or without fees in the commercially reasonable terms.


Getting Started

Overview

There are two main ActiveX control in GvClientX SDK. Their usage scenario and characteristics are compared as follows:

Aspect

GvClientX Control

GvLiveX Control

Code size

Larger

Smaller

Functions

Full client functions.

Very limited functions, mainly: play live video.

See also:

  • GvLiveX Control References
  • GvClientX Control References

GvClientX Control: Example Page

<HTML>
<BODY>
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvActiveXHost" CLASSID="CLSID:D42DC89F-7570-42E0-87B3-43D7437DC28C"
         CODEBASE="GvClientX146.cab#Version=1,0,0,146" width=800 height=600></OBJECT>

<script language="JavaScript">
function getSelectedCh()
{
        var p = document.all("chs");
        var val = p.options[p.selectedIndex].innerText;
        return val;
}

function getSelectedHost()
{
        var p = document.all("hosts");
        var val = p.options[p.selectedIndex].innerText;
        return val;
}

function OpenSimpCon()
{
        GvActiveXHost.OpenSimpleConsole(getSelectedHost(), 3557, "admin", "1234", getSelectedCh(), ":embed:");
}

function OpenFullCon()
{
        GvActiveXHost.OpenFullConsole(getSelectedHost(), 3557,  "");
}

function TakeSnapshot()
{
        GvActiveXHost.TakeJPEGSnapshot("c:\\GvClient.jpg", "");
}

function SerialPtz(str, p1, p2)
{
        GvActiveXHost.SerialPtzControl(str, p1, p2);
}

function getSelectedLang()
{
        var p = document.all("lang");
        var val = p.options[p.selectedIndex].innerText;
        return val;
}

function ChangeLang()
{
        GvActiveXHost.SetLanguage(getSelectedLang());
}
</script>
<p>
Remote Host
<SELECT name="hosts" id="hosts">
<OPTION>192.168.0.8</OPTION>
<OPTION>127.0.0.1</OPTION>
<OPTION>192.168.1.8</OPTION>
<OPTION>192.168.1.8</OPTION>
<OPTION>220.130.142.167</OPTION>
</SELECT><br>
Channel
<SELECT name="chs" id="chs">
<OPTION>C1010</OPTION>
<OPTION>C1013</OPTION>
</SELECT><br>
<input type=Button onclick="OpenSimpCon()" value="1. OpenSimpleConsole">
<input type=Button onclick="TakeSnapshot()" value="2. TakeJPEGSnapshot">
<input type=Button onclick="SerialPtz('TILTUP', 1, 0)" value="SerialPtzControl.Up">
<input type=Button onclick="SerialPtz('PANTILTSTOP', 0, 0)" value="SerialPtzControl.Stop">
<input type=Button onclick="SerialPtz('TILTDOWN', 1, 0)" value="SerialPtzControl.Down">
<input type=Button onclick="SerialPtz('PRESETGOTO', 1, 0)" value="SerialPtzControl.Preset.1">
<input type=Button onclick="SerialPtz('PRESETGOTO', 2, 0)" value="SerialPtzControl.Preset.2">
<input type=Button onclick="OpenFullCon()" value="1. OpenFullConsole">
<br>
<h2>Change Active Language</h2>
<SELECT name="lang" id="lang">
<OPTION>Cht</OPTION>
<OPTION>En</OPTION>
</SELECT><br>
<input type=Button onclick="ChangeLang()" value="SetLanguage">
</BODY>
</HTML>

GvClientX Control: Example Page in Preview Browser

The HTML code illustrated above looks like the following picture when viewed in browser. Provided the GvClientX Control is properly installed.

Insert an OBJECT tag for GvClientX control

To insert an ActiveX control, use following HTML syntax:

<OBJECT ID="GvActiveXHost" CLASSID="CLSID:D42DC89F-7570-42E0-87B3-43D7437DC28C"
                 CODEBASE="GvClientX146.cab#Version=1,0,0,146" width=500 height=500></OBJECT>

The "CODEBASE" is optional if you wish to do over-the-web install mechanism, by which you have to put the .cab file into the correct path of the web server. The above is only an example. One should replace "146" (two occurrences) into proper version numbers.

Insert an OBJECT tag for GvLiveX control

Similar to the example above, the GvLiveX Control is inserted in following OBJECT syntax:

<OBJECT ID="GvActiveXHost" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35"  
CODEBASE="/redist/GvLiveX.cab#Version=1,0,0,234" width=550 height=410></OBJECT>

The above is only an example. One should replace "234" into proper version numbers.

Single-Sign-On Example with PHP

Following example demonstrate how to use PHP to generate a remote-client web page that by-passes Genius Vision NVR password-login.

<?php
try
{
global $user;
$obj = new COM("GvActiveX.GvServerComm");
$obj->SetAuthorizeKey(<correct_auth_key_value>);
$obj->SetSingleSignOn(session_id(), $user->name, $_SERVER["REMOTE_ADDR"]);
$status = $obj->GetProperty("ControlCenterStatus");
$the_user = $user->name;
if ($status=="") $status = "Offline";
?>
<p><strong>Server status: <?php echo $status; ?></strong>
<p><strong>User logged on: <?php echo $the_user; ?></strong>
<?php
if ($status=="Active")
{
?>
<p><strong>伺服器正常運行中</strong>
<p>If you can see the version number, the component is properly installed.
<p>若您已經能看見版本號碼,代表安裝已經完成。
<p>
<OBJECT ID="GvActiveXHost" CLASSID="CLSID:D42DC89F-7570-42E0-87B3-43D7437DC28C"
CODEBASE="/drupal/system/files/GvClientX200.cab#Version=1,0,0,200" width=500 height=100></OBJECT>
<div id="divConnect" style="color: navy">
<p><strong>Click "Connect" button to start</strong>
<p><strong>請按以下"Connect"按鈕開始程序</strong>
<p><input type=button id="btnConnect" onclick="doConnect('220.130.142.167', 'C1010','')" value="Connect SpeedDOM"></input>
<script language="JavaScript">
function doConnect(host, ch, options)
{
        options += ":low_speed:";
        var ssoKey = "<?php echo session_id(); ?>";
        var username = "<?php echo $user->name; ?>";
        GvActiveXHost.SetProperty("domain.remote.host", host, "");
        GvActiveXHost.SetProperty("domain.remote.port", "3557", "");
        GvActiveXHost.SetProperty("simpcon.channel", ch, "");
        GvActiveXHost.SetProperty("simpcon.ssokey", ssoKey, "");
        GvActiveXHost.SetProperty("simpcon.username", username, "");
        GvActiveXHost.SetProperty("simpcon.options", options, "");
        GvActiveXHost.InvokeMacro("i0.cx.11");
}
</script>

<?php
}
else
{
?>
<p><strong>注意:伺服器尚未啟動。</strong>
<p>We're sorry but the server is not currently online. Please contact the administrator for demo. In the meanwhile, you may choose to download and install the client component first, in case the server may be online at later anytime.
<p>很抱歉,但現在伺服器並未開啟,請聯絡系統管理員。建議您可以先行下載安裝用戶端元件,也許伺服器待會就會上線。
<?php
}
}
catch(Exception $e)
{
?>
<p>We're sorry but the demo server is not currently online (disabled). Please contact the administrator for demo. In the meanwhile, you may choose to download and install the client component first, in case the server may be online at later anytime.
<p>很抱歉,但現在展示伺服器並未開啟,請聯絡系統管理員。建議您可以先行下載安裝用戶端元件,也許伺服器待會就會上線。
<?php
}
?>

Note you need to change <correct_auth_key_value> to correct value. You need to contact software vendor to do that.


GvClientX Control References

This document is part of GvClientX SDK. Read "SDK Licensing Terms" before use.

Control Summary Information

Class ID

D42DC89F-7570-42E0-87B3-43D7437DC28C

Licensing Term

Requires signing SDK Licensing Terms

Availability

<NVR_Program_Installation_Dir>\Redist\GvClientX<Version>.CAB

Introduction

Provides full-function Genius Vision NVR remote client. Features:

  • Simple-console (single video window), embedded or pop-up
  • Full-console.
  • Full-console with single-sign-on.
  • Installation allows client to playback .XGV file

Function OpenSimpleConsole()

Synopsis

This function opens a console window. Other client-based function is not available to use before this function is called.

Syntax

GvActiveXHost.OpenSimpleConsole(<RemoteHost>, <Port>, <UserName>, <Password>, <Channel>, <Options>);

Parameters

Parameters

Data Type

Description

RemoteHost

String

Identifies the remote host, in IP address.

Port

Integer

TCP/IP port. Default port of Genius Vision NVR service is 3557.

UserName

String

The user name.

Password

String

The password, in plain text.

Channel

String

The channel name identifier.

Options

String

Additional options. See "Options" sections for details.

Options

Some options can be specified together. To specify two or more options, simply concatenating the option strings into the final string value.

Option

Description

:embed:

Specify this option if you want the control to be embedded in the web page

:resolve:

Resolve  "RemoteHost" through DNS. If one don't specify this option, RemoteHost can only be IP address, not host names.

:audio:

Initialize the console with audio rendering default enabled.

:low_speed:

Specify this option to skip the initial GOV to be dispatched. This may, however, introduce certain initial video delay. May be used when network bandwidth is a under consideration.

:min_menu:

Minimal player menu.

:no_menu:

Display player menu.

:no_snapshot:

Disable snapshot function.

:no_export:

Disable export footage function.

Function TakeJPEGSnapshot()

Synopsis

This function captures a single JPEG frame from the console player window and store in a specified file path.

Syntax

GvActiveXHost.TakeJPEGSnapshot(<FilePath>, <Options>);

Parameters

Parameters

Data Type

Description

FilePath

String

Specifies the file path of the JPEG file to be captured.

Options

String

Reserved for future use. Should be an empty string ("") for current version.

Function OpenFullConsole()

Synopsis

This function opens a remote full console window. This function cannot be used with other SDK client controls (since the full console has taken full control). To use other client-based control function, use OpenSimpleConsole() instead.

Syntax

GvActiveXHost.OpenFullConsole(<RemoteHost>, <Port>, <Options>);

Parameters

Parameters

Data Type

Description

RemoteHost

String

Identifies the remote host, in IP address.

Port

Integer

TCP/IP port. Default port of Genius Vision NVR service is 3557.

Options

String

Reserved for future use. Should be an empty string ("") for current version.

Remarks

Depending on actual licensing scheme, this function may NOT be available.

Function OpenFullConsole2()

Synopsis

Extended version of OpenFullConsole().

Syntax

GvActiveXHost.OpenFullConsole2(<RemoteHost>, <Port>, <UserName>, <Password>, <SsoKey>, <Options>);

Parameters

Parameters

Data Type

Description

RemoteHost

String

Identifies the remote host, in IP address.

Port

Integer

TCP/IP port. Default port of Genius Vision NVR service is 3557.

UserName

String

User name

Password

String

Password

SsoKey

String

Single-Sign-On key. Refer to GvServerComm.SetSingleSignOn() for more information.

Options

String

Reserved for future use. Should be an empty string ("") for current version.

Remarks

Depending on actual licensing scheme, this function may NOT be available.

See also

  • GvServerComm.SetSingleSignOn()
  • Single-Sign-On Example with PHP

Function SetLanguage()

Synopsis

Changes active language for GUI.

Syntax

GvActiveXHost.SetLanguage(<Language>);

Parameters

Parameters

Data Type

Description

Language

String

Current valid values are

  • "En": English
  • "Cht": Traditional Chinese

Remarks

The change only take effect in client side, not in server side.

Function ParseScalarTime()

Synopsis

Converts Year/Month/Day/Hour/Minute/Second into a Scalar Time value.

Syntax

<ScalarTime> = GvActiveXHost.ParseScalarTime(<Year>, <Month>, <Day>, <Hour>, <Minute>, <Second>);

Parameters

Parameters

Data Type

Description

Year/Month/Day

Integer

Year, month, and day in integer.

Hour/Minute/Second

Integer

Hour, minute, and second in integer.

Return Value

Scalar Time, which is floating-point (double) typed value.

Function PlaySeek()

Synopsis

Seek to a specified time to playback.

Syntax

GvActiveXHost.PlaySeek(<Time>, <Options>);

Parameters

Parameters

Data Type

Description

Time

Double

Time represented in Scalar Time. Please use ParseScalarTime().

Options

String

Not currently used. Must be empty string.


GvLiveX Control References

This document is part of GvClientX SDK. Read "SDK Licensing Terms" before use.

Control Summary Information

Class ID

bf863957-f6a7-4a3b-bd23-523b1fc47d35

Licensing Term

Requires signing SDK Licensing Terms

Availability

<NVR_Program_Installation_Dir>\Redist\GvLiveX.CAB

Introduction

Provides embedded live viewing of remote Genius Vision NVR.

Function OpenSimpleConsole()

Synopsis

This function opens a console window, or embed a window inside the control. This function can be called repeatedly. A call to this function will reset effect of previous call.

Syntax

GvActiveXHost.OpenSimpleConsole(<RemoteHost>, <Port>, <UserName>, <Password>, <Channel>, <Options>);

Parameters

Parameters

Data Type

Description

RemoteHost

String

Identifies the remote host, in IP address. If you wish to specify domain name, you need to add ":resolve:" option to "Options" parameter.

Port

Integer

TCP/IP port. Default port of Genius Vision NVR service is 3557.

UserName

String

The user name.

Password

String

The password, in plain text.

Channel

String

The channel name identifier.

Options

String

Additional options. See "Options" sections for details.

Options

Some options can be specified together. To specify two or more options, simply concatenating the option strings into the final string value.

Option

Description

:embed:

Specify this option if you want the control to be embedded in the web page

:resolve:

Resolve  "RemoteHost" through DNS. If one does not specify this option, RemoteHost can only be IP address, not host names.

:stretch:

Strech video to window size. Without this option, video is displayed as the original video size.

Function SetLanguage()

Synopsis

Changes active language for GUI.

Syntax

GvActiveXHost.SetLanguage(<Language>);

Parameters

Parameters

Description

Language

Current valid values are

  • "En": English
  • "Cht": Traditional Chinese

Remarks

The change only take effect in client side, not in server side.

Function OpenControl()

Synopsis

Creates a control connection toward the Genius Vision NVR server.

Syntax

GvActiveXHost.OpenControl(<Control>, <RemoteHost>, <Port>, <UserName>, <Password>, <Options>, <CallbackFunc>, <EventOptions>);

Parameters

Parameters

Data Type

Description

Control

String

Object name of this control connection.

RemoteHost

String

Identifies the remote host, in IP address. If you wish to specify domain name, you need to add ":resolve:" option to "Options" parameter.

Port

Integer

TCP/IP port. Default port of Genius Vision NVR service is 3557.

UserName

String

The user name.

Password

String

The password, in plain text.

Options

String

Additional options. See "Options" sections for details.

CallbackFunc

String

Callback script function name.

EventOptions

String

Options to specify event subscription. See "EventOptions" sections for details.

Options

Option

Description

:resolve:

Resolve  "RemoteHost" through DNS. If one don't specify this option, RemoteHost can only be IP address, not host names.

EventOptions

Option

Description

:conn:

Connection events. Including "Connecting", "Connected", "Disconnected", "ConnectFailed".

:auth:

Authorization events. Including "UserAuthorized", "AccessDenied".

:chind=<channel>:

Channel indication events. Delivered by "SetDeviceInfo" and "ClearDeviceInfo"

:userlog:

Receive Userlog (such as alarm) update events.

:query:

Query all Userlog items at start. Must be used in conjunction with ":userlog:"

Function OpenLivePlayer()

Synopsis

Open a new live video player.

Syntax

GvActiveXHost.OpenLivePlayer(<Control>, <Player>, <Channel>, <x>, <y>, <width>, <height>, <Options>);

Parameters

Parameters

Data Type

Description

Control

String

Name of the control connection.

Player

String

Name of the player.

x, y, width, height

Integer

Location of the newly opened player.

Options

String

Additional options. See "Options" sections for details.

Options

Some options can be specified together. To specify two or more options, simply concatenating the option strings into the final string vaue.

Option

Description

:embed:

Specify this option if you want the control to be embedded in the web page

:fast:

Use DirectX to render instead of GDI, which will be faster.

:stretch:

Stretch video to window size. Without this option, video is displayed as the original video size.

:auto_fit:

Automatically fit window to parent window size.

Function PtzControl()

Synopsis

執行PTZ控制操作。

Syntax

GvActiveXHost.PtzControl(<Control>, <Channel>, <Command>, <Value>, <dx>, <dy>);

Parameters

Parameters

Description

Control

Name of the control connection.

Channel

Name of the channel.

Command

PTZ command, please refer to next table.

Value

A parameter that might be required by the PTZ command.

dx, dy

Not used for now, must be zeroes.

PTZ Commands

Command

Description

Mv:Dir:<Num>

Move by direction. <Num> specify direction number. If the PTZ camera is a 8-direction one, then <Num> ranges from 0 to 7, if 4-direction one, <Num> ranges from 0 to 3.

Stop

Stop all PTZ commands.

Mv:ZI

Zoom-in.

Mv:ZO

Zoom-out.

Mv:Wheel

Zoom-in or out, depending on the sign (positive or negative) of the Value.

Pset:Set

Preset set, Value specifies preset number.

Pset:Recall

Preset recall, Value specifies preset nubmer.

Function ParseScalarTime()

Synopsis

Converts year/month/day/hour/minute/second to Scalar Time.

Syntax

<ScalarTime> = GvActiveXHost.ParseScalarTime(<Year>, <Month>, <Day>, <Hour>, <Minute>, <Second>);

Parameters

Parameters

Data Type

Description

Year/Month/Day

Integer

年/月/日

Hour/Minute/Second

Integer

時/分/秒

Return Value

Scalar Time,其為浮點數double型態。

Function FormatScalarTime()

Synopsis

Convert Scalar Time to string format.

Syntax

<FormattedDateTime> = GvActiveXHost.FormatScalarTime(<ScalarTime>);

Parameters

Parameters

Data Type

Description

ScalarTime

Double

Scalar Time, which is a floating point (double) typed scalar date/time value.

Return Value

String will be formatted in this manner: YYYY-MM-DD HH:NN:SS

“NN” means minutes.

Function OpenQueryQueue()

Synopsis

Open query queue.

 

Commands issued to a particular queue will be executed in first-in-first-out order. You can also open different queues for concurrent operations.

Syntax

GvActiveXHost.OpenQueryQueue(<Control>, <Query>, <CallbackFunc>, <Options>);

Parameters

Parameters

Data Type

Description

Control

String

Name of the control connection. The reference object must be pre-existing.

Query

String

Name of the query queue object to be created.

CallbackFunc

String

The callback function name.

Options

String

Extra options.

Function QueryEvent()

Synopsis

Query archived events.

Syntax

GvActiveXHost.QueryEvent(<Query>, <Cookie>, <Channel>, <StartTime>, <EndTime>);

Parameters

Parameters

Data Type

Description

Query

String

Name of the query queue object. The referenced object must be pre-existing.

Cookie

String

The cookie of current query. This value will be passed to CallbackFunc for reference.

Channel

String

Name of the target channel.

StartTime

Double

Start time. Type is of “Scalar Time”

EndTime

Double

End time. Type is of “Scalar Time”


Event Object Reference

Field

Description

Availability

Type

Data type, can be one of the following

  • Event
  • DataEntry
  • Query

Always available.

Event

Event type, when Type=Event, this value can be one of the following values:

  • Connecting - Connecting(EventOptions must include ":conn:")
  • Connected - Connected(EventOptions must include ":conn:")
  • ConnectFailed - Connection request failed(EventOptions must include ":conn:")
  • Disconnected - Disconnected but is attempting to reconnect(EventOptions must include ":conn:")
  • UserAuthorized - User authorized. (EventOptions must include ":auth:")
  • AccessDenid - Access is denied (EventOptions must include":auth:")
  • SetDeviceInfo - Set of DeviceInfo value (EventOptions must include":chind=<channel_name>:")
  • ClearDeviceInfo - Clear of DeviceInfo range (EventOptions must include":chind=<channel_name>:")

Event type, when Type=Query, this value can be one of the following values:

  • BeginQuery - Begin of query data retrieval.
  • EndQuery - End of query data retrieval.
  • Query.Event - Retrieving query event data.

Type=Event|Query

Tag1

When Event=SetDeviceInfo, this value is the channel name of the SetDeviceInfo directive.

When Event=ClearDeviceInfo時, this value is the channel name of the ClearDeviceInfo directive.

Type=Event , Event=SetDeviceInfo|ClearDeviceInfo

Tag2

When Event=SetDeviceInfo, this value specify the parameter name to set.

When Event=ClearDeviceInfo, this value specify the parameter name prefix to be cleared (deleted).

Type=Event , Event=SetDeviceInfo|ClearDeviceInfo

Tag3

When Event=SetDeviceInfo, this value is the desired value to be set into the parameter.

Type=Event , Event=SetDeviceInfo

EntryType

Type of an DataEntry, can be one of following value:

  • GV_Userlog - If it’s an Userlog.

Type=DataEntry

Key

The primary key of DataEntry.

Type=DataEntry

UserlogType

Type of Userlog, can be one of the following:

  • Alarm - Indicate the record is an alarm.
  • Warn - Indicate the record is an warning message.
  • Info - Indicate the record is an informative message.

Type=DataEntry, EntryType=GV_Userlog

Time

Creation time of the Userlog record.

Type=DataEntry, EntryType=GV_Userlog

MessageRid

Message resource identifier of an Userlog.

Type=DataEntry, EntryType=GV_Userlog

s_chname

Channel name associated with a Userlog record, if any.

Type=DataEntry, EntryType=GV_Userlog

s_user

User name associated with a Userlog record, if any.

Type=DataEntry, EntryType=GV_Userlog

AlarmTypes

Types of alarm included in in alarm instance. It could be any combination of following strings, delimited by semicolon:

  • Vloss
  • Activity

Type=DataEntry, EntryType=GV_Userlog, UserlogType=Alarm

AlarmState

State of an alarm record, can be one of the following value:

  • 0 - Indicate alarm is inactive or processed.
  • 1 - Indicate alarm is “in-progress”.
  • 2 - Indicate alarm is “active”.

Type=DataEntry, EntryType=GV_Userlog, UserlogType=Alarm

EventType

Type of event:

  • ULG - User login interval.
  • MD - Motion detection interval.
  • SysOff1 - Normal system shutdown interval.
  • SysOff2 - Abnormal system shutdown interval.
  • VL - Video loss interval.
  • SR - Scheduled recording interval.
  • PZ - PTZ operation interval.
  • MR - Manual recording interval.
  • UR - Any recording interval.

Type=Query, Event=Query.Event

StartTime

Start time of an event.

Type=Query, Event=Query.Event

EndTime

End time of an event.

Type=Query, Event=Query.Event

F1

Data field 1 of an event

  • If EventType=ULG, this value specifies user name associated.

Type=Query, Event=Query.Event

F2

Data field 2 of an event

  • If EventType=ULG, this value specifies the client IP address of the logged-in user.

Type=Query, Event=Query.Event

F3

Data field 3 of an event, currently unused.

Type=Query, Event=Query.Event


DeviceInfo Reference

DeviceInfo

Meaning

Possible values

cind.rec

Recording indication.

0, 1

cind.alarm

Channel alarm indication.

0, 1, 2

cind.disabled

Channel disable indication.

0, 1

cind.vloss

Channel video loss indication.

0, 1

ptz.enabled

PTZ support indication.

0, 1

ptz.direction

PTZ number of directions.

4, 8

ptz.levels

PTZ number of speed levels.

(Positive integer)

dev.model

Device model (if any)

(String description)

dev.ioport.<num>.id

IO port identifier

(String description)

dev.ioport.<num>.dir

IO port type (in or out)

in, out

dev.ioport.<num>.state

IO port state

0, 1


How to use SDK to receive and query events

This document is part of GvClientX SDK. Read "SDK Licensing Terms" before use.

Note: Some parts of this section is not yet translated to English. If you need the English translation urgently, please contact us.

Introduction

Newer version of GvLiveX component provides methods to support event notification and query. This article will demonstrate how to use it.

 

See also:

  • GvLiveX Control References
  • Getting Started with GvClientX SDK

Establishing Control Connection

Following example is copied from sdk_samples/event_test1.htm

<HTML>
<BODY onload="OpenSimpConEx()">
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvLiveX" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35" width=500 height=500></OBJECT>

<script language="JavaScript">
function OpenSimpConEx()
{
        GvLiveX.OpenControl("Control", "127.0.0.1", 3557, "admin", "1234", "", "eventFunc", ":auth:");
}

function eventFunc(eventObj)
{
        var s = eventObj.Dump();
        alert(s);
}
</script>

Please note that:

  • "Control" means the control connection object name. You will need this name in other context to reference the control connection.
  • "eventFunc" is the name of the callback function. Please note this function should only have one parameter eventObj, which points to an event object containing all details of the event. If you are not sure about the event detail you can use Dump() method of the event object, it will return a text representation of the event object.
  • ":auth:" part is to select which kinds of event to subscribe. (Please refer to EventOptions)

 

After the execution of the above page, following result may appear:

 

This tells us inside eventFunc, we can access eventObj in the following way:

  • eventObj.Type (the value is “Event”)
  • eventObj.Event (the value is “UserAuthorized”)
  • eventObj.Tag1 (the value is an empty string)
  • eventObj.Tag2 (the value is an empty string)
  • eventObj.Tag3 (the value is an empty string)

See also: GvLiveX.OpenControl()

Getting Channel Events

Following code is from sample code sdk_samples/event_test2.htm

<HTML>
<BODY onload="OpenSimpConEx()">
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvLiveX" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35" width=500 height=500></OBJECT>

<script language="JavaScript">
function OpenSimpConEx()
{
        GvLiveX.OpenControl("Control", "127.0.0.1", 3557, "admin", "1234", "", "eventFunc", ":auth:chind=AAA:");
}

function eventFunc(eventObj)
{
        var s = eventObj.Dump();
        alert(s);
}
</script>

In the example above, please note that we added ":chind=AAA:" to EventOptions. “AAA” is a channel name and this writing means you are interested to subscribe event notification about this particular channel. (for example, is there an alarm? is the channel is recording? or other kinds of detailed status information)

 

You will get results similar to the following after executing the example above:

With some additional other SetDeviceInfo alert pop-ups.

DeviceInfo Overview

This section will describe the meaning of DeviceInfo.

 

DeviceInfo is an important information transmission path throughout the Genius Vision NVR system. It mainly reflects device status and is generated according to the device (camera) characteristics. There are two major notification directives: SetDeviceInfo and ClearDeviceInfo.

  • SetDeviceInfo: To set a DeviceInfo value. Tag1 is the channel. Tag2 is the name of the value to set. Tag3 is the value.
  • ClearDeviceInfo: To clear a range of DeviceInfo values. Tag1 is the channel. Tag2 is the prefix of the range to be cleared. (For example if Tag2 is "cind.", then all DeviceInfo entries with name starting with "cind." will be cleared (deleted).

 

The meaning of DeviceInfo please refer to DeviceInfo Definitions.

 

Please note that there could be new DeviceInfo definition as the software is updating to newer versions. Thus developer should ignore unrecognized DeviceInfo directives.

How to open multiple live view windows (and from multiple NVR servers)

Following code is from sample code sdk_samples/event_test3.htm

<HTML>
<BODY onload="OpenSimpConEx()">
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvLiveX" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35" width=400 height=400></OBJECT>

<script language="JavaScript">
function OpenSimpConEx()
{
        GvLiveX.OpenControl("Control", "127.0.0.1", 3557, "admin", "1234", "", "", "");
        GvLiveX.OpenLivePlayer("Control", "Player1", "AAA", 0, 0, 200, 200, ":stretch:embed:");
        GvLiveX.OpenLivePlayer("Control", "Player2", "R2", 200, 0, 200, 200, ":stretch:embed:");

        GvLiveX.OpenControl("Control2", "192.168.0.5", 3557, "admin", "gv.net", "", "eventFunc", ":auth:");
        GvLiveX.OpenLivePlayer("Control2", "Player3", "C1008", 0, 200, 200, 200, ":stretch:embed:");
        GvLiveX.OpenLivePlayer("Control2", "Player4", "C1009", 200, 200, 200, 200, ":stretch:embed:");
}

</script>

以上範例建立兩個控制連線:Control及Control2,並建立四個LivePlayer:

  • Player1連到Control的AAA頻道。
  • Player2連到Control的R2頻道。
  • Player3連到Control2的C1008頻道。
  • Player4連到Control2的C1009頻道。

 

因此結果如下:

 

See also: GvLiveX.OpenControl(), GvLiveX.OpenLivePlayer()

Switching between multi-channel 2x2 layout and 3x3 layout

Please refer to sample code sdk_samples/event_test3a.htm

How to query archived events

Following code is from sample code sdk_samples/event_test4.htm

<HTML>
<BODY onload="OpenSimpConEx()">
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvLiveX" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35" width=400 height=400></OBJECT>

<script language="JavaScript">
function OpenSimpConEx()
{
        GvLiveX.OpenControl("Control", "127.0.0.1", 3557, "admin", "1234", "", "", "");

        Query();
}

function queryCB(eventObj)
{        
        var s = eventObj.Dump();
        if (eventObj.Event == "Query.Event")
        {
                var time = GvLiveX.FormatScalarTime(eventObj.StartTime) + " ~ " + GvLiveX.FormatScalarTime(eventObj.EndTime);
                s += ", FriendlyTime: " + time;
        }
        alert(s);
}

function Query()
{
        cntt = 0;
        GvLiveX.OpenQueryQueue("Control", "Query", "queryCB", "");
        GvLiveX.QueryEvent("Query", "ABC", "AAA", 0, GvLiveX.ParseScalarTime(2010, 10, 5, 22, 0, 0));
}

</script>

以上範例執行結果約如下(若有資料):

The above window will pop repeatedly for a number of times, depending on actual number of records returned.

 

本節重點整理如下:

  • 查詢歷史事件,係使用OpenQueryQueue()及QueryEvent()等API
  • 當收到開始查詢結果之初,將先收到"Event: BeginQuery",接著收到結果"Event: Query.Event",查詢結果之末,將收到"Event: EndQuery"
  • 內部時間為Scalar Time表示法,其係以一浮點數表示,轉換時須使用ParseScalarTime()以及FormatScalarTime()等API,例如GvLiveX.ParseScalarTime(2010, 10, 5, 22, 0, 0),將產生一Scalar Time為本地時間2010-10-05 22:00:00,若將該值調入FormatScalarTime()取值,將得到字串"2010-10-05 22:00:00"。

 

查詢結果各欄位說明如下:(請參閱事件物件定義表)

  • Cookie: 為當初輸入QueryEvent()之Cookie值,用以判別不同次的查詢。
  • BeginTime: 事件開始時間。
  • EndTime: 事件結束時間。
  • EventType: 事件類型ULG為使用者登入、MD為位移偵測、SysOff1為系統關機、SysOff2為系統不正常關機、VL為失去視訊、SR為預約錄影、PZ為PTZ攝影機遭移動、MR為手動錄影、UR為錄影(任何有錄影之區間)。
  • F1, F2, F3為相關資料欄位,依不同Type具不同意義。
  • Id: 為頻道名稱,若為"/Sys"則為系統相關。

How to query live alarm information and receive notification

Following code is from sample code sdk_samples/event_test5.htm

<HTML>
<BODY onload="OpenSimpConEx()">
<h2>GvClientX SDK Sample</h2>
<p>
<OBJECT ID="GvLiveX" CLASSID="CLSID:bf863957-f6a7-4a3b-bd23-523b1fc47d35" width=400 height=400></OBJECT>

<script language="JavaScript">
function OpenSimpConEx()
{
        GvLiveX.OpenControl("Control", "127.0.0.1", 3557, "admin", "1234", "", "eventFunc", ":userlog:");
}

function eventFunc(eventObj)
{
        alert(eventObj.Dump());
}

</script>

The "query alarm" operation actually queries "userlog" entries from NVR "System Briefcase", and also receives notification when the entry changes in real time. System briefcase is located in the highlighted area in the following picture:

 

以上程式執行後,若有警報狀態更新,或新警報產生,將會得到以下訊息:

 

本節重點整理如下:

  • 欲即時接收警報更新或產生,在OpenControl()之EventOptions中加入":userlog:"
  • 欲接收所有警報資訊,在OpenControl()之EventOptions中再加入":query:" (仍須配合":userlog:"使用之)

 

事件物件(eventObj)欄位說明如下:(請參閱事件物件定義表)

  • Type: Fixed value of “DataEntry”
  • UserlogType: Value “Alarm” indicates an alarm.
  • AlarmTypes: 警報類型,若為Vloss則為失去視訊。
  • AlarmState: 若為警報,則此表警報狀態,可能為0, 1, 2
  • MessageRid: 該條目之訊息。
  • Key: 該紀錄之唯一序號(鍵值)。

How to control remote PTZ camera

See also: GvLiveX.PtzControl()

Page  of

Copyright (C) by Genius Vision Inc., 2011-, all rights reserved. 前瞻視野股份有限公司 版權所有