public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); BinarySerializer b = new BinarySerializer(); b.WriteInt(headerBytes.Length); b.WriteBytes(headerBytes); b.WriteByte(status); b.WriteBool(valid); b.WriteInt(axis.Count); for (int i = 0; i < axis.Count; i++) { b.WriteFloat(axis [i]); } b.WriteInt(axis_function.Count); b.WriteBytes(axis_function.ToArray()); b.WriteInt(swit.Count); b.WriteBytes(swit.ToArray()); b.WriteInt(swit_function.Count); b.WriteBytes(swit_function.ToArray()); return(b.GetBytes()); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); BinarySerializer b = new BinarySerializer(); b.WriteInt(headerBytes.Length); b.WriteBytes(headerBytes); b.WriteBool(on); b.WriteBool(running); // voltage b.WriteInt(voltage.Length); for (int i = 0; i < voltage.Length; i++) { b.WriteFloat(voltage [i]); } // frequency b.WriteInt(frequency.Length); for (int i = 0; i < frequency.Length; i++) { b.WriteFloat(frequency [i]); } // current b.WriteInt(current.Length); for (int i = 0; i < current.Length; i++) { b.WriteFloat(current [i]); } return(b.GetBytes()); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; int byteSize = sizeof(uint8); byte[] bytes = new byte[headerSize + sizeof(float)]; headerBytes.CopyTo(bytes, 0); pos += headerSize; BitConverter.GetBytes(turnrate).CopyTo(bytes, pos); pos += sizeof(float); return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; int byteSize = sizeof(uint8); byte[] bytes = new byte[headerSize + 3]; headerBytes.CopyTo(bytes, 0); pos += headerSize; bytes [pos++] = source; bytes [pos++] = mode; bytes [pos++] = state; return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; int floatSize = sizeof(float); byte[] bytes = new byte[headerSize + 2 * floatSize]; headerBytes.CopyTo(bytes, 0); pos += headerSize; BitConverter.GetBytes(magnetic_heading).CopyTo(bytes, pos); pos += floatSize; BitConverter.GetBytes(declination).CopyTo(bytes, pos); pos += floatSize; return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; byte[] bytes = new byte[headerSize + 24]; headerBytes.CopyTo(bytes, 0); pos += headerSize; for (int i = 0; i < 3; i++) { BitConverter.GetBytes(channel [i]).CopyTo(bytes, pos); pos += 8; } return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; byte[] bytes = new byte[headerSize + 12]; headerBytes.CopyTo(bytes, 0); pos += headerSize; BitConverter.GetBytes(aileron).CopyTo(bytes, pos); pos += 4; BitConverter.GetBytes(elevator).CopyTo(bytes, pos); pos += 4; BitConverter.GetBytes(rudder).CopyTo(bytes, pos); pos += 4; return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; byte[] bytes = new byte[headerSize + 4 + value.Length]; headerBytes.CopyTo(bytes, 0); pos += headerSize; BitConverter.GetBytes(value.Length).CopyTo(bytes, pos); pos += 4; for (int i = 0; i < value.Length; i++) { BitConverter.GetBytes(value [i]).CopyTo(bytes, pos); pos += 2; } return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; int floatSize = sizeof(float); byte[] bytes = new byte[headerSize + 3 * floatSize]; headerBytes.CopyTo(bytes, 0); pos += headerSize; BitConverter.GetBytes(altitude).CopyTo(bytes, pos); pos += floatSize; BitConverter.GetBytes(pressure).CopyTo(bytes, pos); pos += floatSize; BitConverter.GetBytes(qnh).CopyTo(bytes, pos); pos += floatSize; return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); //header if (header == null) { header = new Messages.std_msgs.Header(); } pieces.Add(header.Serialize(true)); //child_frame_id if (child_frame_id == null) { child_frame_id = ""; } scratch1 = Encoding.ASCII.GetBytes((string)child_frame_id); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //transform if (transform == null) { transform = new Messages.geometry_msgs.Transform(); } pieces.Add(transform.Serialize(true)); // combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { bool hasmetacomponents = false; List <byte[]> pieces = new List <byte[]>(); //header if (header == null) { header = new Messages.std_msgs.Header(); } pieces.Add(header.Serialize(true)); //status_list hasmetacomponents |= true; if (status_list == null) { status_list = new Messages.actionlib_msgs.GoalStatus[0]; } pieces.Add(BitConverter.GetBytes(status_list.Length)); for (int i = 0; i < status_list.Length; i++) { //status_list[i] if (status_list[i] == null) { status_list[i] = new Messages.actionlib_msgs.GoalStatus(); } pieces.Add(status_list[i].Serialize(true)); } // combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; BinarySerializer b = new BinarySerializer(); b.WriteInt(headerSize); b.WriteBytes(headerBytes); b.WriteInt(voltage.Length); for (int i = 0; i < voltage.Length; i++) { b.WriteFloat(voltage [i]); } b.WriteInt(current.Length); for (int i = 0; i < current.Length; i++) { b.WriteFloat(current [i]); } return(b.GetBytes()); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; byte[] bytes = new byte[headerSize + 12]; headerBytes.CopyTo(bytes, 0); pos += headerSize; for (int i = 0; i < 3; i++) { BitConverter.GetBytes(angular_velocity [i]).CopyTo(bytes, pos); pos += 2; } for (int i = 0; i < 3; i++) { BitConverter.GetBytes(linear_acceleration [i]).CopyTo(bytes, pos); pos += 2; } return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { int pos = 0; byte[] headerBytes = header.Serialize(); int headerSize = headerBytes.Length; int byteSize = sizeof(uint8); byte[] bytes = new byte[headerSize + 5 + channel.Length]; headerBytes.CopyTo(bytes, 0); pos += headerSize; bytes [pos++] = status; int length = channel.Length; BitConverter.GetBytes(length).CopyTo(bytes, pos); pos += 4; for (int i = 0; i < length; i++) { BitConverter.GetBytes(channel [i]).CopyTo(bytes, pos); pos += 2; } return(bytes); }
public override byte[] Serialize(bool partofsomethingelse) { bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //header if (header == null) { header = new Messages.std_msgs.Header(); } pieces.Add(header.Serialize(true)); //level pieces.Add(new[] { (byte)level }); //name if (name == null) { name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)name); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //msg if (msg == null) { msg = ""; } scratch1 = Encoding.ASCII.GetBytes((string)msg); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //file if (file == null) { file = ""; } scratch1 = Encoding.ASCII.GetBytes((string)file); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //function if (function == null) { function = ""; } scratch1 = Encoding.ASCII.GetBytes((string)function); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //line scratch1 = new byte[Marshal.SizeOf(typeof(uint))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(line, h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); //topics hasmetacomponents |= false; if (topics == null) { topics = new string[0]; } pieces.Add(BitConverter.GetBytes(topics.Length)); for (int i = 0; i < topics.Length; i++) { //topics[i] if (topics[i] == null) { topics[i] = ""; } scratch1 = Encoding.ASCII.GetBytes((string)topics[i]); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); } // combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }