Difference between revisions of "Gadspot"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 249: Line 249:
elsif ( $command eq "downright" )
elsif ( $command eq "downright" )
{
{
moveDownLeft();
moveDownRight();
}
}
else
else

Revision as of 15:08, 7 November 2006

The Gadspot GS-9603 and possibly others do work with Zoneminder.

Gadspot GS9603

To setup the Gadspot 9603 add a new monitor with the following settings:

[General]
Remote type: Remote

[Source]
Remote Host Name: Ip address of camera
Remote Host Port: normally 80 but if you changed it you need to update this to whatever you changed it to.

Remote Host Path: You have two options. for a stream use /getData.cgi for jpeg use /Jpeg/CamImg.jpg

Capture Width: needs to be the same as in the gadspot config: (640 is default)
Capture Height: need to be the same as in the gadspot config: (480 is default)


Controlling the GS9603

If you have control turned on in Options you can control the gadspot by enabling control in the control tab.

First off you will need to place the ZM control file in the directory where your zoneminder scripts are located. (Look for zmcontrol-*.pl files and paste the following to a script called zmcontrol-gadspot-v2.pl:

#!/usr/bin/perl -wT
#
# ==========================================================================
#
# ZoneMinder Axis HTTP API v2 Control Script, $Date: 2006/05/08 12:37:48 $, $Revision: 1.9 $
# Copyright (C) 2003, 2004, 2005, 2006  Philip Coombes
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ==========================================================================
#
# This script continuously monitors the recorded events for the given
# monitor and applies any filters which would delete and/or upload 
# matching events
#
use strict;

# ==========================================================================
#
# These are the elements you can edit to suit your installation
#
# ==========================================================================

use constant DBG_ID => "zmctrl-gadspot"; # Tag that appears in debug to identify source
use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug

# ==========================================================================

use ZoneMinder;
use Getopt::Long;

$| = 1;

$ENV{PATH}  = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};

sub Usage
{
	print( "
Usage: zmcontrol-gadspot-v2.pl <various options>
");
	exit( -1 );
}

zmDbgInit( DBG_ID, level=>DBG_LEVEL );

my $arg_string = join( " ", @ARGV );

my $address;
my $command;
my ( $speed, $step );
my ( $xcoord, $ycoord );
my ( $width, $height );
my ( $panspeed, $tiltspeed );
my ( $panstep, $tiltstep );
my $preset;

if ( !GetOptions(
	'address=s'=>\$address,
	'command=s'=>\$command,
	'speed=i'=>\$speed,
	'step=i'=>\$step,
	'xcoord=i'=>\$xcoord,
	'ycoord=i'=>\$ycoord,
	'width=i'=>\$width,
	'height=i'=>\$height,
	'panspeed=i'=>\$panspeed,
	'tiltspeed=i'=>\$tiltspeed,
	'panstep=i'=>\$panstep,
	'tiltstep=i'=>\$tiltstep,
	'preset=i'=>\$preset
	)
)
{
	Usage();
}

if ( !$address )
{
	Usage();
}

Debug( $arg_string."\n" );

srand( time() );

sub printMsg
{
	my $msg = shift;
	my $msg_len = length($msg);

	Debug( $msg."[".$msg_len."]\n" );
}

sub sendCmd
{
	my $cmd = shift;

	my $result = undef;

	printMsg( $cmd, "Tx" );

	use LWP::UserAgent;
	my $ua = LWP::UserAgent->new;
	$ua->agent( "ZoneMinder Control Agent/".ZM_VERSION );

	#print( "http://$address/$cmd\n" );
	my $req = HTTP::Request->new( GET=>"http://$address/$cmd" );
	my $res = $ua->request($req);

	if ( $res->is_success )
	{
		$result = !undef;
	}
	else
	{
		Error( "Error check failed: '".$res->status_line()."'\n" );
	}

	return( $result );
}


sub moveUp
{
	Debug( "Move Up\n" );
	my $cmd = "MoveCamera.cgi?Dir=Up";
	sendCmd( $cmd );
}

sub moveDown
{
	Debug( "Move Down\n" );
	my $cmd = "MoveCamera.cgi?Dir=Down";
	sendCmd( $cmd );
}

sub moveLeft
{
	Debug( "Move Left\n" );
	my $cmd = "MoveCamera.cgi?Dir=Left";
	sendCmd( $cmd );
}

sub moveRight
{
	Debug( "Move Right\n" );
	my $cmd = "MoveCamera.cgi?Dir=Right";
	sendCmd( $cmd );
}

sub moveUpRight
{
	Debug( "Move Up/Right\n" );
	my $cmd = "MoveCamera.cgi?Dir=RightUp";
	sendCmd( $cmd );
}

sub moveUpLeft
{
	Debug( "Move Up/Left\n" );
	my $cmd = "MoveCamera.cgi?Dir=LeftUp";
	sendCmd( $cmd );
}

sub moveDownRight
{
	Debug( "Move Down/Right\n" );
	 my $cmd = "MoveCamera.cgi?Dir=RightDown";
         sendCmd( $cmd );

}

sub moveDownLeft
{
	Debug( "Move Down/Left\n" );
	 my $cmd = "MoveCamera.cgi?Dir=LeftDown";
         sendCmd( $cmd );
}



if ( $command eq "up" )
{
	moveUp();
}
elsif ( $command eq "down" )
{
	moveDown();
}
elsif ( $command eq "left" )
{
	moveLeft();
}
elsif ( $command eq "right" )
{
	moveRight();
}
elsif ( $command eq "upleft" )
{
	moveUpLeft();
}
elsif ( $command eq "upright" )
{
	moveUpRight();
}
elsif ( $command eq "downleft" )
{
	moveDownLeft();
}
elsif ( $command eq "downright" )
{
	moveDownRight();
}
else
{
	Error( "Can't handle command $command\n" );
}

Now Click Edit on the Control Type line in the Monitor setup window's Control tab.

Click add new control when the window pops up.

You will want to set the Type to Remote.

Command: zmcontrol-gadspot-v2.pl (or whatever you named the file above.).

On the Move Tab check Can Move and Can move Diagonally (not sure if the second one is needed but it is in my config).

Now in the Pan tab check Can Pan.

In the Tilt tab check Can Tilt.

Save your settings and close out the add control window and the control list.

You will not want to save your monitor and then reopen it so that the gadspot will display in the Control Type pull down menu. If it is there select it. If not go back and find what you forgot.

Now your GS9603 should be ready to go. Open it up and click control at the top.

Enjoy!

EDIT by ddamron: I made some minor bug fixes to this script... please check.. perl reported 4 warnings about cmd$ being reassigned (or something like that)

Closer examination of my GS9603 (and the axel script) revealed that the command can be LeftUp, but not UpLeft.

Anywho, the above script now doesn't complain... cheers!