|
@@ -0,0 +1,50 @@
|
|
|
+package at.acdp.urweb.rtde.packets;
|
|
|
+
|
|
|
+import java.io.DataInputStream;
|
|
|
+import java.io.DataOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static at.acdp.urweb.rtde.CommandType.RTDE_CONTROL_PACKAGE_SETUP_INPUTS;
|
|
|
+import static at.acdp.urweb.rtde.CommandType.RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS;
|
|
|
+
|
|
|
+public class RtdeSetupInputs implements IRtdeData {
|
|
|
+ public int recipe;
|
|
|
+ public List<String> variables=new ArrayList<>();
|
|
|
+ public List<String> types=new ArrayList<>();
|
|
|
+ public String typesText;
|
|
|
+
|
|
|
+ public RtdeSetupInputs() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public RtdeSetupInputs addVariable(String name) {
|
|
|
+ variables.add(name);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getType() {
|
|
|
+ return RTDE_CONTROL_PACKAGE_SETUP_INPUTS;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RtdeSetupInputs read(DataInputStream d, int length) throws IOException {
|
|
|
+ recipe = d.readByte();
|
|
|
+ byte[] text=new byte[length-1];
|
|
|
+ d.readFully(text);
|
|
|
+ typesText=new String(text);
|
|
|
+ types.addAll(Arrays.asList(typesText.split(",")));
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RtdeSetupInputs send(DataOutputStream dos) throws IOException {
|
|
|
+ var payload = String.join(",", variables).getBytes();
|
|
|
+ sendHeader(dos, payload.length);
|
|
|
+ dos.write(payload);
|
|
|
+ dos.flush();
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+}
|