added computer perph
This commit is contained in:
		
							parent
							
								
									8333cabdc8
								
							
						
					
					
						commit
						f124525d2d
					
				
							
								
								
									
										50
									
								
								src/kernel/peripherals/Computer.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/kernel/peripherals/Computer.hx
									
									
									
									
									
										Normal file
									
								
							@ -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<String> {
 | 
			
		||||
        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");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user