Skip to content
Snippets Groups Projects
Commit 7ed10f9b authored by eric.boise's avatar eric.boise Committed by Martins Mozeiko
Browse files

Bridgehz

parent df7da35d
No related branches found
No related tags found
No related merge requests found
......@@ -187,6 +187,7 @@ namespace Simulator.Bridge.Cyber
{
Topic = topic,
Type = type.ToString(),
Frequency = 0f,
});
}
......@@ -298,6 +299,7 @@ namespace Simulator.Bridge.Cyber
{
Topic = topic,
Type = type.ToString(),
Frequency = 0f,
});
var data = bytes.ToArray();
......
......@@ -23,7 +23,9 @@ namespace Simulator.Bridge
public string Topic;
public string Type;
public int Count;
public int Frequency;
public int StartCount;
public float ElapsedTime;
public float Frequency;
}
public interface IBridge
......
......@@ -163,6 +163,7 @@ namespace Simulator.Bridge.Ros
{
Topic = topic,
Type = messageType,
Frequency = 0f,
});
var data = sb.ToString();
......@@ -299,6 +300,7 @@ namespace Simulator.Bridge.Ros
{
Topic = topic,
Type = messageType,
Frequency = 0f,
});
var data = sb.ToString();
......
......@@ -335,7 +335,7 @@ public class UIManager : MonoBehaviour
sb.AppendLine($"PUB:");
sb.AppendLine($"Topic: {pub.Topic}");
sb.AppendLine($"Type: {pub.Type}");
//sb.AppendLine($"Frequency: {pub.Frequency}");
sb.AppendLine($"Frequency: {pub.Frequency:F2} Hz");
sb.AppendLine($"Count: {pub.Count}");
CurrentBridgeInfo.Add(pub.Topic, CreateBridgeInfo(sb.ToString()));
}
......@@ -346,7 +346,7 @@ public class UIManager : MonoBehaviour
sb.AppendLine($"SUB:");
sb.AppendLine($"Topic: {sub.Topic}");
sb.AppendLine($"Type: {sub.Type}");
//sb.AppendLine($"Frequency: {sub.Frequency}");
sb.AppendLine($"Frequency: {sub.Frequency:F2} Hz");
sb.AppendLine($"Count: {sub.Count}");
CurrentBridgeInfo.Add(sub.Topic, CreateBridgeInfo(sb.ToString()));
}
......@@ -391,11 +391,22 @@ public class UIManager : MonoBehaviour
{
if (CurrentBridgeInfo.TryGetValue(pub.Topic, out Text ui))
{
if (pub.ElapsedTime >= 1 && pub.Count > pub.StartCount)
{
pub.Frequency = (pub.Count - pub.StartCount) / pub.ElapsedTime;
pub.StartCount = pub.Count;
pub.ElapsedTime = 0f;
}
else
{
pub.ElapsedTime += Time.unscaledDeltaTime;
}
sb.Clear();
sb.AppendLine($"PUB:");
sb.AppendLine($"Topic: {pub.Topic}");
sb.AppendLine($"Type: {pub.Type}");
//sb.AppendLine($"Frequency: {pub.Frequency}");
sb.AppendLine($"Frequency: {pub.Frequency:F2} Hz");
sb.AppendLine($"Count: {pub.Count}");
ui.text = sb.ToString();
}
......@@ -405,11 +416,22 @@ public class UIManager : MonoBehaviour
{
if (CurrentBridgeInfo.TryGetValue(sub.Topic, out Text ui))
{
if (sub.ElapsedTime >= 1 && sub.Count > sub.StartCount)
{
sub.Frequency = (sub.Count - sub.StartCount) / sub.ElapsedTime;
sub.StartCount = sub.Count;
sub.ElapsedTime = 0f;
}
else
{
sub.ElapsedTime += Time.unscaledDeltaTime;
}
sb.Clear();
sb.AppendLine($"SUB:");
sb.AppendLine($"Topic: {sub.Topic}");
sb.AppendLine($"Type: {sub.Type}");
//sb.AppendLine($"Frequency: {sub.Frequency}");
sb.AppendLine($"Frequency: {sub.Frequency:F2} Hz");
sb.AppendLine($"Count: {sub.Count}");
ui.text = sb.ToString();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment