public/Set-CTMotion.ps1
#https://$($ip)/stw-cgi/eventsources.cgi?msubmenu=videoanalysis2&action=set&Channel=$($channelnum)&DetectionType=MotionDetection #https://$($ip)/stw-cgi/eventsources.cgi?msubmenu=videoanalysis2&action=set&Channel=$($channelnum) #ROI.1.Coordinate=0,0,1919,0,1919,1079,0,1079&ROI.1.SensitivityLevel=80 #ROI.1.Duration=0& #ROI.1.ThresholdLevel=5 #DetectionType.MotionDetection.DetectionResultOverlay=False Function Set-CTMotion { [cmdletBinding( DefaultParameterSetName='All', #SupportsShouldProcess = $true, ConfirmImpact='high' )] Param( [Parameter( Mandatory=$true, ParameterSetName='All' )] [String]$IP, [Parameter( Mandatory=$true, ParameterSetName='All' )] [pscredential]$Credential, [Parameter( Mandatory=$false, ParameterSetName='All' )] [int]$Channel, [Parameter( Mandatory=$false, ParameterSetName='All' )] [switch]$MotionHighlight #DetectionResultOverlay ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } DetectionType = @{ Mandatory = $false Position = 1 ParameterSetName = "All" Enum = @( 'MotionDetection' 'IntelligentVideo' 'All' #MDAndIV 'Off' ) Value = "MotionDetection" } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Set-CTMotion] Started" $CameraType = $PSBoundParameters.CameraType $DetectionType = $PSBoundParameters.DetectionType if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'eventsources' SubMenu = 'videoanalysis' Action = 'set' Parameters = @() } Credential = $Credential } #Need to add Get-HanwhaCapability here #Add Action Parameters if($MotionHighlight -and $DetectionType -eq 'Off') { Throw "MotionDetection must be enabled to use Highlighting" } $CamCmd.Arguments.Parameters += "Channel=$Channel" if($DetectionType -eq 'All') { $CamCmd.Arguments.Parameters += "DetectionType=MDAndIV" } else { $CamCmd.Arguments.Parameters += "DetectionType=$DetectionType" } $CamCmd.Arguments.Parameters += "DetectionResultOverlay=$MotionHighlight" Invoke-HanwhaCommand @CamCmd } } } |