User Tools

Site Tools


zalozeni:classes:device

Device

Pri vytvareni tridy dedici od Device si vybirame podle toho, pod jakym datovym typem jsou hodnoty na zarizeni adresovany. Jedna se bud o integer (Eurotherm) nebo o String (LabJack).

Doporucuji ke kazdemu zarizeni vytvorit specialni tridu, takze pokud budu mit v zarizeni jak Eurotherm tak LabJack, vytvorim nasledujici dve tridy. Implementace metod connect() a disconnect() postrada originalitu, ale to jenom proto, ze zatim neprisel projekt, kde by tyto metody mely byt komplikovanejsi.

public class Eurotherm extends IntAddrDevice {
 
	@Override
	public void connect() throws ConnectException, Exception {
		this.connection.connect();
		this.deviceStatus = DeviceStatus.CONNECTED;
	}
 
	@Override
	public void disconnect() throws IllegalStateException, Exception {
		this.connection.disconnect();
		this.deviceStatus = DeviceStatus.DISCONNECTED;
	}
 
	@Override
	public String getInfo() {
		// TODO Auto-generated method stub
		return null;
	}
 
}
public class LabJackT7 extends StringAddrDevice {
 
	@Override
	public void connect() throws ConnectException, Exception {
		this.connection.connect();
		this.deviceStatus = DeviceStatus.CONNECTED;
	}
 
	@Override
	public void disconnect() throws IllegalStateException, Exception {
		this.connection.disconnect();
		this.deviceStatus = DeviceStatus.DISCONNECTED;
	}
 
	@Override
	public String getInfo() {
		// TODO Auto-generated method stub
		return null;
	}
 
}
zalozeni/classes/device.txt · Last modified: 2016/07/22 10:43 by jlochman