diff --git a/src/kernel/peripherals/Computer.hx b/src/kernel/peripherals/Computer.hx new file mode 100644 index 0000000..d8f9b08 --- /dev/null +++ b/src/kernel/peripherals/Computer.hx @@ -0,0 +1,50 @@ +package kernel.peripherals; + +import cc.Peripheral; +import kernel.net.Package.NetworkID; + +class Computer implements IPeripheral { + public static inline final TYPE_NAME:String = "computer"; + + private final addr:String; + + @:allow(kernel.peripherals) + private function new(addr: String) { + this.addr = addr; + } + + public function getAddr():String { + return addr; + } + + public function getType():String { + return Computer.TYPE_NAME; + } + + public function isOn():Bool { + return Peripheral.call(addr, "isOn"); + } + + public function getLabel():Null { + return Peripheral.call(addr, "getLabel"); + } + + /** + Return -1 if no ID set yet + **/ + public function getID():NetworkID{ + return Peripheral.call(addr, "getID"); + } + + public function reboot() { + Peripheral.call(addr, "reboot"); + } + + public function shutdown() { + Peripheral.call(addr, "shutdown"); + } + + public function turnOn() { + Peripheral.call(addr, "turnOn"); + } +}