Bug 400 - Made signal check colour monitor specific.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2193 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2007-09-05 15:05:28 +00:00
parent ec3cef978e
commit 8d905aac99
7 changed files with 60 additions and 17 deletions

View File

@ -351,6 +351,7 @@ CREATE TABLE `Monitors` (
`DefaultView` enum('Events','Control') NOT NULL default 'Events',
`DefaultRate` smallint(5) unsigned NOT NULL default '100',
`DefaultScale` smallint(5) unsigned NOT NULL default '100',
`SignalCheckColour` varchar(32) NOT NULL default '#0100BE',
`WebColour` varchar(32) NOT NULL default 'red',
`Sequence` smallint(5) unsigned default NULL,
PRIMARY KEY (`Id`)

View File

@ -7,6 +7,11 @@
--
alter table Monitors add column `StreamReplayBuffer` int(10) unsigned NOT NULL default '1000' after PostEventCount;
--
-- Add a column for signal check colour
--
alter table Monitors add column `SignalCheckColour` varchar(32) NOT NULL default '#0100BE' after DefaultScale;
--
-- Increase the size of the run state definition column
--

View File

@ -663,14 +663,6 @@ our @options =
type => $types{integer},
category => "config",
},
{
name => "ZM_SIGNAL_CHECK_COLOUR",
default => "0100BE",
description => "The colour to check when detecting signal loss",
help => "For locally attached video cameras ZoneMinder can check for signal loss by looking at a number of random points on each captured image. If all of these points are set to the same fixed colour then the camera is assumed to have lost signal. This option defines what that colour is, in hexadecimal RGB (red/green/blue) terms. The default, which is a shade of blue, is most common but other systems may differ.",
type => $types{hexadecimal},
category => "config",
},
{
name => "ZM_CAPTURES_PER_FRAME",
default => "1",

View File

@ -186,6 +186,7 @@ Monitor::Monitor(
int p_fps_report_interval,
int p_ref_blend_perc,
bool p_track_motion,
Rgb p_signal_check_colour,
Purpose p_purpose,
int p_n_zones,
Zone *p_zones[]
@ -210,6 +211,7 @@ Monitor::Monitor(
fps_report_interval( p_fps_report_interval ),
ref_blend_perc( p_ref_blend_perc ),
track_motion( p_track_motion ),
signal_check_colour( p_signal_check_colour ),
image( width, height, p_camera->Colours() ),
ref_image( width, height, p_camera->Colours() ),
purpose( p_purpose ),
@ -859,9 +861,9 @@ bool Monitor::CheckSignal( const Image *image )
if ( static_undef )
{
static_undef = false;
red_val = RGB_RED_VAL(config.signal_check_colour);
green_val = RGB_GREEN_VAL(config.signal_check_colour);
blue_val = RGB_BLUE_VAL(config.signal_check_colour);
red_val = RGB_RED_VAL(signal_check_colour);
green_val = RGB_GREEN_VAL(signal_check_colour);
blue_val = RGB_BLUE_VAL(signal_check_colour);
}
const unsigned char *buffer = image->Buffer();
@ -1363,7 +1365,7 @@ void Monitor::Reload()
closeEvent();
static char sql[BUFSIZ];
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Id = '%d'", id );
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = '%d'", id );
if ( mysql_query( &dbconn, sql ) )
{
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
@ -1403,6 +1405,11 @@ void Monitor::Reload()
fps_report_interval = atoi(dbrow[index++]);
ref_blend_perc = atoi(dbrow[index++]);
track_motion = atoi(dbrow[index++]);
if ( dbrow[index][0] == '#' )
signal_check_colour = strtol(dbrow[index]+1,0,16);
else
signal_check_colour = strtol(dbrow[index],0,16);
index++;
shared_data->state = state = IDLE;
shared_data->alarm_x = shared_data->alarm_y = -1;
@ -1543,11 +1550,11 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
static char sql[BUFSIZ];
if ( !device[0] )
{
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) );
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) );
}
else
{
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device );
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device );
}
if ( mysql_query( &dbconn, sql ) )
{
@ -1607,6 +1614,12 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
int fps_report_interval = atoi(dbrow[col]); col++;
int ref_blend_perc = atoi(dbrow[col]); col++;
int track_motion = atoi(dbrow[col]); col++;
int signal_check_colour;
if ( dbrow[col][0] == '#' )
signal_check_colour = strtol(dbrow[col]+1,0,16);
else
signal_check_colour = strtol(dbrow[col],0,16);
col++;
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
@ -1649,6 +1662,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
fps_report_interval,
ref_blend_perc,
track_motion,
signal_check_colour,
purpose
);
Zone **zones = 0;
@ -1924,7 +1938,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
{
static char sql[BUFSIZ];
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Id = %d", id );
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id );
if ( mysql_query( &dbconn, sql ) )
{
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
@ -1987,6 +2001,11 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
int fps_report_interval = atoi(dbrow[col]); col++;
int ref_blend_perc = atoi(dbrow[col]); col++;
int track_motion = atoi(dbrow[col]); col++;
int signal_check_colour;
if ( dbrow[col][0] == '#' )
signal_check_colour = strtol(dbrow[col]+1,0,16);
else
signal_check_colour = strtol(dbrow[col],0,16);
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
@ -2067,6 +2086,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
fps_report_interval,
ref_blend_perc,
track_motion,
signal_check_colour,
purpose
);

