initial commit
This commit is contained in:
101
src/kernel/peripherals/Modem.hx
Normal file
101
src/kernel/peripherals/Modem.hx
Normal file
@@ -0,0 +1,101 @@
|
||||
package kernel.peripherals;
|
||||
|
||||
import haxe.exceptions.NotImplementedException;
|
||||
import haxe.Exception;
|
||||
|
||||
using lua.Table;
|
||||
|
||||
class Modem {
|
||||
private final nativ:cc.periphs.Modem.Modem;
|
||||
|
||||
public final addr:String;
|
||||
|
||||
@:allow(kernel.peripherals)
|
||||
private function new(nativePeripherals: cc.periphs.Modem.Modem,addr: String) {
|
||||
this.nativ = nativePeripherals;
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public function open(chan: Int) {
|
||||
nativ.open(chan);
|
||||
}
|
||||
|
||||
public function isOpen(chan: Int): Bool {
|
||||
return nativ.isOpen(chan);
|
||||
}
|
||||
|
||||
public function close(chan: Int) {
|
||||
nativ.close(chan);
|
||||
}
|
||||
|
||||
public function closAll() {
|
||||
nativ.closeAll();
|
||||
}
|
||||
|
||||
public function transmit(chan: Int,replyChan: Int,payload: Any) {
|
||||
nativ.transmit(chan,replyChan,payload);
|
||||
}
|
||||
|
||||
public function isWireless(): Bool {
|
||||
return nativ.isWireless();
|
||||
}
|
||||
|
||||
public function getNamesRemote():Array<String> {
|
||||
if (isWireless()){
|
||||
throw new Exception("'getNamesRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
return nativ.getNamesRemote().toArray();
|
||||
}
|
||||
|
||||
public function isPresentRemote(name: String): Bool {
|
||||
if (isWireless()){
|
||||
throw new Exception("'isPresentRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
return nativ.isPresentRemote(name);
|
||||
}
|
||||
|
||||
public function getTypeRemote(name: String): String {
|
||||
if (isWireless()){
|
||||
throw new Exception("'getTypeRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
return nativ.getTypeRemote(name);
|
||||
}
|
||||
|
||||
public function hasTypeRemote(name:String, type:String):Bool {
|
||||
if (isWireless()){
|
||||
throw new Exception("'hasTypeRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
// Missing in upstream API
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
// return nativ.hasRemoteType(name,type);
|
||||
}
|
||||
|
||||
public function getMethodsRemote(name: String): Array<String> {
|
||||
if (isWireless()){
|
||||
throw new Exception("'getMethodsRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
return nativ.getMethodsRemote(name).toArray();
|
||||
}
|
||||
|
||||
public function callRemote(remoteName: String, method:String):Dynamic {
|
||||
if (isWireless()){
|
||||
throw new Exception("'callRemote' only works with wired modems");
|
||||
}
|
||||
|
||||
// TODO: implment or solve differently
|
||||
throw new haxe.exceptions.NotImplementedException();
|
||||
}
|
||||
|
||||
public function getNameLocal(): String {
|
||||
if (isWireless()){
|
||||
throw new Exception("'getNameLocal' only works with wired modems");
|
||||
}
|
||||
|
||||
return nativ.getNameLocal();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user