private/Functions/Hanwha/Set-HanwhaRecordingGeneral.ps1

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


    #Set basic Paramters for Invoke-HanwhaCommand
    $CamCmd = @{
        Arguments = @{
            IP = $Object.IP
            Menu = 'recording'
            SubMenu = 'general'
            Action = 'set'
            Parameters = @()
        }
        Credential = $Object.Credential
    }


    #Add Action Parameters
    if($Object.Channel) {
        $CamCmd.Arguments.Parameters += "Channel=$($Channel)"
    }
    if($Object.Continuous) {
        $CamCmd.Arguments.Parameters += "NormalMode=$($Object.Continuous)"
    }
    if($Object.PreEventDuration) {
        if($Object.PreEventDuration -match '[A-Za-z]') {
            $CamCmd.Arguments.Parameters += "PreEventDuration=$($Object.PreEventDuration)"
        }
        else {
            $CamCmd.Arguments.Parameters += "PreEventDuration=$($Object.PreEventDuration)s"
        }
    }
    if($Object.PostEventDuration) {
        if($Object.PostEventDuration -match '[A-Za-z]') {
            $CamCmd.Arguments.Parameters += "PostEventDuration=$($Object.PostEventDuration)"
        }
        else {
            $CamCmd.Arguments.Parameters += "PostEventDuration=$($Object.PostEventDuration)s"
        }
    }
    if($Object.FileType) {
        $CamCmd.Arguments.Parameters += "RecordedVideoFileType=$($Object.FileType)"
    }

    #If event isn't set, use the value from Continuous
    if($Object.CamEvent) {
        $CamCmd.Arguments.Parameters += "EventMode=$($Object.CamEvent)"
    }
    elseif ($Object.Continuous) {
        $CamCmd.Arguments.Parameters += "EventMode=$($Object.Continuous)"
    }

    Invoke-HanwhaCommand @CamCmd
}