public/Invoke-CTAutofocus.ps1
#https://$($ip)/stw-cgi/image.cgi?msubmenu=focus&action=control&Mode=SimpleFocus&Channel=$($channelnum) Function Invoke-CTAutoFocus { [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' )] [String]$Channel=0 ) DynamicParam { $DynamicParameters = @{ CameraType = @{ Mandatory = $true #Position = 1 ParameterSetName = "All" Enum = $Script:SupportedCameraModels } } return New-DynamicParameterSet -ParameterTable $DynamicParameters } Begin { Write-Debug "[Invoke-CTAutoFocus] Started" $CameraType = $PSBoundParameters.CameraType if($CameraType -eq 'Hanwha') { #Set basic Paramters for Invoke-HanwhaCommand $CamCmd = @{ Arguments = @{ IP = $IP Menu = 'image' SubMenu = 'focus' Action = 'control' Parameters = @( "Mode=SimpleFocus" ) } Credential = $Credential } #Check if SimpleFocus is supported $Param = @{ IP = $IP Credential = $Credential Channel = $Channel Capability = "SimpleFocus" } $Capabilities = Get-HanwhaCapability @Param if($Capabilities) { if($Channel -ne 'All') { #Add Channel and run Command $CamCmd.Arguments.Parameters += "Channel=$Channel" return Invoke-HanwhaCommand @Camcmd } else { #Todo #LOL } } else { $Param = @{ ExceptionName = "System.Management.Automation.CmdletInvocationException" ExceptionMessage = "Channel does not support AutoFocus" ErrorId = "000" CallerPSCmdlet = $PSCmdlet ErrorCategory = 'DeviceError' } ThrowError @Param } } } } |