-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented
roDeviceInfoEvent
(#429)
* Improved `roDeviceInfo` * Implemented `roDeviceInfoEvent` * Prevent CLI to print syslog messages * Static analysis fix * Prettier fix * Fixed Event and test cases * Reformatted test case * Removed unused import
- Loading branch information
Showing
12 changed files
with
355 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { BrsValue, ValueKind, BrsBoolean } from "../BrsType"; | ||
import { BrsComponent } from "./BrsComponent"; | ||
import { BrsType, toAssociativeArray } from ".."; | ||
import { Callable } from "../Callable"; | ||
import { Interpreter } from "../../interpreter"; | ||
|
||
export class RoDeviceInfoEvent extends BrsComponent implements BrsValue { | ||
readonly kind = ValueKind.Object; | ||
private readonly data: any; | ||
private readonly isStatusMsg: boolean = false; | ||
private readonly isCaptionModeMsg: boolean = false; | ||
|
||
constructor(data: any) { | ||
super("roDeviceInfoEvent"); | ||
this.data = data; | ||
if (typeof data.Mode === "string") { | ||
this.isCaptionModeMsg = true; | ||
} else { | ||
this.isStatusMsg = true; | ||
} | ||
this.registerMethods({ | ||
ifDeviceInfoEvent: [this.getInfo, this.isStatusMessage, this.isCaptionModeChanged], | ||
}); | ||
} | ||
|
||
toString(parent?: BrsType): string { | ||
return "<Component: roDeviceInfoEvent>"; | ||
} | ||
|
||
equalTo(other: BrsType) { | ||
return BrsBoolean.False; | ||
} | ||
|
||
/** Checks if the device status has changed. */ | ||
private readonly isStatusMessage = new Callable("isStatusMessage", { | ||
signature: { | ||
args: [], | ||
returns: ValueKind.Boolean, | ||
}, | ||
impl: (_: Interpreter) => { | ||
return BrsBoolean.from(this.isStatusMsg); | ||
}, | ||
}); | ||
|
||
/** Indicates whether the user has changed the closed caption mode. */ | ||
private readonly isCaptionModeChanged = new Callable("isCaptionModeChanged", { | ||
signature: { | ||
args: [], | ||
returns: ValueKind.Boolean, | ||
}, | ||
impl: (_: Interpreter) => { | ||
return BrsBoolean.from(this.isCaptionModeMsg); | ||
}, | ||
}); | ||
|
||
/** Returns an roAssociativeArray with the current status of the device or the caption mode. */ | ||
private readonly getInfo = new Callable("getInfo", { | ||
signature: { | ||
args: [], | ||
returns: ValueKind.Object, | ||
}, | ||
impl: (_: Interpreter) => { | ||
return toAssociativeArray(this.data); | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.