/
TopicUpdate.cs
112 lines (103 loc) · 4.82 KB
/
TopicUpdate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
//////////////////////////////////////////////////
///// AUTOGENERATED MESSAGE DEFINITION /////
//////////////////////////////////////////////////
///// DO NOT MODIFY BY HAND! /////
//////////////////////////////////////////////////
namespace ROS_CS
{
namespace datalink_msgs
{
public class TopicUpdate : ROS_CS.Core.BaseMessage
{
public readonly string typeID = "TopicUpdate";
public readonly string md5sum = "e6d39e0588d11f005f47d62ecc7ac8ae";
public std_msgs.Header header;
public List<string> TopicNames;
public List<string> TopicTypes;
public TopicUpdate ()
{
header = new std_msgs.Header();
TopicNames = new List<string>();
TopicTypes = new List<string>();
}
public override string ToString ()
{
return ROS_CS.Core.PrettyPrinter.PrettyPrint(ToStringRaw());
}
public override string ToStringRaw ()
{
string string_rep = typeID + ":\n";
string_rep += header.ToStringRaw() + "\n";
string_rep += "TopicNames:\n[";
foreach (string element in TopicNames)
{
string_rep += " " + element;
}
string_rep += "]\n\n";
string_rep += "TopicTypes:\n[";
foreach (string element in TopicTypes)
{
string_rep += " " + element;
}
string_rep += "]\n\n";
return string_rep;
}
public override void Serialize(MemoryStream stream)
{
header.Serialize(stream);
System.Byte[] TopicNames_len_bytes = BitConverter.GetBytes((System.UInt32)TopicNames.Count);
stream.Write(TopicNames_len_bytes, 0, TopicNames_len_bytes.Length);
foreach(string element in TopicNames)
{
System.Byte[] element_bytes = System.Text.Encoding.UTF8.GetBytes(element);
System.Byte[] element_len_bytes = BitConverter.GetBytes((System.UInt32)element_bytes.Length);
stream.Write(element_len_bytes, 0, element_len_bytes.Length);
stream.Write(element_bytes, 0, element_bytes.Length);
}
System.Byte[] TopicTypes_len_bytes = BitConverter.GetBytes((System.UInt32)TopicTypes.Count);
stream.Write(TopicTypes_len_bytes, 0, TopicTypes_len_bytes.Length);
foreach(string element in TopicTypes)
{
System.Byte[] element_bytes = System.Text.Encoding.UTF8.GetBytes(element);
System.Byte[] element_len_bytes = BitConverter.GetBytes((System.UInt32)element_bytes.Length);
stream.Write(element_len_bytes, 0, element_len_bytes.Length);
stream.Write(element_bytes, 0, element_bytes.Length);
}
}
public override int Deserialize(System.Byte[] serialized)
{
return Deserialize(serialized, 0);
}
public override int Deserialize(System.Byte[] serialized, int startIndex)
{
int curIndex = startIndex;
curIndex += header.Deserialize(serialized, curIndex);
System.UInt32 TopicNames_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(TopicNames_len).Length;
for (int i = 0; i < (int)TopicNames_len; i++)
{
System.UInt32 element_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(element_len).Length;
string element = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)element_len);
curIndex += (int)element_len;
TopicNames.Add(element);
}
System.UInt32 TopicTypes_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(TopicTypes_len).Length;
for (int i = 0; i < (int)TopicTypes_len; i++)
{
System.UInt32 element_len = BitConverter.ToUInt32(serialized, curIndex);
curIndex += BitConverter.GetBytes(element_len).Length;
string element = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)element_len);
curIndex += (int)element_len;
TopicTypes.Add(element);
}
return (curIndex - startIndex);
}
}
}
}