From accf9b02b756474fd7ea08c5d27384f382a93003 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Fri, 25 Dec 2020 14:18:21 +0100 Subject: [PATCH 1/2] changed the IIO --- .../com/example/aped/communication/IIO.java | 19 +++++++++++++++---- .../example/aped/communication/TestIO.java | 6 +++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/APED/app/src/main/java/com/example/aped/communication/IIO.java b/APED/app/src/main/java/com/example/aped/communication/IIO.java index 7b178a3..9c7f5b5 100644 --- a/APED/app/src/main/java/com/example/aped/communication/IIO.java +++ b/APED/app/src/main/java/com/example/aped/communication/IIO.java @@ -1,8 +1,19 @@ 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); - - public Object write(String deviceName, Object value); + /** + * writes a value to a device connected to the raspberry + * @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); } diff --git a/APED/app/src/main/java/com/example/aped/communication/TestIO.java b/APED/app/src/main/java/com/example/aped/communication/TestIO.java index 3ddfc0c..eb07aae 100644 --- a/APED/app/src/main/java/com/example/aped/communication/TestIO.java +++ b/APED/app/src/main/java/com/example/aped/communication/TestIO.java @@ -3,12 +3,12 @@ package com.example.aped.communication; public class TestIO implements IIO { @Override - public Object read(String deviceName) { - return new String("test"); + public String read(String deviceName) { + return "test"; } @Override - public Object write(String deviceName, Object value) { + public String write(String deviceName, String value) { return value; } } From 4e4e6bd73f8eae57168d90b2bd7b8ab58d6fc047 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Fri, 25 Dec 2020 14:58:09 +0100 Subject: [PATCH 2/2] changed IXML to match the version on the raspberry --- .../com/example/aped/communication/IXML.java | 30 +++++++++++++--- .../example/aped/communication/TestXML.java | 34 +++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/APED/app/src/main/java/com/example/aped/communication/IXML.java b/APED/app/src/main/java/com/example/aped/communication/IXML.java index 880941a..0c2b4a0 100644 --- a/APED/app/src/main/java/com/example/aped/communication/IXML.java +++ b/APED/app/src/main/java/com/example/aped/communication/IXML.java @@ -1,16 +1,38 @@ package com.example.aped.communication; +import java.util.Dictionary; +import java.util.List; + public interface IXML { /** - * - * @return hat Funktioniert? + * downloads the XML from the raspberry to the local folder + * @return 0 for no errors */ int download(); /** - * - * @return hat Funktioniert? + * uploads the local XML to the raspberry + * @return 0 for no errors */ int upload(); + /** + * reads the list of available devices from the XML + * @return the device names as a list of strings + */ + List 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 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 getPort(String deviceName); } diff --git a/APED/app/src/main/java/com/example/aped/communication/TestXML.java b/APED/app/src/main/java/com/example/aped/communication/TestXML.java index 0b43443..3e043d4 100644 --- a/APED/app/src/main/java/com/example/aped/communication/TestXML.java +++ b/APED/app/src/main/java/com/example/aped/communication/TestXML.java @@ -1,6 +1,11 @@ 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 { /** Test Klasse.*/ @Override @@ -12,4 +17,33 @@ public class TestXML implements IXML { public int upload() { return 0; } + + @Override + public List getDeviceNames() { + List returnList = new ArrayList<>(); + returnList.add("stoff"); + returnList.add("schnaps"); + return returnList; + } + + @Override + public Dictionary getValueInfo(String deviceName) { + Dictionary 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 getPort(String deviceName) { + Dictionary returnDict = new Hashtable<>(); + returnDict.put("protocol","DI"); + Dictionary pins = new Hashtable<>(); + pins.put("GPIO2",true); + pins.put("GPIO3",false); + returnDict.put("pins",pins); + return returnDict; + } }