From 7f7ea583b2c21ef01c2201ebbadef502759550cf Mon Sep 17 00:00:00 2001 From: jef Date: Sat, 12 May 2007 00:10:33 +0000 Subject: [PATCH] Decoding of simstats. Can be disable via Settings.ENABLE_SIMSTATS git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1182 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/NetworkManager.cs | 89 ++++++++++++++++++- libsecondlife/Settings.cs | 2 + libsecondlife/Simulator.cs | 27 +++++- .../TestClient/Commands/StatsCommand.cs | 7 +- 4 files changed, 121 insertions(+), 4 deletions(-) diff --git a/libsecondlife/NetworkManager.cs b/libsecondlife/NetworkManager.cs index c3b6899c..5798dcf2 100644 --- a/libsecondlife/NetworkManager.cs +++ b/libsecondlife/NetworkManager.cs @@ -211,7 +211,8 @@ namespace libsecondlife RegisterCallback(PacketType.KickUser, new PacketCallback(KickUserHandler)); RegisterCallback(PacketType.LogoutReply, new PacketCallback(LogoutReplyHandler)); RegisterCallback(PacketType.CompletePingCheck, new PacketCallback(PongHandler)); - + RegisterCallback(PacketType.SimStats, new PacketCallback(SimStatsHandler)); + // The proper timeout for this will get set again at Login DisconnectTimer = new System.Timers.Timer(); DisconnectTimer.Elapsed += new ElapsedEventHandler(DisconnectTimer_Elapsed); @@ -932,6 +933,92 @@ namespace libsecondlife simulator.ReceivedPongs++; // Client.Log(retval, Helpers.LogLevel.Info); } + + private void SimStatsHandler(Packet packet, Simulator simulator) + { + if ( ! Client.Settings.ENABLE_SIMSTATS ) { + return; + } + SimStatsPacket stats = (SimStatsPacket)packet; + for ( int i = 0 ; i < stats.Stat.Length ; i++ ) { + SimStatsPacket.StatBlock s = stats.Stat[i]; + switch (s.StatID ) + { + case 0: + simulator.Dilation = s.StatValue; + break; + case 1: + simulator.FPS = Convert.ToInt32(s.StatValue); + break; + case 2: + simulator.PhysicsFPS = s.StatValue; + break; + case 3: + simulator.AgentUpdates = s.StatValue; + break; + case 4: + simulator.FrameTime = s.StatValue; + break; + case 5: + simulator.NetTime = s.StatValue; + break; + case 7: + simulator.PhysicsTime = s.StatValue; + break; + case 8: + simulator.ImageTime = s.StatValue; + break; + case 9: + simulator.ScriptTime = s.StatValue; + break; + case 10: + simulator.OtherTime = s.StatValue; + break; + case 11: + simulator.Objects = Convert.ToInt32(s.StatValue); + break; + case 12: + simulator.ScriptedObjects = Convert.ToInt32(s.StatValue); + break; + case 13: + simulator.Agents = Convert.ToInt32(s.StatValue); + break; + case 14: + simulator.ChildAgents = Convert.ToInt32(s.StatValue); + break; + case 15: + simulator.ActiveScripts = Convert.ToInt32(s.StatValue); + break; + case 16: + simulator.LSLIPS = Convert.ToInt32(s.StatValue); + break; + case 17: + simulator.INPPS = Convert.ToInt32(s.StatValue); + break; + case 18: + simulator.OUTPPS = Convert.ToInt32(s.StatValue); + break; + case 19: + simulator.PendingDownloads = Convert.ToInt32(s.StatValue); + break; + case 20: + simulator.PendingUploads = Convert.ToInt32(s.StatValue); + break; + case 21: + simulator.VirtualSize = Convert.ToInt32(s.StatValue); + break; + case 22: + simulator.ResidentSize = Convert.ToInt32(s.StatValue); + break; + case 23: + simulator.PendingLocalUploads = Convert.ToInt32(s.StatValue); + break; + case 24: + simulator.UnackedBytes = Convert.ToInt32(s.StatValue); + break; + } + } + } private void RegionHandshakeHandler(Packet packet, Simulator simulator) { diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index e9810451..71ba8459 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -144,6 +144,8 @@ namespace libsecondlife /// Whether to establish connections to HTTP capabilities /// servers for simulators public bool ENABLE_CAPS = true; + /// Whether to decode sim stats + public bool ENABLE_SIMSTATS = true; /// Cost of uploading an asset /// Read-only since this value is dynamically fetched at login diff --git a/libsecondlife/Simulator.cs b/libsecondlife/Simulator.cs index cbc7fdea..9f00eba1 100644 --- a/libsecondlife/Simulator.cs +++ b/libsecondlife/Simulator.cs @@ -184,8 +184,6 @@ namespace libsecondlife public bool IsEstateManager; /// public EstateTools Estate; - /// Current time dilation of this simulator - public float Dilation; /// public RegionFlags Flags; /// @@ -230,6 +228,31 @@ namespace libsecondlife public int LastLag = 0; /// public int MissedPings = 0; + /// Current time dilation of this simulator + public float Dilation = 0; + public int FPS = 0; + public float PhysicsFPS = 0; + public float AgentUpdates = 0; + public float FrameTime = 0; + public float NetTime = 0; + public float PhysicsTime = 0; + public float ImageTime = 0; + public float ScriptTime = 0; + public float OtherTime = 0; + public int Objects = 0; + public int ScriptedObjects = 0; + public int Agents = 0; + public int ChildAgents = 0; + public int ActiveScripts = 0; + public int LSLIPS = 0; + public int INPPS = 0; + public int OUTPPS = 0; + public int PendingDownloads = 0; + public int PendingUploads = 0; + public int VirtualSize = 0; + public int ResidentSize = 0; + public int PendingLocalUploads = 0; + public int UnackedBytes = 0; #endregion Public Members diff --git a/libsecondlife/examples/TestClient/Commands/StatsCommand.cs b/libsecondlife/examples/TestClient/Commands/StatsCommand.cs index 7835ec85..4e171c58 100644 --- a/libsecondlife/examples/TestClient/Commands/StatsCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/StatsCommand.cs @@ -30,8 +30,13 @@ namespace libsecondlife.TestClient sim.ReceivedResends)); } } - output.Append("Packets in the queue: " + Client.Network.InboxCount); + output.AppendLine(String.Format("FPS : {0} PhysicsFPS : {1} AgentUpdates : {2} Objects : {3} Scripted Objects : {4}", + Client.Network.CurrentSim.FPS, Client.Network.CurrentSim.PhysicsFPS, Client.Network.CurrentSim.AgentUpdates, Client.Network.CurrentSim.Objects, Client.Network.CurrentSim.ScriptedObjects)); + output.AppendLine(String.Format("Frame Time : {0} Net Time : {1} Image Time : {2} Physics Time : {3} Script Time : {4} Other Time : {5}", + Client.Network.CurrentSim.FrameTime, Client.Network.CurrentSim.NetTime, Client.Network.CurrentSim.ImageTime, Client.Network.CurrentSim.PhysicsTime, Client.Network.CurrentSim.ScriptTime, Client.Network.CurrentSim.OtherTime)); + output.AppendLine(String.Format("Agents : {0} Child Agents : {1} Active Scripts : {2}", + Client.Network.CurrentSim.Agents, Client.Network.CurrentSim.ChildAgents, Client.Network.CurrentSim.ActiveScripts)); return output.ToString(); }