.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "ZoneMinder::Memory 3pm" .TH ZoneMinder::Memory 3pm "2022-09-24" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ZoneMinder::MappedMem \- ZoneMinder Mapped Memory access module .SH "SYNOPSIS" .IX Header "SYNOPSIS" use ZoneMinder::MappedMem; use ZoneMinder::MappedMem qw(:all); .PP if ( zmMemVerify( \f(CW$monitor\fR ) ) { \f(CW$state\fR = zmGetMonitorState( \f(CW$monitor\fR ); if ( \f(CW$state\fR == \s-1STATE_ALARM\s0 ) { ... } } .PP ( \f(CW$lri\fR, \f(CW$lwi\fR ) = zmMemRead( \f(CW$monitor\fR, [ 'shared_data:last_read_index', 'shared_data:last_write_index' ] ); zmMemWrite( \f(CW$monitor\fR, { 'trigger_data:trigger_showtext' => \*(L"Some Text\*(R" } ); .SH "DESCRIPTION" .IX Header "DESCRIPTION" The ZoneMinder:MappedMem module contains methods for accessing and writing to mapped memory as well as helper methods for common operations. .PP The core elements of ZoneMinder used mapped memory to allow multiple access to resources. Although ZoneMinder scripts have used this information before, up until now it was difficult to access and prone to errors. This module introduces a common \s-1API\s0 for mapped memory access (both reading and writing) making it a lot easier to customise scripts or even create your own. .PP All the methods listed below require a 'monitor' parameter. This must be a reference to a hash with at least the 'Id' field set to the monitor id of the mapped memory you wish to access. Using database methods to select the monitor details will also return this kind of data. Some of the mapped memory methods will add and amend new fields to this hash. .SH "METHODS" .IX Header "METHODS" .ie n .IP "zmMemVerify ( $monitor );" 4 .el .IP "zmMemVerify ( \f(CW$monitor\fR );" 4 .IX Item "zmMemVerify ( $monitor );" Verify that the mapped memory of the monitor given exists and is valid. It will return an undefined value if it is not valid. You should generally call this method first before using any of the other methods, but most of the remaining methods will also do so if the memory has not already been verified. .ie n .IP "zmMemInvalidate ( $monitor );" 4 .el .IP "zmMemInvalidate ( \f(CW$monitor\fR );" 4 .IX Item "zmMemInvalidate ( $monitor );" Following an error, reset the mapped memory ids and attempt to reverify on the next operation. This is mostly used when a mapped memory segment has gone away and been recreated with a different id. .ie n .IP "zmMemRead ( $monitor, $readspec );" 4 .el .IP "zmMemRead ( \f(CW$monitor\fR, \f(CW$readspec\fR );" 4 .IX Item "zmMemRead ( $monitor, $readspec );" This method is used to read data from mapped memory attached to the given monitor. The mapped memory will be verified if it has not already been. The \&'readspec' must either be a string of the form \*(L"
:\*(R" or a reference to an array of strings of the same format. In the first case a single value is returned, in the latter case a list of values is return. Errors will cause undefined to be returned. The allowable sections and field names are described below. .ie n .IP "zmMemWrite ( $monitor, $writespec );" 4 .el .IP "zmMemWrite ( \f(CW$monitor\fR, \f(CW$writespec\fR );" 4 .IX Item "zmMemWrite ( $monitor, $writespec );" This method is used to write data to mapped memory attached to the given monitor. The mapped memory will be verified if it has not already been. The \&'writespec' must be a reference to a hash with keys of the form \&\*(L"
:\*(R" and values as the data to be written. Errors will cause undefined to be returned, otherwise a non-undefined value will be returned. The allowable sections and field names are described below. .ie n .IP "$state = zmGetMonitorState ( $monitor );" 4 .el .IP "\f(CW$state\fR = zmGetMonitorState ( \f(CW$monitor\fR );" 4 .IX Item "$state = zmGetMonitorState ( $monitor );" Return the current state of the given monitor. This is an integer value and can be compared with the \s-1STATE\s0 constants given below. .ie n .IP "$event_id = zmGetLastEvent ( $monitor );" 4 .el .IP "\f(CW$event_id\fR = zmGetLastEvent ( \f(CW$monitor\fR );" 4 .IX Item "$event_id = zmGetLastEvent ( $monitor );" Return the event id of the last event that the monitor generated, or 0 if no event has been generated by the current monitor process. .ie n .IP "zmIsAlarmed ( $monitor );" 4 .el .IP "zmIsAlarmed ( \f(CW$monitor\fR );" 4 .IX Item "zmIsAlarmed ( $monitor );" Return 1 if the monitor given is currently in an alarm state, 0 otherwise. .ie n .IP "zmInAlarm ( $monitor );" 4 .el .IP "zmInAlarm ( \f(CW$monitor\fR );" 4 .IX Item "zmInAlarm ( $monitor );" Return 1 if the monitor given is currently in an alarm or alerted state, 0 otherwise. .ie n .IP "zmHasAlarmed ( $monitor );" 4 .el .IP "zmHasAlarmed ( \f(CW$monitor\fR );" 4 .IX Item "zmHasAlarmed ( $monitor );" Return 1 if the given monitor is in an alarm state, or has been in an alarm state since the last call to this method. .ie n .IP "( $x, $y ) = zmGetAlarmLocation ( $monitor );" 4 .el .IP "( \f(CW$x\fR, \f(CW$y\fR ) = zmGetAlarmLocation ( \f(CW$monitor\fR );" 4 .IX Item "( $x, $y ) = zmGetAlarmLocation ( $monitor );" Return an x,y pair indicating the image co-ordinates of the centre of the last motion event generated by the given monitor. If no event has been generated by the current monitor process, or the alarm was not motion related, returns \-1,\-1. .ie n .IP "zmGetLastWriteTime ( $monitor );" 4 .el .IP "zmGetLastWriteTime ( \f(CW$monitor\fR );" 4 .IX Item "zmGetLastWriteTime ( $monitor );" Returns the time (in utc seconds) since the last image was captured by the given monitor and written to shared memory, or 0 otherwise. .ie n .IP "zmGetLastReadTime ( $monitor );" 4 .el .IP "zmGetLastReadTime ( \f(CW$monitor\fR );" 4 .IX Item "zmGetLastReadTime ( $monitor );" Returns the time (in utc seconds) since the last image was read from shared memory by the analysis daemon of the given monitor, or 0 otherwise or if the monitor is in monitor only mode. .ie n .IP "zmMonitorSuspend ( $monitor );" 4 .el .IP "zmMonitorSuspend ( \f(CW$monitor\fR );" 4 .IX Item "zmMonitorSuspend ( $monitor );" Suspend the given monitor from generating events caused by motion. This method can be used to prevent camera actions such as panning or zooming from causing events. If configured to do so, the monitor may automatically resume after a defined period. .ie n .IP "zmMonitorResume ( $monitor );" 4 .el .IP "zmMonitorResume ( \f(CW$monitor\fR );" 4 .IX Item "zmMonitorResume ( $monitor );" Allow the given monitor to resume generating events caused by motion. .ie n .IP "zmTriggerEventOn ( $monitor, $score, $cause [, $text, $showtext ] );" 4 .el .IP "zmTriggerEventOn ( \f(CW$monitor\fR, \f(CW$score\fR, \f(CW$cause\fR [, \f(CW$text\fR, \f(CW$showtext\fR ] );" 4 .IX Item "zmTriggerEventOn ( $monitor, $score, $cause [, $text, $showtext ] );" Trigger the given monitor to generate an event. You must supply an event score and a cause string indicating the reason for the event. You may also supply a text string containing further details about the event and a showtext string which may be included in the timestamp annotation on any images captured during the event, if configured to do so. .ie n .IP "zmTriggerEventOff ( $monitor );" 4 .el .IP "zmTriggerEventOff ( \f(CW$monitor\fR );" 4 .IX Item "zmTriggerEventOff ( $monitor );" Trigger the given monitor to not generate any events. This method does not cancel zmTriggerEventOn, but is exclusive to it. This method is intended to allow external triggers to prevent normal events being generated by monitors in the same way as zmMonitorSuspend but applies to all events and not just motion, and is intended for longer timescales than are appropriate for suspension. .ie n .IP "zmTriggerEventCancel ( $monitor );" 4 .el .IP "zmTriggerEventCancel ( \f(CW$monitor\fR );" 4 .IX Item "zmTriggerEventCancel ( $monitor );" Cancel any previous trigger on or off requests. This stops a triggered alarm if it exists from a previous 'on' and allows events to be generated once more following a previous 'off'. .ie n .IP "zmTriggerShowtext ( $monitor, $showtest );" 4 .el .IP "zmTriggerShowtext ( \f(CW$monitor\fR, \f(CW$showtest\fR );" 4 .IX Item "zmTriggerShowtext ( $monitor, $showtest );" Indicate that the given text should be displayed in the timestamp annotation on any images captured, if the format of the annotation string defined for the monitor permits. .SH "DATA" .IX Header "DATA" The data fields in mapped memory that may be accessed are as follows. There are two main sections, shared_data which is general data and trigger_data which is used for event triggering. Whilst reading from these fields is harmless, extreme care must be taken when writing to mapped memory, especially in the shared_data section as this is normally written to only by monitor capture and analysis processes. .PP shared_data The general mapped memory section size The size, in bytes, of this section valid Flag indicating whether this section has been initialised active Flag indicating whether this monitor is active (enabled/disabled) signal Flag indicating whether this monitor is receiving a valid signal state The current monitor state, see the \s-1STATE\s0 constants below last_write_index The last index, in the image buffer, that an image has been saved to last_read_index The last index, in the image buffer, that an image has been analysed from last_write_time The time (in utc seconds) when the last image was captured last_read_time The time (in utc seconds) when the last image was analysed last_event The id of the last event generated by the monitor analysis process, 0 if none action The monitor actions bitmask, see the \s-1ACTION\s0 constants below brightness Read/write location for the current monitor brightness hue Read/write location for the current monitor hue colour Read/write location for the current monitor colour contrast Read/write location for the current monitor contrast alarm_x Image x co-ordinate (from left) of the centre of the last motion event, \-1 if none alarm_y Image y co-ordinate (from top) of the centre of the last motion event, \-1 if none alarm_cause The current alarm event cause string along with zone names(s) alarmed .PP trigger_data The triggered event mapped memory section size The size, in bytes of this section trigger_state The current trigger state, see the \s-1TRIGGER\s0 constants below trigger_score The current triggered event score trigger_cause The current triggered event cause string trigger_text The current triggered event descriptive text string trigger_showtext The triggered text that will be displayed on captured image timestamps .SH "CONSTANTS" .IX Header "CONSTANTS" The following constants are used by the methods above, but can also be used by user scripts if required. .IP "\s-1STATE_IDLE STATE_PREALARM STATE_ALARM STATE_ALERT STATE_TAPE\s0" 4 .IX Item "STATE_IDLE STATE_PREALARM STATE_ALARM STATE_ALERT STATE_TAPE" These constants define the state of the monitor with respect to alarms and events. They are used in the shared_data:state field. .IP "\s-1ACTION_GET ACTION_SET ACTION_RELOAD ACTION_SUSPEND ACTION_RESUME\s0" 4 .IX Item "ACTION_GET ACTION_SET ACTION_RELOAD ACTION_SUSPEND ACTION_RESUME" These constants defines the various values that can exist in the shared_data:action field. This is a bitmask which when non-zero defines an action that an executing monitor process should take. \s-1ACTION_GET\s0 requires that the current values of brightness, contrast, colour and hue are taken from the camera and written to the equivalent mapped memory fields. \&\s-1ACTION_SET\s0 implies the reverse, that the values in mapped memory should be written to the camera. \s-1ACTION_RELOAD\s0 signal that the monitor process should reload itself from the database in case any settings have changed there. \&\s-1ACTION_SUSPEND\s0 signals that a monitor should stop exaiming images for motion, though other alarms may still occur. \s-1ACTION_RESUME\s0 sigansl that a monitor should resume motion detectiom. .IP "\s-1TRIGGER_CANCEL TRIGGER_ON TRIGGER_OFF\s0" 4 .IX Item "TRIGGER_CANCEL TRIGGER_ON TRIGGER_OFF" These constants are used in the definition of external triggers. \&\s-1TRIGGER_CANCEL\s0 is used to indicated that any previous trigger settings should be cancelled, \s-1TRIGGER_ON\s0 signals that an alarm should be created (or continued)) as a result of the current trigger and \s-1TRIGGER_OFF\s0 signals that the trigger should prevent any alarms from being generated. See the trigger methods above for further details. .SH "EXPORT" .IX Header "EXPORT" None by default. The :constants tag will export the mapped memory constants which mostly define enumerations for the variables held in memory The :functions tag will export the mapped memory access functions. The :all tag will export all above symbols. .SH "SEE ALSO" .IX Header "SEE ALSO" http://www.zoneminder.com .SH "AUTHOR" .IX Header "AUTHOR" Philip Coombes, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2001\-2008 Philip Coombes .PP 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.