Page 1 of 1

Not sure what I broke but suddenly I can't control my PTZ :(

Posted: Mon May 04, 2009 9:05 pm
by carlo1973
Not sure what I broke but now I can't control the PTZ cam's on our network :(

Originally I had PTZ working for 3 cams in both WATCH and Montage view. Everything worked fine.

Sometime over the weekend the camera controls in the Montage page stoped working. I dont know what changed. I wasn't here. All I know is it worked friday and monday it wasn't working. No errors - just was defaulting back to the first camera in the list and not able to control them.

In the process of trying to fix this issue, I managed to fubar, bork, decafinate, and general overal kaplowied the controls within the WATCH portion. Now controls don't work period <man>
[/code]

I tried adjusting the settings in the PTZ controls and changed from Continuous to Relative and it changed from moveConup to MoveRelup but no difference. still not working.

the camera is a Panasonic PTZ camera. As I said it was working before.

my control script for the Panasonic PTZ camera is as follows:

Code: Select all

package ZoneMinder::Control::PanasonicIP;

use 5.006;
use strict;
use warnings;

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

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

our $VERSION = $ZoneMinder::Base::VERSION;

# ==========================================================================
#
# Panasonic IP Control Protocol
#
# ==========================================================================

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

use Time::HiRes qw( usleep );

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/".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 $res = $self->{ua}->request($req);

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

    return( $result );
}

sub cameraReset
{
    my $self = shift;
    Debug( "Camera Reset" );
    my $cmd = "nphRestart?PAGE=Restart&Restart=OK";
    $self->sendCmd( $cmd );
}


sub moveConUp
{
    my $self = shift;
    Debug( "Move Up" );
    my $cmd = "cgi-bin/camctrl?tilt=-1";
    $self->sendCmd( $cmd );
}

sub moveConDown
{
    my $self = shift;
    Debug( "Move Down" );
    my $cmd = "cgi-bin/camctrl?tilt=1";
    $self->sendCmd( $cmd );
}

sub moveConLeft
{
    my $self = shift;
    Debug( "Move Left" );
    my $cmd = "cgi-bin/camctrl?pan=-1";
    $self->sendCmd( $cmd );
}

sub moveConRight
{
    my $self = shift;
    Debug( "Move Right" );
    my $cmd = "cgi-bin/camctrl?pan=1";
    $self->sendCmd( $cmd );
}

sub moveMap
{
    my $self = shift;
    my $params = shift;
    my $xcoord = $self->getParam( $params, 'xcoord' );
    my $ycoord = $self->getParam( $params, 'ycoord' );
    Debug( "Move Map to $xcoord,$ycoord" );
    my $cmd = "cgi-bin/camctrl?nphControlCamera?Direction=Direct&NewPosition.x=$xcoord&NewPosition.y=$ycoord&Width=".$self->{Monitor}->{Width}."&Height=".$self->{Monitor}->{Height};
    $self->sendCmd( $cmd );
}

sub zoomConTele
{
    my $self = shift;
    my $params = shift;
    my $step = $self->getParam( $params, 'step' );
    Debug( "Zoom Tele" );
    my $cmd = "nphControlCamera?Direction=ZoomTele";
    $self->sendCmd( $cmd );
}

sub zoomConWide
{
    my $self = shift;
    my $params = shift;
    my $step = $self->getParam( $params, 'step' );
    Debug( "Zoom Wide" );
    my $cmd = "nphControlCamera?Direction=ZoomWide";
    $self->sendCmd( $cmd );
}

sub focusConNear
{
    my $self = shift;
    my $params = shift;
    my $step = $self->getParam( $params, 'step' );
    Debug( "Focus Near" );
    my $cmd = "nphControlCamera?Direction=FocusNear";
    $self->sendCmd( $cmd );
}

sub focusConFar
{
    my $self = shift;
    my $params = shift;
    my $step = $self->getParam( $params, 'step' );
    Debug( "Focus Far" );
    my $cmd = "nphControlCamera?Direction=FocusFar";
    $self->sendCmd( $cmd );
}

sub focusAuto
{
    my $self = shift;
    Debug( "Focus Auto" );
    my $cmd = "nphControlCamera?Direction=FocusAuto";
    $self->sendCmd( $cmd );
}

sub focusMan
{
    my $self = shift;
    Debug( "Focus Manual" );
    my $cmd = "/axis-cgi/com/ptz.cgi?autofocus=off";
    $self->sendCmd( $cmd );
}

sub presetClear
{

    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Clear Preset $preset" );
    my $cmd = "cgi-bin/camctrl?preset=scan";
    $self->sendCmd( $cmd );
}

sub presetSet
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Set Preset $preset" );
    my $cmd = "nphPresetNameCheck?PresetName=$preset&Data=$preset";
    $self->sendCmd( $cmd );
}

sub presetGoto
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Goto Preset $preset" );
    my $cmd = "cgi-bin/camctrl?preset=$preset";
    $self->sendCmd( $cmd );
}

sub presetHome
{
    my $self = shift;
    Debug( "Home Preset" );
    my $cmd = "cgi-bin/camctrl?preset=scan";
    $self->sendCmd( $cmd );
}

1;
__END__
Now your probably wondering why I have the home preset set to scan. Well my office really wanted a "Tour" option that steps through each of the presets on its own - this happend to be programed already into the camera and I'm just making use of it.

Also the other thing to note - I only changed the code to reflect the camera's controls. These camera's use cgi-bin/camctrl? for the controls.

Hope I can get help to solve this.

Posted: Mon May 04, 2009 9:29 pm
by cordel
Are you sure your in the right forum?
this looks like a script for an older version of ZM.

If you didn't change anything and it was working before I would check and be sure that there is not some old sockets laying about. Then up the debug and try moving the cam through the command line, you should get something back useful.

Posted: Tue May 05, 2009 12:58 pm
by carlo1973
cordel wrote:Are you sure your in the right forum?
this looks like a script for an older version of ZM.

If you didn't change anything and it was working before I would check and be sure that there is not some old sockets laying about. Then up the debug and try moving the cam through the command line, you should get something back useful.
I hope this is the right forum. I installed ZM 1.24.1 from source. I will try to kill those sockets. I did see quite a few laying there but wasn't sure if I should do anything with them or not. thanks for the tip I'll get back to you if it's still being weird lol

[edit]

For the PTZ controls in the WATCH view, got that working now. Turned out to be a permisions issue of all things. Got that fixed. However PTZ in Montage is still borked.