private/Functions/Hanwha/Invoke-HanwhaAutofocus.ps1

#https://$($ip)/stw-cgi/image.cgi?msubmenu=focus&action=control&Mode=SimpleFocus&Channel=$($channelnum)

Function Invoke-HanwhaAutofocus {
    [cmdletBinding()]
    Param(
        [Parameter()]
        [hashtable]$Object
    )
    
    <#
    Object Definition:
    @{
        IP = [String(Mandatory)]
        Credential = [PSCredential(Mandatory)]
        Channel = [int] as [String(Optional)]
    }
    #>


    $Channel = 0
    if($Object.ContainsKey('Channel')) {
        $Channel = $Object.Channel
    }

    #Set basic Paramters for Invoke-HanwhaCommand
    $CamCmd = @{
        Arguments = @{
            IP = $Object.IP
            Menu = 'image'
            SubMenu = 'focus'
            Action = 'control'
            Parameters = @(
                "Mode=SimpleFocus"
            )
        }
        Credential = $Object.Credential
    }

    #Check if SimpleFocus is supported
    $Param = @{
        IP = $Object.IP
        Credential = $Object.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
    }
}