This commit is contained in:
m_broelemann 2020-12-25 15:24:43 +01:00
commit 83e8ec0aea
4 changed files with 78 additions and 11 deletions

View File

@ -1,8 +1,19 @@
package com.example.aped.communication; package com.example.aped.communication;
public interface IIO { public interface IIO
{
/**
* reads a value from a device connected to the raspberry
* @param deviceName the name of the device to read from
* @return the value read
*/
String read(String deviceName);
public Object read(String deviceName); /**
* writes a value to a device connected to the raspberry
public Object write(String deviceName, Object value); * @param deviceName the name of the device to write to
* @param value the value to write to the device
* @return the value written
*/
String write(String deviceName, String value);
} }

View File

@ -1,16 +1,38 @@
package com.example.aped.communication; package com.example.aped.communication;
import java.util.Dictionary;
import java.util.List;
public interface IXML { public interface IXML {
/** /**
* * downloads the XML from the raspberry to the local folder
* @return hat Funktioniert? * @return 0 for no errors
*/ */
int download(); int download();
/** /**
* * uploads the local XML to the raspberry
* @return hat Funktioniert? * @return 0 for no errors
*/ */
int upload(); int upload();
/**
* reads the list of available devices from the XML
* @return the device names as a list of strings
*/
List<String> getDeviceNames();
/**
* reads the value info of a given device from the XML
* @param deviceName the name of the relevant device
* @return the value info as a Dictionary
*/
Dictionary<String, Object> getValueInfo(String deviceName);
/**
* reads the port information of a given device from the XML
* @param deviceName the name of the relevant device
* @return the value info as a Dictionary
*/
Dictionary<String, Object> getPort(String deviceName);
} }

View File

@ -3,12 +3,12 @@ package com.example.aped.communication;
public class TestIO implements IIO { public class TestIO implements IIO {
@Override @Override
public Object read(String deviceName) { public String read(String deviceName) {
return new String("test"); return "test";
} }
@Override @Override
public Object write(String deviceName, Object value) { public String write(String deviceName, String value) {
return value; return value;
} }
} }

View File

@ -1,6 +1,11 @@
package com.example.aped.communication; package com.example.aped.communication;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
public class TestXML implements IXML { public class TestXML implements IXML {
/** Test Klasse.*/ /** Test Klasse.*/
@Override @Override
@ -12,4 +17,33 @@ public class TestXML implements IXML {
public int upload() { public int upload() {
return 0; return 0;
} }
@Override
public List<String> getDeviceNames() {
List<String> returnList = new ArrayList<>();
returnList.add("stoff");
returnList.add("schnaps");
return returnList;
}
@Override
public Dictionary<String, Object> getValueInfo(String deviceName) {
Dictionary<String,Object> returnDict = new Hashtable<>();
returnDict.put("type","boolean");
returnDict.put("unit","");
returnDict.put("Offset",1.0);
returnDict.put("Factor",1.0);
return returnDict;
}
@Override
public Dictionary<String, Object> getPort(String deviceName) {
Dictionary<String, Object> returnDict = new Hashtable<>();
returnDict.put("protocol","DI");
Dictionary<String,Object> pins = new Hashtable<>();
pins.put("GPIO2",true);
pins.put("GPIO3",false);
returnDict.put("pins",pins);
return returnDict;
}
} }