View File

@ -193,6 +193,7 @@ protected:
int fps_report_interval; // How many images should be captured/processed between reporting the current FPS
int ref_blend_perc; // Percentage of new image going into reference image.
bool track_motion; // Whether this monitor tries to track detected motion
Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected
double fps;
Image image;
@ -231,7 +232,7 @@ protected:
MonitorLink **linked_monitors;
public:
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
~Monitor();
void AddZones( int p_n_zones, Zone *p_zones[] );

View File

@ -103,6 +103,7 @@ else
$monitor['DefaultView'] = 'Events';
$monitor['DefaultRate'] = '100';
$monitor['DefaultScale'] = '100';
$monitor['SignalCheckColour'] = '#0100BE';
$monitor['WebColour'] = 'red';
$monitor['Triggers'] = "";
}
@ -261,6 +262,13 @@ function validateForm(form)
{
errors[errors.length] = "<?= $zmSlangBadFrameSkip ?>";
}
if ( form.elements['new_monitor[Type]'].value == 'Local' )
{
if ( !form.elements['new_monitor[SignalCheckColour]'].value || !form.elements['new_monitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
{
errors[errors.length] = "<?= $zmSlangBadSignalCheckColour ?>";
}
}
if ( !form.elements['new_monitor[WebColour]'].value || !form.elements['new_monitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
{
errors[errors.length] = "<?= $zmSlangBadWebColour ?>";
@ -499,6 +507,12 @@ if ( $tab != 'misc' )
<input type="hidden" name="new_monitor[WebColour]" value="<?= $new_monitor['WebColour'] ?>">
<?php
}
if ( $tab != 'misc' || $new_monitor['Type'] != 'Local' )
{
?>
<input type="hidden" name="new_monitor[SignalCheckColour]" value="<?= $new_monitor['SignalCheckColour'] ?>">
<?php
}
?>
<tr>
<td align="left" class="smallhead" width="50%"><?= $zmSlangParameter ?></td><td align="left" class="smallhead" width="50%"><?= $zmSlangValue ?></td>
@ -669,7 +683,15 @@ switch ( $tab )
</select></td></tr>
<tr><td align="left" class="text"><?= $zmSlangDefaultRate ?></td><td align="left" class="text"><?= buildSelect( "new_monitor[DefaultRate]", $rates ); ?></td></tr>
<tr><td align="left" class="text"><?= $zmSlangDefaultScale ?></td><td align="left" class="text"><?= buildSelect( "new_monitor[DefaultScale]", $scales ); ?></td></tr>
<tr><td align="left" class="text"><?= $zmSlangWebColour ?></td><td align="left" class="text"><input type="text" name="new_monitor[WebColour]" value="<?= $new_monitor['WebColour'] ?>" size="10" class="form" onChange="document.getElementById('Swatch').style.backgroundColor=this.value">&nbsp;&nbsp;<span id="Swatch" style="background-color: <?= $new_monitor['WebColour'] ?>; border: 1px solid black; width: 20px; height: 10px; padding: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<?php
if ( $new_monitor['Type'] == "Local" )
{
?>
<tr><td align="left" class="text"><?= $zmSlangSignalCheckColour ?></td><td align="left" class="text"><input type="text" name="new_monitor[SignalCheckColour]" value="<?= $new_monitor['SignalCheckColour'] ?>" size="10" class="form" onChange="document.getElementById('SignalCheckSwatch').style.backgroundColor=this.value">&nbsp;&nbsp;<span id="SignalCheckSwatch" style="background-color: <?= $new_monitor['SignalCheckColour'] ?>; border: 1px solid black; width: 20px; height: 10px; padding: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<?php
}
?>
<tr><td align="left" class="text"><?= $zmSlangWebColour ?></td><td align="left" class="text"><input type="text" name="new_monitor[WebColour]" value="<?= $new_monitor['WebColour'] ?>" size="10" class="form" onChange="document.getElementById('WebSwatch').style.backgroundColor=this.value">&nbsp;&nbsp;<span id="WebSwatch" style="background-color: <?= $new_monitor['WebColour'] ?>; border: 1px solid black; width: 20px; height: 10px; padding: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<?php
break;
}

View File

@ -140,6 +140,7 @@ $zmSlangBadPostEventCount = 'Post event image count must be an integer of zer
$zmSlangBadPreEventCount = 'Pre event image count must be at least zero, and less than image buffer size';
$zmSlangBadRefBlendPerc = 'Reference blend percentage must be a positive integer';
$zmSlangBadSectionLength = 'Section length must be an integer of 30 or more';
$zmSlangBadSignalCheckColour = 'Signal check colour must be a valid RGB colour string';
$zmSlangBadStreamReplayBuffer= 'Stream replay buffer must be an integer of zero or more';
$zmSlangBadWarmupCount = 'Warmup frames must be an integer of zero or more';
$zmSlangBadWebColour = 'Web colour must be a valid web colour string';
@ -540,6 +541,7 @@ $zmSlangSet = 'Set';
$zmSlangSettings = 'Settings';
$zmSlangShowFilterWindow = 'Show Filter Window';
$zmSlangShowTimeline = 'Show Timeline';
$zmSlangSignalCheckColour = 'Signall Check Colour';
$zmSlangSize = 'Size';
$zmSlangSleep = 'Sleep';
$zmSlangSortAsc = 'Asc';