Difference between revisions of "IVS Module"

From IVS Wiki
Jump to: navigation, search
(Usage)
 
(One intermediate revision by the same user not shown)
Line 556: Line 556:
 
===Example===
 
===Example===
 
<pre>ivs.factorydefault</pre>
 
<pre>ivs.factorydefault</pre>
 +
==loadconfig==
 +
===Usage===
 +
This function is used to load configuration data from a json formatted config file.
 +
===Parameters===
 +
<pre>loadconfig(configfilepath)</pre>
 +
{| class="wikitable"
 +
|-
 +
!Parameter
 +
!Type
 +
!Value
 +
!Required
 +
|-
 +
|configfilepath
 +
|string
 +
|Path to the configuration file.
 +
|Yes
 +
|-
 +
|}
 +
===Example===
 +
<pre>ivs.loadconfig("/usr/local/ivs/config/keypad.cfg")</pre>
 +
==saveconfig==
 +
===Usage===
 +
This function is used to save configuration data to a json formatted config file.
 +
 +
===Parameters===
 +
<pre>saveconfig(configarray,configfilepath)</pre>
 +
{| class="wikitable"
 +
|-
 +
!Parameter
 +
!Type
 +
!Value
 +
!Required
 +
|-
 +
|configarray
 +
|string
 +
|Array containing all configuration information with keys.
 +
|Yes
 +
|-
 +
|configfilepath
 +
|string
 +
|Path to the configuration file.
 +
|Yes
 +
|-
 +
|}
 +
===Example===
 +
<pre>ivs.saveconfig(keypadconfigarray,"/usr/local/ivs/config/keypad.cfg")</pre>

Latest revision as of 14:55, 19 August 2022

Contents

VALT Class

Class Specifications

Usage

Creates a class that is one instance of a connection to a VALT server. The below functions are all defined as part of the valt class and can be called.

Initiation

Upon initiation, the class will attempt to authenticate to the specified VALT server using the provided credentials. If authentication fails upon initiation or upon any further actions, the class will wait 30 seconds and then attempt to reauthenticate. Upon success, the class with reauthenticate every 24 hours.

Variables

Variable Type Value
username string Stores the username used to authenticate to VALT.
password string Stores the password used to authenticate to VALT.
baseurl String Stores the basic url to connect to valt. The url is composed of the valt server address. For example http://ivstest1.ad.ipivs.com/api/v3/
success_reauth_time int The number of seconds to wait before reauthenticating to VALT after a successful authentication. Default is 28800.
failure_reauth_time int The number of seconds to wait before reauthenticating to VALT after a failed authentication attempt. Default is 30.
accesstoken string Stores the current access token retrieved during the last successful authentication. This will be set to 0 upon a failed authentication attempt or an error during any other function.
lastauthtime time Stores the last epoch time when authentication was attempted.

Parameters

valt(server,username,password)
Parameter Type Value Required
server String IP address or DNS name of the Valt application server. Yes
username String Valt Username. Yes
password String Valt Password. Yes

Example

valt = ivs.valt("ivstest1.ad.ipivs.com","admin","admin")

auth

Usage

Connects to the Valt server. This function is executed automatically during initializaton.

Parameters

auth()

This function does not accept any parameters.

Example

valt.auth()

isrecording

Usage

Checks the state of a room and returns True if it is recording, or False if it is not. Returns 2 if an error is encountered.

Parameters

isrecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.isrecording(4):

getrecordingid

Usage

If the room is currently recording, it returns the ID of the active recording. You should check if the room is recording using the isrecording function prior to getting the recording ID.

Parameters

