From f124525d2d1ad173ce5628ab7c8c6acbfa9a0409 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 26 Jun 2023 19:05:10 +0200 Subject: [PATCH] added computer perph --- src/kernel/peripherals/Computer.hx | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/kernel/peripherals/Computer.hx 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"); + } +}