TENVIS JPT3815W Pan/Tilt Control Script

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
hunternet93
Posts: 5
Joined: Sat Feb 26, 2011 6:59 pm

TENVIS JPT3815W Pan/Tilt Control Script

Post by hunternet93 » Wed Jul 09, 2014 4:34 pm

I now have the super-cheap TENVIS JPT3815W pan/tilt camera working in ZoneMinder. My attached script allows ZM to control the camera's pan, tilt, and presets. If you need instructions on installing the script, please reply here and I'll add them.

(copy-pasting here because the attachment box apparently doesn't allow .pm or .txt)
Filename: TENVISJPT3815W.pm

Code: Select all

# ==========================================================================
#
# ZoneMinder Panasonic IP Control Protocol Module, $Date$, $Revision$
# Copyright (C) 2001-2008  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 module contains the implementation of the Panasonic IP camera control
# protocol
#
package ZoneMinder::Control::TENVISJPT3815W;

use 5.006;
use strict;
use warnings;

require ZoneMinder::Base;
require ZoneMinder::Control;

our @ISA = qw(ZoneMinder::Control);

# ==========================================================================
#
# TENVIS JPT2815W Control Protocol
#
# ==========================================================================

use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );

my $axis = 0;

sub new
{
    my $class = shift;
    my $id = shift;
    my $self = ZoneMinder::Control->new( $id );
    bless( $self, $class );
    srand( time() );
    return $self;
}

our $AUTOLOAD;

sub AUTOLOAD
{
    my $self = shift;
    my $class = ref($self) || croak( "$self not object" );
    my $name = $AUTOLOAD;
    $name =~ s/.*://;
    if ( exists($self->{$name}) )
    {
        return( $self->{$name} );
    }
    Fatal( "Can't access $name member of object of class $class" );
}

sub open
{
    my $self = shift;

    $self->loadMonitor();

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

    $self->{state} = 'open';
}

sub close
{
    my $self = shift;
    $self->{state} = 'closed';
}

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

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

sub sendCmd
{
    my $self = shift;
    my $cmd = shift;

    my $result = undef;

    printMsg( $cmd, "Tx" );

    my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
#    my $req = HTTP::Request->new( GET=>"http://10.99.2.191:7777/".$cmd );
#    $req->authorization_basic("admin", "admin");
    my $res = $self->{ua}->request($req);

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

    return( $result );
}

sub cameraReset
{
    my $self = shift;
    Debug( "Camera Reset" );
    my $cmd = "reboot.asp";
    $self->sendCmd( $cmd );
}

sub moveConUp
{
    my $self = shift;
    Debug( "Move Up" );
    $self->moveStop();
    $axis = 1;
    my $cmd = "media/?action=cmd&code=2&value=1";
    $self->sendCmd( $cmd );
}

sub moveConDown
{
    my $self = shift;
    Debug( "Move Down" );
    $self->moveStop();
    $axis = 2;
    my $cmd = "media/?action=cmd&code=2&value=2";
    $self->sendCmd( $cmd );
}

sub moveConLeft
{
    my $self = shift;
    Debug( "Move Left" );
    $self->moveStop();
    $axis = 4;
    my $cmd = "media/?action=cmd&code=2&value=4";
    $self->sendCmd( $cmd );
}

sub moveConRight
{
    my $self = shift;
    Debug( "Move Right" );
    $self->moveStop();
    $axis = 3;
    my $cmd = "media/?action=cmd&code=2&value=3";
    $self->sendCmd( $cmd );
}

sub moveStop
{
    my $self = shift;
    if ($axis != 0) {
        my $cmd = "media/?action=cmd&code=3&value=$axis";
        $self->sendCmd( $cmd );
        $axis = 0;
    }
}

sub presetSet
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Set Preset $preset" );
    my $cmd = "media/?action=cmd&code=11&value=$preset";
    $self->sendCmd( $cmd );
}

sub presetGoto
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Goto Preset $preset" );
    my $cmd = "media/?action=cmd&code=13&value=$preset";
    $self->sendCmd( $cmd );
}

1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

ZoneMinder::Database - Perl extension for blah blah blah

=head1 SYNOPSIS

  use ZoneMinder::Database;
  blah blah blah

=head1 DESCRIPTION

Stub documentation for ZoneMinder, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head2 EXPORT

None by default.



=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2001-2008  Philip Coombes

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.


=cu

SteveGilvarry
Posts: 409
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: TENVIS JPT3815W Pan/Tilt Control Script

Post by SteveGilvarry » Sun Jul 13, 2014 2:09 pm

Don't have PTZ but I believe the scripts all live here if you want to add to Github.

https://github.com/ZoneMinder/ZoneMinde ... er/Control
Production Zoneminder 1.30.0 + feature-h264-videostorage
3 Cameras (Dahua and Hikvision)
More Dev VM's than I care to count.

petegriggs
Posts: 2
Joined: Mon Sep 05, 2016 10:51 am

Re: TENVIS JPT3815W Pan/Tilt Control Script

Post by petegriggs » Thu Jan 26, 2017 9:26 am

Hello,

If you have install instructions that would be good? I can't seem to get it to work.

Best Wishes
Pete.

Verna
Posts: 2
Joined: Tue Jun 12, 2018 2:39 pm

Re: TENVIS JPT3815W Pan/Tilt Control Script

Post by Verna » Wed Jun 13, 2018 7:41 am

Hello mates!!

I have the same camera but I am unable to configurate it.
Can somebody help me to do that?
I need help with the script and with the steps to configurate it.

Many thanks in advance!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests