create iremote.ps1

This commit is contained in:
pblivingston 2025-11-25 14:39:10 -05:00
parent bd0779add2
commit 2404bfb50f
2 changed files with 50 additions and 0 deletions

View File

@ -2,6 +2,7 @@
. $PSScriptRoot\meta.ps1
. $PSScriptRoot\base.ps1
. $PSScriptRoot\kinds.ps1
. $PSScriptRoot\iremote.ps1
. $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1
. $PSScriptRoot\macrobuttons.ps1

49
lib/iremote.ps1 Normal file
View File

@ -0,0 +1,49 @@
class IRemote {
[int]$index
[Object]$remote
IRemote ([Object]$remote) {
$this.remote = $remote
}
IRemote ([int]$index, [Object]$remote) {
$this.index = $index
$this.remote = $remote
}
[single] Getter ($param) {
$this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug
return $this.remote.Getter($this.Cmd($param))
}
[string] Getter_String ($param) {
$this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug
return $this.remote.Getter_String($this.Cmd($param))
}
[void] Setter ($param, $val) {
$this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug
if ($val -is [Boolean]) {
$this.remote.Setter($this.Cmd($param), $(if ($val) { 1 } else { 0 }))
}
else {
$this.remote.Setter($this.Cmd($param), $val)
}
}
[string] Cmd ($param) {
if ([string]::IsNullOrEmpty($param)) {
return $this.identifier()
}
return "$($this.identifier()).$param"
}
# Must be overridden by derived classes
[string] identifier () {
throw [System.NotImplementedException]::new("$($this.GetType().Name) must override identifier()")
}
[string] ToString() {
return $this.GetType().Name
}
}