diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index c8d95dd..d570190 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -5,13 +5,17 @@ class Recorder : IRemote { Recorder ([Object]$remote) : base ($remote) { $this.mode = [RecorderMode]::new($remote) + $this.armstrip = @() - 0..($remote.kind.p_in + $remote.kind.v_in - 1) | ForEach-Object { - $this.armstrip.Add([RecorderArmStrip]::new($_, $remote)) + $stripCount = $($remote.kind.p_in + $remote.kind.v_in) + for ($i = 0; $i -lt $stripCount; $i++) { + $this.armstrip.Add([BoolArrayMember]::new($i, 'armstrip', $this)) } + $this.armbus = @() - 0..($remote.kind.p_out + $remote.kind.v_out - 1) | ForEach-Object { - $this.armbus.Add([RecorderArmBus]::new($_, $remote)) + $busCount = $($remote.kind.p_out + $remote.kind.v_out) + for ($i = 0; $i -lt $busCount; $i++) { + $this.armbus.Add([BoolArrayMember]::new($i, 'armbus', $this)) } AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rew') @@ -96,6 +100,26 @@ class Recorder : IRemote { } ) + hidden $_armedbus = $($this | Add-Member ScriptProperty 'armedbus' ` + { + foreach ($bus in 0..$($this.remote.kind.p_out + $this.remote.kind.v_out - 1)) { + if ($this.remote.Getter("Recorder.ArmBus[$bus]")) { + break + } + } + return $bus + } ` + { + param([int]$arg) + $busMax = $this.remote.kind.p_out + $this.remote.kind.v_out - 1 + if ($arg -ge 0 -and $arg -le $busMax) { + $this._armedbus = $this.remote.Setter("Recorder.ArmBus[$arg]", 1) + } + else { + Write-Warning ("Expected a bus index between 0 and $busMax") + } + }) + [void] Load ([string]$filename) { $this.Setter('load', $filename) } diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index 7e45b03..22b9c55 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -160,6 +160,20 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { It 'Should set and get Recorder.loop' { $vmr.recorder.loop = $value } + + It 'Should set and get Recorder.armstrip[i]' -ForEach @( + @{ Index = $phys_in }, @{ Index = $virt_in } + ) { + $vmr.recorder.armstrip[$index].set($value) + $vmr.recorder.armstrip[$index].get() | Should -Be $value + } + + It 'Should set and get Recorder.armbus[i]' -ForEach @( + @{ Index = $phys_out }, @{ Index = $virt_out } + ) { + $vmr.recorder.armbus[$index].set($value) + $vmr.recorder.armbus[$index].get() | Should -Be $value + } } Context 'Command' { @@ -603,6 +617,15 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } } + + Context 'Recorder' -Skip:$ifBasic { + It 'Should set and get Recorder.armedbus' -ForEach @( + @{ Value = $phys_out }, @{ Value = $virt_out } + ) { + $vmr.recorder.armedbus = $value + $vmr.recorder.armedbus | Should -Be $value + } + } } Describe 'String Tests' -Tag 'string' {