getrecordingid(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

current_recording = valt.getrecording(4)

startrecording

Usage

Starts a new recording in the specified room.

Parameters

startrecording(room,name,author)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes
name String The name that will be associated with the recording in Valt. Yes
author int The user id under which the recording should be started. If not specified, the recording will be started under the authenticated user. Must be specified as author= when calling the function. See the example below. No

Example

valt.startrecording(4,"My Recording",author=12)

stoprecording

Usage

Stops the current recording in the specified room.

Parameters

stoprecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.stoprecording(4)

pauserecording

Usage

Pauses the current recording in the specified room.

Parameters

pauserecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.pauserecording(4)

resumerecording

Usage

Unpauses the current recording in the specified room.

Parameters

resumerecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.resumerecording(4)

WARNING

As of the writing of this article, pausing and unpausing the recording will reset the duration timer for the recording. This may cause issues with inserting markers.

addmarker

Usage

Adds a marker to the recording in progress in the specified room.

Parameters

addmarker(room,markername,color,markertime)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes
markername String Name for the marker in the Valt application. Yes
color String Color for the marker, valid values are white, gray, red, yellow, purple, cyan, blue, green, and orange. If not specified, will default to red. No
markertime int Time index to insert the marker. If not specified will use the current time index. When specifying a marker time, you must also specify a color. No

Example

valt.addmarker(4,"My Marker","green",137)

getrecordingtime

Usage

Returns the current time value of the recording in the specified room. Primarily used by the add marker function to specify the time for the marker.

Parameters

getrecordingtime(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

current_recording_time = valt.getrecordingtime(4)

ispaused

Usage

Checks the state of a room and returns True if it is paused, or False if it is not.

Parameters

ispaused(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.ispaused(4):

islocked

Usage

Checks the state of a room and returns True if it is locked and False if it is not.

Parameters

islocked(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.islocked(4):

getcameras

Usage

Returns a nested list, containing details for the cameras in the specified room.

Parameters

getcameras(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

cameras = valt.getcameras(4)

getrooms

Usage

Returns a list of rooms if successful. Each list item is actually a dictionary containing information about that room.

Parameters

getrooms()

This function does not accept any parameters.

Example

rooms = valt.getrooms()

getschedule

Usage

Returns a nested list of all upcoming schedules for the specified room. The returned list contains the start and end time for each schedule.

Parameters

getschedule(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

schedules = valt.getschedule(4)

getroomname

Usage

Returns the name of the room in VALT.

Parameters

getroomname(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

roomname = valt.getroomname(4)

getusername

Usage

Returns the name of the user in VALT.

Parameters

getusername(user)
Parameter Type Value Required
user Integer The user number of the user in the Valt application. This must be the actual user ID number, not the user name. This can be obtained from the database. Yes

Example

username = valt.getusername(4)

getroomstatus

Usage

Returns a value indicating the current status of the room. This should be used instead of islocked, ispaused, or isrecording as it also includes better error handling.

Room Status Return Value
ERROR 0
Available 1
Recording 2
Paused 3
Locked 4
Prepared 5

Parameters

getroomstatus(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

roomstatus = valt.getroomstatus(4)

getusers

Usage

Function to return a list of users. Each list item is a dictionary with information about the user. Returns 0 on failure. Returns 99 if not currently authenticated to VALT.

Parameters

getusers()

This function does not accept any parameters.

Example

users = valt.getusers()

setsharing

Usage

Function changes/sets sharing permission on the specified recording. Users and groups must be passed as lists, encloded in []. Returns 0 on failure. Returns 99 if not currently authenticated to VALT.

Parameters

setsharing(recid,users=[],groups=[])
Parameter Type Value Required
recid Integer The recording number of the record in the Valt application. This must be the actual record ID number, not the record name. This can be obtained from the database. Yes
users list Comma separated list of users to be granted permission to the specified video. This must be the user ID number. This is an optional parameter and must be specified as users=[1,2,3,4].
No
groups list Comma separated list of groups to be granted permission to the specified video. This must be the groups ID number. This is an optional parameter and must be specified as groups=[1,2,3,4]. No

Example

valt.setsharing(176,users=[4,36,17,28],groups=[2,4])

lockroom

Usage

Locks the specified room.

Parameters

lockroom(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.lockroom(4)

unlockroom

Usage

Unlocks the specified room.

Parameters

unlockroom(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.unlockroom(4)

Other Functions

log

Usage

Used to to write log entries to a standard central log. This function is used by the valt class. This function writes a time stamp in YYYY-MM-DD HH:MM:SS format before each log entry.

Parameters

log(message,logpath)
Parameter Type Value Required
message string String to be written to the log. Yes
logpath string Local path to the log file. If not specified it will default to ivs.log in the same directory as the executed python program. No

Example

ivs.log("Room 127 Unlocked")

factorydefault

Usage

This function is specific to the use of IVS accessories. The factory default function restores all config files to a template and re-enables the web service. It then reboots the device. This function is currently only supported on the IVS Keypad and IVS Card Reader.

Example

ivs.factorydefault

loadconfig

Usage

This function is used to load configuration data from a json formatted config file.

Parameters

loadconfig(configfilepath)
Parameter Type Value Required
configfilepath string Path to the configuration file. Yes

Example

ivs.loadconfig("/usr/local/ivs/config/keypad.cfg")

saveconfig

Usage

This function is used to save configuration data to a json formatted config file.

Parameters

saveconfig(configarray,configfilepath)
Parameter Type Value Required
configarray string Array containing all configuration information with keys. Yes
configfilepath string Path to the configuration file. Yes

Example

ivs.saveconfig(keypadconfigarray,"/usr/local/ivs/config/keypad.cfg")