2022-01-06 15:26:38 +00:00
|
|
|
. $PSScriptRoot\meta.ps1
|
|
|
|
|
2021-04-28 17:38:36 +01:00
|
|
|
class Bus {
|
2022-01-08 16:10:14 +00:00
|
|
|
[Int]$id
|
2021-05-16 00:14:51 +01:00
|
|
|
|
2021-04-28 17:38:36 +01:00
|
|
|
# Constructor
|
|
|
|
Bus ([Int]$id)
|
|
|
|
{
|
|
|
|
$this.id = $id
|
|
|
|
|
2022-01-19 21:52:59 +00:00
|
|
|
AddBoolMembers -PARAMS @('mono', 'mute')
|
2022-01-24 20:01:55 +00:00
|
|
|
AddStringMembers -PARAMS @('label')
|
2022-01-19 21:52:59 +00:00
|
|
|
AddFloatMembers -PARAMS @('gain')
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-28 18:21:32 +01:00
|
|
|
[Single] Getter($cmd) {
|
2022-01-19 21:52:59 +00:00
|
|
|
return Param_Get -PARAM $cmd -IS_STRING $false
|
|
|
|
}
|
|
|
|
|
|
|
|
[String] Getter_String($cmd) {
|
|
|
|
return Param_Get -PARAM $cmd -IS_STRING $true
|
|
|
|
}
|
|
|
|
|
|
|
|
[void] Setter($cmd, $set) {
|
|
|
|
Param_Set -PARAM $cmd -VALUE $set
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[string] cmd ($arg) {
|
|
|
|
return "Bus[" + $this.id + "].$arg"
|
|
|
|
}
|
2022-01-06 15:26:38 +00:00
|
|
|
|
|
|
|
hidden $_eq = $($this | Add-Member ScriptProperty 'eq' `
|
|
|
|
{
|
|
|
|
$this.Getter($this.cmd('EQ.on'))
|
|
|
|
}`
|
|
|
|
{
|
|
|
|
param ( $arg )
|
|
|
|
$this._eq = $this.Setter($this.cmd('EQ.on'), $arg)
|
|
|
|
}
|
|
|
|
)
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-01-10 20:56:17 +00:00
|
|
|
class PhysicalBus : Bus {
|
|
|
|
PhysicalBus ([Int]$id) : base ($id) {
|
|
|
|
}
|
2022-01-24 20:01:55 +00:00
|
|
|
hidden $_device = $($this | Add-Member ScriptProperty 'device' `
|
|
|
|
{
|
|
|
|
$this.Getter_String($this.cmd('device.name'))
|
|
|
|
}`
|
|
|
|
{
|
|
|
|
return Write-Warning("ERROR: " + $this.cmd('device.name') + " is read only")
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
|
|
|
|
{
|
|
|
|
$this.Getter($this.cmd('device.sr'))
|
|
|
|
}`
|
|
|
|
{
|
|
|
|
return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only")
|
|
|
|
}
|
|
|
|
)
|
2022-01-10 20:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VirtualBus : Bus {
|
|
|
|
VirtualBus ([Int]$id) : base ($id) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 21:52:59 +00:00
|
|
|
Function Make_Buses {
|
2021-04-28 17:38:36 +01:00
|
|
|
[System.Collections.ArrayList]$bus = @()
|
2022-01-10 20:56:17 +00:00
|
|
|
0..$($layout.p_out + $layout.v_out -1) | ForEach-Object {
|
|
|
|
if ($_ -lt $layout.p_out) { [void]$bus.Add([PhysicalBus]::new($_)) }
|
|
|
|
else { [void]$bus.Add([VirtualBus]::new($_)) }
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
$bus
|
|
|
|
}
|