diff options
author | Teravus Ovares | 2007-12-12 06:58:55 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-12-12 06:58:55 +0000 |
commit | 081f4403ea2a2f8352d480910052bf5032e2e4a5 (patch) | |
tree | 9eeda0d127f84b1e0538ac834e7921a074b6503e /OpenSim/Region/Environment/Scenes | |
parent | * Patch from justincc to fix Inconsistent automatic mysql table creation - se... (diff) | |
download | opensim-SC-081f4403ea2a2f8352d480910052bf5032e2e4a5.zip opensim-SC-081f4403ea2a2f8352d480910052bf5032e2e4a5.tar.gz opensim-SC-081f4403ea2a2f8352d480910052bf5032e2e4a5.tar.bz2 opensim-SC-081f4403ea2a2f8352d480910052bf5032e2e4a5.tar.xz |
* Added some simstats to fill the simulator pane of the Statistics monitor.
* I stress, this is an initial implementation and the Agents(Child and Root) are definately obviously incorrect.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/InnerScene.cs | 52 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 78 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SimStatsReporter.cs | 158 |
4 files changed, 284 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index c0e07cb..b274d47 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs | |||
@@ -57,6 +57,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
57 | protected RegionInfo m_regInfo; | 57 | protected RegionInfo m_regInfo; |
58 | protected Scene m_parentScene; | 58 | protected Scene m_parentScene; |
59 | protected PermissionManager PermissionsMngr; | 59 | protected PermissionManager PermissionsMngr; |
60 | protected int m_numRootAgents = 0; | ||
61 | protected int m_numPrim = 0; | ||
62 | protected int m_numChildAgents = 0; | ||
60 | 63 | ||
61 | internal object m_syncRoot = new object(); | 64 | internal object m_syncRoot = new object(); |
62 | 65 | ||
@@ -133,11 +136,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
133 | } | 136 | } |
134 | } | 137 | } |
135 | 138 | ||
136 | internal void UpdatePhysics(double elapsed) | 139 | internal float UpdatePhysics(double elapsed) |
137 | { | 140 | { |
138 | lock (m_syncRoot) | 141 | lock (m_syncRoot) |
139 | { | 142 | { |
140 | _PhyScene.Simulate((float)elapsed); | 143 | return _PhyScene.Simulate((float)elapsed); |
141 | } | 144 | } |
142 | } | 145 | } |
143 | 146 | ||
@@ -171,6 +174,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
171 | { | 174 | { |
172 | // QuadTree.AddObject(sceneObject); | 175 | // QuadTree.AddObject(sceneObject); |
173 | Entities.Add(sceneObject.UUID, sceneObject); | 176 | Entities.Add(sceneObject.UUID, sceneObject); |
177 | m_numPrim++; | ||
174 | } | 178 | } |
175 | } | 179 | } |
176 | 180 | ||
@@ -183,6 +187,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
183 | if (((SceneObjectGroup)obj).LocalId == localID) | 187 | if (((SceneObjectGroup)obj).LocalId == localID) |
184 | { | 188 | { |
185 | m_parentScene.RemoveEntity((SceneObjectGroup)obj); | 189 | m_parentScene.RemoveEntity((SceneObjectGroup)obj); |
190 | m_numPrim--; | ||
186 | return; | 191 | return; |
187 | } | 192 | } |
188 | } | 193 | } |
@@ -198,10 +203,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
198 | 203 | ||
199 | if (child) | 204 | if (child) |
200 | { | 205 | { |
206 | m_numChildAgents++; | ||
201 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); | 207 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); |
202 | } | 208 | } |
203 | else | 209 | else |
204 | { | 210 | { |
211 | m_numRootAgents++; | ||
205 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); | 212 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); |
206 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); | 213 | MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); |
207 | 214 | ||
@@ -233,6 +240,47 @@ namespace OpenSim.Region.Environment.Scenes | |||
233 | 240 | ||
234 | return newAvatar; | 241 | return newAvatar; |
235 | } | 242 | } |
243 | public void SwapRootChildAgent(bool direction_RC_CR_T_F) | ||
244 | { | ||
245 | if (direction_RC_CR_T_F) | ||
246 | { | ||
247 | m_numRootAgents--; | ||
248 | m_numChildAgents++; | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | m_numChildAgents--; | ||
253 | m_numRootAgents++; | ||
254 | } | ||
255 | } | ||
256 | public void removeUserCount(bool TypeRCTF) | ||
257 | { | ||
258 | if (TypeRCTF) | ||
259 | { | ||
260 | m_numRootAgents--; | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | m_numChildAgents--; | ||
265 | } | ||
266 | } | ||
267 | public void RemoveAPrimCount() | ||
268 | { | ||
269 | m_numPrim--; | ||
270 | } | ||
271 | public void AddAPrimCount() | ||
272 | { | ||
273 | m_numPrim++; | ||
274 | } | ||
275 | public int GetChildAgentCount() | ||
276 | { | ||
277 | return m_numChildAgents; | ||
278 | } | ||
279 | |||
280 | public int GetRootAgentCount() | ||
281 | { | ||
282 | return m_numRootAgents; | ||
283 | } | ||
236 | #endregion | 284 | #endregion |
237 | 285 | ||
238 | #region Get Methods | 286 | #region Get Methods |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f2b5643..5462e77 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -59,6 +59,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
59 | protected Timer m_heartbeatTimer = new Timer(); | 59 | protected Timer m_heartbeatTimer = new Timer(); |
60 | protected Timer m_restartWaitTimer = new Timer(); | 60 | protected Timer m_restartWaitTimer = new Timer(); |
61 | 61 | ||
62 | protected SimStatsReporter m_statsReporter; | ||
63 | |||
62 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 64 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
63 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 65 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
64 | 66 | ||
@@ -256,6 +258,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
256 | 258 | ||
257 | httpListener = httpServer; | 259 | httpListener = httpServer; |
258 | m_dumpAssetsToFile = dumpAssetsToFile; | 260 | m_dumpAssetsToFile = dumpAssetsToFile; |
261 | |||
262 | m_statsReporter = new SimStatsReporter(regInfo); | ||
263 | m_statsReporter.OnSendStatsResult += SendSimStatsPackets; | ||
259 | } | 264 | } |
260 | 265 | ||
261 | #endregion | 266 | #endregion |
@@ -531,7 +536,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
531 | TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; | 536 | TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; |
532 | // Aquire a lock so only one update call happens at once | 537 | // Aquire a lock so only one update call happens at once |
533 | updateLock.WaitOne(); | 538 | updateLock.WaitOne(); |
534 | 539 | float physicsFPS = 0; | |
535 | try | 540 | try |
536 | { | 541 | { |
537 | // Increment the frame counter | 542 | // Increment the frame counter |
@@ -548,7 +553,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
548 | m_innerScene.UpdateEntityMovement(); | 553 | m_innerScene.UpdateEntityMovement(); |
549 | 554 | ||
550 | if (m_frame % m_update_physics == 0) | 555 | if (m_frame % m_update_physics == 0) |
551 | m_innerScene.UpdatePhysics( | 556 | physicsFPS = m_innerScene.UpdatePhysics( |
552 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) | 557 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) |
553 | ); | 558 | ); |
554 | 559 | ||
@@ -569,6 +574,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
569 | 574 | ||
570 | // if (m_frame%m_update_avatars == 0) | 575 | // if (m_frame%m_update_avatars == 0) |
571 | // UpdateInWorldTime(); | 576 | // UpdateInWorldTime(); |
577 | m_statsReporter.AddPhysicsFPS(physicsFPS); | ||
578 | m_statsReporter.SetTimeDilation(m_timedilation); | ||
579 | m_statsReporter.AddFPS(1); | ||
580 | m_statsReporter.AddAgentUpdates(1); | ||
581 | m_statsReporter.AddInPackets(0); | ||
582 | m_statsReporter.SetRootAgents(m_innerScene.GetRootAgentCount()); | ||
583 | m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); | ||
584 | |||
572 | } | 585 | } |
573 | catch (NotImplementedException) | 586 | catch (NotImplementedException) |
574 | { | 587 | { |
@@ -607,6 +620,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
607 | } | 620 | } |
608 | } | 621 | } |
609 | 622 | ||
623 | private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) | ||
624 | { | ||
625 | List<ScenePresence> StatSendAgents = GetScenePresences(); | ||
626 | foreach (ScenePresence agent in StatSendAgents) | ||
627 | { | ||
628 | if (!agent.IsChildAgent) | ||
629 | { | ||
630 | agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); | ||
631 | |||
632 | } | ||
633 | } | ||
634 | |||
635 | } | ||
610 | private void UpdateLand() | 636 | private void UpdateLand() |
611 | { | 637 | { |
612 | if (m_LandManager.landPrimCountTainted) | 638 | if (m_LandManager.landPrimCountTainted) |
@@ -939,6 +965,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
939 | // subscribe to physics events. | 965 | // subscribe to physics events. |
940 | rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); | 966 | rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); |
941 | } | 967 | } |
968 | m_innerScene.AddAPrimCount(); | ||
942 | } | 969 | } |
943 | } | 970 | } |
944 | 971 | ||
@@ -967,6 +994,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
967 | public void AddEntity(SceneObjectGroup sceneObject) | 994 | public void AddEntity(SceneObjectGroup sceneObject) |
968 | { | 995 | { |
969 | m_innerScene.AddEntity(sceneObject); | 996 | m_innerScene.AddEntity(sceneObject); |
997 | |||
970 | } | 998 | } |
971 | 999 | ||
972 | public void RemoveEntity(SceneObjectGroup sceneObject) | 1000 | public void RemoveEntity(SceneObjectGroup sceneObject) |
@@ -976,6 +1004,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
976 | m_LandManager.removePrimFromLandPrimCounts(sceneObject); | 1004 | m_LandManager.removePrimFromLandPrimCounts(sceneObject); |
977 | Entities.Remove(sceneObject.UUID); | 1005 | Entities.Remove(sceneObject.UUID); |
978 | m_LandManager.setPrimsTainted(); | 1006 | m_LandManager.setPrimsTainted(); |
1007 | m_innerScene.RemoveAPrimCount(); | ||
979 | } | 1008 | } |
980 | } | 1009 | } |
981 | 1010 | ||
@@ -1135,7 +1164,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
1135 | m_eventManager.TriggerOnRemovePresence(agentID); | 1164 | m_eventManager.TriggerOnRemovePresence(agentID); |
1136 | 1165 | ||
1137 | ScenePresence avatar = GetScenePresence(agentID); | 1166 | ScenePresence avatar = GetScenePresence(agentID); |
1138 | 1167 | ||
1168 | if (avatar.IsChildAgent) | ||
1169 | { | ||
1170 | m_innerScene.removeUserCount(false); | ||
1171 | } | ||
1172 | else | ||
1173 | { | ||
1174 | m_innerScene.removeUserCount(true); | ||
1175 | } | ||
1176 | |||
1139 | Broadcast(delegate(IClientAPI client) | 1177 | Broadcast(delegate(IClientAPI client) |
1140 | { | 1178 | { |
1141 | try | 1179 | try |
@@ -1196,6 +1234,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1196 | { | 1234 | { |
1197 | Entities.Remove(entID); | 1235 | Entities.Remove(entID); |
1198 | m_storageManager.DataStore.RemoveObject(entID, m_regInfo.RegionID); | 1236 | m_storageManager.DataStore.RemoveObject(entID, m_regInfo.RegionID); |
1237 | m_innerScene.RemoveAPrimCount(); | ||
1199 | return true; | 1238 | return true; |
1200 | } | 1239 | } |
1201 | return false; | 1240 | return false; |
@@ -1287,6 +1326,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1287 | if (m_scenePresences.ContainsKey(agentID)) | 1326 | if (m_scenePresences.ContainsKey(agentID)) |
1288 | { | 1327 | { |
1289 | m_scenePresences[agentID].MakeRootAgent(position, isFlying); | 1328 | m_scenePresences[agentID].MakeRootAgent(position, isFlying); |
1329 | m_innerScene.SwapRootChildAgent(false); | ||
1290 | } | 1330 | } |
1291 | } | 1331 | } |
1292 | } | 1332 | } |
@@ -1321,6 +1361,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
1321 | ScenePresence presence = m_innerScene.GetScenePresence(agentID); | 1361 | ScenePresence presence = m_innerScene.GetScenePresence(agentID); |
1322 | if (presence != null) | 1362 | if (presence != null) |
1323 | { | 1363 | { |
1364 | if (presence.IsChildAgent) | ||
1365 | { | ||
1366 | m_innerScene.removeUserCount(false); | ||
1367 | } | ||
1368 | else | ||
1369 | { | ||
1370 | m_innerScene.removeUserCount(true); | ||
1371 | } | ||
1324 | // Tell a single agent to disconnect from the region. | 1372 | // Tell a single agent to disconnect from the region. |
1325 | libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); | 1373 | libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); |
1326 | presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); | 1374 | presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); |
@@ -1617,6 +1665,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
1617 | if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? | 1665 | if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? |
1618 | { | 1666 | { |
1619 | controller.Kick(Helpers.FieldToUTF8String(reason)); | 1667 | controller.Kick(Helpers.FieldToUTF8String(reason)); |
1668 | |||
1669 | if (childagent) | ||
1670 | { | ||
1671 | m_innerScene.removeUserCount(false); | ||
1672 | } | ||
1673 | else | ||
1674 | { | ||
1675 | m_innerScene.removeUserCount(true); | ||
1676 | } | ||
1677 | |||
1620 | } | 1678 | } |
1621 | } | 1679 | } |
1622 | ); | 1680 | ); |
@@ -1636,6 +1694,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
1636 | } | 1694 | } |
1637 | else | 1695 | else |
1638 | { | 1696 | { |
1697 | if (m_scenePresences[agentID].IsChildAgent) | ||
1698 | { | ||
1699 | m_innerScene.removeUserCount(false); | ||
1700 | } | ||
1701 | else | ||
1702 | { | ||
1703 | m_innerScene.removeUserCount(true); | ||
1704 | } | ||
1705 | |||
1639 | m_scenePresences[agentID].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); | 1706 | m_scenePresences[agentID].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); |
1640 | m_scenePresences[agentID].ControllingClient.Close(); | 1707 | m_scenePresences[agentID].ControllingClient.Close(); |
1641 | } | 1708 | } |
@@ -1848,7 +1915,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
1848 | { | 1915 | { |
1849 | return m_innerScene.ConvertLocalIDToFullID(localID); | 1916 | return m_innerScene.ConvertLocalIDToFullID(localID); |
1850 | } | 1917 | } |
1851 | 1918 | public void SwapRootAgentCount(bool rootChildChildRootTF) | |
1919 | { | ||
1920 | m_innerScene.SwapRootChildAgent(rootChildChildRootTF); | ||
1921 | } | ||
1852 | /// <summary> | 1922 | /// <summary> |
1853 | /// | 1923 | /// |
1854 | /// </summary> | 1924 | /// </summary> |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index c82d066..0640067 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -465,6 +465,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
465 | AddToPhysicalScene(); | 465 | AddToPhysicalScene(); |
466 | m_physicsActor.Flying = isFlying; | 466 | m_physicsActor.Flying = isFlying; |
467 | 467 | ||
468 | m_scene.SwapRootAgentCount(false); | ||
468 | m_scene.CommsManager.UserProfileCacheService.UpdateUserInventory(m_uuid); | 469 | m_scene.CommsManager.UserProfileCacheService.UpdateUserInventory(m_uuid); |
469 | //if (!m_gotAllObjectsInScene) | 470 | //if (!m_gotAllObjectsInScene) |
470 | //{ | 471 | //{ |
@@ -484,7 +485,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
484 | { | 485 | { |
485 | Velocity = new LLVector3(0, 0, 0); | 486 | Velocity = new LLVector3(0, 0, 0); |
486 | m_isChildAgent = true; | 487 | m_isChildAgent = true; |
487 | 488 | m_scene.SwapRootAgentCount(true); | |
488 | RemoveFromPhysicalScene(); | 489 | RemoveFromPhysicalScene(); |
489 | 490 | ||
490 | //this.Pos = new LLVector3(128, 128, 70); | 491 | //this.Pos = new LLVector3(128, 128, 70); |
diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs new file mode 100644 index 0000000..55bd6a7 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs | |||
@@ -0,0 +1,158 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Timers; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Framework; | ||
7 | using Timer = System.Timers.Timer; | ||
8 | |||
9 | namespace OpenSim.Region.Environment.Scenes | ||
10 | { | ||
11 | public class SimStatsReporter | ||
12 | { | ||
13 | public delegate void SendStatResult(SimStatsPacket pack); | ||
14 | |||
15 | public event SendStatResult OnSendStatsResult; | ||
16 | |||
17 | private enum Stats : uint | ||
18 | { | ||
19 | TimeDilation = 0, | ||
20 | SimFPS = 1, | ||
21 | PhysicsFPS = 2, | ||
22 | AgentUpdates = 3, | ||
23 | Agents = 13, | ||
24 | ChildAgents = 14, | ||
25 | InPacketsPerSecond = 17, | ||
26 | OutPacketsPerSecond = 18, | ||
27 | UnAckedBytes = 24 | ||
28 | } | ||
29 | |||
30 | private int statsUpdatesEveryMS = 1000; | ||
31 | private float m_timeDilation = 0; | ||
32 | private int m_fps = 0; | ||
33 | private float m_pfps = 0; | ||
34 | private float m_agentUpdates = 0; | ||
35 | private int m_rootAgents = 0; | ||
36 | private int m_childAgents = 0; | ||
37 | private int m_inPacketsPerSecond = 0; | ||
38 | private int m_outPacketsPerSecond = 0; | ||
39 | private int m_unAckedBytes = 0; | ||
40 | private RegionInfo ReportingRegion; | ||
41 | |||
42 | private Timer m_report = new Timer(); | ||
43 | |||
44 | |||
45 | public SimStatsReporter(RegionInfo regionData) | ||
46 | { | ||
47 | ReportingRegion = regionData; | ||
48 | m_report.AutoReset = true; | ||
49 | m_report.Interval = statsUpdatesEveryMS; | ||
50 | m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); | ||
51 | m_report.Enabled = true; | ||
52 | } | ||
53 | |||
54 | private void statsHeartBeat(object sender, EventArgs e) | ||
55 | { | ||
56 | m_report.Enabled = false; | ||
57 | SimStatsPacket statpack = new SimStatsPacket(); | ||
58 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[9]; | ||
59 | statpack.Region = new SimStatsPacket.RegionBlock(); | ||
60 | statpack.Region.RegionX = ReportingRegion.RegionLocX; | ||
61 | statpack.Region.RegionY = ReportingRegion.RegionLocY; | ||
62 | statpack.Region.RegionFlags = (uint)21; | ||
63 | statpack.Region.ObjectCapacity = (uint)15000; | ||
64 | |||
65 | sb[0] = new SimStatsPacket.StatBlock(); | ||
66 | sb[0].StatID = (uint)Stats.TimeDilation; | ||
67 | sb[0].StatValue = (m_timeDilation); | ||
68 | |||
69 | sb[1] = new SimStatsPacket.StatBlock(); | ||
70 | sb[1].StatID = (uint)Stats.SimFPS; | ||
71 | sb[1].StatValue = (int)(m_fps); | ||
72 | |||
73 | sb[2] = new SimStatsPacket.StatBlock(); | ||
74 | sb[2].StatID = (uint)Stats.PhysicsFPS; | ||
75 | sb[2].StatValue = (m_pfps / statsUpdatesEveryMS); | ||
76 | |||
77 | sb[3] = new SimStatsPacket.StatBlock(); | ||
78 | sb[3].StatID = (uint)Stats.AgentUpdates; | ||
79 | sb[3].StatValue = (m_agentUpdates / statsUpdatesEveryMS); | ||
80 | |||
81 | sb[4] = new SimStatsPacket.StatBlock(); | ||
82 | sb[4].StatID = (uint)Stats.Agents; | ||
83 | sb[4].StatValue = m_rootAgents; | ||
84 | |||
85 | sb[5] = new SimStatsPacket.StatBlock(); | ||
86 | sb[5].StatID = (uint)Stats.ChildAgents; | ||
87 | sb[5].StatValue = m_childAgents; | ||
88 | |||
89 | sb[6] = new SimStatsPacket.StatBlock(); | ||
90 | sb[6].StatID = (uint)Stats.InPacketsPerSecond; | ||
91 | sb[6].StatValue = (int)(m_inPacketsPerSecond / statsUpdatesEveryMS); | ||
92 | |||
93 | sb[7] = new SimStatsPacket.StatBlock(); | ||
94 | sb[7].StatID = (uint)Stats.OutPacketsPerSecond; | ||
95 | sb[7].StatValue = (int)(m_outPacketsPerSecond / statsUpdatesEveryMS); | ||
96 | |||
97 | sb[8] = new SimStatsPacket.StatBlock(); | ||
98 | sb[8].StatID = (uint)Stats.UnAckedBytes; | ||
99 | sb[8].StatValue = (int) (m_unAckedBytes / statsUpdatesEveryMS); | ||
100 | |||
101 | statpack.Stat = sb; | ||
102 | |||
103 | if (OnSendStatsResult != null) | ||
104 | { | ||
105 | OnSendStatsResult(statpack); | ||
106 | } | ||
107 | resetvalues(); | ||
108 | m_report.Enabled = true; | ||
109 | } | ||
110 | |||
111 | private void resetvalues() | ||
112 | { | ||
113 | m_fps = 0; | ||
114 | m_pfps = 0; | ||
115 | m_agentUpdates = 0; | ||
116 | m_inPacketsPerSecond = 0; | ||
117 | m_outPacketsPerSecond = 0; | ||
118 | m_unAckedBytes = 0; | ||
119 | |||
120 | } | ||
121 | public void SetTimeDilation(float td) | ||
122 | { | ||
123 | m_timeDilation = td; | ||
124 | } | ||
125 | public void SetRootAgents(int rootAgents) | ||
126 | { | ||
127 | m_rootAgents = rootAgents; | ||
128 | } | ||
129 | public void SetChildAgents(int childAgents) | ||
130 | { | ||
131 | m_childAgents = childAgents; | ||
132 | } | ||
133 | public void AddFPS(int frames) | ||
134 | { | ||
135 | m_fps += frames; | ||
136 | } | ||
137 | public void AddPhysicsFPS(float frames) | ||
138 | { | ||
139 | m_pfps += frames; | ||
140 | } | ||
141 | public void AddAgentUpdates(float numUpdates) | ||
142 | { | ||
143 | m_agentUpdates += numUpdates; | ||
144 | } | ||
145 | public void AddInPackets(int numPackets) | ||
146 | { | ||
147 | m_inPacketsPerSecond += numPackets; | ||
148 | } | ||
149 | public void AddOutPackets(int numPackets) | ||
150 | { | ||
151 | m_outPacketsPerSecond += numPackets; | ||
152 | } | ||
153 | public void AddunAckedBytes(int numBytes) | ||
154 | { | ||
155 | m_unAckedBytes += numBytes; | ||
156 | } | ||
157 | } | ||
158 | } | ||