From 75befda6df8f0000122e440ad437338287c5d27c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 13 Nov 2015 02:12:13 +0000 Subject: [PATCH] Add some values to the SimulatorFeatures cap's OpenSimExtras section relative to FPS statistics. This is transition code ported from avinationmerge. --- .../RegionModulesControllerPlugin.cs | 2 + OpenSim/Region/Framework/Scenes/Scene.cs | 41 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 17edb67d18..8f38a2978b 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -509,6 +509,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { module.RegionLoaded(scene); } + + scene.AllModulesLoaded(); } public void RemoveRegionFromModules (Scene scene) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cca8963aa9..2fe6e22c1f 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -39,6 +39,7 @@ using Nini.Config; using OpenMetaverse; using OpenMetaverse.Packets; using OpenMetaverse.Imaging; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Monitoring; using OpenSim.Services.Interfaces; @@ -381,6 +382,9 @@ namespace OpenSim.Region.Framework.Scenes } private int m_minFrameTicks; + public int FrameTimeWarnPercent { get; private set; } + public int FrameTimeCritPercent { get; private set; } + // Normalize the frame related stats to nominal 55fps for viewer and scripts option // see SimStatsReporter.cs public bool Normalized55FPS { get; private set; } @@ -860,6 +864,8 @@ namespace OpenSim.Region.Framework.Scenes { m_config = config; MinFrameTicks = 89; + FrameTimeWarnPercent = 60; + FrameTimeCritPercent = 40; Normalized55FPS = true; MinMaintenanceTicks = 1000; SeeIntoRegion = true; @@ -1088,6 +1094,8 @@ namespace OpenSim.Region.Framework.Scenes if (startupConfig.Contains("MinFrameTime")) MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000); + FrameTimeWarnPercent = startupConfig.GetInt( "FrameTimeWarnPercent", FrameTimeWarnPercent); + FrameTimeCritPercent = startupConfig.GetInt( "FrameTimeCritPercent", FrameTimeCritPercent); Normalized55FPS = startupConfig.GetBoolean( "Normalized55FPS", Normalized55FPS); m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup); @@ -1256,13 +1264,44 @@ namespace OpenSim.Region.Framework.Scenes get { return m_sceneGraph; } } - protected virtual void RegisterDefaultSceneEvents() + /// + /// Called by the module loader when all modules are loaded, after each module's + /// RegionLoaded hook is called. This is the earliest time where RequestModuleInterface + /// may be used. + /// + public void AllModulesLoaded() { IDialogModule dm = RequestModuleInterface(); if (dm != null) m_eventManager.OnPermissionError += dm.SendAlertToUser; + ISimulatorFeaturesModule fm = RequestModuleInterface(); + if (fm != null) + { + OSD openSimExtras; + OSDMap openSimExtrasMap; + + if (!fm.TryGetFeature("OpenSimExtras", out openSimExtras)) + openSimExtras = new OSDMap(); + + float FrameTime = MinFrameTicks / 1000.0f; + float statisticsFPSfactor = 1.0f; + if(Normalized55FPS) + statisticsFPSfactor = 55.0f * FrameTime; + + openSimExtrasMap = (OSDMap)openSimExtras; + openSimExtrasMap["SimulatorFPS"] = OSD.FromReal(1.0f / FrameTime); + openSimExtrasMap["SimulatorFPSFactor"] = OSD.FromReal(statisticsFPSfactor); + openSimExtrasMap["SimulatorFPSWarnPercent"] = OSD.FromInteger(FrameTimeWarnPercent); + openSimExtrasMap["SimulatorFPSCritPercent"] = OSD.FromInteger(FrameTimeCritPercent); + + fm.AddFeature("OpenSimExtras", openSimExtrasMap); + } + } + + protected virtual void RegisterDefaultSceneEvents() + { m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; }