Skip to content

Instantly share code, notes, and snippets.

@joshooaj
Created June 18, 2024 22:01
Show Gist options
  • Save joshooaj/ff6ef4c2b19603e1406cf144520966d8 to your computer and use it in GitHub Desktop.
Save joshooaj/ff6ef4c2b19603e1406cf144520966d8 to your computer and use it in GitHub Desktop.
function Get-VmsFisheyeLens {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'Camera')]
[VideoOS.Platform.ConfigurationItems.Camera]
$Camera,
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Id')]
[Guid]
$Id
)
process {
if ($PSCmdlet.ParameterSetName -eq 'Camera') {
$Id = $Camera.Id
}
Get-ConfigurationItem -Path "FisheyeLens[$Id]"
}
}
function Set-VmsFisheyeLens {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'ConfigurationItem')]
[VideoOS.ConfigurationApi.ClientService.ConfigurationItem]
$FisheyeLens,
[Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'Camera')]
[VideoOS.Platform.ConfigurationItems.Camera]
$Camera,
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'Id')]
[Guid]
$Id,
[Parameter()]
[bool]
$Enabled,
[Parameter()]
[string]
$RegisteredPanomorphLens,
[Parameter()]
[ValidateSet('Ceiling', 'Wall', 'Ground')]
[string]
$Orientation,
[Parameter()]
[string]
$RegisteredPanomorphLensNumber,
[Parameter()]
[ValidateRange(80, 360)]
[double]
$FisheyeFieldOfView
)
process {
if ($PSCmdlet.ParameterSetName -eq 'Camera') {
$FisheyeLens = $Camera | Get-VmsFisheyeLens
} elseif ($PSCmdlet.ParameterSetName -eq 'Id') {
$FisheyeLens = Get-VmsFisheyeLens -Id $Id
}
if ($MyInvocation.BoundParameters.ContainsKey('Enabled')) {
$FisheyeLens.EnableProperty.Enabled = $Enabled
}
if ($MyInvocation.BoundParameters.ContainsKey('RegisteredPanomorphLens')) {
$FisheyeLens | Set-ConfigurationItemProperty -Key 'RegisteredPanomorphLens' -Value $RegisteredPanomorphLens
}
if ($MyInvocation.BoundParameters.ContainsKey('Orientation')) {
$FisheyeLens | Set-ConfigurationItemProperty -Key 'Orientation' -Value $Orientation
}
if ($MyInvocation.BoundParameters.ContainsKey('RegisteredPanomorphLensNumber')) {
$FisheyeLens | Set-ConfigurationItemProperty -Key 'RegisteredPanomorphLensNumber' -Value $RegisteredPanomorphLensNumber
}
if ($MyInvocation.BoundParameters.ContainsKey('FisheyeFieldOfView')) {
$FisheyeLens | Set-ConfigurationItemProperty -Key 'FisheyeFieldOfView' -Value $FisheyeFieldOfView
} else {
$fov = [double]($FisheyeLens | Get-ConfigurationItemProperty -Key FisheyeFieldOfView)
if ($fov -lt 80 -or $fov -gt 360) {
$FisheyeLens | Set-ConfigurationItemProperty -Key FisheyeFieldOfView -Value 360
}
}
$FisheyeLens | Set-ConfigurationItem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment