/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane Deserialize(Stream stream) { CDTIPlane instance = new CDTIPlane(); Deserialize(stream, instance); return(instance); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane DeserializeLength(Stream stream, int length) { CDTIPlane instance = new CDTIPlane(); DeserializeLength(stream, length, instance); return(instance); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane DeserializeLengthDelimited(Stream stream) { CDTIPlane instance = new CDTIPlane(); DeserializeLengthDelimited(stream, instance); return(instance); }
/// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary> public static CDTIPlane Deserialize(byte[] buffer) { CDTIPlane instance = new CDTIPlane(); using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return instance; }
/// <summary>Helper: Serialize with a varint length prefix</summary> public static void SerializeLengthDelimited(Stream stream, CDTIPlane instance) { var data = SerializeToBytes(instance); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length); stream.Write(data, 0, data.Length); }
/// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary> public static CDTIPlane Deserialize(byte[] buffer) { CDTIPlane instance = new CDTIPlane(); using (var ms = new MemoryStream(buffer)) Deserialize(ms, instance); return(instance); }
/// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary> public static byte[] SerializeToBytes(CDTIPlane instance) { using (var ms = new MemoryStream()) { Serialize(ms, instance); return(ms.ToArray()); } }
public void addText(CDTIPlane plane) { text = new GameObject(); text.AddComponent<TextMesh>(); text.transform.SetParent(transform); Instantiate(text); text.GetComponent<TextMesh>().fontSize = 60; text.GetComponent<TextMesh>().fontStyle = FontStyle.Normal; text.GetComponent<TextMesh>().text = "" + plane.Position.Z; text.transform.localScale = new Vector3(.05f, .05f, 1); text.transform.position = transform.position + new Vector3(.2f, .2f, 0); }
public void testPostion() { CDTIPlane plane = new CDTIPlane(); plane.Position = new Vector(5, 5, 0); NetworkInput toTest = new NetworkInput(); Assert.That(1.25 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x); Assert.That(1.25== toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y); toTest.zoomIn(); Assert.That(1.5625 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x); Assert.That(1.5625 == toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y); toTest.zoomOut(); toTest.zoomOut(); Assert.That(1.041667 == toTest.figurePositon(plane).x, "got: " + toTest.figurePositon(plane).x); Assert.That(1.041667 == toTest.figurePositon(plane).y, "got: " + toTest.figurePositon(plane).y); }
private static CDTIPlane buildPlanes(double px, double py, double pz, double vx, double vy, double vz, string id) { CDTIPlane toReturn = new CDTIPlane(); Vector v = new Vector(); Vector p = new Vector(); p.N = (float)px; p.E = (float)py; p.D = (float)pz; v.N = (float)vx; v.E = (float)vy; v.D = (float)vz; toReturn.Position = p; toReturn.Velocity = v; toReturn.Id = id; return toReturn; }
private static void send() { Example.CDTIReport report = new Example.CDTIReport(); Example.CDTIPlane ownship = new Example.CDTIPlane(); ownship.Id = "2"; ownship.Position = new Example.Vector(5, 3, 4); ownship.Velocity = new Example.Vector(5, 3, 4); ownship.severity = (Example.CDTIPlane.Severity.TRAFFIC); report.Ownship = ownship; report.Timestamp = 1; report.AdvisoryLevel = (Example.CDTIReport.Severity) 0; report.AdvisoryMessage = "message"; report.Planes = planes; byte junkByte = 200; //stream.WriteByte(junkByte); Example.CDTIReport.Serialize(stream, report); }
/// <summary>Serialize the instance into the stream</summary> public static void Serialize(Stream stream, CDTIPlane instance) { var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop(); if (instance.Id == null) { throw new ArgumentNullException("Id", "Required by proto specification."); } // Key for field: 1, LengthDelimited stream.WriteByte(10); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Id)); if (instance.Position == null) { throw new ArgumentNullException("Position", "Required by proto specification."); } // Key for field: 2, LengthDelimited stream.WriteByte(18); msField.SetLength(0); Example.Vector.Serialize(msField, instance.Position); // Length delimited byte array uint length2 = (uint)msField.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length2); stream.Write(msField.GetBuffer(), 0, (int)length2); if (instance.Velocity == null) { throw new ArgumentNullException("Velocity", "Required by proto specification."); } // Key for field: 3, LengthDelimited stream.WriteByte(26); msField.SetLength(0); Example.Vector.Serialize(msField, instance.Velocity); // Length delimited byte array uint length3 = (uint)msField.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length3); stream.Write(msField.GetBuffer(), 0, (int)length3); // Key for field: 4, Varint stream.WriteByte(32); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream, (ulong)instance.severity); global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField); }
public Quaternion figureRotation(CDTIPlane plane) { try { float theta = 0; theta = (float)(Math.Atan2(plane.Velocity.Y, plane.Velocity.X) * 180 / 3.14 - 90); print(theta); if (plane.Velocity.X == 0 && plane.Velocity.Y == 0) { theta = 0; } return Quaternion.AngleAxis(theta, new Vector3(0, 0, 1)); } catch (Exception) { return Quaternion.AngleAxis(0, new Vector3(0, 0, 1)); } }
public Vector3 figurePositon(CDTIPlane plane) { Vector3 positon; if (plane == null) { positon.x = pos.X / maxRange * 5; positon.y = pos.Y / maxRange * 5; positon.z = 0; return positon; } positon.x = plane.Position.X/maxRange*5; positon.y = plane.Position.Y/maxRange*5; positon.z = 0; //add writing for the elevation later return positon; // throw new NotImplementedException(); }
public void testRotation() { CDTIPlane plane = new CDTIPlane(); plane.Velocity = new Vector(1, 0, 0); NetworkInput toTest = new NetworkInput(); Assert.That(Quaternion.AngleAxis(-90, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(1, 1, 0); Assert.That(Quaternion.AngleAxis(-45, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(0, 1, 0); Assert.That(Quaternion.AngleAxis(0, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(-1, 1, 0); Assert.That(Quaternion.AngleAxis(45, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(-1, 0, 0); Assert.That(Quaternion.AngleAxis(90, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(-1, -1, 0); Assert.That(Quaternion.AngleAxis(135, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(0, -1, 0); Assert.That(Quaternion.AngleAxis(180, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); plane.Velocity = new Vector(1, -1, 0); Assert.That(Quaternion.AngleAxis(225, new Vector3(0, 0, 1)).Equals(toTest.figureRotation(plane))); }
private void setUpText(GameObject toAdd, CDTIPlane plane) { throw new NotImplementedException(); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane DeserializeLength(Stream stream, int length) { CDTIPlane instance = new CDTIPlane(); DeserializeLength(stream, length, instance); return instance; }
/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane DeserializeLengthDelimited(Stream stream) { CDTIPlane instance = new CDTIPlane(); DeserializeLengthDelimited(stream, instance); return instance; }
/// <summary>Serialize the instance into the stream</summary> public static void Serialize(Stream stream, CDTIPlane instance) { var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop(); if (instance.Id == null) throw new ArgumentNullException("Id", "Required by proto specification."); // Key for field: 1, LengthDelimited stream.WriteByte(10); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Id)); if (instance.Position == null) throw new ArgumentNullException("Position", "Required by proto specification."); // Key for field: 2, LengthDelimited stream.WriteByte(18); msField.SetLength(0); Example.Vector.Serialize(msField, instance.Position); // Length delimited byte array uint length2 = (uint)msField.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length2); stream.Write(msField.GetBuffer(), 0, (int)length2); if (instance.Velocity == null) throw new ArgumentNullException("Velocity", "Required by proto specification."); // Key for field: 3, LengthDelimited stream.WriteByte(26); msField.SetLength(0); Example.Vector.Serialize(msField, instance.Velocity); // Length delimited byte array uint length3 = (uint)msField.Length; global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length3); stream.Write(msField.GetBuffer(), 0, (int)length3); // Key for field: 4, Varint stream.WriteByte(32); global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.severity); global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField); }
/// <summary>Helper: create a new instance to deserializing into</summary> public static CDTIPlane Deserialize(Stream stream) { CDTIPlane instance = new CDTIPlane(); Deserialize(stream, instance); return instance; }
private static void send() { Example.CDTIReport report = new Example.CDTIReport(); Example.CDTIPlane ownship = new Example.CDTIPlane(); ownship.Id = "2"; ownship.Position = new Example.Vector(5,3,4); ownship.Velocity = new Example.Vector(5,3,4); ownship.severity = (Example.CDTIPlane.Severity.TRAFFIC); report.Ownship = ownship; report.Timestamp = 1; report.AdvisoryLevel = (Example.CDTIReport.Severity)0; report.AdvisoryMessage = "message"; report.Planes = planes; byte junkByte = 200; //stream.WriteByte(junkByte); Example.CDTIReport.Serialize(stream, report); }
private Sprite getCorrectSprite(CDTIPlane plane) { if(plane == null) { return airTrafficDirectional; } switch (plane.severity) { case (CDTIPlane.Severity.PROXIMATE): if (plane.Velocity.X == 0 && plane.Velocity.Y == 0) { return proximateTrafficNonDirectional; } else return proximateTrafficDirectional; case (CDTIPlane.Severity.TRAFFIC): return trafficAdvisoryDirectional; case (CDTIPlane.Severity.RESOLUTION): return resolutionAdvisoryDirectional; default: if (plane.Velocity.X == 0 && plane.Velocity.Y == 0) { return airTrafficNonDirectional; } else return airTrafficDirectional; } }
private void AddToScreen(CDTIPlane plane) { if(plane == null) { return; } GameObject toAdd; if (aircraftHidden.Count > 0) { toAdd = aircraftHidden[0]; aircraftHidden.Remove(toAdd); } else { toAdd = Instantiate(aircraftBuilder) as GameObject; } toAdd.GetComponent<SpriteRenderer>().sprite = getCorrectSprite(plane); toAdd.GetComponent<Transform>().position = figurePositon(plane); toAdd.GetComponent<Transform>().rotation = figureRotation(plane); if(plane != null && plane.Position.X != 0 || plane.Position.Y != 0 || plane.Position.Z != 0) { toAdd.GetComponent<Aircraft>().addText(plane); } logger("added to screed " + plane.Id); aircraft.Add(toAdd); //throw new NotImplementedException(); }
/// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary> public static byte[] SerializeToBytes(CDTIPlane instance) { using (var ms = new MemoryStream()) { Serialize(ms, instance); return ms.ToArray(); } }