Merged in changes for enhanced triggers and showtext.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2061 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2006-11-16 11:32:56 +00:00
parent 3f785e52eb
commit fd0a44e816
4 changed files with 50 additions and 7 deletions

View File

@ -147,7 +147,7 @@ our $shm_data =
"trigger_score" => { "type"=>"int", "seq"=>$shm_seq++ },
"trigger_cause" => { "type"=>"char[32]", "seq"=>$shm_seq++ },
"trigger_text" => { "type"=>"char[256]", "seq"=>$shm_seq++ },
"trigger_showtext" => { "type"=>"char[32]", "seq"=>$shm_seq++ },
"trigger_showtext" => { "type"=>"char[256]", "seq"=>$shm_seq++ },
}
},
"end" => { "seq"=>$shm_seq++, "size"=> 0 }

View File

@ -151,6 +151,10 @@ sub putMessages
return( undef );
}
sub timedActions
{
}
sub DESTROY
{
}

View File

@ -46,7 +46,7 @@ sub new
{
my $class = shift;
my $path = shift;
my $self = (ZoneMinder::Trigger::Connection->new( @_ );
my $self = ZoneMinder::Trigger::Connection->new( @_ );
bless( $self, $class );
return $self;
}

View File

@ -59,9 +59,9 @@ push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel
use ZoneMinder;
use DBI;
use POSIX;
#use Socket;
use Data::Dumper;
use Time::HiRes qw( usleep );
$| = 1;
@ -248,6 +248,30 @@ while( 1 )
delete( $actions{$action_time} );
}
# Allow connections to do their own timed actions
foreach my $connection ( @connections )
{
my $messages = $connection->timedActions();
if ( defined($messages) )
{
foreach my $message ( @$messages )
{
handleMessage( $connection, $message );
}
}
}
foreach my $connection ( values(%spawned_connections) )
{
my $messages = $connection->timedActions();
if ( defined($messages) )
{
foreach my $message ( @$messages )
{
handleMessage( $connection, $message );
}
}
}
# If necessary reload monitors
if ( (time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL )
{
@ -351,13 +375,28 @@ sub handleMessage
if ( $trigger eq "on" )
{
zmTriggerEventOn( $monitor, $score, $cause, $text );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Trigger '$trigger' '$cause'\n" );
}
elsif ( $trigger eq "off" )
{
my $last_event = zmGetLastEvent( $monitor );
zmTriggerEventOff( $monitor );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Trigger '$trigger'\n" );
# Wait til it's finished
while( zmInAlarm( $monitor ) && ($last_event == zmGetLastEvent( $monitor )) )
{
# Tenth of a second
usleep( 100000 );
}
zmTriggerEventCancel( $monitor );
}
else
{
zmTriggerEventOff( $monitor );
Info( "Trigger '$trigger'\n" );
zmTriggerEventCancel( $monitor );
}
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Triggered event '$trigger' '$cause'\n" );
if ( $delay )
{
my $action_time = time()+$delay;
@ -376,7 +415,7 @@ sub handleMessage
{
zmTriggerEventCancel( $monitor );
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
Info( "Cancelled event '$cause'\n" );
Info( "Cancelled event\n" );
}
elsif( $action eq "show" )
{