Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit 1507e56c authored by Jean Meurice's avatar Jean Meurice

SimplePacketType & PortInformation fixes

parent 44c1b74e
Pipeline #381485 passed with stage
in 49 seconds
......@@ -8,7 +8,7 @@
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.12</version>
<version>2.0.13</version>
<properties>
......
package de.rwth.montisim.commons.dynamicinterface;
import java.util.HashSet;
import java.util.Set;
import java.util.Vector;
public class PortInformation {
public static enum PortDirection {
......@@ -20,7 +19,7 @@ public class PortInformation {
public DataType data_type;
public boolean allows_multiple_inputs = true;
public boolean optional = false;
public final Set<String> tags = new HashSet<>(); // Tags for routing. Example: 'network' tag -> gets collected by the Gateway component
public Vector<String> tags = new Vector<>(); // Tags for routing. Example: 'network' tag -> gets collected by the Gateway component
protected PortInformation() {}
......
......@@ -17,8 +17,8 @@ public class ProgramInterface {
String res = "ProgramInterface of "+name+ " (v" + version+"):\n";
for (PortInformation p : ports) {
res += '\t';
if (p.direction == PortDirection.INPUT) res += (p.port_type == PortType.SOCKET) ? "sock_in" : "I ";
else res += (p.port_type == PortType.SOCKET) ? "sock_out" : "O ";
if (p.direction == PortDirection.INPUT) res += (p.port_type == PortType.SOCKET) ? "sock_in " : "I ";
else res += (p.port_type == PortType.SOCKET) ? "sock_out " : "O ";
res += p.name + ": "+p.data_type.toString()+"\n";
}
return res;
......
......@@ -87,19 +87,22 @@ public class SimplePacketType extends DataType {
public void toBinary(DataOutputStream os, Object o) throws IOException {
Object packet[] = (Object[]) o;
String addr = (String)packet[0];
os.writeShort(addr.length());
os.write(addr.getBytes());
os.writeByte(0); // Termination char
payloadType.toBinary(os, packet[1]);
}
@Override
public Object fromBinary(DataInputStream is) throws IOException {
Object res[] = new Object[2];
short addrSize = is.readShort();
//res[0] = new String(is.readNBytes(addrSize));
byte bytes[] = new byte[addrSize];
for (int i = 0; i < addrSize; ++i) bytes[i] = is.readByte();
res[0] = new String(bytes);
StringBuilder sb = new StringBuilder();
byte c;
do {
c = is.readByte();
if (c == 0) break;
sb.append((char)c);
} while (true);
res[0] = sb.toString();
res[1] = payloadType.fromBinary(is);
return res;
}
......@@ -113,6 +116,11 @@ public class SimplePacketType extends DataType {
return res;
}
@Override
public String toString() {
return "SimplePacket(" + payloadType + ")";
}
@Override
public Class<?> getArrayType() {
return Object[].class;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment